Buttons changing color when tapped.
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
rectangle.cpp@2:bd49dd9c7bd6, 2019-05-19 (annotated)
- Committer:
- fzajdel
- Date:
- Sun May 19 11:59:32 2019 +0000
- Revision:
- 2:bd49dd9c7bd6
- Parent:
- 0:6d5a5f60d228
Touch screen with buttons
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fzajdel | 0:6d5a5f60d228 | 1 | #include "rectangle.h" |
fzajdel | 0:6d5a5f60d228 | 2 | #include "LCD_DISCO_F429ZI.h" |
fzajdel | 0:6d5a5f60d228 | 3 | |
fzajdel | 0:6d5a5f60d228 | 4 | Rectangle::Rectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint32_t FillingColor, uint32_t FrameColor, string Text, uint32_t TextColor): |
fzajdel | 0:6d5a5f60d228 | 5 | x(x), y(y), width(width), height(height), FillingColor(FillingColor), FrameColor(FrameColor), TextColor(TextColor), Text(Text){} |
fzajdel | 0:6d5a5f60d228 | 6 | |
fzajdel | 0:6d5a5f60d228 | 7 | LCD_DISCO_F429ZI & Rectangle::Draw(LCD_DISCO_F429ZI &lcd){ |
fzajdel | 0:6d5a5f60d228 | 8 | lcd.SetTextColor(FrameColor); |
fzajdel | 0:6d5a5f60d228 | 9 | lcd.DrawRect(x,y,width, height); |
fzajdel | 0:6d5a5f60d228 | 10 | |
fzajdel | 0:6d5a5f60d228 | 11 | lcd.SetTextColor(FillingColor); |
fzajdel | 0:6d5a5f60d228 | 12 | lcd.FillRect(x+1,y+1,width-1,height-1); |
fzajdel | 0:6d5a5f60d228 | 13 | |
fzajdel | 0:6d5a5f60d228 | 14 | DisplayString(lcd); |
fzajdel | 0:6d5a5f60d228 | 15 | |
fzajdel | 0:6d5a5f60d228 | 16 | return lcd; |
fzajdel | 0:6d5a5f60d228 | 17 | } |
fzajdel | 0:6d5a5f60d228 | 18 | |
fzajdel | 0:6d5a5f60d228 | 19 | void Rectangle::SetFillingColor(uint32_t Color){ |
fzajdel | 0:6d5a5f60d228 | 20 | this->FillingColor = Color; |
fzajdel | 0:6d5a5f60d228 | 21 | } |
fzajdel | 0:6d5a5f60d228 | 22 | |
fzajdel | 0:6d5a5f60d228 | 23 | void Rectangle::SetFrameColor(uint32_t Color){ |
fzajdel | 0:6d5a5f60d228 | 24 | this->FrameColor = Color; |
fzajdel | 0:6d5a5f60d228 | 25 | } |
fzajdel | 0:6d5a5f60d228 | 26 | |
fzajdel | 0:6d5a5f60d228 | 27 | void Rectangle::SetText(string Text, uint32_t TextColor, uint32_t TextBackColor){ |
fzajdel | 0:6d5a5f60d228 | 28 | this->Text = Text; |
fzajdel | 0:6d5a5f60d228 | 29 | this->TextColor = TextColor; |
fzajdel | 0:6d5a5f60d228 | 30 | this->TextBackColor = TextBackColor; |
fzajdel | 0:6d5a5f60d228 | 31 | } |
fzajdel | 0:6d5a5f60d228 | 32 | |
fzajdel | 0:6d5a5f60d228 | 33 | void Rectangle::DisplayString(LCD_DISCO_F429ZI &lcd){ |
fzajdel | 0:6d5a5f60d228 | 34 | |
fzajdel | 0:6d5a5f60d228 | 35 | uint8_t *uText = new uint8_t [Text.length()+1]; |
fzajdel | 2:bd49dd9c7bd6 | 36 | sprintf((char*)uText, "%s", Text.c_str()); |
fzajdel | 0:6d5a5f60d228 | 37 | lcd.SetBackColor(TextBackColor); |
fzajdel | 0:6d5a5f60d228 | 38 | lcd.SetTextColor(TextColor); |
fzajdel | 0:6d5a5f60d228 | 39 | lcd.DisplayStringAt(x, y, uText, LEFT_MODE); |
fzajdel | 0:6d5a5f60d228 | 40 | |
fzajdel | 0:6d5a5f60d228 | 41 | delete []uText; |
fzajdel | 0:6d5a5f60d228 | 42 | } |
fzajdel | 0:6d5a5f60d228 | 43 | |
fzajdel | 0:6d5a5f60d228 | 44 | uint16_t Rectangle::GetX(){ |
fzajdel | 0:6d5a5f60d228 | 45 | return x; |
fzajdel | 0:6d5a5f60d228 | 46 | } |
fzajdel | 0:6d5a5f60d228 | 47 | uint16_t Rectangle::GetY(){ |
fzajdel | 0:6d5a5f60d228 | 48 | return y; |
fzajdel | 0:6d5a5f60d228 | 49 | } |
fzajdel | 0:6d5a5f60d228 | 50 | uint16_t Rectangle::GetWidth(){ |
fzajdel | 0:6d5a5f60d228 | 51 | return width; |
fzajdel | 0:6d5a5f60d228 | 52 | } |
fzajdel | 0:6d5a5f60d228 | 53 | uint16_t Rectangle::GetHeight(){ |
fzajdel | 0:6d5a5f60d228 | 54 | return height; |
fzajdel | 0:6d5a5f60d228 | 55 | } |