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 1:36b3fd4a01fd, committed 2020-05-09
- Comitter:
- matis755
- Date:
- Sat May 09 08:31:59 2020 +0000
- Parent:
- 0:f4a48c08fea7
- Child:
- 2:db40a2b0b177
- Commit message:
- Add second column on display
Changed in this revision
--- a/Keyboard_Ts.cpp Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts.cpp Sat May 09 08:31:59 2020 +0000
@@ -9,16 +9,16 @@
TS_StateTypeDef TS_State;
GetState(&TS_State);
if ((TS_State.TouchDetected) && (TS_State.Y > 0 ) && (TS_State.Y < 80) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
- return BUTTON_1;
+ return BUTTON_0;
}
else if ((TS_State.TouchDetected) && (TS_State.Y > 80 ) && (TS_State.Y < 160) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
- return BUTTON_2;
+ return BUTTON_1;
}
else if ((TS_State.TouchDetected) && (TS_State.Y > 160 ) && (TS_State.Y < 240) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
- return BUTTON_3;
+ return BUTTON_2;
}
else if ((TS_State.TouchDetected) && (TS_State.Y > 240 ) && (TS_State.Y < 320) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
- return BUTTON_4;
+ return BUTTON_3;
}
else{
return RELASED;
--- a/Keyboard_Ts.h Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts.h Sat May 09 08:31:59 2020 +0000
@@ -5,10 +5,10 @@
enum KeyboardState{
RELASED,
+ BUTTON_0,
BUTTON_1,
BUTTON_2,
- BUTTON_3,
- BUTTON_4
+ BUTTON_3
};
class KeyboardTs : private TS_DISCO_F429ZI {
--- a/Keyboard_Ts_Lcd.cpp Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts_Lcd.cpp Sat May 09 08:31:59 2020 +0000
@@ -6,22 +6,24 @@
pLed = new LedLcd(_ucColumn);
};
-void KeyboardTsLcd::eRead(void) {
- switch(pKeyboard -> eRead()) {
+enum KeyboardState KeyboardTsLcd::eRead(void) {
+ enum KeyboardState eButton = pKeyboard -> eRead();
+ switch(eButton) {
+ case BUTTON_0:
+ pLed -> On(0);
+ break;
case BUTTON_1:
- pLed -> On(0);
+ pLed -> On(1);
break;
case BUTTON_2:
- pLed -> On(1);
+ pLed -> On(2);
break;
case BUTTON_3:
- pLed -> On(2);
- break;
- case BUTTON_4:
pLed -> On(3);
break;
default :
pLed -> On(4);
break;
- }
+ }
+ return eButton;
}
\ No newline at end of file
--- a/Keyboard_Ts_Lcd.h Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts_Lcd.h Sat May 09 08:31:59 2020 +0000
@@ -1,5 +1,5 @@
-#ifndef KEYBOARDLCD
-#define KEYBOARDLCD
+#ifndef KEYBOARD_TS_LCD
+#define KEYBOARD_TS_LCD
#include "Led_Lcd.h"
#include "Keyboard_Ts.h"
@@ -7,7 +7,7 @@
class KeyboardTsLcd {
public:
KeyboardTsLcd(unsigned char);
- void eRead(void);
+ enum KeyboardState eRead(void);
private:
LedLcd *pLed;
KeyboardTs *pKeyboard;
--- a/main.cpp Thu May 07 15:13:01 2020 +0000
+++ b/main.cpp Sat May 09 08:31:59 2020 +0000
@@ -1,11 +1,27 @@
-#include "mbed.h"
#include "Keyboard_Ts_Lcd.h"
int main() {
- KeyboardTsLcd Keyboard(1);
+ KeyboardTsLcd Keyboard(0);
+ LedLcd Led(2);
while(1) {
- Keyboard.eRead();
+ switch(Keyboard.eRead()) {
+ case BUTTON_0:
+ Led.On(3);
+ break;
+ case BUTTON_1:
+ Led.On(2);
+ break;
+ case BUTTON_2:
+ Led.On(1);
+ break;
+ case BUTTON_3:
+ Led.On(0);
+ break;
+ default :
+ Led.On(4);
+ break;
+ }
wait(0.1);
}
}
\ No newline at end of file