mbeed1sdf
Dependencies: BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed
Fork of 2D_2_ by
Revision 0:1f84f23f3814, committed 2017-05-29
- Comitter:
- adrianow795
- Date:
- Mon May 29 14:37:50 2017 +0000
- Commit message:
- mbed1
Changed in this revision
diff -r 000000000000 -r 1f84f23f3814 BSP_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F429ZI.lib Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#de9280158372
diff -r 000000000000 -r 1f84f23f3814 KeyboardTsLcd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardTsLcd.cpp Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,35 @@ +#include "KeyboardTsLcd.h" + +KeyboardTsLcd::KeyboardTsLcd(unsigned char _ucColumn) +{ +pKeyboard = new KeyboardTs(_ucColumn); +pLed = new LedLcd(_ucColumn); +}; + +KeyboardState KeyboardTsLcd::eRead() + { + KeyboardState BP; + switch(BP = 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; + } + return BP; + + } \ No newline at end of file
diff -r 000000000000 -r 1f84f23f3814 KeyboardTsLcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardTsLcd.h Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,25 @@ +#ifndef KEYBOARDTSLCD_H +#define KEYBOARDTSLCD_H +#include "Keyboard_Ts.h" +#include "Led_Lcd.h" + +class KeyboardTsLcd +{ + public: + KeyboardTsLcd (unsigned char); + KeyboardState eRead(); + private: + LedLcd * pLed; + KeyboardTs * pKeyboard; +}; + + + + + + + + + + +#endif
diff -r 000000000000 -r 1f84f23f3814 Keyboard_Ts.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.cpp Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,35 @@ +#include "Keyboard_Ts.h" + +KeyboardTs::KeyboardTs(uint8_t Col) +{ + ts.Init(240, 320); + Column = Col; +} + + KeyboardState KeyboardTs::eRead() +{ + ts.GetState(&TS_State); + if ((TS_State.TouchDetected) && (TS_State.Y > 0) && (TS_State.Y < 80) && (TS_State.X < (Column + 1) * 80) &&(TS_State.X > Column * 80) ) + { + return BUTTON_0; + + + } + else if ((TS_State.TouchDetected) && (TS_State.Y > 80) && (TS_State.Y < 160) && (TS_State.X < (Column + 1) * 80) &&(TS_State.X > Column * 80) ) + { + return BUTTON_1; + + } + else if ((TS_State.TouchDetected) && (TS_State.Y > 160) && (TS_State.Y < 240) && (TS_State.X < (Column + 1) * 80) &&(TS_State.X > Column * 80) ) + { + return BUTTON_2; + } + else if ((TS_State.TouchDetected) && (TS_State.Y > 240) && (TS_State.Y < 320) && (TS_State.X < (Column + 1) * 80) &&(TS_State.X > Column * 80) ) + { + return BUTTON_3; + } + else + { + return RELASED; + } +} \ No newline at end of file
diff -r 000000000000 -r 1f84f23f3814 Keyboard_Ts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.h Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,24 @@ +#ifndef KEYBOARD_TS_H +#define KEYBOARD_TS_H +#include "TS_DISCO_F429ZI.h" +enum KeyboardState{ + BUTTON_0, + BUTTON_1, + BUTTON_2, + BUTTON_3, + RELASED + }; + +class KeyboardTs +{ + public: + KeyboardTs(uint8_t); + KeyboardState eRead(); + private: + uint8_t Column; + TS_DISCO_F429ZI ts; + TS_StateTypeDef TS_State; + +}; + +#endif \ No newline at end of file
diff -r 000000000000 -r 1f84f23f3814 LCD_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
diff -r 000000000000 -r 1f84f23f3814 Led_Lcd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.cpp Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,76 @@ +#include "Led_Lcd.h" +#include "mbed.h" + + +LedLcd::LedLcd(uint8_t Col) +{ + Column = Col; + lcd.Clear(LCD_COLOR_BLACK); + DrawButton(0,"0"); + DrawButton(1,"1"); + DrawButton(2,"2"); + DrawButton(3,"3"); +} + + void LedLcd::DrawButton(uint8_t number, char title []) + { + lcd.SetFont(&Font24); + lcd.SetTextColor(LCD_COLOR_GREEN ); + lcd.DrawRect(Column * 80,number * 80,80,80); + lcd.SetTextColor(LCD_COLOR_BLUE ); + lcd.FillRect(Column * 80 + 1,number * 80 + 1,78,78); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE ); + lcd.DisplayStringAt(Column * 80, number * 80, (uint8_t *)title, LEFT_MODE); + } + + void LedLcd::PressButton(uint8_t number, char title []) + { + lcd.SetTextColor(LCD_COLOR_GREEN ); + lcd.FillRect(Column * 80 + 1,number * 80 + 1,78,78); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE ); + lcd.DisplayStringAt(Column * 80, number * 80, (uint8_t *)title, LEFT_MODE); + + } + + void LedLcd::On(uint8_t Position) + { + if (Position == 0) + { + PressButton(0,"0"); + DrawButton(1,"1"); + DrawButton(2,"2"); + DrawButton(3,"3"); + } + else if (Position == 1) + { + PressButton(1,"1"); + DrawButton(0,"0"); + DrawButton(2,"2"); + DrawButton(3,"3"); + + } + else if (Position == 2 ) + { + PressButton(2,"2"); + DrawButton(0,"0"); + DrawButton(1,"1"); + DrawButton(3,"3"); + } + else if (Position == 3) + { + PressButton(3,"3"); + DrawButton(0,"0"); + DrawButton(2,"2"); + DrawButton(1,"1"); + } + else + { + DrawButton(0,"0"); + DrawButton(1,"1"); + DrawButton(2,"2"); + DrawButton(3,"3"); + } + } + \ No newline at end of file
diff -r 000000000000 -r 1f84f23f3814 Led_Lcd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Led_Lcd.h Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,18 @@ +#ifndef LED_LCD_H +#define LED_LCD_H + +#include "LCD_DISCO_F429ZI.h" + +class LedLcd +{ + public: + LedLcd(uint8_t); + void On(uint8_t ); + private: + uint8_t Column; + LCD_DISCO_F429ZI lcd; + void DrawButton(uint8_t , char []); + void PressButton(uint8_t , char []); +}; + +#endif
diff -r 000000000000 -r 1f84f23f3814 TS_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F429ZI.lib Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
diff -r 000000000000 -r 1f84f23f3814 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,34 @@ +#include "KeyboardTsLcd.h" + +int main() +{ + KeyboardTsLcd Keyboard(0); + LedLcd LedMirror(2); + + while(1) { + + switch(Keyboard.eRead()) { + case BUTTON_0: + LedMirror.On(3); + break; + + case BUTTON_1: + LedMirror.On(2); + break; + + case BUTTON_2: + LedMirror.On(1); + break; + + case BUTTON_3: + LedMirror.On(0); + break; + + default : + LedMirror.On(4); + break; + + } + wait(0.1); + } +} \ No newline at end of file
diff -r 000000000000 -r 1f84f23f3814 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 29 14:37:50 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file