Finalna wersja programu 2d_2 z pierwszej części zestawu mbed
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Diff: Led_Lcd.cpp
- Revision:
- 0:15cfee7b5bad
- Child:
- 1:29d67154ca51
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.cpp Sun May 10 21:48:38 2020 +0000 @@ -0,0 +1,59 @@ +#include "Led_Lcd.h" + +LedLcd::LedLcd(unsigned char ucColumn) +{ + ucXLed = ucColumn * 80; + lcd.Clear(LCD_COLOR_BLACK); +} + +void LedLcd::On(unsigned char ucCtr) +{ + switch(ucCtr) + { + 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; + } +} + +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