ex. 2a, PPO

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Committer:
shinoku99
Date:
Sat May 16 12:24:31 2020 +0000
Revision:
0:b4138dcce926
2a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shinoku99 0:b4138dcce926 1 #include "mbed.h"
shinoku99 0:b4138dcce926 2 #include "TS_DISCO_F429ZI.h"
shinoku99 0:b4138dcce926 3 #include "LCD_DISCO_F429ZI.h"
shinoku99 0:b4138dcce926 4
shinoku99 0:b4138dcce926 5 LCD_DISCO_F429ZI MyLcd;
shinoku99 0:b4138dcce926 6 TS_DISCO_F429ZI MyTS;
shinoku99 0:b4138dcce926 7
shinoku99 0:b4138dcce926 8 int main(){
shinoku99 0:b4138dcce926 9 TS_StateTypeDef TS_State;
shinoku99 0:b4138dcce926 10
shinoku99 0:b4138dcce926 11 MyLcd.Clear(LCD_COLOR_BLACK);
shinoku99 0:b4138dcce926 12
shinoku99 0:b4138dcce926 13 while(1){
shinoku99 0:b4138dcce926 14 for(int a=0; a<4; a++){
shinoku99 0:b4138dcce926 15 //niebieskie przyciski
shinoku99 0:b4138dcce926 16 MyLcd.SetTextColor(LCD_COLOR_BLUE);
shinoku99 0:b4138dcce926 17 MyLcd.FillRect(0, a*80, 80, 80);
shinoku99 0:b4138dcce926 18 }
shinoku99 0:b4138dcce926 19
shinoku99 0:b4138dcce926 20 MyTS.GetState(&TS_State);
shinoku99 0:b4138dcce926 21 if ((TS_State.TouchDetected) && (TS_State.X > 0) && (TS_State.X < 80) && (TS_State.Y > 0) && (TS_State.Y < 80)){
shinoku99 0:b4138dcce926 22 MyLcd.SetTextColor(LCD_COLOR_YELLOW);
shinoku99 0:b4138dcce926 23 MyLcd.FillRect(0, 0, 80, 80);
shinoku99 0:b4138dcce926 24 }
shinoku99 0:b4138dcce926 25 else if ((TS_State.TouchDetected) && (TS_State.X > 0) && (TS_State.X < 80) && (TS_State.Y > 80) && (TS_State.Y < 160)){
shinoku99 0:b4138dcce926 26 MyLcd.SetTextColor(LCD_COLOR_YELLOW);
shinoku99 0:b4138dcce926 27 MyLcd.FillRect(0, 80, 80, 80);
shinoku99 0:b4138dcce926 28 }
shinoku99 0:b4138dcce926 29 else if ((TS_State.TouchDetected) && (TS_State.X > 0) && (TS_State.X < 80) && (TS_State.Y > 160) && (TS_State.Y < 240)){
shinoku99 0:b4138dcce926 30 MyLcd.SetTextColor(LCD_COLOR_YELLOW);
shinoku99 0:b4138dcce926 31 MyLcd.FillRect(0, 160, 80, 80);
shinoku99 0:b4138dcce926 32 }
shinoku99 0:b4138dcce926 33 else if ((TS_State.TouchDetected) && (TS_State.X > 0) && (TS_State.X < 80) && (TS_State.Y > 240) && (TS_State.Y < 320)){
shinoku99 0:b4138dcce926 34 MyLcd.SetTextColor(LCD_COLOR_YELLOW);
shinoku99 0:b4138dcce926 35 MyLcd.FillRect(0, 240, 80, 80);
shinoku99 0:b4138dcce926 36 }
shinoku99 0:b4138dcce926 37
shinoku99 0:b4138dcce926 38 for(int b=0; b<4; b++){
shinoku99 0:b4138dcce926 39 //zielone ramki
shinoku99 0:b4138dcce926 40 MyLcd.SetTextColor(LCD_COLOR_GREEN);
shinoku99 0:b4138dcce926 41 MyLcd.DrawRect(0, b*80, 80, 80);
shinoku99 0:b4138dcce926 42 }
shinoku99 0:b4138dcce926 43
shinoku99 0:b4138dcce926 44 MyLcd.SetFont(&Font24);
shinoku99 0:b4138dcce926 45
shinoku99 0:b4138dcce926 46 //czerwone
shinoku99 0:b4138dcce926 47 MyLcd.SetBackColor(LCD_COLOR_RED);
shinoku99 0:b4138dcce926 48 MyLcd.SetTextColor(LCD_COLOR_WHITE);
shinoku99 0:b4138dcce926 49 MyLcd.DisplayStringAt(0, 0, (uint8_t *)"0", LEFT_MODE);
shinoku99 0:b4138dcce926 50 MyLcd.DisplayStringAt(0, 80, (uint8_t *)"1", LEFT_MODE);
shinoku99 0:b4138dcce926 51 MyLcd.DisplayStringAt(0, 160, (uint8_t *)"2", LEFT_MODE);
shinoku99 0:b4138dcce926 52 MyLcd.DisplayStringAt(0, 240, (uint8_t *)"3", LEFT_MODE);
shinoku99 0:b4138dcce926 53
shinoku99 0:b4138dcce926 54 wait(0.1);
shinoku99 0:b4138dcce926 55 }
shinoku99 0:b4138dcce926 56 }