Smart Home Controller
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG sMotor
main.cpp
- Committer:
- TwinToe
- Date:
- 2019-01-08
- Revision:
- 1:7f6f6627aacd
- Parent:
- 0:dfbc18a77337
- Child:
- 2:2f4e4558277c
File content as of revision 1:7f6f6627aacd:
#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() { // Variables 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()); lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.SetFont(&Font24); //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; } } }