mbed_1 - last program

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
matisembed
Date:
Mon Jun 01 17:08:22 2020 +0000
Parent:
1:4a8b2dbb7ff3
Commit message:
asdasd

Changed in this revision

KeyboardTsLcd.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard_Ts.cpp Show annotated file Show diff for this revision Revisions of this file
Led_Lcd.cpp 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
diff -r 4a8b2dbb7ff3 -r 39601122cf74 KeyboardTsLcd.cpp
--- a/KeyboardTsLcd.cpp	Mon May 11 18:19:58 2020 +0000
+++ b/KeyboardTsLcd.cpp	Mon Jun 01 17:08:22 2020 +0000
@@ -19,7 +19,7 @@
         case BUTTON_3:
             pLed -> On(3);
             break;
-        default :
+        default:
             pLed -> On(4);
             break;
     }
diff -r 4a8b2dbb7ff3 -r 39601122cf74 Keyboard_Ts.cpp
--- a/Keyboard_Ts.cpp	Mon May 11 18:19:58 2020 +0000
+++ b/Keyboard_Ts.cpp	Mon Jun 01 17:08:22 2020 +0000
@@ -5,16 +5,7 @@
 KeyboardTs::KeyboardTs(unsigned char ucColumnNr){
     
     TouchScreen.Init(lcd.GetXSize(), lcd.GetYSize());
-    
-    if(ucColumnNr == 1){
-        square_x_pos = 80;    
-    }
-    else if(ucColumnNr == 2){
-        square_x_pos = 160;    
-    }
-    else{
-        square_x_pos = 0;
-    }
+    square_x_pos = ucColumnNr * LENGTH_SIDE_SQUARE;
 }
 
 enum KeyboardState KeyboardTs::eRead(void){
@@ -34,7 +25,7 @@
                 return BUTTON_2;
             }
             else if((TSState.Y > 3 * LENGTH_SIDE_SQUARE) && (TSState.Y <= 4 * LENGTH_SIDE_SQUARE)){
-                return BUTTON_3;       
+                return BUTTON_3;
             }
         }
     }
diff -r 4a8b2dbb7ff3 -r 39601122cf74 Led_Lcd.cpp
--- a/Led_Lcd.cpp	Mon May 11 18:19:58 2020 +0000
+++ b/Led_Lcd.cpp	Mon Jun 01 17:08:22 2020 +0000
@@ -2,40 +2,31 @@
 
 #define LENGTH_SIDE_SQUARE 80
 
-LedLcd::LedLcd(unsigned char ucColumnNr){
-    
+DigitalOut myled(LED1);
+
+LedLcd::LedLcd(unsigned char ucColumnNr){    
     lcd.Clear(LCD_COLOR_BLACK);
     lcd.SetFont(&Font24);
-    
-    if(ucColumnNr == 1){
-        square_x_pos = 80;  
-    }
-    else if(ucColumnNr == 2){
-        square_x_pos = 160;  
-    }
-    else{
-        square_x_pos = 0;
-    }  
+    square_x_pos = ucColumnNr * LENGTH_SIDE_SQUARE;
 }
 
 void LedLcd::On(unsigned char uLedLcdNumber){
+    char cText[2] = {'0'};
+    char *pText = cText;
     
     for(unsigned char ucSquareCounter = 0; ucSquareCounter <= 3; ucSquareCounter++){
+        *pText += 1;
         lcd.SetTextColor(LCD_COLOR_GREEN);
         lcd.DrawRect(square_x_pos, ucSquareCounter * LENGTH_SIDE_SQUARE, LENGTH_SIDE_SQUARE, LENGTH_SIDE_SQUARE);
         if(ucSquareCounter == uLedLcdNumber){
-            lcd.SetTextColor(LCD_COLOR_YELLOW);
+            lcd.SetTextColor(LCD_COLOR_MAGENTA);
         }
         else{
             lcd.SetTextColor(LCD_COLOR_BLUE);
         }
         lcd.FillRect(square_x_pos + 1, ucSquareCounter * LENGTH_SIDE_SQUARE + 1, LENGTH_SIDE_SQUARE - 2, LENGTH_SIDE_SQUARE - 2);
-        
+        lcd.SetBackColor(LCD_COLOR_RED);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        lcd.DisplayStringAt(square_x_pos, ucSquareCounter * LENGTH_SIDE_SQUARE, (uint8_t *)pText, LEFT_MODE);
     }
-    lcd.SetBackColor(LCD_COLOR_RED);
-    lcd.SetTextColor(LCD_COLOR_WHITE);
-    lcd.DisplayStringAt(square_x_pos, 0 * LENGTH_SIDE_SQUARE,(uint8_t *)"0", LEFT_MODE);
-    lcd.DisplayStringAt(square_x_pos, 1 * LENGTH_SIDE_SQUARE,(uint8_t *)"1", LEFT_MODE);
-    lcd.DisplayStringAt(square_x_pos, 2 * LENGTH_SIDE_SQUARE,(uint8_t *)"2", LEFT_MODE);
-    lcd.DisplayStringAt(square_x_pos, 3 * LENGTH_SIDE_SQUARE,(uint8_t *)"3", LEFT_MODE);
 }
diff -r 4a8b2dbb7ff3 -r 39601122cf74 main.cpp
--- a/main.cpp	Mon May 11 18:19:58 2020 +0000
+++ b/main.cpp	Mon Jun 01 17:08:22 2020 +0000
@@ -9,7 +9,23 @@
     while(1){
         Keyboard.eRead();
         wait(0.1);
-        LedLcd.pLed -> On(3 - Keyboard.pKeyboard -> eRead());
+        switch(Keyboard.pKeyboard -> eRead()){
+            case BUTTON_0:
+                LedLcd.pLed -> On(BUTTON_3);
+            break;
+            case BUTTON_1:
+                LedLcd.pLed -> On(BUTTON_2);
+            break;
+            case BUTTON_2:
+                LedLcd.pLed -> On(BUTTON_1);
+            break;
+            case BUTTON_3:
+                LedLcd.pLed -> On(BUTTON_0);
+            break;
+            default:
+                LedLcd.pLed -> On(NO_BUTTON_PRESSED);
+            break;
+        }
         wait(0.1);
     }
 }
\ No newline at end of file