Podpunkt 2d_2 z ćwiczenia mbed_cz1

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
depsztyczek
Date:
Mon May 18 11:50:27 2020 +0000
Commit message:
The whole mbed_cz1 program.

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F429ZI.lib	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTsLcd.cpp	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "KeyboardTsLcd.h"
+
+
+KeyboardTsLcd::KeyboardTsLcd(uint8_t _ucColumn){
+    
+    pKeyboard = new KeyboardTs(_ucColumn);
+    pLed = new LedLcd(_ucColumn);
+    
+};
+
+Buttons KeyboardTsLcd::eRead(void){
+     
+     switch( pKeyboard->eRead() ) {
+            case BUTTON_0:
+                pLed->On(0);
+                return BUTTON_0;                
+            case BUTTON_1:
+                pLed->On(1);
+                return BUTTON_1;
+            case BUTTON_2:
+                pLed->On(2);
+                return BUTTON_2;
+            case BUTTON_3:
+                pLed->On(3);
+                return BUTTON_3;
+            default :
+                pLed->On(4);
+                return BUTTON_4;   
+        }
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTsLcd.h	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,17 @@
+#ifndef KEYBOARD_TS_LCD_H
+#define KEYBOARD_TS_LCD_H
+
+#include "Keyboard_Ts.h"
+#include "Led_Lcd.h"
+
+class KeyboardTsLcd{
+    public:
+        KeyboardTsLcd(uint8_t _ucColumn);
+        Buttons eRead(void);
+        KeyboardTs *pKeyboard;
+        LedLcd *pLed;
+};
+
+
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts.cpp	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,39 @@
+#include "Keyboard_Ts.h"
+#include "mbed.h"
+
+#define BUTTON_0_Y 0
+#define BUTTON_1_Y 80
+#define BUTTON_2_Y 160
+#define BUTTON_3_Y 240
+#define BUTTON_X 80
+
+
+
+KeyboardTs :: Buttons KeyboardTs :: eRead(void){
+    
+    TS_StateTypeDef TS_State;
+    GetState(&TS_State);
+    
+    if( ( TS_State.TouchDetected) && ( TS_State.Y > BUTTON_0_Y ) && ( TS_State.Y < BUTTON_1_Y ) && ( TS_State.X < BUTTON_X * Column) ){
+        return BUTTON_0; 
+    }
+    else if( ( TS_State.TouchDetected) && ( TS_State.Y > BUTTON_1_Y ) && ( TS_State.Y < BUTTON_2_Y ) && ( TS_State.X < BUTTON_X * Column ) ){
+        return BUTTON_1; 
+    }
+    else if( ( TS_State.TouchDetected) && ( TS_State.Y > BUTTON_2_Y ) && ( TS_State.Y < BUTTON_3_Y  ) && ( TS_State.X < BUTTON_X * Column ) ){
+        return BUTTON_2; 
+    }
+    else if( ( TS_State.TouchDetected) && ( TS_State.Y > BUTTON_3_Y ) && ( TS_State.X < BUTTON_X * Column ) ){
+        return BUTTON_3; 
+    }
+    else{
+       return BUTTON_4; 
+    }            
+    
+    
+}
+KeyboardTs :: KeyboardTs(uint8_t SetColumn){
+    
+    Column=SetColumn+1;
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts.h	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,17 @@
+#ifndef KEYBOARD_TS_H
+#define KEYBOARD_TS_H
+
+#include "TS_DISCO_F429ZI.h"
+
+enum Buttons{BUTTON_0,BUTTON_1,BUTTON_2,BUTTON_3, BUTTON_4};
+
+class KeyboardTs : public TS_DISCO_F429ZI{
+    public:
+        enum Buttons{BUTTON_0,BUTTON_1,BUTTON_2,BUTTON_3, BUTTON_4};
+        Buttons eRead(void); 
+        KeyboardTs(uint8_t Column);
+    private:
+        uint8_t Column;    
+};
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F429ZI.lib	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Lcd.cpp	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,36 @@
+#include "Led_Lcd.h"
+#define SQUARE_WIDTH 80
+
+void LedLcd :: On(uint8_t InButtonNumber){
+
+      
+      for(uint8_t ButtonNumber=0; ButtonNumber<4 ; ButtonNumber++){
+              
+              
+              uint8_t String[2]={ButtonNumber+'0',0};
+              SetTextColor(LCD_COLOR_GREEN);
+              DrawRect(Column*SQUARE_WIDTH, SQUARE_WIDTH * ButtonNumber, SQUARE_WIDTH, SQUARE_WIDTH );
+              
+              if( InButtonNumber == ButtonNumber ){
+                SetTextColor(LCD_COLOR_YELLOW);
+              }
+              else{
+                SetTextColor(LCD_COLOR_BLUE);  
+              }
+              
+              FillRect(1+Column*SQUARE_WIDTH, SQUARE_WIDTH * ButtonNumber + 1, SQUARE_WIDTH-2, SQUARE_WIDTH-2);
+              SetBackColor(LCD_COLOR_RED);
+              SetTextColor(LCD_COLOR_WHITE);
+              DisplayStringAt(Column*SQUARE_WIDTH, SQUARE_WIDTH * ButtonNumber, (uint8_t *)String, LEFT_MODE);
+              
+          }    
+       
+}
+
+LedLcd :: LedLcd(uint8_t SetColumn){
+        
+      Clear(LCD_COLOR_BLACK);
+      SetFont(&Font24);
+      Column=SetColumn;
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Lcd.h	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,14 @@
+#ifndef LED_LCD_H
+#define LED_LCD_H
+
+#include "LCD_DISCO_F429ZI.h"
+
+class LedLcd : public LCD_DISCO_F429ZI {
+    public:        
+        void On(uint8_t ButtonNumber);
+        LedLcd(uint8_t SetColumn=0);
+    private:
+        uint8_t Column;
+};
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F429ZI.lib	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "Keyboard_Ts.h"
+#include "Led_Lcd.h"
+#include "KeyboardTsLcd.h"
+
+int main(){
+    
+    KeyboardTsLcd KeyboardLead(0);
+    KeyboardTsLcd KeyboardFollow(2);
+
+    while(1) {
+     
+     switch( KeyboardLead.eRead() ) {
+            case BUTTON_0:
+                KeyboardFollow.pLed->On(3);
+                break;               
+            case BUTTON_1:
+                KeyboardFollow.pLed->On(2);
+                break;
+            case BUTTON_2:
+                KeyboardFollow.pLed->On(1);
+                break;
+            case BUTTON_3:
+                KeyboardFollow.pLed->On(0);
+                break;                
+            default:
+                KeyboardFollow.pLed->On(4);
+                break;       
+      }
+    wait(0.1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 18 11:50:27 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file