int main(void) { u32 cmd; u32 delay; u32 hr; arduino_init(0,0,0,0); config_arduino_switch(A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_SDA, A_SCL, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO); // Run application while(1){ // wait and store valid command while((MAILBOX_CMD_ADDR)==0); cmd = MAILBOX_CMD_ADDR; switch(cmd){ case CONFIG_IOP_SWITCH: // use dedicated I2C config_arduino_switch(A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_SDA, A_SCL, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO); MAILBOX_CMD_ADDR = 0x0; break; case READ_DATA: hr = read_fingerHR(); // write out hr, reset mailbox MAILBOX_DATA(0) = hr; MAILBOX_CMD_ADDR = 0x0; break; case READ_AND_LOG_DATA: // initialize logging variables, reset cmd cb_init(&arduino_log, LOG_BASE_ADDRESS, LOG_CAPACITY, LOG_ITEM_SIZE); delay = MAILBOX_DATA(1); MAILBOX_CMD_ADDR = 0x0; do{ // push sample to log and delay hr = read_fingerHR(); cb_push_back(&arduino_log, &hr); delay_ms(delay); } while((MAILBOX_CMD_ADDR & 0x1)== 0); break; default: MAILBOX_CMD_ADDR = 0x0; // reset command break; } } return 0; }
int do_arduino_config(int cfg_X, int cfg_Y) { //port COM petitchiffre.Print("DEVICE ON COM:",cfg_X+20,cfg_Y+45); Rect Comport(Vec2D(cfg_X+120,cfg_Y+30),Vec2D(50,25)); Comport.SetRoundness(rondeur_fader/2); Comport.SetLineWidth(epaisseur_ligne_fader); Comport.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+30 && mouse_y<cfg_Y+30+25) { Comport.DrawOutline(CouleurLevel); if(mouse_button==1 && mouse_released==0) { Comport.Draw(CouleurBlind); int new_comport=atoi(numeric); reset_numeric_entry(); if( new_comport>0 && new_comport<18) { if(arduino_device_0_is_ignited==1){arduino_close(0);} arduino_com0=new_comport; arduino_init(0); mouse_released=1; } } } petitchiffre.Print(ol::ToString(arduino_com0),cfg_X+140,cfg_Y+45); //BAUD RATE petitchiffre.Print("BAUD-RATE:",cfg_X+20,cfg_Y+75); Rect BaudrateB(Vec2D(cfg_X+120,cfg_Y+60),Vec2D(50,25)); BaudrateB.SetRoundness(rondeur_fader/2); BaudrateB.SetLineWidth(epaisseur_ligne_fader); BaudrateB.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+60 && mouse_y<cfg_Y+60+25) { BaudrateB.DrawOutline(CouleurLevel); if(mouse_button==1 && mouse_released==0) { BaudrateB.Draw(CouleurBlind); int new_Baudrate=atoi(numeric); reset_numeric_entry(); if( new_Baudrate>0 && (new_Baudrate ==300 || new_Baudrate==1200 || new_Baudrate==2400 || new_Baudrate==4800 || new_Baudrate==9600 || new_Baudrate==14400 || new_Baudrate==19200 || new_Baudrate==28800 || new_Baudrate==38400 || new_Baudrate==57600 || new_Baudrate==115200)) { if(arduino_device_0_is_ignited==1){arduino_close(0);} arduino_baud_rate0=new_Baudrate; arduino_init(0); mouse_released=1; } } } petitchiffre.Print(ol::ToString(arduino_baud_rate0),cfg_X+128,cfg_Y+75); //REQUEST RATE petitchiffre.Print("REQUEST-RATE:",cfg_X+20,cfg_Y+105); Rect ReqrateB(Vec2D(cfg_X+120,cfg_Y+90),Vec2D(50,25)); ReqrateB.SetRoundness(rondeur_fader/2); ReqrateB.SetLineWidth(epaisseur_ligne_fader); ReqrateB.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+90 && mouse_y<cfg_Y+90+25) { ReqrateB.DrawOutline(CouleurLevel); if(mouse_button==1 && mouse_released==0) { ReqrateB.Draw(CouleurBlind); int new_Reqrate=atoi(numeric); reset_numeric_entry(); if( new_Reqrate>0 && new_Reqrate<=100 ) { ARDUINO_RATE=new_Reqrate; install_int_ex(ticker_arduino ,BPS_TO_TIMER(ARDUINO_RATE)); mouse_released=1; } } } petitchiffre.Print(ol::ToString(ARDUINO_RATE),cfg_X+140,cfg_Y+105); ////////////////LIMITATION DE CARTES /////////////////////////////////////////// petitchiffre.Print("LAST I/O:",cfg_X+20,cfg_Y+135); Rect MaxIOB(Vec2D(cfg_X+120,cfg_Y+120),Vec2D(50,25)); MaxIOB.SetRoundness(rondeur_fader/2); MaxIOB.SetLineWidth(epaisseur_ligne_fader); MaxIOB.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+120 && mouse_y<cfg_Y+120+25) { MaxIOB.DrawOutline(CouleurLevel); if(mouse_button==1 && mouse_released==0) { MaxIOB.Draw(CouleurBlind); int new_maxio=atoi(numeric); reset_numeric_entry(); if( new_maxio>=0 && new_maxio<=digital_limit ) { arduino_max_digital=new_maxio; mouse_released=1; } } } petitchiffre.Print(ol::ToString(arduino_max_digital),cfg_X+140,cfg_Y+135); /////////////////////////////// petitchiffre.Print("LAST ANALOG:",cfg_X+20,cfg_Y+165); Rect MaxAnB(Vec2D(cfg_X+120,cfg_Y+150),Vec2D(50,25)); MaxAnB.SetRoundness(rondeur_fader/2); MaxAnB.SetLineWidth(epaisseur_ligne_fader); MaxAnB.Draw(CouleurFond.WithAlpha(0.5)); if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+150 && mouse_y<cfg_Y+150+25) { MaxAnB.DrawOutline(CouleurLevel); if(mouse_button==1 && mouse_released==0) { MaxAnB.Draw(CouleurBlind); int new_maxan=atoi(numeric); reset_numeric_entry(); if( new_maxan>=0 && new_maxan<=analog_limit ) { arduino_max_analog=new_maxan; mouse_released=1; } } } petitchiffre.Print(ol::ToString(arduino_max_analog),cfg_X+140,cfg_Y+165); ///////////////////////////////// petitchiffre.Print("OPEN:",cfg_X+20,cfg_Y+195); Rect OpenB(Vec2D(cfg_X+120,cfg_Y+180),Vec2D(50,25)); OpenB.SetRoundness(rondeur_fader/2); OpenB.SetLineWidth(epaisseur_ligne_fader); OpenB.Draw(CouleurFond.WithAlpha(0.5)); switch (arduino_device_0_is_ignited) { case 0: petitchiffre.Print("is OFF",cfg_X+130,cfg_Y+195); break; case 1: petitchiffre.Print("is ON",cfg_X+130,cfg_Y+195); break; } if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+180 && mouse_y<cfg_Y+180+25) { OpenB.DrawOutline(CouleurLevel); if(mouse_button==1 && mouse_released==0) { OpenB.Draw(CouleurBlind); switch (arduino_device_0_is_ignited) { case 0: arduino_init(0); break; case 1: arduino_close(0); arduino_device_0_is_ignited=0; break; } mouse_released=1; } } /////////////////////////////////////////////////////////// petitchiffre.Print("Digital affectation:",cfg_X+200,cfg_Y+20); petitchiffre.Print("Analog affectation:",cfg_X+510,cfg_Y+20); ///////////////////BOX AFFECTATION DIGITAL//////////////// char string_temp_def[25]; char string_temp_familly[25]; for (int y=0;y<12;y++) { ////////DIG///////////////////////////////////////////////////////////////// Rect OverTyp(Vec2D(cfg_X+200+5,(cfg_Y+40+(y*20)-10)),Vec2D(70,18)); OverTyp.SetRoundness(rondeur_fader/2); OverTyp.Draw(CouleurFond.WithAlpha(0.3)); Rect OverAction(Vec2D(cfg_X+280+5,(cfg_Y+40+(y*20)-10)),Vec2D(140,18)); OverAction.SetRoundness(rondeur_fader/2); OverAction.Draw(CouleurFond.WithAlpha(0.3)); Rect OverVal(Vec2D(cfg_X+430+5,(cfg_Y+40+(y*20)-10)),Vec2D(30,18)); OverVal.SetRoundness(rondeur_fader/2); OverVal.Draw(CouleurFond.WithAlpha(0.3)); /////////ANA/////////////////////////////////////////////////////////////// Rect OverAff(Vec2D(cfg_X+520+5,(cfg_Y+40+(y*20)-10)),Vec2D(105,18)); OverAff.SetRoundness(rondeur_fader/2); OverAff.Draw(CouleurFond.WithAlpha(0.3)); Rect OverValA(Vec2D(cfg_X+630+5,(cfg_Y+40+(y*20)-10)),Vec2D(30,18)); OverValA.SetRoundness(rondeur_fader/2); OverValA.Draw(CouleurFond.WithAlpha(0.3)); if(mouse_y>(cfg_Y+40+(y*20)-10) && mouse_y<(cfg_Y+40+(y*20)+5)) { ////////////////////DIG////////////////////////////////////////////////////////// //changement type if(mouse_x>cfg_X+200+5 && mouse_x<cfg_X+200+5+70) { OverTyp.DrawOutline(CouleurLigne); if(mouse_button==1 && mouse_released==0) { arduino_digital_type[position_line_io+y]++; arduino_digital_function_input[position_line_io+y][1]=0; arduino_digital_function_input[position_line_io+y][0]=0; arduino_digital_function_output[position_line_io+y][1]=0; arduino_digital_function_output[position_line_io+y][0]=0; if(arduino_digital_type[position_line_io+y]>3) {arduino_digital_type[position_line_io+y]=0;} OverTyp.Draw(CouleurFader); mouse_released=1; } } //////L'ASSIGNATION INPUT///////////////////////////////////////////// //arduino_digital_function_input[128][2];//action // Val 1 if(mouse_x>cfg_X+280+5 && mouse_x<cfg_X+280+5+140)//famille d action { OverAction.DrawOutline(CouleurLigne); if(mouse_button==1 && mouse_released==0) { if(arduino_digital_type[position_line_io+y]==1)//input { arduino_digital_function_input[position_line_io+y][0]++; if(arduino_digital_function_input[position_line_io+y][0]>33) {arduino_digital_function_input[position_line_io+y][0]=0;} arduino_digital_function_input[position_line_io+y][1]=0; } if(arduino_digital_type[position_line_io+y]==2 || arduino_digital_type[position_line_io+y]==3)//output ON OF ET PWM { arduino_digital_function_output[position_line_io+y][0]++; if(arduino_digital_function_output[position_line_io+y][0]>2) {arduino_digital_function_output[position_line_io+y][0]=0;} arduino_digital_function_output[position_line_io+y][1]=0; } OverAction.Draw(CouleurFader); mouse_released=1; } } ///////La valeur de l'ordre si il y en a une ( par ex. num fader)/////// if(mouse_x>cfg_X+430+5 && mouse_x<cfg_X+430+5+30)//famille d action { OverVal.DrawOutline(CouleurLigne); if(mouse_button==1 && mouse_released==0) { int valois=atoi(numeric); ///INPUT///////////////////////////////////////////////////////////////////// //data Val1 range pour un input de type fader ( 0 à 11 ) if( arduino_digital_type[position_line_io+y]==1 && arduino_digital_function_input[position_line_io+y][0]>=0 && arduino_digital_function_input[position_line_io+y][0]<=11 && valois>0 && valois<=48 ) { arduino_digital_function_input[position_line_io+y][1]=valois; } //faire data range pour le picth: 0 à 127 if( arduino_digital_type[position_line_io+y]==1 && ( arduino_digital_function_input[position_line_io+y][0]>=17 || arduino_digital_function_input[position_line_io+y][0]<=32) && valois>=0 && valois<=127 ) { arduino_digital_function_input[position_line_io+y][1]=valois; } ///////////OUTPUT ON OFF ET PWM/////////////////////////////////////////////////////////////// if((arduino_digital_type[position_line_io+y]==2 || arduino_digital_type[position_line_io+y]==3) && arduino_digital_function_output[position_line_io+y][0]==1 && valois>0 && valois<513)//CHANNEL { arduino_digital_function_output[position_line_io+y][1]=valois; } if((arduino_digital_type[position_line_io+y]==2 || arduino_digital_type[position_line_io+y]==3) && arduino_digital_function_output[position_line_io+y][0]==2 && valois>0 && valois<49)//Fader { arduino_digital_function_output[position_line_io+y][1]=valois; } reset_numeric_entry(); OverVal.Draw(CouleurFader); mouse_released=1; } } /////////////////////////////////////// ///////////////////BOX AFFECTATION ANALOG//////////////// //////L'ASSIGNATION Analog///////////////////////////////////////////// //changement affectation if(mouse_x>cfg_X+520+5 && mouse_x<cfg_X+520+5+105) { OverAff.DrawOutline(CouleurLigne); if(mouse_button==1 && mouse_released==0) { arduino_analog_function_input[position_line_ana+y]++; arduino_analog_attribution_input[position_line_ana+y]=0; if(arduino_analog_function_input[position_line_ana+y]>20) {arduino_analog_function_input[position_line_ana+y]=0;} OverAff.Draw(CouleurFader); mouse_released=1; } } ///////////////LA VALEUR///////////////////////////// if(mouse_x>cfg_X+630+5 && mouse_x<cfg_X+630+5+30)//valeur { OverValA.DrawOutline(CouleurLigne); if(mouse_button==1 && mouse_released==0) { int valana=0; valana=atoi(numeric); reset_numeric_entry(); /////////////INPUT //limitation des valeurs aux types d entrees if(arduino_analog_function_input[position_line_ana+y]==1 || arduino_analog_function_input[position_line_ana+y]==2)//faders level et speed { if(valana>0 && valana<=48) {arduino_analog_attribution_input[position_line_ana+y]=valana-1;} } if( arduino_analog_function_input[position_line_ana+y]==4)//seq scene et preset { if(valana>0 && valana<=3)//1 stage 2 preset 3 speed {arduino_analog_attribution_input[position_line_ana+y]=valana-1;} } if( arduino_analog_function_input[position_line_ana+y]>=5 && arduino_analog_function_input[position_line_ana+y]<=20 )//simulation midi { if(valana>=0 && valana<=127)//Pitch {arduino_analog_attribution_input[position_line_ana+y]=valana;} } OverValA.Draw(CouleurFader); mouse_released=1; } } /////////////////////////////////////////////////////////////////////////////// } //////////////////AFFICHAGE/////////////////////////////// if(position_line_io+y==0) { sprintf(string_temp_def,"0: Serial",position_line_io+y); sprintf(string_temp_familly,"Rx"); OverTyp.Draw(CouleurFond); petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20)); petitchiffre.Print(string_temp_def,cfg_X+200+15,cfg_Y+43+(y*20)); petitchiffrerouge.Print(ol::ToString(digital_data_from_arduino[position_line_io+y]),cfg_X+475,cfg_Y+43+(y*20)); } if(position_line_io+y==1) { sprintf(string_temp_def,"1: Serial",position_line_io+y); sprintf(string_temp_familly,"Tx"); OverTyp.Draw(CouleurFond); petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20)); petitchiffre.Print(string_temp_def,cfg_X+200+15,cfg_Y+43+(y*20)); petitchiffrerouge.Print(ol::ToString(digital_data_from_arduino[position_line_io+y]),cfg_X+475,cfg_Y+43+(y*20)); } if(position_line_io+y>1 && position_line_io+y<=arduino_max_digital) { ///////LE TYPE //////////////////////////////////////////// switch(arduino_digital_type[position_line_io+y]) { case 0://desafected sprintf(string_temp_def,"%d: -",position_line_io+y); break; case 1://input sprintf(string_temp_def,"%d: Input",position_line_io+y); OverTyp.Draw(CouleurRed); break; case 2://output sprintf(string_temp_def,"%d: Output",position_line_io+y); OverTyp.Draw(CouleurGreen); break; case 3://pwm sprintf(string_temp_def,"%d: PWM",position_line_io+y); OverTyp.Draw(CouleurYellow); break; default: break; } ////////////ACTIONS ///////////////////////////////////////////////// ////////////////GRANDE FAMILLE INPUT//////////////////////////////////////// if(arduino_digital_type[position_line_io+y]==1)//si de la famille des inputs { switch(arduino_digital_function_input[position_line_io+y][0]) { case 0://desafected sprintf(string_temp_familly,"-"); break; case 1: //fader up sprintf(string_temp_familly,"Fader: UP"); break; case 2://fader down sprintf(string_temp_familly,"Fader: DOWN"); break; case 3://Fader saw sprintf(string_temp_familly,"Fader: SAW"); break; case 4: sprintf(string_temp_familly,"Fader: ToPREVDock"); break; case 5: sprintf(string_temp_familly,"Fader: ToNEXTDock"); break; case 6: sprintf(string_temp_familly,"Fader: Up/Down"); break; case 7: sprintf(string_temp_familly,"Fader: LOCK"); break; case 8: sprintf(string_temp_familly,"Fader: FLASH"); break; case 9: sprintf(string_temp_familly,"Fader: All at 0"); break; case 10: sprintf(string_temp_familly,"Fader: L/Unloop dock"); break; case 11: sprintf(string_temp_familly,"Fader: L/Unloop all"); break; case 12: sprintf(string_temp_familly,"Seq: GO"); break; case 13: sprintf(string_temp_familly,"Seq: GO BACK"); break; case 14: sprintf(string_temp_familly,"Seq: JUMP"); break; case 15: sprintf(string_temp_familly,"Seq: SHIFT-W"); break; case 16: sprintf(string_temp_familly,"Seq: SHIFT-X"); break; case 17: sprintf(string_temp_familly,"Bang Banger num"); break; case 18: sprintf(string_temp_familly,"As Key-On CH0 Pitch:"); break; case 19: sprintf(string_temp_familly,"As Key-On CH1 Pitch:"); break; case 20: sprintf(string_temp_familly,"As Key-On CH2 Pitch:"); break; case 21: sprintf(string_temp_familly,"As Key-On CH3 Pitch:"); break; case 22: sprintf(string_temp_familly,"As Key-On CH4 Pitch:"); break; case 23: sprintf(string_temp_familly,"As Key-On CH5 Pitch:"); break; case 24: sprintf(string_temp_familly,"As Key-On CH6 Pitch:"); break; case 25: sprintf(string_temp_familly,"As Key-On CH7 Pitch:"); break; case 26: sprintf(string_temp_familly,"As Key-On CH8 Pitch:"); break; case 27: sprintf(string_temp_familly,"As Key-On CH9 Pitch:"); break; case 28: sprintf(string_temp_familly,"As Key-On CH10 Pitch:"); break; case 29: sprintf(string_temp_familly,"As Key-On CH11 Pitch:"); break; case 30: sprintf(string_temp_familly,"As Key-On CH12 Pitch:"); break; case 31: sprintf(string_temp_familly,"As Key-On CH13 Pitch:"); break; case 32: sprintf(string_temp_familly,"As Key-On CH14 Pitch:"); break; case 33: sprintf(string_temp_familly,"As Key-On CH15 Pitch:"); break; default: break; } petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20)); petitchiffre.Print(ol::ToString(arduino_digital_function_input[position_line_io+y][1]),cfg_X+440+3,cfg_Y+43+(y*20)); } petitchiffrerouge.Print(ol::ToString(digital_data_from_arduino[position_line_io+y]),cfg_X+475,cfg_Y+43+(y*20)); petitchiffre.Print(string_temp_def,cfg_X+200+15,cfg_Y+43+(y*20)); } if(arduino_digital_type[position_line_io+y]==2)//si de la famille des Outputs { switch(arduino_digital_function_output[position_line_io+y][0]) { case 0://desafected sprintf(string_temp_familly,"-"); break; case 1: //relié à un circuit sprintf(string_temp_familly,"Channel >10"); break; case 2://relié à un fader sprintf(string_temp_familly,"Fader >10"); break; } petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20)); petitchiffre.Print(ol::ToString(arduino_digital_function_output[position_line_io+y][1]),cfg_X+440+3,cfg_Y+43+(y*20)); } if(arduino_digital_type[position_line_io+y]==3)//si de la famille pwm { switch(arduino_digital_function_output[position_line_io+y][0]) { case 0://desafected sprintf(string_temp_familly,"-"); break; case 1: //relié à un circuit sprintf(string_temp_familly,"Channel"); break; case 2://relié à un fader sprintf(string_temp_familly,"Fader"); break; } petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20)); petitchiffre.Print(ol::ToString(arduino_digital_function_output[position_line_io+y][1]),cfg_X+440+3,cfg_Y+43+(y*20)); } //affichage analog if(position_line_ana+y<=arduino_max_analog) { sprintf(string_temp_def,"%d:",position_line_ana+y); petitchiffre.Print(string_temp_def,cfg_X+510,cfg_Y+43+(y*20)); switch(arduino_analog_function_input[position_line_ana+y]) { case 0://desafected sprintf(string_temp_familly,"-"); break; case 1: //faders lvl sprintf(string_temp_familly,"Fader Level:"); petitchiffre.Print(ol::ToString((arduino_analog_attribution_input[position_line_ana+y]+1)),cfg_X+645,cfg_Y+43+(y*20)); break; case 2://faders speeed sprintf(string_temp_familly,"Fader Speed:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]+1),cfg_X+645,cfg_Y+43+(y*20)); break; case 3://master sprintf(string_temp_familly,"Grand Master"); break; case 4://seq scene et preset et vitesse sprintf(string_temp_familly,"Sequence:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]+1),cfg_X+645,cfg_Y+43+(y*20)); break; case 5://Midi CH0 sprintf(string_temp_familly,"As CC CH0 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 6://Midi CH1 sprintf(string_temp_familly,"As CC CH1 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 7://Midi CH2 sprintf(string_temp_familly,"As CC CH2 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 8://Midi CH3 sprintf(string_temp_familly,"As CC CH3 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 9://Midi CH4 sprintf(string_temp_familly,"As CC CH4 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 10://Midi CH5 sprintf(string_temp_familly,"As CC CH5 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 11://Midi CH6 sprintf(string_temp_familly,"As CC CH6 Picth:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 12://Midi CH7 sprintf(string_temp_familly,"As CC CH7 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 13://Midi CH8 sprintf(string_temp_familly,"As CC CH8 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 14://Midi CH9 sprintf(string_temp_familly,"As CC CH9 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 15://Midi CH10 sprintf(string_temp_familly,"As CC CH10 Picth:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 16://Midi CH11 sprintf(string_temp_familly,"As CC CH11 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 17://Midi CH12 sprintf(string_temp_familly,"As CC CH12 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 18://Midi CH13 sprintf(string_temp_familly,"As CC CH13 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 19://Midi CH14 sprintf(string_temp_familly,"As CC CH14 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; case 20://Midi CH15 sprintf(string_temp_familly,"As CC CH15 Pitch:"); petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); break; default: break; } petitchiffre.Print(string_temp_familly,cfg_X+515+15,cfg_Y+43+(y*20)); petitchiffrerouge.Print(ol::ToString(analog_data_from_arduino[position_line_ana+y]),cfg_X+670+5,cfg_Y+43+(y*20)); } //fin boucle des 12 lignes } /////////////////UP DOWN LINE IO ///////////////////// Circle LineUp(Vec2D(cfg_X+200+200,cfg_Y+15),12); LineUp.Draw(CouleurFond.WithAlpha(0.3)); Circle LineDown(Vec2D(cfg_X+200+240,cfg_Y+15),12); LineDown.Draw(CouleurFond.WithAlpha(0.3)); if(mouse_y>cfg_Y+15-12 && mouse_y<cfg_Y+15+12) { if(mouse_x>cfg_X+200+200-12 && mouse_x<cfg_X+200+200+12) { LineUp.Draw(CouleurSurvol); if(mouse_button==1) { LineUp.Draw(CouleurFader); if(position_line_io>0){position_line_io--;} } } else if(mouse_x>cfg_X+200+240-12 && mouse_x<cfg_X+200+240+12) { LineDown.Draw(CouleurSurvol); if(mouse_button==1) { LineDown.Draw(CouleurFader); if(position_line_io<digital_limit-1){position_line_io++;} } } } petitchiffre.Print("-",cfg_X+200+198,cfg_Y+19); petitchiffre.Print("+",cfg_X+200+236,cfg_Y+19); LineUp.DrawOutline(CouleurLigne.WithAlpha(0.6)); LineDown.DrawOutline(CouleurLigne.WithAlpha(0.6)); /////////////////UP DOWN ANA ///////////////////// Circle LineUpA(Vec2D(cfg_X+510+150,cfg_Y+15),12); LineUpA.Draw(CouleurFond.WithAlpha(0.3)); Circle LineDownA(Vec2D(cfg_X+510+190,cfg_Y+15),12); LineDownA.Draw(CouleurFond.WithAlpha(0.3)); if(mouse_y>cfg_Y+15-12 && mouse_y<cfg_Y+15+12) { if(mouse_x>cfg_X+510+150-12 && mouse_x<cfg_X+510+150+12) { LineUpA.Draw(CouleurSurvol); if(mouse_button==1) { LineUpA.Draw(CouleurFader); if(position_line_ana>0){position_line_ana--;} } } else if(mouse_x>cfg_X+510+190-12 && mouse_x<cfg_X+510+190+12) { LineDownA.Draw(CouleurSurvol); if(mouse_button==1) { LineDownA.Draw(CouleurFader); if(position_line_ana<analog_limit-1){position_line_ana++;} } } } petitchiffre.Print("-",cfg_X+510+148,cfg_Y+19); petitchiffre.Print("+",cfg_X+510+186,cfg_Y+19); LineUpA.DrawOutline(CouleurLigne.WithAlpha(0.6)); LineDownA.DrawOutline(CouleurLigne.WithAlpha(0.6)); //FEEDBACK petitpetitchiffre.Print("Bytes received:",cfg_X+10,cfg_Y+260); petitchiffre.Print(ol::ToString( nBytesReadArduino0),cfg_X+110,cfg_Y+260); petitpetitchiffre.Print("Last str. received:",cfg_X+10,cfg_Y+270); petitpetitchiffre.Print(tmp_str_arduino,cfg_X+110,cfg_Y+270); petitchiffrerouge.Print(string_Arduino_status,cfg_X+10,cfg_Y+285); return(0); }
int main(void) { u32 cmd, data_channels, delay; u32 xStatus; u8 iop_pins[19]; int i, log_capacity; u32 xadc_raw_value; float xadc_voltage; // Initialize PMOD and timers arduino_init(0,0,0,0); // SysMon Initialize SysMonConfigPtr = XSysMon_LookupConfig(SYSMON_DEVICE_ID); if(SysMonConfigPtr == NULL) xil_printf("SysMon LookupConfig failed.\n\r"); xStatus = XSysMon_CfgInitialize(SysMonInstPtr, SysMonConfigPtr, SysMonConfigPtr->BaseAddress); if(XST_SUCCESS != xStatus) xil_printf("SysMon CfgInitialize failed\r\n"); // Clear the old status XSysMon_GetStatus(SysMonInstPtr); // Initialize the default switch config_arduino_switch(A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO); while(1){ // wait and store valid command while((MAILBOX_CMD_ADDR & 0x1)==0); cmd = (MAILBOX_CMD_ADDR & 0xF); switch(cmd){ case CONFIG_IOP_SWITCH: // Assign default pin configurations iop_pins[0] = MAILBOX_DATA(0); iop_pins[1] = MAILBOX_DATA(1); iop_pins[2] = MAILBOX_DATA(2); iop_pins[3] = MAILBOX_DATA(3); iop_pins[4] = MAILBOX_DATA(4); iop_pins[5] = MAILBOX_DATA(5); iop_pins[6] = D_GPIO; iop_pins[7] = D_GPIO; iop_pins[8] = D_GPIO; iop_pins[9] = D_GPIO; iop_pins[10] = D_GPIO; iop_pins[11] = D_GPIO; iop_pins[12] = D_GPIO; iop_pins[13] = D_GPIO; iop_pins[14] = D_GPIO; iop_pins[15] = D_GPIO; iop_pins[16] = D_GPIO; iop_pins[17] = D_GPIO; iop_pins[18] = D_GPIO; config_arduino_switch(iop_pins[0], iop_pins[1], iop_pins[2], iop_pins[3], iop_pins[4], iop_pins[5], iop_pins[6], iop_pins[7], iop_pins[8], iop_pins[9], iop_pins[10], iop_pins[11], iop_pins[12], iop_pins[13], iop_pins[14], iop_pins[15], iop_pins[16], iop_pins[17], iop_pins[18]); MAILBOX_CMD_ADDR = 0x0; break; case GET_RAW_DATA: i=0; // Wait for the conversion complete while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) != XSM_SR_EOS_MASK); data_channels = MAILBOX_CMD_ADDR >> 8; if(data_channels & 0x1) MAILBOX_DATA(i++) = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+1); if(data_channels & 0x2) MAILBOX_DATA(i++) = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+9); if(data_channels & 0x4) MAILBOX_DATA(i++) = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+6); if(data_channels & 0x8) MAILBOX_DATA(i++) = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+15); if(data_channels & 0x10) MAILBOX_DATA(i++) = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+5); if(data_channels & 0x20) MAILBOX_DATA(i++) = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+13); MAILBOX_CMD_ADDR = 0x0; break; case GET_VOLTAGE: i=0; // Wait for the conversion complete while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) != XSM_SR_EOS_MASK); data_channels = MAILBOX_CMD_ADDR >> 8; if(data_channels & 0x1) MAILBOX_DATA_FLOAT(i++) = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+1)*V_REF/65536); if(data_channels & 0x2) MAILBOX_DATA_FLOAT(i++) = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+9)*V_REF/65536); if(data_channels & 0x4) MAILBOX_DATA_FLOAT(i++) = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+6)*V_REF/65536); if(data_channels & 0x8) MAILBOX_DATA_FLOAT(i++) = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+15)*V_REF/65536); if(data_channels & 0x10) MAILBOX_DATA_FLOAT(i++) = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+5)*V_REF/65536); if(data_channels & 0x20) MAILBOX_DATA_FLOAT(i++) = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+13)*V_REF/65536); MAILBOX_CMD_ADDR = 0x0; break; case READ_AND_LOG_RAW: // initialize logging variables, reset cmd delay = MAILBOX_DATA(1); // get channels to be sampled data_channels = MAILBOX_CMD_ADDR >> 8; // allocate 1000 samples per channel log_capacity = 4000 / LOG_INT_SIZE * count_set_bits(data_channels); cb_init(&arduino_log, LOG_BASE_ADDRESS, log_capacity, LOG_INT_SIZE); while(MAILBOX_CMD_ADDR != RESET_ANALOG){ // wait for sample conversion while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) != XSM_SR_EOS_MASK); if(data_channels & 0x1) { xadc_raw_value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+1); cb_push_back(&arduino_log, &xadc_raw_value); } if(data_channels & 0x2) { xadc_raw_value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+9); cb_push_back(&arduino_log, &xadc_raw_value); } if(data_channels & 0x4) { xadc_raw_value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+6); cb_push_back(&arduino_log, &xadc_raw_value); } if(data_channels & 0x8) { xadc_raw_value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+15); cb_push_back(&arduino_log, &xadc_raw_value); } if(data_channels & 0x10) { xadc_raw_value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+5); cb_push_back(&arduino_log, &xadc_raw_value); } if(data_channels & 0x20) { xadc_raw_value = XSysMon_GetAdcData(SysMonInstPtr, XSM_CH_AUX_MIN+13); cb_push_back(&arduino_log, &xadc_raw_value); } delay_ms(delay); } MAILBOX_CMD_ADDR = 0x0; break; case READ_AND_LOG_FLOAT: // initialize logging variables, reset cmd delay = MAILBOX_DATA(1); // get channels to be sampled data_channels = MAILBOX_CMD_ADDR >> 8; // allocate 1000 samples per channel log_capacity = 4000 / LOG_FLOAT_SIZE * count_set_bits(data_channels); cb_init(&arduino_log, LOG_BASE_ADDRESS, log_capacity, LOG_FLOAT_SIZE); while(MAILBOX_CMD_ADDR != RESET_ANALOG){ // wait for sample conversion while ((XSysMon_GetStatus(SysMonInstPtr) & XSM_SR_EOS_MASK) != XSM_SR_EOS_MASK); if(data_channels & 0x1) { xadc_voltage = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+1)*V_REF/65536); cb_push_back_float(&arduino_log, &xadc_voltage); } if(data_channels & 0x2) { xadc_voltage = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+9)*V_REF/65536); cb_push_back_float(&arduino_log, &xadc_voltage); } if(data_channels & 0x4) { xadc_voltage = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+6)*V_REF/65536); cb_push_back_float(&arduino_log, &xadc_voltage); } if(data_channels & 0x8) { xadc_voltage = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+15)*V_REF/65536); cb_push_back_float(&arduino_log, &xadc_voltage); } if(data_channels & 0x10) { xadc_voltage = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+5)*V_REF/65536); cb_push_back_float(&arduino_log, &xadc_voltage); } if(data_channels & 0x20) { xadc_voltage = (float)(XSysMon_GetAdcData( SysMonInstPtr,XSM_CH_AUX_MIN+13)*V_REF/65536); cb_push_back_float(&arduino_log, &xadc_voltage); } delay_ms(delay); } MAILBOX_CMD_ADDR = 0x0; break; case RESET_ANALOG: // SysMon Initialize SysMonConfigPtr = XSysMon_LookupConfig(SYSMON_DEVICE_ID); if(SysMonConfigPtr == NULL) xil_printf("SysMon LookupConfig failed.\n\r"); xStatus = XSysMon_CfgInitialize(SysMonInstPtr, SysMonConfigPtr, SysMonConfigPtr->BaseAddress); if(XST_SUCCESS != xStatus) xil_printf("SysMon CfgInitialize failed.\r\n"); // Clear the old status XSysMon_GetStatus(SysMonInstPtr); MAILBOX_CMD_ADDR = 0x0; break; default: MAILBOX_CMD_ADDR = 0x0; break; } } return 0; }
int main(void) { int i=0; int period_us = 0x55; int num_cycles = 10; u32 cmd; arduino_init(0,0,0,0); /* * Configuring IO Switch to connect GPIO * bit-0 will be controlled by the software to drive the speaker * Buzzer is connected to bit[0] of the Channel 1 of AXI GPIO instance */ config_arduino_switch(A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO); XGpio_Initialize(&pb_speaker, XPAR_GPIO_1_DEVICE_ID); XGpio_SetDataDirection(&pb_speaker, SPEAKER_CHANNEL, 0x0); // initially keep it OFF XGpio_DiscreteWrite(&pb_speaker, 1, 0); while(1){ while((MAILBOX_CMD_ADDR & 0x01)==0); cmd = MAILBOX_CMD_ADDR; switch(cmd){ case CONFIG_IOP_SWITCH: shift = MAILBOX_DATA(0)-2; config_arduino_switch(A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_GPIO, A_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO, D_GPIO); XGpio_Initialize(&pb_speaker, XPAR_GPIO_1_DEVICE_ID); XGpio_SetDataDirection(&pb_speaker, SPEAKER_CHANNEL, 0x0); XGpio_DiscreteWrite(&pb_speaker, 1, 0); MAILBOX_CMD_ADDR = 0x0; break; case PLAY_TONE: period_us = MAILBOX_DATA(0); num_cycles = MAILBOX_DATA(1); for(i=0; i<num_cycles; i++){ generateTone(period_us); } MAILBOX_CMD_ADDR = 0x0; break; case PLAY_DEMO: melody_demo(); MAILBOX_CMD_ADDR = 0x0; break; default: MAILBOX_CMD_ADDR = 0x0; break; } } return 0; }