Demo program for setting up RTC via the touchscreen on the F746 and touch screen demo. Hold push button on boot up to set time. Press button while drawing to clear screen.

Dependencies:   BSP_DISCO_F746NG BUTTON_GROUP LCD_DISCO_F746NG LCDclockSet_F746 TS_DISCO_F746NG mbed

Fork of DISCO-F746NG-clockSet by Kevin Braun

Files at this revision

API Documentation at this revision

Comitter:
rickd25
Date:
Wed Jun 15 01:37:52 2016 +0000
Parent:
0:1200a8585607
Commit message:
initial

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 1200a8585607 -r 5e8986c83a89 main.cpp
--- a/main.cpp	Fri Mar 04 00:31:32 2016 +0000
+++ b/main.cpp	Wed Jun 15 01:37:52 2016 +0000
@@ -12,6 +12,7 @@
 TS_DISCO_F746NG ts;                         // Object for touch pannel
 RawSerial pc(USBTX, USBRX);                 // terminal console
 DigitalOut gled(LED1);
+DigitalIn my_button(USER_BUTTON);
 
 LCDclockSet ss("ss");                       //graphic display items
 
@@ -40,14 +41,15 @@
 //--------------------------------------------------------------------------------------------------------------------------------------//
 // Display clock on LCD
 
-#define CLOCKX                  338
-#define CLOCKLINE               21
+#define CLOCKX                  0
+#define CLOCKLINE               10
 
 void DispClockLCD() {
     sprintf((char*)lcd_text, "%s %s", timebuf_dMyy, timebuf_hms);
     uint32_t tc = lcd.GetTextColor();
+    lcd.SetFont(&Font24); 
     lcd.SetTextColor(LCD_COLOR_YELLOW);
-    lcd.DisplayStringAt(CLOCKX, LINE(CLOCKLINE) + 8, (uint8_t *)&lcd_text, LEFT_MODE);
+    lcd.DisplayStringAt(CLOCKX, LINE(CLOCKLINE), (uint8_t *)&lcd_text, CENTER_MODE);
     lcd.SetTextColor(tc);
 }
 
@@ -74,14 +76,14 @@
 
 int readTouch() {
     do{
-        wait_ms(50);
+        wait_ms(25);
         ts.GetState(&TS_State);
     } while(!(TS_State.touchDetected));
     int TouchData = 255;
     uint8_t idx;
     uint16_t x, y;
     do{
-        wait_ms(50);
+        wait_ms(25);
         for (idx = 0; idx < TS_State.touchDetected; idx++) {
             x = TS_State.touchX[idx];
             y = TS_State.touchY[idx];
@@ -189,9 +191,9 @@
     
     gled = 1;
     
-    pc.baud(230400);
+    //pc.baud(230400);
     
-    // Setting of button group
+    // Setting of button group - boot screen
     lcd.Clear(LCD_COLOR_BLACK);
     lcd.SetBackColor(LCD_COLOR_BLACK);
     lcd.SetTextColor(LCD_COLOR_CYAN);
@@ -215,48 +217,66 @@
     wait(1.5);
     
     //go set the RTC via the LCD
-    SetRTClcd();
+    if(my_button) {
+            SetRTClcd();
+        }
+
+    //*lcd.SetFont(&Font12);     //12
+    lcd.Clear(LCD_COLOR_BLACK);
+    //*lcd.SetBackColor(LCD_COLOR_BLACK);
+    //*lcd.SetTextColor(LCD_COLOR_WHITE);
 
-    lcd.SetFont(&Font12);
-    lcd.Clear(LCD_COLOR_BLUE);
-    lcd.SetBackColor(LCD_COLOR_BLUE);
-    lcd.SetTextColor(LCD_COLOR_WHITE);
-
-    //the touchscreen demo with RTC in the lower-right corner
+    //Loop - the touchscreen demo----------------------------------------
     while (true) {
+        //button push clear screen
+        if(my_button) {
+            lcd.Clear(LCD_COLOR_BLACK);
+        }
+        
+        lcd.SetFont(&Font12);     //12
+        lcd.SetBackColor(LCD_COLOR_BLACK);
+        lcd.SetTextColor(LCD_COLOR_WHITE);       
+        
         ts.GetState(&TS_State);
         if (TS_State.touchDetected) {
             // Clear lines corresponding to old touches coordinates
-            if (TS_State.touchDetected < prev_nb_touches) {
-                for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) {
-                    lcd.ClearStringLine(idx);
-                }
-            }
+            //if (TS_State.touchDetected < prev_nb_touches) {
+            //    for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) {
+            //        lcd.ClearStringLine(idx);
+            //    }
+            //}
             prev_nb_touches = TS_State.touchDetected;
 
             cleared = 0;
-
             sprintf((char*)lcd_text, "Touched: %d", TS_State.touchDetected);
             lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&lcd_text, LEFT_MODE);
 
-            for (idx = 0; idx < TS_State.touchDetected; idx++) {
-                x = TS_State.touchX[idx];
-                y = TS_State.touchY[idx];
-                sprintf((char*)lcd_text, "Touch %d: x=%d y=%d    ", idx+1, x, y);
-                lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&lcd_text, LEFT_MODE);
-            }
-            lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
+            //for (idx = 0; idx < TS_State.touchDetected; idx++) {
+            //    x = TS_State.touchX[idx];
+            //    y = TS_State.touchY[idx];
+            //    sprintf((char*)lcd_text, "Touch %d: x=%d y=%d    ", idx+1, x, y);
+            //    lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&lcd_text, LEFT_MODE);
+            //}
+            //drawing dots
+            lcd.SetTextColor(LCD_COLOR_LIGHTBLUE);
+            lcd.FillCircle(TS_State.touchX[0], TS_State.touchY[0], 1);  //lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
+            lcd.DrawPixel(TS_State.touchX[1], TS_State.touchY[1], LCD_COLOR_ORANGE);
+            lcd.DrawPixel(TS_State.touchX[2], TS_State.touchY[2], LCD_COLOR_GREEN);
+            lcd.DrawPixel(TS_State.touchX[3], TS_State.touchY[3], LCD_COLOR_MAGENTA);
+            //lcd.FillCircle(TS_State.touchX[1], TS_State.touchY[1], 1);
         } else {
             if (!cleared) {
-                lcd.Clear(LCD_COLOR_BLUE);
+                //*lcd.Clear(LCD_COLOR_BLACK);
                 sprintf((char*)lcd_text, "Touches: 0");
                 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&lcd_text, LEFT_MODE);
                 cleared = 1;
             }
         }
         gled = !gled;
-        wait_ms(200);
+        //wait_ms(0.1);
         UpdateTime();
+        
+        //with RTC in the lower-right corner
         DispClockLCD();
     }
 }