Kevin Leong / Mbed 2 deprecated Program3

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Revision:
0:e579c6f35abf
Child:
1:9770f292298c
diff -r 000000000000 -r e579c6f35abf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 15 21:53:52 2020 +0000
@@ -0,0 +1,78 @@
+#include "mbed.h"
+#include "TS_DISCO_F429ZI.h"
+#include "LCD_DISCO_F429ZI.h"
+
+extern "C" uint32_t getQuad ( uint16_t x, uint16_t y);
+extern "C" uint32_t swapRedBlue ( uint32_t color);
+extern "C" uint32_t toggleAlphaMSB ( uint32_t color);
+//extern "C" uint32_t rotateRGBBytes ( uint32_t color);
+//extern "C" uint32_t setRGBBits ( uint32_t color, uint8_t n);
+
+LCD_DISCO_F429ZI lcd;
+TS_DISCO_F429ZI ts;
+
+int main()
+{
+    TS_StateTypeDef TS_State;
+    uint16_t x, y;
+    uint8_t text[30];
+    //uint8_t status;
+  
+    BSP_LCD_SetFont(&Font20);
+  
+    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Project 3!!!", CENTER_MODE);
+    wait(1);
+    
+    int xSize = lcd.GetXSize()/2;
+    int ySize = lcd.GetYSize()/2;
+    
+    uint32_t blue = 0xFF0000FF;
+    uint32_t green = 0xFF00FF00;
+    uint32_t red = 0xFFFF0000;
+    uint32_t yellow = 0xFFFFFF00;
+    
+    lcd.SetTextColor(blue); //blue
+    lcd.FillRect(0, 0, xSize, ySize);
+    lcd.SetTextColor(green); //green
+    lcd.FillRect(0, ySize, xSize, ySize);
+    lcd.SetTextColor(red); //red
+    lcd.FillRect(xSize, 0, xSize, ySize);
+    lcd.SetTextColor(yellow); //yellow
+    lcd.FillRect(xSize, ySize, xSize, ySize);
+  
+    //status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
+    
+    wait(1);
+    
+    while(1)
+    {
+      ts.GetState(&TS_State);      
+      if (TS_State.TouchDetected)
+      {
+        x = TS_State.X;
+        y = TS_State.Y;
+        sprintf((char*)text, "x=%d y=%d    ", x, y);
+        lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+        
+        int quad = getQuad(x, y);
+        
+        if(quad == 1){
+            blue = swapRedBlue(blue);
+            lcd.SetTextColor(blue);
+            lcd.FillRect(0, 0, xSize, ySize);
+        }
+        else if(quad == 2){
+            red = toggleAlphaMSB(red);
+            lcd.SetTextColor(red);
+            lcd.FillRect(xSize, 0, xSize, ySize);
+        }
+        else if(quad == 3){
+        }
+        else if(quad == 4){
+            
+        }
+        
+        
+      }
+    }
+}