![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
a demo of GUI on DISCOF7 consisting of a few buttons and feeders
Dependencies: ADXL345 BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Diff: main.cpp
- Revision:
- 2:76522cfa03cd
- Parent:
- 1:4f356fb65677
- Child:
- 3:afd2bb1331a4
--- a/main.cpp Thu Aug 04 15:36:07 2016 +0000 +++ b/main.cpp Fri Aug 05 23:49:42 2016 +0000 @@ -18,35 +18,18 @@ bool x_is_in =0; bool y_is_in = 0; - //uint16_t tx, ty; - - //ts.GetState(&TS_State); - //tx = TS_State.touchX[0]; - //ty = TS_State.touchY[0]; - //printf("your touches are %d , %d\r\n",tx,ty); - if( (tx>x) && (tx<(x+width))) x_is_in = 1; if( (ty>y) && (ty<(y+height))) y_is_in = 1; - bool buttest; buttest = x_is_in & y_is_in; - //if(buttest){ - // printf("welldone\r\n"); - //} - return (bool) buttest; - } uint16_t h_feeder(uint16_t tx, uint16_t ty,uint16_t x, uint16_t y, uint16_t width, uint16_t height){ - //uint16_t tx, ty; - //ts.GetState(&TS_State); - //tx = TS_State.touchX[0]; - //ty = TS_State.touchY[0]; bool x_is_in =0; bool y_is_in =0; @@ -113,25 +96,16 @@ wait(1); - //lcd.SetFont(&Font12); - //lcd.SetBackColor(LCD_COLOR_GREEN); - //lcd.SetTextColor(LCD_COLOR_WHITE); - //lcd.Clear(LCD_COLOR_GREEN); - while(1){ - //ts.ResetTouchData(&TS_State); - //ts.ITClear(); but1=0; but2=0; but3=0; - ts.GetState(&TS_State); if (TS_State.touchDetected) { - feed1_dist = h_feeder(TS_State.touchX[0],TS_State.touchY[0],48, 152, 384, 30); feed2_dist = h_feeder(TS_State.touchX[0],TS_State.touchY[0],48, 212, 384, 30); but1 = touch_test_rectangle(TS_State.touchX[0],TS_State.touchY[0], 48, 68, 96, 60); @@ -155,10 +129,7 @@ if(but1){ lcd.SetTextColor(LCD_COLOR_GREEN); - lcd.FillRect(48, 68, 96, 60); - - - + lcd.FillRect(48, 68, 96, 60); } else{ lcd.SetTextColor(LCD_COLOR_RED); @@ -173,15 +144,14 @@ lcd.SetTextColor(LCD_COLOR_RED); lcd.FillRect(192, 68, 96, 60); } - - if(but3){ - lcd.SetTextColor(LCD_COLOR_GREEN); - lcd.FillRect(338, 68, 96, 60); - } - else{ - lcd.SetTextColor(LCD_COLOR_RED); - lcd.FillRect(338, 68, 96, 60); - } + if(but3){ + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.FillRect(338, 68, 96, 60); + } + else{ + lcd.SetTextColor(LCD_COLOR_RED); + lcd.FillRect(338, 68, 96, 60); + } } }