aghmtmppo

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
domino5740
Date:
Mon Jun 15 17:39:40 2020 +0000
Commit message:
final

Changed in this revision

BSP_DISCO_F429ZI.lib Show annotated file Show diff for this revision Revisions of this file
Keyboard.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard.h Show annotated file Show diff for this revision Revisions of this file
Keyboard_Led.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard_Led.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.cpp Show annotated file Show diff for this revision Revisions of this file
Led.h Show annotated file Show diff for this revision Revisions of this file
Led_Board.cpp Show annotated file Show diff for this revision Revisions of this file
Led_Board.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 Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard.cpp	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,27 @@
+#include "Keyboard.h"
+#include "LCD_DISCO_F429ZI.h"
+#include "TS_DISCO_F429ZI.h"
+
+extern LCD_DISCO_F429ZI lcd;
+
+Keyboard::Keyboard(unsigned char ucColumn) {
+    ts.Init(lcd.GetXSize(), lcd.GetYSize());
+    ucColXPos = ucColumn * 80;
+    if(ucColXPos != 0) ucColXPos -= 1;
+}
+
+enum Read Keyboard::eRead() {
+    ts.GetState(&TS_State);      
+    if (TS_State.TouchDetected)
+    {
+        x = TS_State.X;
+        y = TS_State.Y;     
+        if(x >= ucColXPos && x <= (79 + ucColXPos)) {
+            if(y <= 79)                  return BUTTON_0;
+            else if(y > 79 && y <= 159)  return BUTTON_1;
+            else if(y > 159 && y <= 239) return BUTTON_2;
+            else if(y > 239 && y <= 319) return BUTTON_3;
+        }
+    }
+    return NO_BUTTON;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard.h	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,19 @@
+#ifndef KEYBOARD_H
+#define KEYBOARD_H
+
+#include "TS_DISCO_F429ZI.h"
+
+enum Read {BUTTON_0, BUTTON_1, BUTTON_2, BUTTON_3, NO_BUTTON };
+
+class Keyboard {
+    public:
+        Keyboard(unsigned char ucColumn = 0);
+        enum Read eRead();
+    private:
+        TS_DISCO_F429ZI ts;
+        unsigned char ucColXPos;
+        TS_StateTypeDef TS_State;
+        uint16_t x, y;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Led.cpp	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,26 @@
+#include "Keyboard_Led.h"
+
+KeyboardLed::KeyboardLed(unsigned char ucColumn) {
+    pKeyboard = new Keyboard(ucColumn);
+    pLed = new LedBoard(ucColumn);
+}
+
+enum Read KeyboardLed::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 -> Off();
+                return NO_BUTTON;
+        }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Led.h	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,15 @@
+#ifndef KEYBOARD_LED_H
+#define KEYBOARD_LED_H
+
+#include "Keyboard.h"
+#include "Led_Board.h"
+
+class KeyboardLed {
+    public:
+        KeyboardLed(unsigned char ucColNum);
+        enum Read eRead();
+    private:
+        Keyboard *pKeyboard;
+        LedBoard *pLed;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F429ZI.lib	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led.cpp	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,38 @@
+#include "LCD_DISCO_F429ZI.h"
+#include "Led.h"
+
+extern LCD_DISCO_F429ZI lcd;
+
+Led::Led(unsigned char ucColumn, unsigned char ucRow) {
+    
+    this -> ucColumn = ucColumn;
+    this -> ucRow = ucRow;
+    
+    Redraw(LCD_COLOR_BLUE);
+    
+}
+
+void Led::On(void) {
+    Redraw(LCD_COLOR_MAGENTA);
+}
+
+void Led::Off(void) {
+    Redraw(LCD_COLOR_BLUE);
+}
+
+void Led::Redraw(uint32_t Color) {
+        
+    unsigned int xPos = ucColumn ? (ucColumn * 80 - 1) : ucColumn;
+    unsigned int yPos = ucRow ? (ucRow * 80 - 1) : ucRow;
+    char text[1];
+
+    lcd.SetTextColor(Color);
+    lcd.FillRect(xPos, yPos, 80, 80);
+    
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.DrawRect(xPos, yPos, 80, 80);
+    lcd.SetBackColor(LCD_COLOR_RED);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    sprintf((char*)text, "%d", ucRow);
+    lcd.DisplayStringAt(xPos, yPos, (uint8_t *)&text, LEFT_MODE);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led.h	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,16 @@
+#ifndef LED_H
+#define LED_H
+
+#include "LCD_DISCO_F429ZI.h"
+
+class Led {
+    public:
+        Led(unsigned char ucColumn, unsigned char ucRow);
+        void On(void);
+        void Off(void);
+    private:
+        unsigned char ucColumn, ucRow;
+        void Redraw(uint32_t Color);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Board.cpp	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,30 @@
+#include "Led_Board.h"
+#include "LCD_DISCO_F429ZI.h"
+
+extern LCD_DISCO_F429ZI lcd;
+
+LedBoard::LedBoard(unsigned char ucColumn) {
+    
+    lcd.Clear(LCD_COLOR_BLACK);
+    lcd.SetBackColor(LCD_COLOR_BLACK);
+    BSP_LCD_SetFont(&Font24);
+    
+    for(unsigned char ucRow = 0; ucRow < 4; ucRow++) {
+        Leds[ucRow] = new Led(ucColumn, ucRow);
+    }
+}
+
+void LedBoard::On(unsigned char ucRow) {
+    
+    Off();
+    Leds[ucRow] -> On(); 
+        
+}
+
+void LedBoard::Off(void) {
+    
+    for(unsigned char ucRow = 0; ucRow < 4; ucRow++) {
+        Leds[ucRow] -> Off();
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Led_Board.h	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,15 @@
+#ifndef LED_BOARD_H
+#define LED_BOARD_H
+
+#include "Led.h"
+
+class LedBoard {
+    public:
+        LedBoard(unsigned char ucColumn = 0);
+        void On(unsigned char ucRow);
+        void Off(void);
+    private:
+        Led *Leds[4];
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F429ZI.lib	Mon Jun 15 17:39:40 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 Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "Keyboard_Led.h"
+#include "Led_Board.h"
+#include "LCD_DISCO_F429ZI.h"
+
+LCD_DISCO_F429ZI lcd;
+
+int main()
+{  
+    KeyboardLed Keyboard(0);
+    LedBoard *pLedBoard;
+    pLedBoard = new LedBoard(2);
+    
+    while(1) {
+        switch(Keyboard.eRead()) {
+            case BUTTON_0:
+                pLedBoard -> On(3);
+                break;
+            case BUTTON_1:
+                pLedBoard -> On(2);
+                break;
+            case BUTTON_2:
+                pLedBoard -> On(1);
+                break;
+            case BUTTON_3:
+                pLedBoard -> On(0);
+                break;
+            default:
+                pLedBoard -> Off();
+                break;
+        }
+        wait(0.1);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 15 17:39:40 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file