Mbed p1
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 1:57b3cfb31293, committed 2020-06-06
- Comitter:
- juten
- Date:
- Sat Jun 06 16:02:36 2020 +0000
- Parent:
- 0:57867f829c01
- Commit message:
- new and improved mbed1_2d
Changed in this revision
--- a/Keyboard_Ts_Lcd.cpp Mon May 25 19:45:09 2020 +0000 +++ b/Keyboard_Ts_Lcd.cpp Sat Jun 06 16:02:36 2020 +0000 @@ -8,21 +8,20 @@ KeyState Keyboard_Ts_Lcd::Read(){ switch(pKeyboard->Read()) { case BUTTON_0: - pLed->On(0); - break; + pLed->Led_Board(0); + return BUTTON_0; case BUTTON_1: - pLed->On(1); - break; + pLed->Led_Board(1); + return BUTTON_1; case BUTTON_2: - pLed->On(2); - break; + pLed->Led_Board(2); + return BUTTON_2; case BUTTON_3: - pLed->On(3); - break; + pLed->Led_Board(3); + return BUTTON_3; default : - pLed->Off(); - break; - } - return(pKeyboard->Read()); + pLed->Led_Board(4); + return NONE; + } } \ No newline at end of file
--- a/Led_Lcd.cpp Mon May 25 19:45:09 2020 +0000 +++ b/Led_Lcd.cpp Sat Jun 06 16:02:36 2020 +0000 @@ -16,7 +16,7 @@ } void Led_Lcd::DrawLed(unsigned char ucLedNumber, LedState eLedState){ - char cBuffer[3]; + char cBuffer[1]; lcd.SetTextColor(LCD_COLOR_GREEN); lcd.DrawRect(80*ucColumnNumber,80*ucLedNumber,80,80); if (eLedState == PRESSED){ @@ -30,21 +30,24 @@ lcd.SetTextColor(LCD_COLOR_WHITE); lcd.DisplayStringAt(1+80*ucColumnNumber,1+80*ucLedNumber,(uint8_t *)&cBuffer, LEFT_MODE); } + void Led_Lcd::On(unsigned char ucLedNo){ + DrawLed(ucLedNo, PRESSED); +} + +void Led_Lcd::Off(unsigned char ucLedNo){ + DrawLed(ucLedNo, RELEASED); +} + +void Led_Lcd::Led_Board(unsigned char ucLedNo){ for (unsigned char ucLedCounter = 0; ucLedCounter < LED_COUNT; ucLedCounter++){ - if (ucLedCounter == ucLedNo) + if (ucLedCounter == ucLedNo) { - DrawLed(ucLedCounter, PRESSED); + On(ucLedCounter); } else { - DrawLed(ucLedCounter, RELEASED); + Off(ucLedCounter); } } } - -void Led_Lcd::Off(){ - for (unsigned char ucLedCounter = 0; ucLedCounter < LED_COUNT; ucLedCounter++){ - DrawLed(ucLedCounter, RELEASED); - } -} \ No newline at end of file
--- a/Led_Lcd.h Mon May 25 19:45:09 2020 +0000 +++ b/Led_Lcd.h Sat Jun 06 16:02:36 2020 +0000 @@ -9,7 +9,8 @@ public: Led_Lcd(unsigned char ucColumnNo); void On(unsigned char ucLedNo); - void Off(); + void Off(unsigned char ucLedNo); + void Led_Board(unsigned char ucLedNo); private: void DrawLed(unsigned char ucLedNumber, LedState eLedState); unsigned char ucColumnNumber;
--- a/main.cpp Mon May 25 19:45:09 2020 +0000 +++ b/main.cpp Sat Jun 06 16:02:36 2020 +0000 @@ -12,22 +12,21 @@ { switch(Keyboard.Read()){ case BUTTON_0: - Leds.On(3); + Leds.Led_Board(3); break; case BUTTON_1: - Leds.On(2); + Leds.Led_Board(2); break; case BUTTON_2: - Leds.On(1); + Leds.Led_Board(1); break; case BUTTON_3: - Leds.On(0); + Leds.Led_Board(0); break; default : - Leds.Off(); + Leds.Led_Board(4); break; } - Keyboard.Read(); wait(REFRESH_PERIOD); } }