aghmtmppo

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Led.cpp

Committer:
domino5740
Date:
2020-06-15
Revision:
0:b7f6cb529d74

File content as of revision 0:b7f6cb529d74:

#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);
}