a demo of GUI on DISCOF7 consisting of a few buttons and feeders

Dependencies:   ADXL345 BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
habiburrahman
Date:
Thu Aug 04 15:06:03 2016 +0000
Child:
1:4f356fb65677
Commit message:
demo

Changed in this revision

BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
ESP8266NodeMCUInterface.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Thu Aug 04 15:06:03 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#c9112f0c67e3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ESP8266NodeMCUInterface.lib	Thu Aug 04 15:06:03 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ESP8266/code/ESP8266NodeMCUInterface/#6031f70e3914
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Thu Aug 04 15:06:03 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Thu Aug 04 15:06:03 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 04 15:06:03 2016 +0000
@@ -0,0 +1,182 @@
+#include "mbed.h"
+#include "TS_DISCO_F746NG.h"
+#include "LCD_DISCO_F746NG.h"
+#include "ESP8266.h"
+#include "TCPSocketConnection.h"
+#include <string>
+using namespace std;
+ 
+
+ 
+LCD_DISCO_F746NG lcd;
+TS_DISCO_F746NG ts;
+TS_StateTypeDef TS_State;
+
+
+
+bool touch_test_rectangle(uint16_t tx, uint16_t ty, uint16_t x, uint16_t y, uint16_t width, uint16_t height){
+
+    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;
+    
+    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){
+        return tx - x;
+    }
+    
+    
+}
+
+bool but1=0,but2=0,but3=0;
+uint16_t feed1_dist = 0;
+uint16_t feed2_dist = 0;
+
+int main()
+{
+   
+    uint16_t x, y;
+    uint8_t text[30];
+    uint8_t status;
+    uint8_t idx;
+    uint8_t cleared = 0;
+    uint8_t prev_nb_touches = 0;
+
+    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE);
+    wait(1);
+
+    status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
+    if (status != TS_OK) {
+        lcd.Clear(LCD_COLOR_RED);
+        lcd.SetBackColor(LCD_COLOR_RED);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
+    } else {
+        lcd.Clear(LCD_COLOR_BLUE);
+        lcd.SetBackColor(LCD_COLOR_BLUE);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
+    }
+    
+    lcd.SetBackColor(LCD_COLOR_YELLOW);
+    lcd.SetTextColor(LCD_COLOR_RED);
+    
+    lcd.Clear(LCD_COLOR_WHITE);
+    
+    
+    lcd.SetTextColor(LCD_COLOR_RED);
+    lcd.FillRect(48, 68, 96, 60);
+    lcd.FillRect(192, 68, 96, 60);
+    lcd.FillRect(338, 68, 96, 60);
+    
+    lcd.FillRect(48, 152, 384, 30);
+    lcd.FillRect(48, 212, 384, 30);
+    
+    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);
+            but2 = touch_test_rectangle(TS_State.touchX[0],TS_State.touchY[0], 192, 68, 96, 60);
+            but3 = touch_test_rectangle(TS_State.touchX[0],TS_State.touchY[0], 338, 68, 96, 60);
+            
+            if(feed1_dist>0){
+            lcd.SetTextColor(LCD_COLOR_RED);
+            lcd.FillRect(48, 152, 384, 30);
+            lcd.SetTextColor(LCD_COLOR_GREEN);
+            lcd.FillRect(48, 152, feed1_dist, 30);
+            }
+            
+            if(feed2_dist>0){
+            lcd.SetTextColor(LCD_COLOR_RED);
+            lcd.FillRect(48, 212, 384, 30);
+            lcd.SetTextColor(LCD_COLOR_GREEN);
+            lcd.FillRect(48, 212, feed2_dist, 30);
+            }   
+        }
+        
+        if(but1){
+                lcd.SetTextColor(LCD_COLOR_GREEN);
+                lcd.FillRect(48, 68, 96, 60);
+        }
+        else{
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.FillRect(48, 68, 96, 60);   
+        }
+        
+        if(but2){
+                lcd.SetTextColor(LCD_COLOR_GREEN);
+                lcd.FillRect(192, 68, 96, 60);
+        }
+        else{
+                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);   
+    }        
+        
+    }
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Aug 04 15:06:03 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file