code review
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 0:db2c7dc10f89, committed 2020-05-14
- Comitter:
- thepaueu
- Date:
- Thu May 14 18:45:14 2020 +0000
- Commit message:
- Pawel Majtas cw 2d2
Changed in this revision
diff -r 000000000000 -r db2c7dc10f89 BSP_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F429ZI.lib Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
diff -r 000000000000 -r db2c7dc10f89 KeyboardTs.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardTs.cpp Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,31 @@ +#include "KeyboardTs.h" + + +KeyboardTs::KeyboardTs(unsigned char ucStartCol){ + ucColumn = ucStartCol; + } + + enum BUTTON KeyboardTs::eRead(void){ + int x,y; + + TS_StateTypeDef TS_State; + ts.GetState(&TS_State); + if (TS_State.TouchDetected){ + x = TS_State.X; + y = TS_State.Y; + } + if(TS_State.TouchDetected && x>= ucColumn*80 && x <= 80*(ucColumn+1) ){ + + if(y>=0 && y<=80) + return BUTTON_0; + else if(y>=81 && y<=160) + return BUTTON_1; + else if(y>=161 && y<=240) + return BUTTON_2; + else if(y>=241 && y<=320) + return BUTTON_3; + } + else + return NONE; + +} \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 KeyboardTs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardTs.h Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,27 @@ +#ifndef _KEYBOARDTS_H +#define _KEYBOARDTS_H + +#include "TS_DISCO_F429ZI.h" + +enum BUTTON { + BUTTON_0, + BUTTON_1, + BUTTON_2, + BUTTON_3, + NONE +}; + +class KeyboardTs{ + + public: + KeyboardTs(unsigned char); + enum BUTTON eRead(void); + + private: + TS_DISCO_F429ZI ts; + unsigned char ucColumn; + + }; + + +#endif \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 KeyboardTsLcd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardTsLcd.cpp Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,35 @@ +#include "KeyboardTsLcd.h" + + + +KeyboardTsLcd::KeyboardTsLcd(unsigned char _ucColumn) +{ + pKeyboard = new KeyboardTs(_ucColumn); + pLed = new LedLcd(_ucColumn); +}; + +enum BUTTON KeyboardTsLcd::eRead( void ){ + + switch(pKeyboard->eRead()){ + case BUTTON_0 : + pLed->On(0); + return BUTTON_0; + + case BUTTON_1 : + pLed->On(1); + return BUTTON_1; + + case BUTTON_2 : + pLed->On(2); + return BUTTON_2; + + case BUTTON_3 : + pLed->On(3); + return BUTTON_3; + + default: + pLed->On(4); + return NONE; + } + + } \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 KeyboardTsLcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardTsLcd.h Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,17 @@ +#ifndef _KEYBOARDTSLCD_H +#define _KEYBOARDTSLCD_H + +#include "KeyboardTs.h" +#include "LedLcd.h" + + +class KeyboardTsLcd{ + + public: + KeyboardTsLcd(unsigned char); + enum BUTTON eRead(void); + KeyboardTs *pKeyboard; + LedLcd *pLed; + }; + +#endif \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 LCD_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
diff -r 000000000000 -r db2c7dc10f89 LedLcd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LedLcd.cpp Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,34 @@ +#include "LedLcd.h" + + + + +LedLcd::LedLcd(unsigned char ucStartCol){ + lcd.Clear(LCD_COLOR_BLACK); + lcd.SetFont(&Font24); + ucColumn = ucStartCol; + } + +void LedLcd::On( unsigned char ucPos){ + + uint8_t text[2]; + unsigned char ucRect; + + for (ucRect=0;ucRect<4;ucRect++){ + + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.DrawRect(ucColumn*80,ucRect*80,80,80); + + if(ucPos==ucRect) + lcd.SetTextColor(LCD_COLOR_YELLOW); + else + lcd.SetTextColor(LCD_COLOR_BLUE); + + lcd.FillRect(1 + ucColumn*80,ucRect*80+1,78,78); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + sprintf((char*)text, "%d", ucRect); + lcd.DisplayStringAt(ucColumn*80, ucRect*80,(uint8_t *)&text,LEFT_MODE); + + } + } \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 LedLcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LedLcd.h Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,21 @@ +#ifndef _LEDLCD_H +#define _LEDLCD_H + +#include "LCD_DISCO_F429ZI.h" + +class LedLcd{ + + public: + LedLcd(unsigned char); + void On(unsigned char); + + private: + + LCD_DISCO_F429ZI lcd; + unsigned char ucColumn; + + }; + + + +#endif \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 TS_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F429ZI.lib Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
diff -r 000000000000 -r db2c7dc10f89 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,17 @@ +#include "KeyboardTsLcd.h" + + + +int main(){ + + KeyboardTsLcd KeyboardLeft(0); + LedLcd Led(2); + + while(1){ + + Led.On(3 - KeyboardLeft.eRead() ); + wait_ms(100); + + } + +} \ No newline at end of file
diff -r 000000000000 -r db2c7dc10f89 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 14 18:45:14 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file