Mbed cz.1 cwiczenie ostatnie (2d2)

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
dzialowy04
Date:
Mon May 18 05:54:39 2020 +0000
Commit message:
mbed cz.1 cwiczenie ostatnie (2d2)

Changed in this revision

BSP_DISCO_F429ZI.lib Show annotated file Show diff for this revision Revisions of this file
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
Keyboard_Ts.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard_Ts.h Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F429ZI.lib 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
Led_Lcd.h Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F429ZI.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.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 036c13c6cbb6 BSP_DISCO_F429ZI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F429ZI.lib	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
diff -r 000000000000 -r 036c13c6cbb6 KeyboardTsLcd.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTsLcd.cpp	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,31 @@
+#include "KeyboardTsLcd.h"
+
+KeyboardTsLcd::KeyboardTsLcd(unsigned char _ucColumn){
+    pKeyboard = new KeyboardTs(_ucColumn);
+    pLed = new LedLcd(_ucColumn);
+}
+
+enum KeyboardState KeyboardTsLcd::eRead(){
+    switch(pKeyboard->eRead()){
+        case BUTTON_0:
+            pLed->On(0);
+            return BUTTON_0;
+            break;
+        case BUTTON_1:
+            pLed->On(1);
+            return BUTTON_1;
+            break;
+        case BUTTON_2:
+            pLed->On(2);
+            return BUTTON_2;
+            break;
+        case BUTTON_3:
+            pLed->On(3);
+            return  BUTTON_3;
+            break;
+        default:
+            pLed->On(4);
+            return RELASED;
+            break;    
+        }    
+}
\ No newline at end of file
diff -r 000000000000 -r 036c13c6cbb6 KeyboardTsLcd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTsLcd.h	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,15 @@
+#ifndef KEYBOARDTSLCD_H
+#define KEYBOARDTSLCD_H
+#include "Keyboard_Ts.h"
+#include "Led_Lcd.h"
+
+class KeyboardTsLcd{
+    public:
+        KeyboardTsLcd(unsigned char);
+        enum KeyboardState eRead();
+    private:
+        KeyboardTs *pKeyboard;
+        LedLcd *pLed;
+};
+
+#endif
\ No newline at end of file
diff -r 000000000000 -r 036c13c6cbb6 Keyboard_Ts.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts.cpp	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,27 @@
+#include "Keyboard_Ts.h"
+
+KeyboardTs::KeyboardTs(unsigned char ucColumnIndex){
+    ucLeftBoundary = ucColumnIndex*80;
+    ucRightBoundary = ucColumnIndex*80 + 80;
+}
+
+enum KeyboardState KeyboardTs::eRead(){
+    ts.GetState(&TS_State);
+    if (TS_State.TouchDetected & (TS_State.X >= ucLeftBoundary) & (TS_State.X < ucRightBoundary)){ 
+        if(TS_State.Y <80){
+            return BUTTON_0;
+        }
+        else if(TS_State.Y <160){
+            return BUTTON_1;    
+        }
+        else if(TS_State.Y <240){
+            return BUTTON_2;
+        }
+        else{
+            return BUTTON_3;   
+        }
+    }
+    else{
+        return RELASED;
+    }         
+}
diff -r 000000000000 -r 036c13c6cbb6 Keyboard_Ts.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts.h	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,24 @@
+#ifndef KEYBOARDTS_H
+#define KEYBOARDTS_H
+#include "TS_DISCO_F429ZI.h"
+
+enum KeyboardState{
+    RELASED,
+    BUTTON_0,
+    BUTTON_1,
+    BUTTON_2,
+    BUTTON_3
+};
+
+class KeyboardTs{
+    private:
+        TS_DISCO_F429ZI ts;
+        TS_StateTypeDef TS_State;
+        unsigned char ucLeftBoundary;
+        unsigned char ucRightBoundary;
+    public:
+        KeyboardTs(unsigned char);
+        enum KeyboardState eRead();
+};
+
+#endif
\ No newline at end of file
diff -r 000000000000 -r 036c13c6cbb6 LCD_DISCO_F429ZI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F429ZI.lib	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
diff -r 000000000000 -r 036c13c6cbb6 Led_Lcd.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Lcd.cpp	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,34 @@
+#include "Led_Lcd.h"
+
+LedLcd::LedLcd(unsigned char ucColumnIndex){
+    
+    ucLedPos = ucColumnIndex*80;
+    lcd.Clear(LCD_COLOR_BLACK);
+    BSP_LCD_SetFont(&Font24);    
+    lcd.SetBackColor(LCD_COLOR_RED);
+    //lcd.SetTextColor(LCD_COLOR_GREEN);
+    
+    //for(unsigned char ucRectNumber = 0; ucRectNumber < 4; ucRectNumber++){
+      //  lcd.DrawRect(ucLedPos, ucRectNumber*80, 80, 80);
+    //}
+}
+
+void LedLcd::On(unsigned char ucLedIndex){
+    
+    unsigned char ucKeyNumber[2];
+    
+    for(unsigned char ucKeyCounter = 0; ucKeyCounter < 4; ucKeyCounter++){
+        if(ucLedIndex == ucKeyCounter){
+            lcd.SetTextColor(LCD_COLOR_YELLOW);    
+        }
+        else{
+            lcd.SetTextColor(LCD_COLOR_BLUE);
+        }
+        lcd.FillRect(ucLedPos+1, ucKeyCounter*80 + 1, 79, 79);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        sprintf((char*)ucKeyNumber, "%d", ucKeyCounter);
+        lcd.DisplayStringAt(ucLedPos, ucKeyCounter*80, (uint8_t *) &ucKeyNumber, LEFT_MODE);
+        lcd.SetTextColor(LCD_COLOR_GREEN);
+        lcd.DrawRect(ucLedPos, ucKeyCounter*80, 80, 80);
+    }
+}  
\ No newline at end of file
diff -r 000000000000 -r 036c13c6cbb6 Led_Lcd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Lcd.h	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,14 @@
+#ifndef LED_LCD_H
+#define LED_LCD_H
+#include "LCD_DISCO_F429ZI.h"
+
+class LedLcd{
+    private:
+        LCD_DISCO_F429ZI lcd;
+        unsigned char ucLedPos;
+    public:
+        LedLcd(unsigned char);
+        void On(unsigned char);   
+};
+
+#endif
\ No newline at end of file
diff -r 000000000000 -r 036c13c6cbb6 TS_DISCO_F429ZI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F429ZI.lib	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
diff -r 000000000000 -r 036c13c6cbb6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "KeyboardTsLcd.h"
+
+int main(){
+
+    LedLcd Led(2);
+    KeyboardTsLcd Keyboard(0);
+    
+    
+    while(1){
+        switch(Keyboard.eRead()){
+            case BUTTON_0:
+                Led.On(3);
+                break;
+            case BUTTON_1:
+                Led.On(2);
+                break;
+            case BUTTON_2:
+                Led.On(1);
+                break;
+            case BUTTON_3:
+                Led.On(0);
+                break;
+            default:
+                Led.On(4);
+                break;    
+        }    
+        wait(0.1);
+    }    
+}
\ No newline at end of file
diff -r 000000000000 -r 036c13c6cbb6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 18 05:54:39 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file