Smart Home Controller
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG sMotor
Diff: main.cpp
- Revision:
- 1:7f6f6627aacd
- Parent:
- 0:dfbc18a77337
- Child:
- 2:2f4e4558277c
--- a/main.cpp Tue Jan 08 11:22:52 2019 +0000 +++ b/main.cpp Tue Jan 08 13:36:48 2019 +0000 @@ -1,9 +1,11 @@ #include "mbed.h" +#include "stdio.h" #include "TS_DISCO_F746NG.h" #include "LCD_DISCO_F746NG.h" LCD_DISCO_F746NG lcd; TS_DISCO_F746NG ts; +DigitalOut led(D8); int main() { @@ -11,6 +13,11 @@ TS_StateTypeDef TS_State; uint16_t x, y; uint16_t status; + uint8_t text[30]; + uint8_t text2[30]; + uint8_t idx; + uint8_t touches = 0; + bool touched; //Initial conf status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); @@ -22,7 +29,37 @@ //Start screen lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Test String", CENTER_MODE); wait(2); + lcd.Clear(LCD_COLOR_RED); + while(1) { + x = TS_State.touchX[idx]; + y = TS_State.touchY[idx]; + sprintf((char*)text, "Touch %d: x=%d y=%d ", touches, x, y); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); + ts.GetState(&TS_State); + lcd.DrawRect(0, 190, 80, 80); + lcd.DrawRect(133, 190, 80, 80); + lcd.DrawRect(266, 190, 80, 80); + lcd.DrawRect(399, 190, 80, 80); + + if ((TS_State.touchDetected == 0) && (touched == true)) + { + touches++; + touched = false; + } + if (TS_State.touchDetected == 1) + { + touched = true; + } + if ((TS_State.touchDetected) && (TS_State.touchX[0] < 100) && (TS_State.touchY[0] > 190 )) + { + led = 1; + } + else + { + led = 0; + } + } }