a
Dependencies: BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed
main.cpp
00001 #include "mbed.h" 00002 #include "TS_DISCO_F429ZI.h" 00003 #include "LCD_DISCO_F429ZI.h" 00004 00005 00006 LCD_DISCO_F429ZI lcd; 00007 TS_DISCO_F429ZI ts; 00008 00009 00010 00011 00012 00013 void ButtonNoPushed(uint16_t x_pos,uint16_t y_pos, uint16_t width, uint16_t height){ 00014 lcd.SetTextColor(LCD_COLOR_GREEN); 00015 lcd.DrawRect(x_pos,y_pos,width,height); 00016 lcd.SetTextColor(LCD_COLOR_BLUE); 00017 lcd.FillRect(x_pos+1,y_pos+1,width-1,height-1); 00018 } 00019 void ButtonPushed(uint16_t x_pos,uint16_t y_pos, uint16_t width, uint16_t height) { 00020 lcd.SetTextColor(LCD_COLOR_GREEN); 00021 lcd.DrawRect(x_pos,y_pos,width,height); 00022 lcd.SetTextColor(LCD_COLOR_GREEN); 00023 lcd.FillRect(x_pos+1,y_pos+1,width-1,height-1); 00024 } 00025 00026 void SetString(uint8_t x_pos,uint8_t y_pos,uint8_t *pText, Text_AlignModeTypdef mode) { 00027 lcd.SetFont(&Font24); 00028 lcd.SetTextColor(LCD_COLOR_WHITE); 00029 lcd.SetBackColor(LCD_COLOR_RED); 00030 lcd.DisplayStringAt(x_pos, y_pos,pText, mode); 00031 } 00032 00033 00034 00035 00036 int main() { 00037 TS_StateTypeDef TS_State; 00038 ts.Init(240,320); 00039 lcd.Clear(LCD_COLOR_BLACK); 00040 00041 while(1) { 00042 wait(0.1); 00043 00044 ts.GetState(&TS_State); 00045 ButtonNoPushed(0,0,80,80); 00046 ButtonNoPushed(0,79,80,80); 00047 ButtonNoPushed(0,159,80,80); 00048 ButtonNoPushed(0,239,80,80); 00049 00050 if (TS_State.TouchDetected && TS_State.X<80 && TS_State.Y <80) { 00051 ButtonPushed(0,0,80,80); 00052 } 00053 00054 if (TS_State.TouchDetected && TS_State.X<80 && TS_State.Y>=80 && TS_State.Y <160) { 00055 ButtonPushed(0,79,80,80); 00056 } 00057 00058 00059 if (TS_State.TouchDetected && TS_State.X<80 && TS_State.Y>=160 && TS_State.Y <240) { 00060 ButtonPushed(0,159,80,80); 00061 } 00062 00063 00064 if (TS_State.TouchDetected && TS_State.X<80 && TS_State.Y>=240 && TS_State.Y <320) { 00065 ButtonPushed(0,239,80,80); 00066 } 00067 00068 00069 00070 00071 SetString(0,0,(uint8_t *)"0",LEFT_MODE); 00072 SetString(0,79,(uint8_t *)"1",LEFT_MODE); 00073 SetString(0,159,(uint8_t *)"2",LEFT_MODE); 00074 SetString(0,239,(uint8_t *)"3",LEFT_MODE); 00075 } 00076 00077 00078 } 00079 00080 00081
Generated on Wed Jul 13 2022 08:20:04 by 1.7.2