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 4:459a0389bb9f, committed 2020-06-16
- Comitter:
- matis755
- Date:
- Tue Jun 16 09:35:53 2020 +0000
- Parent:
- 3:15deb9bc946b
- Commit message:
- dd
Changed in this revision
--- a/Keyboard.cpp Sun May 24 06:01:02 2020 +0000
+++ b/Keyboard.cpp Tue Jun 16 09:35:53 2020 +0000
@@ -8,19 +8,12 @@
enum KeyboardState Keyboard::eRead(void) {
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_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_1;
+
+ for(unsigned char ucButton=BUTTON_0; ucButton<=BUTTON_3; ++ucButton) {
+ KeyboardState btn_idx = static_cast<KeyboardState>(ucButton);
+ if ((TS_State.TouchDetected) && (TS_State.Y > 80*(btn_idx-1) ) && (TS_State.Y < btn_idx*80) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))){
+ return btn_idx;
+ }
}
- 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_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_3;
- }
- else{
- return RELASED;
- }
+ return RELASED;
}
\ No newline at end of file
--- a/Led.cpp Sun May 24 06:01:02 2020 +0000
+++ b/Led.cpp Tue Jun 16 09:35:53 2020 +0000
@@ -6,6 +6,8 @@
Led::Led(unsigned char ucColIdx, unsigned char ucRowIdx) {
ucColumn = ucColIdx;
ucRow = ucRowIdx;
+ Lcd.SetTextColor(LCD_COLOR_GREEN);
+ Lcd.DrawRect(80*ucColumn, 80*ucRow, 80, 80);
}
void Led::On(void) {
--- a/Ledboard.cpp Sun May 24 06:01:02 2020 +0000
+++ b/Ledboard.cpp Tue Jun 16 09:35:53 2020 +0000
@@ -3,12 +3,8 @@
extern LCD_DISCO_F429ZI Lcd;
-Ledboard::Ledboard(unsigned char ucIdx) {
- Lcd.SetFont(&Font24);
- Lcd.Clear(LCD_COLOR_BLACK);
- Lcd.SetTextColor(LCD_COLOR_GREEN);
+Ledboard::Ledboard(unsigned char ucIdx) {
for(unsigned char I = 0; I < 4; I++) {
- Lcd.DrawRect(80*ucIdx, 80*I, 80, 80);
Leds[I] = new Led(ucIdx, I);
}
}
--- a/main.cpp Sun May 24 06:01:02 2020 +0000
+++ b/main.cpp Tue Jun 16 09:35:53 2020 +0000
@@ -4,6 +4,9 @@
LCD_DISCO_F429ZI Lcd;
int main() {
+ Lcd.Clear(LCD_COLOR_BLACK);
+ Lcd.SetFont(&Font24);
+
KeyboardLed Keyboard(0);
Ledboard Led(2);