LCD TS

Dependencies:   mbed LCD_DISCO_F746NG BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
James1208
Date:
Thu Jun 16 08:47:53 2022 +0000
Parent:
2:ab13f201cdc0
Child:
7:896fb491fbfb
Commit message:
Disco Display

Changed in this revision

BSP_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
--- a/BSP_DISCO_F746NG.lib	Wed Oct 07 15:46:30 2015 +0000
+++ b/BSP_DISCO_F746NG.lib	Thu Jun 16 08:47:53 2022 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#c9112f0c67e3
+http://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#458ab1edf6b2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Thu Jun 16 08:47:53 2022 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- a/main.cpp	Wed Oct 07 15:46:30 2015 +0000
+++ b/main.cpp	Thu Jun 16 08:47:53 2022 +0000
@@ -1,46 +1,207 @@
 #include "mbed.h"
+#include "TS_DISCO_F746NG.h"
 #include "LCD_DISCO_F746NG.h"
 
 LCD_DISCO_F746NG lcd;
+TS_DISCO_F746NG ts;
 
-DigitalOut led1(LED1);
+InterruptIn draw_start(D7);
+InterruptIn draw_ask(D6);
+InterruptIn draw_pass(D5);
+InterruptIn draw_fail(D4);
+InterruptIn draw_proc(D3);
+
+DigitalOut ack(D2);
+DigitalOut yes_no(D1);
+DigitalOut ck(D0);
+
+int page = 5;
+
+void draw_start_rtn()
+{
+    page = 0;
+} // end
+
+void draw_ask_rtn()
+{
+    page = 1;
+} // end
+
+void draw_pass_rtn()
+{
+    page = 2;
+} // end
+
+void draw_fail_rtn()
+{
+    page = 3;
+} // end
+
+void draw_proc_rtn()
+{
+    page = 4;
+} // end
 
 int main()
-{  
-    led1 = 1;
+{
+
+    TS_StateTypeDef TS_State;
+    uint8_t status;
+
+    int lcd_width = lcd.GetXSize();
+
+    draw_ask.mode(PullDown);
+    draw_start.mode(PullDown);
+    draw_pass.mode(PullDown);
+    draw_fail.mode(PullDown);
+    draw_proc.mode(PullDown);
+
+    draw_ask.rise(&draw_ask_rtn);
+    draw_start.rise(&draw_start_rtn);
+    draw_pass.rise(&draw_pass_rtn);
+    draw_fail.rise(&draw_fail_rtn);
+    draw_proc.rise(&draw_proc_rtn);
+
+    status = ts.Init(lcd_width, lcd.GetYSize());
+    
+    ack = 1;
+    yes_no = 1;
+    ck = 1;
+    
+    if (status != TS_OK) {
+        lcd.Clear(LCD_COLOR_RED);
+        lcd.SetBackColor(LCD_COLOR_RED);
+        lcd.SetTextColor(LCD_COLOR_BLACK);
+        lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
+        wait(1);
+    } // if (status != TS_OK)
 
-    lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE);
-    wait(1);
-  
-    while(1)
-    {
-      lcd.Clear(LCD_COLOR_BLUE);
-      lcd.SetBackColor(LCD_COLOR_BLUE);
-      lcd.SetTextColor(LCD_COLOR_WHITE);
-      wait(0.3);
-      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"DISCOVERY STM32F746NG", CENTER_MODE);
-      wait(1);
+    while(1) {
+        switch (page) {
+            case 0:
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_BLACK);
+                wait(0.1);
+                lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"INSERT DVD TRAY", CENTER_MODE);
+                lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"AND LABEL SHEET", CENTER_MODE);
+                lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"[ START ]", CENTER_MODE);
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(!(TS_State.touchDetected));
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(TS_State.touchDetected);
+
+                ack = 0;
+                wait_ms(50);
+                ack = 1;
+
+                page = 5;
+                break;
+
+            case 1:
+                lcd.Clear(LCD_COLOR_YELLOW);
+                lcd.SetBackColor(LCD_COLOR_YELLOW);
+                lcd.SetTextColor(LCD_COLOR_BLACK);
+                wait(0.1);
+                lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"MORE LABEL SHEETS?", CENTER_MODE);
+                lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"[ NO ]", LEFT_MODE);
+                lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"[ YES ]", RIGHT_MODE);
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(!(TS_State.touchDetected));
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(TS_State.touchDetected);
 
-      lcd.Clear(LCD_COLOR_GREEN);
-      
-      lcd.SetTextColor(LCD_COLOR_BLUE);
-      lcd.DrawRect(10, 20, 50, 50);
-      wait(0.1);
-      lcd.SetTextColor(LCD_COLOR_BROWN);
-      lcd.DrawCircle(80, 80, 50);
-      wait(0.1);
-      lcd.SetTextColor(LCD_COLOR_YELLOW);
-      lcd.DrawEllipse(150, 150, 50, 100);
-      wait(0.1);
-      lcd.SetTextColor(LCD_COLOR_RED);
-      lcd.FillCircle(200, 200, 40);
-      wait(1);
+                if (TS_State.touchX[0] > (lcd_width/2)) {
+                    yes_no = 1;
+                    wait_ms(50);
+                    ck = 0;
+                    wait_ms(50);
+                    ck = 1;
+                } else {
+                    yes_no = 0;
+                    wait_ms(50);
+                    ck = 0;
+                    wait_ms(50);
+                    ck = 1;
+                } // if (TS_State.touchX[0] > (lcd_width/2))
+
+                page = 5;
+                break;
+
+            case 2:
+                lcd.Clear(LCD_COLOR_GREEN);
+                lcd.SetBackColor(LCD_COLOR_GREEN);
+                lcd.SetTextColor(LCD_COLOR_BLACK);
+                wait(0.1);
+                lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"PASS", CENTER_MODE);
+                lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"[ CONTINUE ]", CENTER_MODE);
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(!(TS_State.touchDetected));
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(TS_State.touchDetected);
+
+                ack = 0;
+                wait_ms(50);
+                ack = 1;
 
-      lcd.SetBackColor(LCD_COLOR_ORANGE);
-      lcd.SetTextColor(LCD_COLOR_CYAN);
-      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"HAVE FUN !!!", CENTER_MODE);
-      wait(1);
+                page = 5;
+                break;
+
+            case 3:
+                lcd.Clear(LCD_COLOR_RED);
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_BLACK);
+                wait(0.1);
+                lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"FAIL", CENTER_MODE);
+                lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"[ CONTINUE ]", CENTER_MODE);
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(!(TS_State.touchDetected));
+
+                do {
+                    wait_ms(50);
+                    ts.GetState(&TS_State);
+                } while(TS_State.touchDetected);
 
-      led1 = !led1;
-    }
-}
+                ack = 0;
+                wait_ms(50);
+                ack = 1;
+
+                page = 5;
+                break;
+
+            case 4:
+                lcd.Clear(LCD_COLOR_YELLOW);
+                lcd.SetBackColor(LCD_COLOR_YELLOW);
+                lcd.SetTextColor(LCD_COLOR_BLACK);
+                wait(0.1);
+                lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"PROCESSING...", CENTER_MODE);
+
+                page = 5;
+                break;
+
+            default:
+                break;
+        } // switch (page)
+    } // while (1)
+} // end
--- a/mbed.bld	Wed Oct 07 15:46:30 2015 +0000
+++ b/mbed.bld	Thu Jun 16 08:47:53 2022 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file