cw2d-2

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
wolve265
Date:
Mon May 11 19:07:50 2020 +0000
Parent:
0:6d0b62cb7525
Commit message:
final version

Changed in this revision

KeyboardTsLcd.cpp Show annotated file Show diff for this revision Revisions of this file
KeyboardTsLcd.h 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 6d0b62cb7525 -r a89a995856ce KeyboardTsLcd.cpp
--- a/KeyboardTsLcd.cpp	Fri May 08 09:17:00 2020 +0000
+++ b/KeyboardTsLcd.cpp	Mon May 11 19:07:50 2020 +0000
@@ -5,22 +5,22 @@
     pLed = new LedLcd(ucColumn);
 }
 
-void KeyboardTsLcd::eRead(){
+enum KeyboardState KeyboardTsLcd::eRead(){
     switch(pKeyboard->eRead()){
         case BUTTON_0:
             pLed->On(0);
-        break;
+            return BUTTON_0;
         case BUTTON_1:
             pLed->On(1);
-        break;
+            return BUTTON_1;
         case BUTTON_2:
             pLed->On(2);
-        break;
+            return BUTTON_2;
         case BUTTON_3:
             pLed->On(3);
-        break;
+            return BUTTON_3;
         default :
             pLed->On(4);
-        break;
+            return RELEASED;
     }
 }
\ No newline at end of file
diff -r 6d0b62cb7525 -r a89a995856ce KeyboardTsLcd.h
--- a/KeyboardTsLcd.h	Fri May 08 09:17:00 2020 +0000
+++ b/KeyboardTsLcd.h	Mon May 11 19:07:50 2020 +0000
@@ -6,11 +6,11 @@
 
 class KeyboardTsLcd{
     private:
-        KeyboardTs *pKeyboard;
-        LedLcd *pLed; 
+        KeyboardTs *pKeyboard;    
     public:
+        LedLcd *pLed;
         KeyboardTsLcd(unsigned char);
-        void eRead();
+        enum KeyboardState eRead();
 };
 
 #endif
\ No newline at end of file
diff -r 6d0b62cb7525 -r a89a995856ce Led_Lcd.cpp
--- a/Led_Lcd.cpp	Fri May 08 09:17:00 2020 +0000
+++ b/Led_Lcd.cpp	Mon May 11 19:07:50 2020 +0000
@@ -6,16 +6,15 @@
     lcd.SetBackColor(LCD_COLOR_RED);
     lcd.SetTextColor(LCD_COLOR_GREEN);
     ucLedPosX = ucColumn*80;
-    
-    for(unsigned int uiLedPosY = 0; uiLedPosY < 320; uiLedPosY=uiLedPosY+80){
-        lcd.DrawRect(ucLedPosX, uiLedPosY, 80, 80);     
-    }
 }
 
 void LedLcd::On(unsigned char ucLedNumber){
     unsigned char ucLedNumbers[2];
     
     for(unsigned char ucLedCounter = 0; ucLedCounter < 4; ucLedCounter++){
+        lcd.SetTextColor(LCD_COLOR_GREEN);
+        lcd.DrawRect(ucLedPosX, ucLedCounter*80, 80, 80);
+        
         if(ucLedCounter == ucLedNumber){
              lcd.SetTextColor(LCD_COLOR_GREEN);  
         }
diff -r 6d0b62cb7525 -r a89a995856ce main.cpp
--- a/main.cpp	Fri May 08 09:17:00 2020 +0000
+++ b/main.cpp	Mon May 11 19:07:50 2020 +0000
@@ -2,10 +2,27 @@
 #include "KeyboardTsLcd.h"
 
 int main(){
-    KeyboardTsLcd Keyboard(1);
+    KeyboardTsLcd Keyboard(0);
+    KeyboardTsLcd Keyboard2(2);
     
     while(1) {
-        Keyboard.eRead();
+        switch(Keyboard.eRead()){
+            case BUTTON_0:
+                Keyboard2.pLed->On(3);
+            break;
+            case BUTTON_1:
+                Keyboard2.pLed->On(2);
+            break;
+            case BUTTON_2:
+                Keyboard2.pLed->On(1);
+            break;
+            case BUTTON_3:
+                Keyboard2.pLed->On(0);
+            break;
+            default:
+                Keyboard2.pLed->On(4);
+            break;
+        }
         wait(0.1);
     }
 }
\ No newline at end of file