Thread

Dependencies:   BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG mbed-rtos mbed

Fork of DISCO-F746NG_LCDTS_demo by ST

Files at this revision

API Documentation at this revision

Comitter:
mekai
Date:
Thu Dec 22 05:57:00 2016 +0000
Parent:
1:eb206d2bca5d
Commit message:
161222_?????

Changed in this revision

BSP_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-rtos.lib 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 eb206d2bca5d -r 5ca8733edc78 BSP_DISCO_F746NG.lib
--- a/BSP_DISCO_F746NG.lib	Wed Oct 07 15:55:00 2015 +0000
+++ b/BSP_DISCO_F746NG.lib	Thu Dec 22 05:57:00 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#c9112f0c67e3
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#fe313c53cdb5
diff -r eb206d2bca5d -r 5ca8733edc78 main.cpp
--- a/main.cpp	Wed Oct 07 15:55:00 2015 +0000
+++ b/main.cpp	Thu Dec 22 05:57:00 2016 +0000
@@ -1,9 +1,134 @@
 #include "mbed.h"
 #include "TS_DISCO_F746NG.h"
 #include "LCD_DISCO_F746NG.h"
+#include "Thread.h"
+#include "rtos.h"
+
+
 
 LCD_DISCO_F746NG lcd;
 TS_DISCO_F746NG ts;
+Mutex stdio_mutex;
+uint8_t r=0,g=0,b=0;
+
+
+
+
+
+class DRAW            //クラス宣言
+{
+private:
+    uint32_t color;
+    uint16_t Xpos;
+    uint16_t Ypos;
+    uint16_t Rad;
+public:
+    void fillcircle(uint32_t col,uint16_t x,uint16_t y,uint16_t rad);
+};
+
+
+void DRAW::fillcircle(uint32_t col,uint16_t x,uint16_t y,uint16_t rad){
+    lcd.SetTextColor(col|0xFF000000);
+    lcd.FillCircle(x,y,rad);
+}
+
+
+DRAW draw;
+
+void lcd_r_thread(void const *args) {
+    while (true) {
+        stdio_mutex.lock();
+        draw.fillcircle(r*0x00010000,100,150,30);
+        stdio_mutex.unlock();
+        r++;
+        Thread::wait(20);
+    }
+}
+void lcd_g_thread(void const *args) {
+    while (true) {
+        stdio_mutex.lock();
+        draw.fillcircle(g*0x00000100,200,150,30);
+        stdio_mutex.unlock();
+        g++;
+        Thread::wait(40);
+    }
+}
+void lcd_b_thread(void const *args) {
+    while (true) {
+        stdio_mutex.lock();
+        draw.fillcircle(b,300,150,30);
+        stdio_mutex.unlock();
+        b++;
+        Thread::wait(60);
+    }
+}
+void RGBtext(void const *args) {
+    uint8_t text[30];
+    while (true) {
+        stdio_mutex.lock();
+        lcd.SetFont(&Font24);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        sprintf((char*)text, "R:0x%x",r);
+        lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+        sprintf((char*)text, "G:0x%x",g);
+        lcd.DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE);
+        sprintf((char*)text, "B:0x%x",b);
+        lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, LEFT_MODE);
+        stdio_mutex.unlock();
+        Thread::wait(100);
+    }
+}
+void TPtext(void const *args) {
+    TS_StateTypeDef TS_State;
+    uint16_t x, y;
+    uint8_t text[30];
+    uint8_t status;
+    uint8_t idx;
+    uint8_t cleared = 0;
+    uint8_t prev_nb_touches = 0;
+    while (true) {
+        stdio_mutex.lock();
+        lcd.SetFont(&Font12);
+        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);
+                }
+            }
+            prev_nb_touches = TS_State.touchDetected;
+
+            cleared = 0;
+
+            sprintf((char*)text, "Touches: %d", TS_State.touchDetected);
+            lcd.DisplayStringAt(150, LINE(0), (uint8_t *)&text, LEFT_MODE);
+
+            for (idx = 0; idx < TS_State.touchDetected; idx++) {
+                x = TS_State.touchX[idx];
+                y = TS_State.touchY[idx];
+                sprintf((char*)text, "Touch %d: x=%d y=%d    ", idx+1, x, y);
+                lcd.DisplayStringAt(150, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
+            }
+
+            lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
+        } else {
+            if (!cleared) {
+                lcd.Clear(LCD_COLOR_BLACK);
+                sprintf((char*)text, "Touches: 0");
+                lcd.DisplayStringAt(150, LINE(0), (uint8_t *)&text, LEFT_MODE);
+                cleared = 1;
+            }
+        }        
+        stdio_mutex.unlock();
+        Thread::wait(1);
+    }
+}
+
+
+
 
 int main()
 {
@@ -14,6 +139,12 @@
     uint8_t idx;
     uint8_t cleared = 0;
     uint8_t prev_nb_touches = 0;
+    
+//    RtosTimer lcd_r_timer(fillcircle, osTimerPeriodic, (void *)0);
+//    RtosTimer lcd_r_timer(fillcircle(r*0x00010000,100,150,30), osTimerPeriodic);
+
+
+    
 
     lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE);
     wait(1);
