BAse sous ,projet 3 - soufflerue
Dependents: SimonBaseProgrammeSP3-STM32-F411
affichage.cpp@1:7a1dd20a34b6, 2021-02-23 (annotated)
- Committer:
- schnf30
- Date:
- Tue Feb 23 10:15:34 2021 +0000
- Revision:
- 1:7a1dd20a34b6
- Parent:
- 0:660735eb3958
Mise a jour
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
schnf30 | 0:660735eb3958 | 1 | #include "mbed.h" |
schnf30 | 0:660735eb3958 | 2 | #include "FT_Platform.h" |
schnf30 | 0:660735eb3958 | 3 | #include "affichage.h" |
schnf30 | 0:660735eb3958 | 4 | |
schnf30 | 0:660735eb3958 | 5 | // NUCLEO F411RE |
schnf30 | 0:660735eb3958 | 6 | FT800 TFT (PB_5,PB_4,PB_3,PA_8,PB_10,PA_9); // mosi, miso, sck, ss, int, pd |
schnf30 | 0:660735eb3958 | 7 | char sliderVal = 0; |
schnf30 | 0:660735eb3958 | 8 | |
schnf30 | 0:660735eb3958 | 9 | // Variable pour les donnees a afficher |
schnf30 | 0:660735eb3958 | 10 | // en liaison SP1 et Tablette |
schnf30 | 0:660735eb3958 | 11 | volatile unsigned char ConsigneVitFluxAir; // Vitesse de Flux d'air consigne |
schnf30 | 0:660735eb3958 | 12 | volatile unsigned char MesVitFluxAir; //Vitesse de Flux d'air mesure Sp1 |
schnf30 | 0:660735eb3958 | 13 | volatile unsigned char TempSoufflerie; // temperature chambre soufflerie Sp1 |
schnf30 | 0:660735eb3958 | 14 | volatile unsigned char HumiditéSoufflerie; // humidite chambre soufflerie SP1 |
schnf30 | 0:660735eb3958 | 15 | |
schnf30 | 0:660735eb3958 | 16 | // en liaison SP1 et Tablette |
schnf30 | 0:660735eb3958 | 17 | volatile signed char ConsigneAngleIncid ; // Vitesse de Flux d'air consigne |
schnf30 | 0:660735eb3958 | 18 | |
schnf30 | 0:660735eb3958 | 19 | volatile signed char ConsigneChampPression[8] ; // Vitesse de Flux d'air consigne |
schnf30 | 0:660735eb3958 | 20 | |
schnf30 | 0:660735eb3958 | 21 | /* |
schnf30 | 0:660735eb3958 | 22 | Angle incidence mesure |
schnf30 | 0:660735eb3958 | 23 | Champs de pression : 8 valeurs |
schnf30 | 0:660735eb3958 | 24 | Cx : coefficients de traînée (C_x) |
schnf30 | 0:660735eb3958 | 25 | Cz : coefficients de portance (C_z) |
schnf30 | 0:660735eb3958 | 26 | */ |
schnf30 | 0:660735eb3958 | 27 | |
schnf30 | 0:660735eb3958 | 28 | // permet d'indiquer qu'une variable a changer et qu'il faut reafficher l'ecran |
schnf30 | 0:660735eb3958 | 29 | |
schnf30 | 0:660735eb3958 | 30 | volatile bool DataChange = true; // true indique qu'il faut afficher l'ecran |
schnf30 | 0:660735eb3958 | 31 | |
schnf30 | 0:660735eb3958 | 32 | // permet d'affecter une valeur a consigne de flux d'air |
schnf30 | 0:660735eb3958 | 33 | void SetConsigneVitFluxAir(unsigned char variable) |
schnf30 | 0:660735eb3958 | 34 | { |
schnf30 | 0:660735eb3958 | 35 | ConsigneVitFluxAir = variable; |
schnf30 | 0:660735eb3958 | 36 | DataChange = true; |
schnf30 | 0:660735eb3958 | 37 | } |
schnf30 | 0:660735eb3958 | 38 | |
schnf30 | 0:660735eb3958 | 39 | void InitScreen(void) |
schnf30 | 0:660735eb3958 | 40 | { |
schnf30 | 0:660735eb3958 | 41 | luminosite(128); |
schnf30 | 0:660735eb3958 | 42 | TFT.Calibrate(); |
schnf30 | 0:660735eb3958 | 43 | TFT.Track(244, 45, 161, 17, 2); |
schnf30 | 0:660735eb3958 | 44 | } |
schnf30 | 0:660735eb3958 | 45 | |
schnf30 | 0:660735eb3958 | 46 | ft_void_t luminosite( ft_int32_t lum) |
schnf30 | 0:660735eb3958 | 47 | { |
schnf30 | 0:660735eb3958 | 48 | TFT.DLstart(); // wait until after the swap |
schnf30 | 0:660735eb3958 | 49 | TFT.MemWrite(REG_PWM_DUTY, 4); // write to the PWM_DUTY register |
schnf30 | 0:660735eb3958 | 50 | TFT.StartFunc( FT_CMD_SIZE*1); |
schnf30 | 0:660735eb3958 | 51 | TFT.SendCmd(lum); |
schnf30 | 0:660735eb3958 | 52 | TFT.EndFunc( (FT_CMD_SIZE*1)); |
schnf30 | 0:660735eb3958 | 53 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
schnf30 | 0:660735eb3958 | 54 | TFT.WaitCmdfifo_empty(); |
schnf30 | 0:660735eb3958 | 55 | } |
schnf30 | 0:660735eb3958 | 56 | |
schnf30 | 1:7a1dd20a34b6 | 57 | ft_void_t drawline( ft_int32_t x0, ft_int32_t y0,ft_int32_t x1,ft_int32_t y1) |
schnf30 | 1:7a1dd20a34b6 | 58 | { |
schnf30 | 1:7a1dd20a34b6 | 59 | TFT.DL(BEGIN(LINES)); |
schnf30 | 1:7a1dd20a34b6 | 60 | TFT.DL(VERTEX2F(x0*16,y0*16)); |
schnf30 | 1:7a1dd20a34b6 | 61 | TFT.DL(VERTEX2F(x1*16,y1*16)); |
schnf30 | 1:7a1dd20a34b6 | 62 | } |
schnf30 | 0:660735eb3958 | 63 | |
schnf30 | 0:660735eb3958 | 64 | /***********************************************************************************************************************/ |
schnf30 | 0:660735eb3958 | 65 | /* Construct the screen and downloasd it to the TFT */ |
schnf30 | 0:660735eb3958 | 66 | void AfficheEcranSp3() |
schnf30 | 0:660735eb3958 | 67 | { |
schnf30 | 0:660735eb3958 | 68 | |
schnf30 | 0:660735eb3958 | 69 | TFT.DLstart(); |
schnf30 | 0:660735eb3958 | 70 | TFT.DL(CLEAR_COLOR_RGB(255, 255, 255)); |
schnf30 | 0:660735eb3958 | 71 | TFT.DL(CLEAR(1, 1, 1)); |
schnf30 | 0:660735eb3958 | 72 | |
schnf30 | 0:660735eb3958 | 73 | TFT.FgColor(0xC1004D); |
schnf30 | 0:660735eb3958 | 74 | |
schnf30 | 0:660735eb3958 | 75 | TFT.Keys(27, 127, 271, 41, 29, 0, "123"); |
schnf30 | 0:660735eb3958 | 76 | |
schnf30 | 0:660735eb3958 | 77 | TFT.DL(TAG(1)); |
schnf30 | 0:660735eb3958 | 78 | TFT.Button(31, 32, 148, 57, 27, OPT_FLAT, "Button"); |
schnf30 | 0:660735eb3958 | 79 | |
schnf30 | 0:660735eb3958 | 80 | TFT.DL(TAG(2)); |
schnf30 | 0:660735eb3958 | 81 | TFT.Slider(244, 45, 161, 17, 0, sliderVal, 255); |
schnf30 | 0:660735eb3958 | 82 | |
schnf30 | 0:660735eb3958 | 83 | // track the touch screen |
schnf30 | 0:660735eb3958 | 84 | // a sortir mettre dans une fonction qui gere le tactile si besoins |
schnf30 | 0:660735eb3958 | 85 | |
schnf30 | 0:660735eb3958 | 86 | char pressedButton = TFT.Rd8(REG_TOUCH_TAG); |
schnf30 | 0:660735eb3958 | 87 | int pressedSlider = TFT.Rd32(REG_TRACKER); |
schnf30 | 0:660735eb3958 | 88 | if (pressedButton == 2) { |
schnf30 | 0:660735eb3958 | 89 | sliderVal = (pressedSlider >> 16) * 255 / 65536; |
schnf30 | 0:660735eb3958 | 90 | } |
schnf30 | 0:660735eb3958 | 91 | |
schnf30 | 0:660735eb3958 | 92 | TFT.DL(COLOR_RGB(0, 0, 0)); |
schnf30 | 0:660735eb3958 | 93 | TFT.Text(28, 213, 28, 0, "REG_TOUCH_TAG"); |
schnf30 | 0:660735eb3958 | 94 | TFT.Text(28, 237, 28, 0, "REG_TRACKER"); |
schnf30 | 0:660735eb3958 | 95 | |
schnf30 | 0:660735eb3958 | 96 | |
schnf30 | 0:660735eb3958 | 97 | TFT.Number(230, 237, 28, 0, pressedButton); |
schnf30 | 0:660735eb3958 | 98 | TFT.Number(230, 213, 28, 0, sliderVal); |
schnf30 | 0:660735eb3958 | 99 | |
schnf30 | 0:660735eb3958 | 100 | // pour afficher variable consigne vitesse de flux d'air |
schnf30 | 0:660735eb3958 | 101 | |
schnf30 | 0:660735eb3958 | 102 | TFT.Text(28, 190, 28, 0, "Consigne flux dair"); |
schnf30 | 0:660735eb3958 | 103 | TFT.Number(230, 190, 28, 0, ConsigneVitFluxAir); |
schnf30 | 1:7a1dd20a34b6 | 104 | drawline(28,191,470,191); |
schnf30 | 0:660735eb3958 | 105 | |
schnf30 | 0:660735eb3958 | 106 | TFT.DL(DISPLAY()); |
schnf30 | 0:660735eb3958 | 107 | TFT.Swap(); |
schnf30 | 0:660735eb3958 | 108 | TFT.Flush_Co_Buffer(); |
schnf30 | 0:660735eb3958 | 109 | TFT.WaitCmdfifo_empty(); |
schnf30 | 0:660735eb3958 | 110 | DataChange = false; |
schnf30 | 0:660735eb3958 | 111 | } |