IHM

Dependencies:   TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
Nanaud
Date:
Wed Jul 07 20:32:01 2021 +0000
Commit message:
IHM

Changed in this revision

BSP_DISCO_F746NG.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
main.h 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
diff -r 000000000000 -r d0499d2eac3a BSP_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Wed Jul 07 20:32:01 2021 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#df2ea349c37a
diff -r 000000000000 -r d0499d2eac3a LCD_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Wed Jul 07 20:32:01 2021 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
diff -r 000000000000 -r d0499d2eac3a TS_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Wed Jul 07 20:32:01 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
diff -r 000000000000 -r d0499d2eac3a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 07 20:32:01 2021 +0000
@@ -0,0 +1,179 @@
+#include "main.h"
+
+/* LCD */
+LCD_DISCO_F746NG lcd;
+
+/* TS */
+TS_DISCO_F746NG ts;
+
+/* Serial */
+Serial pc(USBTX,USBRX);
+Serial robot(PC_6,PC_7,115200); // D1,D0 Serial 6
+
+/* Variables */
+uint16_t x = 0, y = 0;
+bool port_depart = BLEU;
+bool match_started = false;
+bool robot_init = true;
+uint8_t menu_select = MENU1;
+
+int main()
+{
+    pc.printf("ARES21_IHM\r\n");
+
+    TS_StateTypeDef TS_State;
+    ts.Init(LARGEUR_LCD, HAUTEUR_LCD);
+
+    lcd.Clear(LCD_COLOR_BLACK);
+    lcd.SetBackColor(LCD_COLOR_BLACK);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+
+    lcd.SetFont(&Font24);
+    lcd.DisplayStringAt(0,  100, (uint8_t *)"Ares ENSEA", CENTER_MODE);
+    lcd.SetFont(&Font12);
+    lcd.DisplayStringAt(0,  150, (uint8_t *)"Coupe de France de robotique 2021", CENTER_MODE);
+    lcd.SetFont(&Font12);
+    lcd.DisplayStringAt(0,  200, (uint8_t *)"Robot en cours d'initialisation...", CENTER_MODE);
+
+    wait(3);
+    aff_preparation(port_depart);
+
+    while(1) {
+
+
+        ts.GetState(&TS_State);
+        if (TS_State.touchDetected) {
+            x = TS_State.touchX[0];
+            y = TS_State.touchY[0];
+            pc.printf("touchX = %d, touchY = %d\r\n",x,y);
+
+            switch(menu_select) {
+                case MENU1 :
+                    if (x >= 25 && x <= 225 && y >= 68 && y <= 194) {
+                        wait_unpressed(TS_State);
+                        port_depart = !port_depart;
+                        if (port_depart == JAUNE) robot.printf("J\n");
+                        else  robot.printf("B\n");
+
+                        aff_preparation(port_depart);
+                    } else if(x >= 255 && x <= 455 && y >= 68 && y <= 194) {
+                        wait_unpressed(TS_State);
+                        menu_select = MENU2;
+                        aff_score();
+                    } else if(x >= 145 && x <= 345 && y >= 212 && y <= 262) {
+                        if(match_started == 0) {
+                            wait_unpressed(TS_State);
+                            menu_select = MENU1;
+                            robot.printf("M\n");
+                            match_started = true;
+                            aff_preparation(port_depart);
+                        }
+                    }
+                    break;
+
+                case MENU2 :
+                    if(x >= 420 && x <= 470 && y >= 10 && y <= 60) {
+                        wait_unpressed(TS_State);
+                        menu_select = MENU1;
+                        aff_preparation(port_depart);
+                    } else {
+                        lcd.SetTextColor(LCD_COLOR_WHITE);
+                        lcd.FillCircle(x, y, 10);
+                    }
+
+                    break;
+
+                case MENU3 :
+                    if(x >= 255 && x <= 455 && y >= 212 && y <= 262) {
+                        wait_unpressed(TS_State);
+                        menu_select = MENU1;
+                        aff_preparation(port_depart);
+                    }
+                    break;
+
+                default :
+                    break;
+            }
+        }
+    }
+}
+
+int decodeMsgRobot(char *buffer)
+{
+    switch(buffer[0]) {
+        case 'I' :
+            robot_init = true;
+            aff_preparation(port_depart);
+            break;
+        default :
+            break;
+    }
+
+    return 0;
+}
+
+void wait_unpressed(TS_StateTypeDef TS_State)
+{
+    do {
+        ts.GetState(&TS_State);
+    } while(TS_State.touchDetected);
+}
+
+void aff_preparation(bool port_depart)
+{
+    lcd.Clear(LCD_COLOR_BLACK);
+    lcd.SetBackColor(LCD_COLOR_BLACK);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.SetFont(&Font24);
+    lcd.DisplayStringAt(0, 20, (uint8_t *)"Preparation d'avant match", CENTER_MODE);
+
+    if (port_depart == JAUNE) lcd.SetTextColor(LCD_COLOR_YELLOW);
+    else lcd.SetTextColor(LCD_COLOR_BLUE);
+    lcd.FillRect(25, 68, 200, 126);
+
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.FillRect(255, 68, 200, 126);
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_BLACK);
+    lcd.DisplayStringAt(312, 125, (uint8_t *)"Score", LEFT_MODE);
+
+    if (match_started == 0) {
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        lcd.FillRect(145, 212, 200, 50);
+        lcd.SetBackColor(LCD_COLOR_WHITE);
+        lcd.SetTextColor(LCD_COLOR_BLACK);
+        lcd.DisplayStringAt(170, 229, (uint8_t *)"(Tirette)", LEFT_MODE);
+    }
+}
+
+void aff_score()
+{
+    lcd.Clear(LCD_COLOR_BLACK);
+
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.FillCircle(445, 35, 25);
+
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_BLACK);
+    lcd.SetFont(&Font12);
+    lcd.DisplayStringAt(425, 30, (uint8_t *)"Retour", LEFT_MODE);
+}
+
+void aff_tests()
+{
+    lcd.Clear(LCD_COLOR_BLACK);
+
+    lcd.SetBackColor(LCD_COLOR_BLACK);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.SetFont(&Font24);
+    lcd.DisplayStringAt(0, 20, (uint8_t *)"Preparation d'avant match", CENTER_MODE);
+
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.FillRect(255, 212, 200, 50);
+
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_BLACK);
+    lcd.SetFont(&Font24);
+    lcd.DisplayStringAt(305, 229, (uint8_t *)"Retour", LEFT_MODE);
+}
diff -r 000000000000 -r d0499d2eac3a main.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Wed Jul 07 20:32:01 2021 +0000
@@ -0,0 +1,28 @@
+#ifndef ARES21_LIDAR_RDR
+#define ARES21_LIDAR_RDR
+
+/* INCLUDES */
+#include "mbed.h"
+#include "LCD_DISCO_F746NG.h"
+#include "TS_DISCO_F746NG.h"
+#include <string.h>
+
+/* DEFINES */
+#define HAUTEUR_LCD 272
+#define LARGEUR_LCD 480
+
+#define JAUNE 0
+#define BLEU 1
+
+#define MENU1 0
+#define MENU2 1
+#define MENU3 2
+
+/* PROTOTYPES */
+int decodeMsgRobot(char *buffer);
+void wait_unpressed(TS_StateTypeDef TS_State);
+void aff_preparation(bool);
+void aff_score();
+void aff_tests();
+
+#endif
diff -r 000000000000 -r d0499d2eac3a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jul 07 20:32:01 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file