MBED Gaweda Cz1

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
kacpergaweda
Date:
Mon Jun 01 11:21:26 2020 +0000
Parent:
0:8a56d85a76bc
Commit message:
MBED GAWEDA cz1

Changed in this revision

KeyboardTs.cpp Show annotated file Show diff for this revision Revisions of this file
KeyboardTs.h Show annotated file Show diff for this revision Revisions of this file
KeyboardTs.lib 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
KeyboardTsLcd.lib Show diff for this revision Revisions of this file
LedLcd.cpp Show annotated file Show diff for this revision Revisions of this file
LedLcd.h Show annotated file Show diff for this revision Revisions of this file
Led_Lcd.lib Show diff for this revision Revisions of this file
diff -r 8a56d85a76bc -r 1ce1a6359874 KeyboardTs.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTs.cpp	Mon Jun 01 11:21:26 2020 +0000
@@ -0,0 +1,46 @@
+#include "TS_DISCO_F429ZI.h"
+#include "KeyboardTs.h"
+
+TS_DISCO_F429ZI ts;
+
+TS_StateTypeDef TS_State;
+
+KeyboardTs::KeyboardTs(uint8_t iColumnNumberConstructor){
+    iColumnNumber = iColumnNumberConstructor;
+}
+
+
+
+enum eKEYBOARD_KEY KeyboardTs::eRead(){
+    ts.GetState(&TS_State);
+    if (TS_State.TouchDetected)
+    {
+        x = TS_State.X;
+        y = TS_State.Y;
+        if(x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >= 0 & y <= 80)
+        {
+            return BUTTON_0;
+        }
+        else if (x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >=80 & y <= 160)
+        {
+            return BUTTON_1;
+        }
+        else if (x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >=160 & y <= 240)
+        {
+            return BUTTON_2;
+        }
+        else if (x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >=240 & y <= 320)
+        {
+            return BUTTON_3;
+        }
+        else
+        {
+            return NOT_TOUCHED;
+        }      
+    }
+    else
+    {
+        return NOT_TOUCHED;
+    }
+}    
+
diff -r 8a56d85a76bc -r 1ce1a6359874 KeyboardTs.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTs.h	Mon Jun 01 11:21:26 2020 +0000
@@ -0,0 +1,24 @@
+#ifndef KEYBOARDTS_H
+#define KEYBOARDTS_H
+#include "mbed.h"
+
+enum eKEYBOARD_KEY {BUTTON_0, BUTTON_1, BUTTON_2, BUTTON_3, NOT_TOUCHED};
+
+class KeyboardTs{
+    public:
+        KeyboardTs(uint8_t iColumnNumberConstructor);
+        enum eKEYBOARD_KEY eRead(void);
+        uint8_t iColumnNumber;
+    private:    
+        uint16_t x, y;
+    
+    
+    
+    };
+
+
+
+
+
+
+#endif
\ No newline at end of file
diff -r 8a56d85a76bc -r 1ce1a6359874 KeyboardTs.lib
--- a/KeyboardTs.lib	Mon Jun 01 11:13:48 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-KeyboardTs#eaf97ac7b4c5
diff -r 8a56d85a76bc -r 1ce1a6359874 KeyboardTsLcd.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTsLcd.cpp	Mon Jun 01 11:21:26 2020 +0000
@@ -0,0 +1,37 @@
+#include "KeyboardTs.h"
+#include "LedLcd.h"
+#include "mbed.h"
+#include "KeyboardTsLcd.h"
+
+KeyboardTs *pKeyboard;
+LedLcd *pLed;  
+
+KeyboardTsLcd::KeyboardTsLcd(unsigned char _ucColumn)
+{
+pKeyboard = new KeyboardTs(_ucColumn);
+pLed = new LedLcd(_ucColumn);
+}
+
+  
+
+enum eKEYBOARD_KEY KeyboardTsLcd::eRead(){    
+    
+        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 NOT_TOUCHED;
+        } 
+   
+}
\ No newline at end of file
diff -r 8a56d85a76bc -r 1ce1a6359874 KeyboardTsLcd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardTsLcd.h	Mon Jun 01 11:21:26 2020 +0000
@@ -0,0 +1,15 @@
+#ifndef KEYBOARDTSLCD_H
+#define KEYBOARDTSLCD_H
+
+
+class KeyboardTsLcd{
+    public:
+        enum eKEYBOARD_KEY eRead(void);
+        KeyboardTsLcd(unsigned char _ucColumn);
+};        
+
+
+
+
+
+#endif        
\ No newline at end of file
diff -r 8a56d85a76bc -r 1ce1a6359874 KeyboardTsLcd.lib
--- a/KeyboardTsLcd.lib	Mon Jun 01 11:13:48 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-KeyboardTsLcd#bde7434e8e7c
diff -r 8a56d85a76bc -r 1ce1a6359874 LedLcd.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LedLcd.cpp	Mon Jun 01 11:21:26 2020 +0000
@@ -0,0 +1,71 @@
+#include "LedLcd.h"
+#include "LCD_DISCO_F429ZI.h"
+
+LCD_DISCO_F429ZI lcd;
+
+
+LedLcd::LedLcd(uint8_t iColumnNumberConstructor){
+    iColumnNumber = iColumnNumberConstructor;
+    LcdInit();
+}
+
+
+void LedLcd::DrawKey(uint16_t iXPosKey, uint16_t iyPosKey, uint8_t iKeyNumber, uint32_t iColor){
+    uint8_t iKeyNumberArray[1];
+    lcd.SetFont(&Font24);
+    lcd.SetTextColor(iColor);
+    lcd.FillRect(iXPosKey, iyPosKey, 80, 80);
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.DrawRect(iXPosKey, iyPosKey, 80, 80);
+    lcd.SetBackColor(LCD_COLOR_RED);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    sprintf((char*)iKeyNumberArray, "%d", iKeyNumber);
+    lcd.DisplayStringAt(iXPosKey, iyPosKey, (uint8_t *) &iKeyNumberArray , LEFT_MODE);
+
+        
+}
+    
+void LedLcd::On(uint8_t iKeyIndex){
+    uint8_t iKeyCounter;
+
+    for(iKeyCounter = 0; iKeyCounter <= 3; iKeyCounter++){
+       if(iKeyIndex == iKeyCounter){
+            DrawKey(iColumnNumber*80, iKeyCounter*80, iKeyCounter, LCD_COLOR_GREEN); 
+       }
+       else{
+            DrawKey(iColumnNumber*80, iKeyCounter*80 , iKeyCounter, LCD_COLOR_BLUE);
+       }
+    }        
+}
+/*
+void LedLcd::TouchScreenInit(){
+    uint8_t status;
+    BSP_LCD_SetFont(&Font20);
+    status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
+  
+    if (status != TS_OK)
+    {
+      lcd.Clear(LCD_COLOR_RED);
+      lcd.SetBackColor(LCD_COLOR_RED);
+      lcd.SetTextColor(LCD_COLOR_WHITE);
+      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+      lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT FAIL", CENTER_MODE);
+    }
+    else
+    {
+      lcd.Clear(LCD_COLOR_GREEN);
+      lcd.SetBackColor(LCD_COLOR_GREEN);
+      lcd.SetTextColor(LCD_COLOR_WHITE);
+      lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+      lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT OK", CENTER_MODE);
+    }
+}
+*/
+
+void LedLcd::LcdInit(void){
+    lcd.Clear(LCD_COLOR_BLACK);
+    lcd.SetBackColor(LCD_COLOR_BLACK);
+}
+
+
+
diff -r 8a56d85a76bc -r 1ce1a6359874 LedLcd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LedLcd.h	Mon Jun 01 11:21:26 2020 +0000
@@ -0,0 +1,24 @@
+#ifndef LED_LCD
+#define LED_LCD
+#include "mbed.h"
+
+class LedLcd {
+    private:
+        void DrawKey(uint16_t iXPosKey, uint16_t iyPosKey, uint8_t iKeyNumber, uint32_t iColor);
+        uint8_t iColumnNumber;
+    public:
+        LedLcd(uint8_t iColumnNumberConstructor);
+        void LcdInit(void);
+        void On(uint8_t iKeyIndex);
+};
+
+
+
+
+
+
+
+
+
+
+#endif
\ No newline at end of file
diff -r 8a56d85a76bc -r 1ce1a6359874 Led_Lcd.lib
--- a/Led_Lcd.lib	Mon Jun 01 11:13:48 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Led_Lcd#6a3992dd0bfd