
a
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 0:515a71b6fd11, committed 2022-05-11
- Comitter:
- wierzba100
- Date:
- Wed May 11 14:04:35 2022 +0000
- Commit message:
- a
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F429ZI.lib Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.cpp Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,90 @@ +#include "Keyboard_Ts.h" +#include "TS_DISCO_F429ZI.h" + +TS_DISCO_F429ZI ts; + +TS_StateTypeDef TS_State; + +KeyboardTs::KeyboardTs(unsigned char ucButtonPos): ucButtonMode(ucButtonPos){} + +enum KeyboardState KeyboardTs::eRead(void) +{ + ts.GetState(&TS_State); + unsigned int uiX; + unsigned int uiY; + if (TS_State.TouchDetected) + { + uiX=TS_State.X; + uiY=TS_State.Y; + }else + { + uiX=0; + uiY=0; + } + switch(ucButtonMode) + { + case 0: + if(uiX > 0 && uiX < 79 && uiY > 0 && uiY < 79) + { + return BUTTON_0; + } + else if(uiX > 0 && uiX < 79 && uiY > 80 && uiY < 160) + { + return BUTTON_1; + } + else if(uiX > 0 && uiX < 79 && uiY > 160 && uiY < 240) + { + return BUTTON_2; + } + else if(uiX > 0 && uiX < 79 && uiY > 240 && uiY < 320) + { + return BUTTON_3; + } + else{ + return RELASED; + } + case 1: + if(uiX > 80 && uiX < 160 && uiY > 0 && uiY < 79) + { + return BUTTON_0; + } + else if(uiX > 80 && uiX < 160 && uiY > 80 && uiY < 160) + { + return BUTTON_1; + } + else if(uiX > 80 && uiX < 160 && uiY > 160 && uiY < 240) + { + return BUTTON_2; + } + else if(uiX > 80 && uiX < 160 && uiY > 240 && uiY < 320) + { + return BUTTON_3; + } + else{ + return RELASED; + } + default: + if(uiX > 160 && uiX < 240 && uiY > 0 && uiY < 79) + { + return BUTTON_0; + } + else if(uiX > 160 && uiX < 240 && uiY > 80 && uiY < 160) + { + return BUTTON_1; + } + else if(uiX > 160 && uiX < 240 && uiY > 160 && uiY < 240) + { + return BUTTON_2; + } + else if(uiX > 160 && uiX < 240 && uiY > 240 && uiY < 320) + { + return BUTTON_3; + } + else{ + return RELASED; + } + } +} + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.h Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,24 @@ +#ifndef __KEBOARDTS_H +#define __KEBOARDTS_H + +#include "mbed.h" + +enum KeyboardState +{ + RELASED, + BUTTON_0, + BUTTON_1, + BUTTON_2, + BUTTON_3 +}; + +class KeyboardTs +{ + public: + KeyboardTs(unsigned char); + enum KeyboardState eRead(void); + private: + unsigned char ucButtonMode; +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.cpp Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,200 @@ +#include "Led_Lcd.h" + +LCD_DISCO_F429ZI lcd; + +LedLcd::LedLcd(unsigned char ucButtonPos): ucButtonDisplayMode(ucButtonPos){} + +void LedLcd::ButtonPlacement(unsigned int uiXpos, unsigned int uiYpos, unsigned int uiWidth,unsigned int uiHeight, uint8_t *pText,unsigned char ucPressed) +{ + if(ucPressed == 1) + { + lcd.SetTextColor(LCD_COLOR_YELLOW); + }else + { + lcd.SetTextColor(LCD_COLOR_BLUE); + } + lcd.FillRect(uiXpos, uiYpos, uiWidth, uiHeight); + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.DrawRect(uiXpos, uiYpos, uiWidth, uiHeight); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.DisplayStringAt(uiXpos, uiYpos, pText , LEFT_MODE); +} + +void LedLcd::On(unsigned char ucLedNr) +{ + lcd.Clear(LCD_COLOR_BLACK); + lcd.SetBackColor(LCD_COLOR_BLACK); + switch(ucButtonDisplayMode) + { + case 0: + switch(ucLedNr) + { + case 0: + //Button 1 + ButtonPlacement(0,0,79,79,(uint8_t *)"1", 1); + //Button 2 + ButtonPlacement(0,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(0,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(0,240,79,79,(uint8_t *)"4", 0); + break; + case 1: + //Button 1 + ButtonPlacement(0,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(0,80,79,79,(uint8_t *)"2", 1); + //button 3 + ButtonPlacement(0,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(0,240,79,79,(uint8_t *)"4", 0); + break; + case 2: + //Button 1 + ButtonPlacement(0,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(0,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(0,160,79,79,(uint8_t *)"3", 1); + //button 4 + ButtonPlacement(0,240,79,79,(uint8_t *)"4", 0); + break; + case 3: + //Button 1 + ButtonPlacement(0,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(0,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(0,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(0,240,79,79,(uint8_t *)"4", 1); + break; + default: + //Button 1 + ButtonPlacement(0,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(0,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(0,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(0,240,79,79,(uint8_t *)"4", 0); + break; + } + break; + case 1: + switch(ucLedNr) + { + case 0: + //Button 1 + ButtonPlacement(80,0,79,79,(uint8_t *)"1", 1); + //Button 2 + ButtonPlacement(80,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(80,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(80,240,79,79,(uint8_t *)"4", 0); + break; + case 1: + //Button 1 + ButtonPlacement(80,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(80,80,79,79,(uint8_t *)"2", 1); + //button 3 + ButtonPlacement(80,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(80,240,79,79,(uint8_t *)"4", 0); + break; + case 2: + //Button 1 + ButtonPlacement(80,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(80,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(80,160,79,79,(uint8_t *)"3", 1); + //button 4 + ButtonPlacement(80,240,79,79,(uint8_t *)"4", 0); + break; + case 3: + //Button 1 + ButtonPlacement(80,0,79,79,(uint8_t *)"1", 0); + //Button 2 + ButtonPlacement(80,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(80,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(80,240,79,79,(uint8_t *)"4", 1); + break; + default: + //Button 0 + ButtonPlacement(80,0,79,79,(uint8_t *)"1", 0); + //Button 1 + ButtonPlacement(80,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(80,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(80,240,79,79,(uint8_t *)"4", 0); + break; + } + break; + default: + switch(ucLedNr) + { + case 0: + //Button 0 + ButtonPlacement(160,0,79,79,(uint8_t *)"1", 1); + //Button 1 + ButtonPlacement(160,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(160,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(160,240,79,79,(uint8_t *)"4", 0); + break; + case 1: + //Button 0 + ButtonPlacement(160,0,79,79,(uint8_t *)"1", 0); + //Button 1 + ButtonPlacement(160,80,79,79,(uint8_t *)"2", 1); + //button 3 + ButtonPlacement(160,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(160,240,79,79,(uint8_t *)"4", 0); + break; + case 2: + //Button 0 + ButtonPlacement(160,0,79,79,(uint8_t *)"1", 0); + //Button 1 + ButtonPlacement(160,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(160,160,79,79,(uint8_t *)"3", 1); + //button 4 + ButtonPlacement(160,240,79,79,(uint8_t *)"4", 0); + break; + case 3: + //Button 0 + ButtonPlacement(160,0,79,79,(uint8_t *)"1", 0); + //Button 1 + ButtonPlacement(160,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(160,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(160,240,79,79,(uint8_t *)"4", 1); + break; + default: + //Button 0 + ButtonPlacement(160,0,79,79,(uint8_t *)"1", 0); + //Button 1 + ButtonPlacement(160,80,79,79,(uint8_t *)"2", 0); + //button 3 + ButtonPlacement(160,160,79,79,(uint8_t *)"3", 0); + //button 4 + ButtonPlacement(160,240,79,79,(uint8_t *)"4", 0); + break; + } + break; + + } + + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.h Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,16 @@ +#ifndef __LEDLCD_H +#define __LEDLCD_H + +#include "LCD_DISCO_F429ZI.h" + +class LedLcd +{ + public: + LedLcd(unsigned char); + void On(unsigned char); + private: + unsigned char ucButtonDisplayMode; + void ButtonPlacement(unsigned int, unsigned int, unsigned int,unsigned int, uint8_t *pText, unsigned char); +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F429ZI.lib Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +#include "Keyboard_Ts.h" +#include "Led_Lcd.h" + +int main() +{ + LedLcd Led(1); + KeyboardTs Keyboard(1); + + while(1) { + switch(Keyboard.eRead()) + { + case BUTTON_0: + Led.On(0); + break; + case BUTTON_1: + Led.On(1); + break; + case BUTTON_2: + Led.On(2); + break; + case BUTTON_3: + Led.On(3); + break; + default : + Led.On(4); + break; + } + wait(0.1); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 11 14:04:35 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file