
...
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 0:bd1186e6ebb2, committed 2019-04-27
- Comitter:
- Mistmist
- Date:
- Sat Apr 27 16:41:11 2019 +0000
- Commit message:
- ...
Changed in this revision
diff -r 000000000000 -r bd1186e6ebb2 BSP_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F429ZI.lib Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
diff -r 000000000000 -r bd1186e6ebb2 Keyboard_Ts.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.cpp Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,57 @@ +#include "Keyboard_Ts.h" +#include "button.h" +#include "LCD_DISCO_F429ZI.h" +#include "TS_DISCO_F429ZI.h" + +LCD_DISCO_F429ZI Lcd; +TS_DISCO_F429ZI Ts; + +TS_StateTypeDef TS_State; + +#define BUTTON_REL_COLOR LCD_COLOR_BLUE +#define BACKGROUND LCD_COLOR_BLACK + +extern Button Button0('0', 0, 0, 80, 80, BUTTON_REL_COLOR, 0); +extern Button Button1('1', 0, 80, 80, 80, BUTTON_REL_COLOR, 0); +extern Button Button2('2', 0, 160, 80, 80, BUTTON_REL_COLOR, 0); +extern Button Button3('3', 0, 240, 80, 80, BUTTON_REL_COLOR, 0); + +KeyboardTs::KeyboardTs(uint16_t ColNr){ + //Background + Lcd.SetTextColor(BACKGROUND); + Lcd.FillRect(0, 0, 240, 320); + //Buttons + SetCol(ColNr); + Button0.SetCol(ColNr); + Button1.SetCol(ColNr); + Button2.SetCol(ColNr); + Button3.SetCol(ColNr); + Button0.DrawButton(BUTTON_REL_COLOR); + Button1.DrawButton(BUTTON_REL_COLOR); + Button2.DrawButton(BUTTON_REL_COLOR); + Button3.DrawButton(BUTTON_REL_COLOR); + } + +enum KeyboardState KeyboardTs::eRead(void){ + Ts.GetState(&TS_State); + + if(TS_State.TouchDetected && TS_State.X >= (1+KeyboardTs::ColNr*80) && TS_State.X < (80+KeyboardTs::ColNr*80) && TS_State.Y >= 1 && TS_State.Y < 80){ + return BUTTON_0; + } + else if(TS_State.TouchDetected && TS_State.X >= (1+KeyboardTs::ColNr*80) && TS_State.X < (80+KeyboardTs::ColNr*80) && TS_State.Y >= 81 && TS_State.Y < 160){ + return BUTTON_1; + } + else if(TS_State.TouchDetected && TS_State.X >= (1+KeyboardTs::ColNr*80) && TS_State.X < (80+KeyboardTs::ColNr*80) && TS_State.Y >= 161 && TS_State.Y < 240){ + return BUTTON_2; + } + else if(TS_State.TouchDetected && TS_State.X >= (1+KeyboardTs::ColNr*80) && TS_State.X < (80+KeyboardTs::ColNr*80) && TS_State.Y >= 241 && TS_State.Y < 320){ + return BUTTON_3; + } + else{ + return RELEASED; + } + } + +void KeyboardTs::SetCol(uint16_t ColNr){ + KeyboardTs::ColNr = ColNr; +} \ No newline at end of file
diff -r 000000000000 -r bd1186e6ebb2 Keyboard_Ts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.h Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,16 @@ +#ifndef KEYBOARD_TS_H +#define KEYBOARD_TS_H +#include "mbed.h" + +enum KeyboardState {RELEASED, BUTTON_0, BUTTON_1, BUTTON_2, BUTTON_3}; + +class KeyboardTs{ + private: + uint16_t ColNr; + public: + KeyboardTs(uint16_t ColNr); + enum KeyboardState eRead(void); + void SetCol(uint16_t ColNr); + }; + +#endif
diff -r 000000000000 -r bd1186e6ebb2 LCD_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
diff -r 000000000000 -r bd1186e6ebb2 Led_Lcd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.cpp Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,50 @@ +#include "Led_Lcd.h" +#include "LCD_DISCO_F429ZI.h" + +#define BUTTON0_PR_COLOR LCD_COLOR_RED +#define BUTTON1_PR_COLOR LCD_COLOR_DARKGREEN +#define BUTTON2_PR_COLOR LCD_COLOR_LIGHTRED +#define BUTTON3_PR_COLOR LCD_COLOR_BLACK +#define BUTTON_REL_COLOR LCD_COLOR_BLUE + +extern LCD_DISCO_F429ZI Lcd; +extern Button Button4('0', 0, 0, 80, 80, BUTTON_REL_COLOR, 0); +extern Button Button5('1', 0, 80, 80, 80, BUTTON_REL_COLOR, 0); +extern Button Button6('2', 0, 160, 80, 80, BUTTON_REL_COLOR, 0); +extern Button Button7('3', 0, 240, 80, 80, BUTTON_REL_COLOR, 0); + +LedLcd::LedLcd(uint16_t ColNr){ + Button4.SetCol(ColNr); + Button5.SetCol(ColNr); + Button6.SetCol(ColNr); + Button7.SetCol(ColNr); + Button4.DrawButton(BUTTON_REL_COLOR); + Button5.DrawButton(BUTTON_REL_COLOR); + Button6.DrawButton(BUTTON_REL_COLOR); + Button7.DrawButton(BUTTON_REL_COLOR); + } + +void LedLcd::On(uint16_t ucButtonNr){ + Button4.DrawButton(BUTTON_REL_COLOR); + Button5.DrawButton(BUTTON_REL_COLOR); + Button6.DrawButton(BUTTON_REL_COLOR); + Button7.DrawButton(BUTTON_REL_COLOR); + + switch(ucButtonNr){ + case 0: + Button4.DrawButton(BUTTON0_PR_COLOR); + break; + case 1: + Button5.DrawButton(BUTTON1_PR_COLOR); + break; + case 2: + Button6.DrawButton(BUTTON2_PR_COLOR); + break; + case 3: + Button7.DrawButton(BUTTON3_PR_COLOR); + break; + default: + break; + } + } + \ No newline at end of file
diff -r 000000000000 -r bd1186e6ebb2 Led_Lcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.h Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,12 @@ +#ifndef LED_LCD_H +#define LED_LCD_H +#include "mbed.h" +#include "button.h" + +class LedLcd{ + public: + LedLcd(uint16_t ColNr); + void On(uint16_t ucButtonNr); + }; + +#endif
diff -r 000000000000 -r bd1186e6ebb2 TS_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F429ZI.lib Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
diff -r 000000000000 -r bd1186e6ebb2 button.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/button.cpp Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,34 @@ +#include "button.h" + +#include "LCD_DISCO_F429ZI.h" + +#define FRAME_COLOR LCD_COLOR_GREEN +#define ID_COLOR LCD_COLOR_WHITE +#define ID_RECT_COLOR LCD_COLOR_RED + +extern LCD_DISCO_F429ZI Lcd; + +Button::Button(uint8_t id, uint16_t posx, uint16_t posy, uint16_t width, uint16_t height, uint32_t color, uint16_t ColNr){ + Button::id = id; + Button::posx = posx; + Button::posy = posy; + Button::width = width; + Button::height = height; + Button::color = color; + Button::ColNr = ColNr; + } + +void Button::DrawButton(uint32_t color){ + Lcd.SetTextColor(FRAME_COLOR); + Lcd.DrawRect(posx+(80*Button::ColNr), posy, width, height); + Lcd.SetTextColor(color); + Lcd.FillRect(posx+(80*Button::ColNr)+1, posy+1, width-2, height-2); + Lcd.SetBackColor(ID_RECT_COLOR); + Lcd.SetTextColor(ID_COLOR); + //id = '0' + id; + Lcd.DisplayStringAt(posx+(80*Button::ColNr), posy, &id, LEFT_MODE); + } + +void Button::SetCol(uint16_t ColNr){ + Button::ColNr = ColNr; + } \ No newline at end of file
diff -r 000000000000 -r bd1186e6ebb2 button.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/button.h Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,17 @@ +#ifndef BUTTON_H +#define BUTTON_H +#include "mbed.h" + +class Button{ + private: + uint8_t id; + uint16_t posx, posy, width, height; + uint32_t color; + public: + uint16_t ColNr; + Button(uint8_t id, uint16_t posx, uint16_t posy, uint16_t width, uint16_t height, uint32_t color, uint16_t ColNr); + void DrawButton(uint32_t color); + void SetCol(uint16_t ColNr); + }; + +#endif
diff -r 000000000000 -r bd1186e6ebb2 keyboardtslcd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/keyboardtslcd.cpp Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,27 @@ +#include "keyboardtslcd.h" + +KeyboardTsLcd::KeyboardTsLcd(uint16_t _ucColNr){ + pKeyboard = new KeyboardTs(_ucColNr); + pLed = new LedLcd(_ucColNr); +}; + +KeyboardTsLcd::eRead(void){ + switch(pKeyboard.eRead()){ + case BUTTON_0: + pLed.On(0); + break; + case BUTTON_1: + pLed.On(1); + break; + case BUTTON_2: + pLed.On(2); + break; + case BUTTON_3: + pLed.On(3); + break; + default: + pLed.On(4); + break; + + } + } \ No newline at end of file
diff -r 000000000000 -r bd1186e6ebb2 keyboardtslcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/keyboardtslcd.h Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,16 @@ +#ifndef KEYBOARD_TS_LCD_H +#define KEYBOARD_TS_LCD_H +#include "mbed.h" +#include "Keyboard_Ts.h" +#include "Led_Lcd.h" + +class KeyboardTsLcd{ + private: + KeyboardTs(uint16_t _ucColNr) pKeyboard; + LedLcd(uint16_t _ucColNr) pLed; + public: + KeyboardTsLcd(uint16_t _ucColNr); + void eRead(void); + }; + +#endif
diff -r 000000000000 -r bd1186e6ebb2 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,11 @@ +#include "mbed.h" +#include "keyboardtslcd.h" + +int main(){ + KeyboardTsLcd Keyboard(1); + while(1) { + Keyboard.eRead(); + wait(0.1); + } +} +
diff -r 000000000000 -r bd1186e6ebb2 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Apr 27 16:41:11 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file