aghmtmppo
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Diff: Led.cpp
- Revision:
- 0:b7f6cb529d74
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led.cpp Mon Jun 15 17:39:40 2020 +0000 @@ -0,0 +1,38 @@ +#include "LCD_DISCO_F429ZI.h" +#include "Led.h" + +extern LCD_DISCO_F429ZI lcd; + +Led::Led(unsigned char ucColumn, unsigned char ucRow) { + + this -> ucColumn = ucColumn; + this -> ucRow = ucRow; + + Redraw(LCD_COLOR_BLUE); + +} + +void Led::On(void) { + Redraw(LCD_COLOR_MAGENTA); +} + +void Led::Off(void) { + Redraw(LCD_COLOR_BLUE); +} + +void Led::Redraw(uint32_t Color) { + + unsigned int xPos = ucColumn ? (ucColumn * 80 - 1) : ucColumn; + unsigned int yPos = ucRow ? (ucRow * 80 - 1) : ucRow; + char text[1]; + + lcd.SetTextColor(Color); + lcd.FillRect(xPos, yPos, 80, 80); + + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.DrawRect(xPos, yPos, 80, 80); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + sprintf((char*)text, "%d", ucRow); + lcd.DisplayStringAt(xPos, yPos, (uint8_t *)&text, LEFT_MODE); +} \ No newline at end of file