Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG Slider TS_DISCO_F746NG mbed
main.cpp
00001 #include "mbed.h" 00002 #include "LCD_DISCO_F746NG.h" 00003 #include "TS_DISCO_F746NG.h" 00004 #include "Slider.h" 00005 00006 LCD_DISCO_F746NG lcd; // Instanciation de l'écran LCD 00007 TS_DISCO_F746NG ts; // Instanciation de la dalle tactile 00008 00009 DigitalOut led1(LED1); // Instanciation de LED verte 00010 00011 int main() 00012 { 00013 led1 = 1; 00014 uint32_t color; 00015 uint16_t red,green,blue; 00016 TS_StateTypeDef TS_State; 00017 Slider Slider1(10,10,30,200,LCD_COLOR_RED,LCD_COLOR_LIGHTGRAY); 00018 Slider Slider2(50,10,30,200,LCD_COLOR_GREEN,LCD_COLOR_LIGHTGRAY); 00019 Slider Slider3(90,10,30,200,LCD_COLOR_BLUE,LCD_COLOR_LIGHTGRAY); 00020 char Str1[50]; 00021 uint8_t status; 00022 int Y=136; 00023 status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); 00024 if (status != TS_OK) 00025 { 00026 lcd.Clear(LCD_COLOR_RED); 00027 lcd.SetBackColor(LCD_COLOR_RED); 00028 lcd.SetTextColor(LCD_COLOR_WHITE); 00029 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); 00030 } 00031 else 00032 { 00033 lcd.Clear(LCD_COLOR_GREEN); 00034 lcd.SetBackColor(LCD_COLOR_GREEN); 00035 lcd.SetTextColor(LCD_COLOR_WHITE); 00036 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); 00037 } 00038 wait(1); 00039 lcd.Clear(LCD_COLOR_WHITE); 00040 00041 00042 lcd.SetBackColor(LCD_COLOR_WHITE); 00043 00044 lcd.SetTextColor(LCD_COLOR_BLACK); 00045 lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"IUT GEII TOURS", CENTER_MODE); 00046 00047 00048 wait(1); 00049 lcd.Clear(LCD_COLOR_WHITE); 00050 00051 // Draw the 3 sliders 00052 Slider1.Show(); 00053 Slider2.Show(); 00054 Slider3.Show(); 00055 00056 // read the sliders values 00057 red=Slider1.GetValue(); 00058 green=Slider2.GetValue(); 00059 blue=Slider3.GetValue(); 00060 00061 // Calculate and draw the RGB color 00062 color=0xFF000000; 00063 color+=red*65536+green*256+blue; 00064 sprintf(Str1,"Color: 0x%8X",color); 00065 lcd.SetFont(&Font16); 00066 lcd.SetTextColor(LCD_COLOR_BLACK); 00067 lcd.DisplayStringAt(200,250,(uint8_t*) Str1,LEFT_MODE); 00068 lcd.DrawCircle(300,136,51); 00069 lcd.SetTextColor(color); 00070 lcd.FillCircle(300,136,50); 00071 00072 while(1) 00073 { 00074 ts.GetState(&TS_State); 00075 if (TS_State.touchDetected) 00076 { 00077 led1 = 1; 00078 for (int I=0;I<TS_State.touchDetected;I++) 00079 { 00080 // Test touch screen position and move sliders 00081 Slider1.Move(TS_State.touchX[I],TS_State.touchY[I]); 00082 Slider2.Move(TS_State.touchX[I],TS_State.touchY[I]); 00083 Slider3.Move(TS_State.touchX[I],TS_State.touchY[I]); 00084 00085 // read the sliders values 00086 red=Slider1.GetValue(); 00087 green=Slider2.GetValue(); 00088 blue=Slider3.GetValue(); 00089 00090 // Calculate and draw the RGB color 00091 color=0xFF000000; 00092 color+=red*65536+green*256+blue; 00093 sprintf(Str1,"Color: 0x%8X",color); 00094 lcd.SetTextColor(LCD_COLOR_BLACK); 00095 lcd.SetFont(&Font16); 00096 lcd.DisplayStringAt(200,250,(uint8_t*) Str1,LEFT_MODE); 00097 00098 lcd.SetTextColor(color); 00099 lcd.FillCircle(300,136,50); 00100 } 00101 //wait(0.2); 00102 } 00103 else 00104 { 00105 led1 = 0; 00106 } 00107 00108 00109 00110 } 00111 }
Generated on Thu Jul 14 2022 16:14:03 by
1.7.2