void GAME_EventHandler2() { if( IOE_TP_GetState()->TouchDetected ){ player2IsReversed = 1; while( IOE_TP_GetState()->TouchDetected ); player2IsReversed = 0; } }
void ui_touch_detect() { static TP_STATE* TP_State; TP_State = IOE_TP_GetState(); if(TP_State->TouchDetected){ //bpm mius if(TP_State->X > 70 && TP_State->X < 70+40 && TP_State->Y > 55 && TP_State->Y < 55 + 40){ metronome_bpm--; if(metronome_bpm < 40){ metronome_bpm = 208; } } //bpm plus if(TP_State->X > 70+60 && TP_State->X < 70+40+60 && TP_State->Y > 55 && TP_State->Y < 55 + 40){ metronome_bpm++; if(metronome_bpm > 208){ metronome_bpm = 40; } } //beat minus if(TP_State->X > 70 && TP_State->X < 70+40 && TP_State->Y > 55+75 && TP_State->Y < 55+40+75){ metronome_beat_count--; if(metronome_beat_count < 0){ metronome_beat_count = 7; } } //beat plus if(TP_State->X > 70+60 && TP_State->X < 70+40+60 && TP_State->Y > 55+75 && TP_State->Y < 55+40+75){ metronome_beat_count++; if(metronome_beat_count > 7){ metronome_beat_count = 0; } } //start/stop if(TP_State->X > 20 && TP_State->X < 20+40 && TP_State->Y > 260 && TP_State->Y < 300){ metro_status = !metro_status; } //easter egg if(TP_State->X > 140 && TP_State->X < 180 && TP_State->Y > 240 && TP_State->Y < 300){ if(metro_status == 1){ easter_egg++; }else{ easter_egg = 0; } if(easter_egg > 20){ ui_draw_flower(); } } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { uint16_t linenum = 0; static TP_STATE* TP_State; /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f429_439xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* LCD initialization */ LCD_Init(); /* LCD Layer initialization */ LCD_LayerInit(); /* Enable the LTDC */ LTDC_Cmd(ENABLE); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); /* Touch Panel configuration */ TP_Config(); while (1) { TP_State = IOE_TP_GetState(); if((TP_State->TouchDetected) && ((TP_State->Y < 245) && (TP_State->Y >= 3))) { if((TP_State->X >= 237) || (TP_State->X < 3)) {} else { LCD_DrawFullCircle(TP_State->X, TP_State->Y, 3); } } else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && (TP_State->Y >= 250) && (TP_State->X >= 5) && (TP_State->X <= 35)) { LCD_SetTextColor(LCD_COLOR_BLUE2); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && (TP_State->Y >= 250) && (TP_State->X >= 40) && (TP_State->X <= 70)) { LCD_SetTextColor(LCD_COLOR_CYAN); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && (TP_State->Y >= 250) && (TP_State->X >= 75) && (TP_State->X <= 105)) { LCD_SetTextColor(LCD_COLOR_YELLOW); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 5) && (TP_State->X <= 35)) { LCD_SetTextColor(LCD_COLOR_RED); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 40) && (TP_State->X <= 70)) { LCD_SetTextColor(LCD_COLOR_BLUE); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 75) && (TP_State->X <= 105)) { LCD_SetTextColor(LCD_COLOR_GREEN); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 110) && (TP_State->X <= 140)) { LCD_SetTextColor(LCD_COLOR_BLACK); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 145) && (TP_State->X <= 175)) { LCD_SetTextColor(LCD_COLOR_MAGENTA); } else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 270) && (TP_State->X >= 180) && (TP_State->X <= 230)) { LCD_SetFont(&Font8x8); for(linenum = 0; linenum < 31; linenum++) { LCD_ClearLine(LINE(linenum)); } } else { } } }
void MainMenu(){ Button configuration={5,220," Configure "}; Button chart={5,270," Chats "}; Label temperatureLabel={10,10,"Temperature[C]:"}; Label humidityLabel={10,50,"Humidity[%]:"}; Label pressureLabel={10,90,"Pressure[hPa]:"}; Label externalTemperatureLabel={10,130,"Ext Temperature[C]:"}; float data[]={1,10,15,1,4,3,4,5}; ButtonDraw(&configuration); ButtonDraw(&chart); LabelDraw(&temperatureLabel); LabelDraw(&humidityLabel); LabelDraw(&pressureLabel); LabelDraw(&externalTemperatureLabel); IOE_TP_Config(); TP_STATE state; while(1){ state=*IOE_TP_GetState(); if (state.TouchDetected == 128 ) { int s=state.TouchDetected; if(ButtonCheckIfPressed(state.X,state.Y,&chart)==CLICKED){ state.TouchDetected=0; results.changed=1; ChartsMenu(); results.changed=1; } state.TouchDetected=0; } if(results.changed){ LCD_SetColors(0x0000,0xffff); LCD_DrawFullRect(0,0,240,320); ButtonDraw(&configuration); ButtonDraw(&chart); if(results.temperatureAndHumidity.ERROR_CODE==0){ LabelDraw(&temperatureLabel); LabelDraw(&humidityLabel); DrawFloat(150,30,(float)results.temperatureAndHumidity.temperature,2); DrawFloat(150,70,(float)results.temperatureAndHumidity.humidity,2); } else{ Label tmp=temperatureLabel; tmp.string="DHT_11 Error"; LabelDraw(&tmp); } if(results.externalTemperature.ERROR_CODE==0){ LabelDraw(&externalTemperatureLabel); DrawFloat(150,150,(float)results.externalTemperature.temperature,2); } else{ Label tmp=externalTemperatureLabel; tmp.string="DS18B20 Error"; LabelDraw(&tmp); } if(results.pressure.ERROR_CODE==0){ LabelDraw(&pressureLabel); DrawFloat(150,110,(float)results.pressure.pressure,2); } else{ Label tmp=pressureLabel; tmp.string="LPS331 Error"; LabelDraw(&tmp); } results.changed=0; } delayMSC(100); } }