schneider françois / Affichage

Dependencies:   FT800_2

Dependents:   SimonBaseProgrammeSP3-STM32-F411

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers affichage.cpp Source File

affichage.cpp

00001 #include "mbed.h"
00002 #include "FT_Platform.h"
00003 #include "affichage.h"
00004 
00005 // NUCLEO F411RE
00006 FT800 TFT (PB_5,PB_4,PB_3,PA_8,PB_10,PA_9); // mosi, miso, sck, ss, int, pd
00007 char sliderVal = 0;
00008 
00009 // Variable pour les donnees a afficher 
00010 // en liaison SP1 et Tablette
00011 volatile unsigned char ConsigneVitFluxAir; // Vitesse de Flux d'air consigne  
00012 volatile unsigned char MesVitFluxAir; //Vitesse de Flux d'air mesure Sp1
00013 volatile unsigned char TempSoufflerie; // temperature chambre soufflerie Sp1
00014 volatile unsigned char HumiditéSoufflerie; // humidite chambre soufflerie SP1
00015 
00016 // en liaison SP1 et Tablette
00017 volatile signed char ConsigneAngleIncid ; // Vitesse de Flux d'air consigne 
00018 
00019 volatile signed char ConsigneChampPression[8] ; // Vitesse de Flux d'air consigne 
00020 
00021 /*
00022 Angle incidence mesure
00023 Champs de pression : 8 valeurs
00024 Cx : coefficients de traînée (C_x)
00025 Cz : coefficients de portance (C_z)
00026 */
00027 
00028 // permet d'indiquer qu'une variable a changer et qu'il faut reafficher l'ecran
00029 
00030 volatile bool DataChange = true; // true indique qu'il faut afficher l'ecran
00031 
00032 // permet d'affecter une valeur a consigne de flux d'air
00033 void SetConsigneVitFluxAir(unsigned char variable)
00034 {
00035     ConsigneVitFluxAir = variable;
00036     DataChange = true;
00037     }
00038 
00039 void InitScreen(void)
00040 {
00041     luminosite(128);
00042     TFT.Calibrate();
00043     TFT.Track(244, 45, 161, 17, 2);
00044 }
00045 
00046 ft_void_t luminosite( ft_int32_t lum)
00047 {
00048     TFT.DLstart(); // wait until after the swap
00049     TFT.MemWrite(REG_PWM_DUTY, 4); // write to the PWM_DUTY register
00050     TFT.StartFunc( FT_CMD_SIZE*1);
00051     TFT.SendCmd(lum);
00052     TFT.EndFunc( (FT_CMD_SIZE*1));
00053     TFT.Flush_Co_Buffer();                 // Download the command list into fifo
00054     TFT.WaitCmdfifo_empty();
00055 }
00056 
00057 ft_void_t drawline( ft_int32_t x0, ft_int32_t y0,ft_int32_t x1,ft_int32_t y1)
00058 {
00059     TFT.DL(BEGIN(LINES));
00060     TFT.DL(VERTEX2F(x0*16,y0*16));
00061     TFT.DL(VERTEX2F(x1*16,y1*16));
00062 }
00063 
00064 /***********************************************************************************************************************/
00065 /* Construct the screen and downloasd it to the TFT */
00066 void AfficheEcranSp3()
00067 {
00068     
00069     TFT.DLstart();
00070     TFT.DL(CLEAR_COLOR_RGB(255, 255, 255));
00071     TFT.DL(CLEAR(1, 1, 1));
00072 
00073     TFT.FgColor(0xC1004D);
00074 
00075     TFT.Keys(27, 127, 271, 41, 29, 0, "123");
00076 
00077     TFT.DL(TAG(1));
00078     TFT.Button(31, 32, 148, 57, 27, OPT_FLAT, "Button");
00079 
00080     TFT.DL(TAG(2));
00081     TFT.Slider(244, 45, 161, 17, 0, sliderVal, 255);
00082 
00083     // track the touch screen 
00084     // a sortir mettre dans une fonction qui gere le tactile si besoins
00085     
00086     char pressedButton = TFT.Rd8(REG_TOUCH_TAG);
00087     int pressedSlider = TFT.Rd32(REG_TRACKER);
00088     if (pressedButton == 2) {
00089         sliderVal = (pressedSlider >> 16) * 255 / 65536;
00090     }
00091 
00092     TFT.DL(COLOR_RGB(0, 0, 0));
00093     TFT.Text(28, 213, 28, 0, "REG_TOUCH_TAG");
00094     TFT.Text(28, 237, 28, 0, "REG_TRACKER");
00095     
00096  
00097     TFT.Number(230, 237, 28, 0, pressedButton);
00098     TFT.Number(230, 213, 28, 0, sliderVal);
00099 
00100 // pour afficher variable consigne vitesse de flux d'air
00101 
00102     TFT.Text(28, 190, 28, 0, "Consigne flux dair");      
00103     TFT.Number(230, 190, 28, 0, ConsigneVitFluxAir);   
00104     drawline(28,191,470,191);
00105 
00106     TFT.DL(DISPLAY());
00107     TFT.Swap();
00108     TFT.Flush_Co_Buffer();
00109     TFT.WaitCmdfifo_empty();
00110     DataChange = false;
00111 }