@@ -32,12 +163,57 @@
     }
 
     wait(1);
-    lcd.SetFont(&Font12);
-    lcd.SetBackColor(LCD_COLOR_BLUE);
+    lcd.SetFont(&Font24);
+    lcd.SetBackColor(LCD_COLOR_BLACK);
     lcd.SetTextColor(LCD_COLOR_WHITE);
+    
+//    thread.start(lcd, color_cng);
+//    Thread::wait(5000);
+//    running = false;
+//    thread.join();
 
+//    lcd_r_timer.start(100);
+    Thread thread1(lcd_r_thread);
+    Thread thread2(lcd_g_thread);
+    Thread thread3(lcd_b_thread);
+    Thread thread4(RGBtext);
+    Thread thread5(TPtext);
+    
     while(1) {
+        
+/*        
+        lcd.SetTextColor(r*0x00010000|0xFF000000);
+        lcd.FillCircle(100,150,100);
+        lcd.SetTextColor(g*0x00000100|0xFF000000);
+        lcd.FillCircle(200,150,100);
+        lcd.SetTextColor(b|0xFF000000);
+        lcd.FillCircle(300,150,100);
+*/
+//        draw.fillcircle(r*0x00010000,100,150,30);
+//        lcd.SetTextColor(r*0x00010000|0xFF000000);
+//        lcd.FillCircle(100,150,30);
+//        lcd.SetTextColor(g*0x00000100|0xFF000000);
+//        lcd.FillCircle(200,150,30);
+//        lcd.SetTextColor(b|0xFF000000);
+//        lcd.FillCircle(300,150,30);
+/*
+        lcd.SetFont(&Font24);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        sprintf((char*)text, "R:0x%x",r);
+        lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+        sprintf((char*)text, "G:0x%x",g);
+        lcd.DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE);
+        sprintf((char*)text, "B:0x%x",b);
+        lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, LEFT_MODE);
+*/
+/*        lcd.SetFont(&Font12);
+//        lcd.SetBackColor(~col|0xFF000000);
+//        lcd.SetTextColor(col|0xFF000000);
 
+        
+        
+        
+        
         ts.GetState(&TS_State);
         if (TS_State.touchDetected) {
             // Clear lines corresponding to old touches coordinates
@@ -51,23 +227,25 @@
             cleared = 0;
 
             sprintf((char*)text, "Touches: %d", TS_State.touchDetected);
-            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+            lcd.DisplayStringAt(150, LINE(0), (uint8_t *)&text, LEFT_MODE);
 
             for (idx = 0; idx < TS_State.touchDetected; idx++) {
                 x = TS_State.touchX[idx];
                 y = TS_State.touchY[idx];
                 sprintf((char*)text, "Touch %d: x=%d y=%d    ", idx+1, x, y);
-                lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
+                lcd.DisplayStringAt(150, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
             }
 
             lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
         } else {
             if (!cleared) {
-                lcd.Clear(LCD_COLOR_BLUE);
+                lcd.Clear(LCD_COLOR_BLACK);
                 sprintf((char*)text, "Touches: 0");
-                lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+                lcd.DisplayStringAt(150, LINE(0), (uint8_t *)&text, LEFT_MODE);
                 cleared = 1;
             }
-        }
+        }*/
     }
 }
+
+
diff -r eb206d2bca5d -r 5ca8733edc78 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Dec 22 05:57:00 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
diff -r eb206d2bca5d -r 5ca8733edc78 mbed.bld
--- a/mbed.bld	Wed Oct 07 15:55:00 2015 +0000
+++ b/mbed.bld	Thu Dec 22 05:57:00 2016 +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/faff56e089b2
\ No newline at end of file