Dominik Chat / Mbed 2 deprecated Program_punkt_2D

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
lolkusus
Date:
Fri May 08 15:43:58 2020 +0000
Child:
1:d392393df3d0
Commit message:
Finished? Mbed p1

Changed in this revision

BSP_DISCO_F429ZI.lib 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
Keyboard_Ts_Lcd.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard_Ts_Lcd.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	Fri May 08 15:43:58 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/Keyboard_Ts.cpp	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,32 @@
+#include "Keyboard_Ts.h"
+#include "TS_DISCO_F429ZI.h"
+
+TS_DISCO_F429ZI ts;
+
+KeyboardTs::KeyboardTs(unsigned char ucColumn)
+{
+    ts.Init(240, 320);
+    ucColumnNumber = ucColumn;
+}
+
+KeyState KeyboardTs::eRead()
+{
+    TS_StateTypeDef TS_State;
+    ts.GetState(&TS_State);
+    if ((TS_State.TouchDetected) && (TS_State.X <= 80*(ucColumnNumber+1)) && (TS_State.X >= 80*ucColumnNumber))
+    {
+        if (TS_State.Y <= 80)
+            return BUTTON_0;
+                
+        else if ((TS_State.Y >= 81) && (TS_State.Y <= 160))
+            return BUTTON_1;
+
+        else if ((TS_State.Y >= 161) && (TS_State.Y <= 240))
+            return BUTTON_2;
+            
+        else if ((TS_State.Y >= 241) && (TS_State.Y <= 320))
+            return BUTTON_3;
+
+    }
+        return NONE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts.h	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,22 @@
+#ifndef __Keyboard_Ts_H
+#define __Keyboard_Ts_H
+
+typedef enum KeyState
+{
+    BUTTON_0,
+    BUTTON_1,
+    BUTTON_2,
+    BUTTON_3,
+    NONE
+} KeyState;
+
+class KeyboardTs
+{
+    public:
+        KeyboardTs(unsigned char ucColumn = 0);
+        KeyState eRead();    
+    private:
+        unsigned char ucColumnNumber;
+};
+
+#endif   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts_Lcd.cpp	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,29 @@
+#include "Keyboard_Ts_Lcd.h"
+
+KeyboardTsLcd::KeyboardTsLcd(unsigned char _ucColumn)
+{
+    pKeyboard = new KeyboardTs(_ucColumn);
+    pLed = new LedLcd(_ucColumn);
+};
+
+void KeyboardTsLcd::eRead()
+{
+    switch(pKeyboard->eRead()) 
+        {
+            case BUTTON_0:
+            pLed->On(0);
+            break;
+            case BUTTON_1:
+            pLed->On(1);
+            break;
+            case BUTTON_2:
+            pLed->On(2);
+            break;
+            case BUTTON_3:
+            pLed->On(3);
+            break;
+            default :
+            pLed->On(4);
+            break;
+        }    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts_Lcd.h	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,17 @@
+#ifndef __Keyboard_Ts_Lcd_H
+#define __Keyboard_Ts_Lcd_H
+
+#include "Led_Lcd.h"
+#include "Keyboard_Ts.h"
+
+class KeyboardTsLcd
+{
+    public:
+        KeyboardTsLcd(unsigned char _ucColumn = 0);
+        void eRead();
+    protected:
+        KeyboardTs *pKeyboard;
+        LedLcd     *pLed;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F429ZI.lib	Fri May 08 15:43:58 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	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,55 @@
+#include "Led_Lcd.h"
+#include "LCD_DISCO_F429ZI.h"
+
+LCD_DISCO_F429ZI lcd;
+
+LedLcd::LedLcd(unsigned char ucColumn)
+{
+    ucColumnNumber = ucColumn;
+    
+    lcd.Clear(LCD_COLOR_BLACK);
+    
+    lcd.SetFont(&Font24);
+    lcd.SetBackColor(LCD_COLOR_RED);
+    
+    for (unsigned char ucButtonCounter = 0; ucButtonCounter < BUTTON_COUNT; ucButtonCounter++)
+    {
+        DrawButton(ucButtonCounter,DEPRESSED);
+    }
+}
+
+void LedLcd::DrawButton(unsigned char ucButtonNumber, ButtonState eButtonState)
+{
+    char cBuffor[3];
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.DrawRect(80*ucColumnNumber,80*ucButtonNumber,80,80);
+        
+    if (eButtonState == PRESSED)
+    {
+        lcd.SetTextColor(LCD_COLOR_GREEN);
+    }
+    else
+    {
+        lcd.SetTextColor(LCD_COLOR_BLUE);
+    }
+    lcd.FillRect(2+80*ucColumnNumber,2+80*ucButtonNumber,77,77);
+        
+    sprintf(cBuffor, "%d", ucButtonNumber);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.DisplayStringAt(1+80*ucColumnNumber,1+80*ucButtonNumber,(uint8_t *)&cBuffor, LEFT_MODE);
+}
+
+void LedLcd::On(unsigned char ledNumber)
+{
+    for (unsigned char ucLedCounter = 0; ucLedCounter < BUTTON_COUNT; ucLedCounter++)
+    {
+        if (ucLedCounter == ledNumber)
+        {
+            DrawButton(ucLedCounter, PRESSED);
+        }   
+        else
+        {
+            DrawButton(ucLedCounter, DEPRESSED);    
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Lcd.h	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,22 @@
+#ifndef __Led_Lcd_H
+#define __Led_Lcd_H
+
+#define BUTTON_COUNT 4
+
+typedef enum ButtonState
+{
+    PRESSED,
+    DEPRESSED
+} ButtonState;
+
+class LedLcd
+{
+    public:
+        LedLcd(unsigned char ucColumn = 0);
+        void On(unsigned char ledNumber);
+    private:
+        void DrawButton(unsigned char ucButtonNumber, ButtonState eButtonState); 
+        unsigned char ucColumnNumber;  
+};
+
+#endif   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F429ZI.lib	Fri May 08 15:43:58 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	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+#include "Keyboard_Ts_Lcd.h"
+
+#define REFRESH_PERIOD 0.1
+
+KeyboardTsLcd Keyboard_Left(0);
+KeyboardTsLcd Keyboard_Right(2);
+
+int main()
+{
+    while(1)
+    {
+        Keyboard_Left.eRead();
+        Keyboard_Right.eRead();
+        wait(REFRESH_PERIOD);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 08 15:43:58 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file