Finalna wersja programu 2d_2 z pierwszej części zestawu mbed
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 1:29d67154ca51, committed 2020-05-12
- Comitter:
- azmuth_sd
- Date:
- Tue May 12 08:14:12 2020 +0000
- Parent:
- 0:15cfee7b5bad
- Commit message:
- Finalna wersja mbed
Changed in this revision
Led_Lcd.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 15cfee7b5bad -r 29d67154ca51 Led_Lcd.cpp --- a/Led_Lcd.cpp Sun May 10 21:48:38 2020 +0000 +++ b/Led_Lcd.cpp Tue May 12 08:14:12 2020 +0000 @@ -4,56 +4,28 @@ { ucXLed = ucColumn * 80; lcd.Clear(LCD_COLOR_BLACK); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetFont(&Font24); } void LedLcd::On(unsigned char ucCtr) { - switch(ucCtr) + const char* btnText[] = {"0", "1", "2", "3"}; + + for(uint8_t i = 0; i < 4; i++) { - case 0: - lcd.SetTextColor(LCD_COLOR_YELLOW); - lcd.FillRect(ucXLed+2, 2, 77, 77); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(ucXLed, 0, (uint8_t *)"0", LEFT_MODE); - break; - case 1: - lcd.SetTextColor(LCD_COLOR_YELLOW); - lcd.FillRect(ucXLed+2, 82, 77, 77); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(ucXLed, 80, (uint8_t *)"1", LEFT_MODE); - break; - case 2: - lcd.SetTextColor(LCD_COLOR_YELLOW); - lcd.FillRect(ucXLed+2, 162, 77, 77); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(ucXLed, 160, (uint8_t *)"2", LEFT_MODE); - break; - case 3: - lcd.SetTextColor(LCD_COLOR_YELLOW); - lcd.FillRect(ucXLed+2, 242, 77, 77); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(ucXLed, 240, (uint8_t *)"3", LEFT_MODE); - break; - default: - draw_button(ucXLed,0,80,80); - draw_button(ucXLed,80,80,80); - draw_button(ucXLed,160,80,80); - draw_button(ucXLed,240,80,80); - lcd.SetTextColor(LCD_COLOR_WHITE); - lcd.SetFont(&Font24); - lcd.DisplayStringAt(ucXLed, 0, (uint8_t *)"0", LEFT_MODE); - lcd.DisplayStringAt(ucXLed, 80, (uint8_t *)"1", LEFT_MODE); - lcd.DisplayStringAt(ucXLed, 160, (uint8_t *)"2", LEFT_MODE); - lcd.DisplayStringAt(ucXLed, 240, (uint8_t *)"3", LEFT_MODE); - lcd.SetBackColor(LCD_COLOR_RED); - break; + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.DrawRect(ucXLed, i*80, 80, 80); + if( ucCtr == i ) + { + lcd.SetTextColor(LCD_COLOR_YELLOW); + } + else + { + lcd.SetTextColor(LCD_COLOR_BLUE); + } + lcd.FillRect(ucXLed+1, (80*i)+1 , 78, 78); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(ucXLed, i*80, (uint8_t *) btnText[i], LEFT_MODE); } } - -void LedLcd::draw_button(int x_pos, int y_pos, int width, int height) -{ - lcd.SetTextColor(LCD_COLOR_GREEN); - lcd.DrawRect(x_pos, y_pos, width, height); - lcd.SetTextColor(LCD_COLOR_BLUE); - lcd.FillRect(x_pos+1, y_pos+1, width-2, height-2); -} \ No newline at end of file