Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 0:d5dd7ece746d, committed 2020-05-08
- Comitter:
- lolkusus
- Date:
- Fri May 08 15:43:58 2020 +0000
- Child:
- 1:d392393df3d0
- Commit message:
- Finished? Mbed p1
Changed in this revision
--- /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