Moussa Oudjama / Mbed 2 deprecated TP_Interfacage_Capteur_Courant

Dependencies:   BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG mbed

Files at this revision

API Documentation at this revision

Comitter:
MoussOudj
Date:
Thu Jun 21 08:16:30 2018 +0000
Child:
1:724f5e3b485a
Commit message:
TP_Capteur_courant_v1

Changed in this revision

BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
Smiley.h Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Thu Jun 21 08:16:30 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#c9112f0c67e3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Thu Jun 21 08:16:30 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Smiley.h	Thu Jun 21 08:16:30 2018 +0000
@@ -0,0 +1,44 @@
+
+/*******************************************************************************
+* image
+* filename: unsaved
+* name: stop
+*
+* preset name: Color A8R8G8B8
+* data block size: 8 bit(s), uint8_t
+* RLE compression enabled: no
+* conversion type: Color, not_used not_used
+* bits per pixel: 24
+*
+* preprocess:
+*  main scan direction: left_to_right
+*  line scan direction: forward
+*  inverse: no
+*******************************************************************************/
+
+/*
+ typedef struct {
+     const uint8_t *data;
+     uint16_t width;
+     uint16_t height;
+     uint8_t dataSize;
+     } tImage;
+*/
+#include <stdint.h>
+
+
+
+__ALIGN_BEGIN const unsigned char test[] __ALIGN_END ={
+0x41,0x59,0x56,0x41,0x57,0x54,0x40,0x4E,0x4B,0x42,0x51,0x50,0x41,0x58,0x55,0x44,
+0x5F,0x51,0x41,0x59,0x4D,0x44,0x5E,0x58,0x42,0x62,0x5B,0x42,0x63,0x58,0x43,0x62,
+0x57,0x41,0x5A,0x54,0x42,0x57,0x52,0x43,0x59,0x53,0x45,0x5E,0x55,0x43,0x60,0x55,
+0x3B,0x58,0x4D,0x3A,0x59,0x4B,0x32,0x48,0x3B,0x28,0x38,0x31,0x34,0x4C,0x45,0x3F,
+0x5C,0x50,0x3F,0x65,0x56,0x3F,0x6F,0x5F,0x3E,0x69,0x58,0x3A,0x5C,0x50,0x3D,0x5C,
+0x53,0x42,0x5E,0x58,0x45,0x60,0x56,0x42,0x60,0x55,0x44,0x66,0x5B,0x42,0x6A,0x5A,
+0x3B,0x5F,0x4F,0x3A,0x53,0x49,0x34,0x46,0x3D,0x39,0x4E,0x45,0x39,0x5A,0x4F,0x41,
+0x67,0x5A,0x4B,0x6B,0x62,0x4A,0x66,0x5C,0x46,0x62,0x58,0x40,0x5A,0x50,0x3E,0x57,
+0x4D,0x42,0x5E,0x55,0x46,0x63,0x5A,0x46,0x65,0x5D,0x49,0x6A,0x63,0x49,0x66,0x62,
+0x48,0x61,0x5B,0x49,0x5F,0x57,0x42,0x55,0x51,0x46,0x5C,0x56,0x44,0x5B,0x56,0x3F,
+0x56,0x53,0x41,0x5A,0x55,0x40,0x5F,0x59,0x42,0x64,0x5C,0x43,0x62,0x59,0x40,0x5C,
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Thu Jun 21 08:16:30 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 21 08:16:30 2018 +0000
@@ -0,0 +1,217 @@
+#include "mbed.h"
+#include "TS_DISCO_F746NG.h"
+#include "LCD_DISCO_F746NG.h"
+#include "Smiley.h"
+
+LCD_DISCO_F746NG lcd;
+TS_DISCO_F746NG ts;
+AnalogIn anal(A4);
+TS_StateTypeDef TS_State;
+
+///////////////////////////////////Déclaration des variables///////////////////////////////////////////
+double tension = 0;
+double amp = 0;
+int active=0;
+
+
+uint16_t x, y;
+uint8_t text[30];
+uint8_t status;
+uint8_t idx;
+uint8_t cleared = 0;
+uint8_t prev_nb_touches = 0;
+///////////////////////////////////Déclaration des variables///////////////////////////////////////////
+
+
+
+//////////////////////////////////////////PROTOTYPE////////////////////////////////////////////////////
+void Init_TS(void);             //Fonction d'initialisation du TouchScreen
+void Init_Bouton(void);         //Fonction d'initalisation des boutons
+void Affichage_valeurs(void);   //Fonction d'affichage de la tension et du courant
+void Action_bouton(void);       //Fonction d'action à l'appui des bouton
+//////////////////////////////////////////PROTOTYPE////////////////////////////////////////////////////
+
+
+
+
+int main()
+{
+    
+    
+    
+   Init_TS();           //Appel de la fonction d'initialisation du TouchScreen
+   
+   Init_Bouton();       //Appel de la fonction d'initialisation des boutons
+    
+   //lcd.DrawBitmap(20,20,(uint8_t *)test);
+    
+    
+    while(1) {
+        
+        
+        Affichage_valeurs();    //Appel de la fonction pour calculer et afficher sur l'ecran LCD la tension et le courant
+        
+        ts.GetState(&TS_State); //Récupération de l'état du TouchScreen
+         
+        if (TS_State.touchDetected) {    //Si touché détecté
+           
+            
+            for (idx = 0; idx < TS_State.touchDetected; idx++) {   //Récupération de l'axe x et y 
+                x = TS_State.touchX[idx];                          //Récupération de l'axe x
+                y = TS_State.touchY[idx];                          //Récupération de l'axey 
+            }
+        
+        
+        Action_bouton();        //Appel de la fonction qui permet d'effectuer l'action des boutons Start et Stop
+      
+           
+        }
+    }
+}
+
+
+
+
+
+
+
+///////////////////////////////////////Initialisation TouchScreen//////////////////////////////////
+void Init_TS(void) 
+{
+  lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Capteur courant DEMO", CENTER_MODE); //Affichage titre projet
+   
+    wait(4); //Temporisation
+
+    status = ts.Init(lcd.GetXSize(), lcd.GetYSize());       //Acquisition des dimensions de l'écran
+    
+    if (status != TS_OK) {  //Si TouchScreen différent de OK
+        lcd.Clear(LCD_COLOR_RED);
+        lcd.SetBackColor(LCD_COLOR_RED);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);  //Afficher Etat fail
+    } else {    //Sinon
+        lcd.Clear(LCD_COLOR_GREEN);
+        lcd.SetBackColor(LCD_COLOR_GREEN);
+        lcd.SetTextColor(LCD_COLOR_WHITE);
+        lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);    //Afficher Etat OK
+    }   
+    
+    wait(1); //Temporisation
+
+
+}
+///////////////////////////////////////Initialisation TouchScreen//////////////////////////////////
+
+
+
+///////////////////////////////////////Initialisation Bouton///////////////////////////////////////
+void Init_Bouton(void)
+{
+
+
+    lcd.Clear(LCD_COLOR_BLUE); //Effacer l'affichage actuel
+    lcd.SetFont(&Font16);
+    lcd.SetBackColor(LCD_COLOR_BLUE);   //Background en bleu
+    
+    lcd.SetTextColor(LCD_COLOR_RED);    //Dessine le premier bouton en rouge
+    lcd.DrawCircle(350, 230, 30);       //Dessine le bouton (x,y,rayon)
+    lcd.FillCircle(350, 230, 30);       //Remplis le bouton (x,y,rayon)
+    
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.DrawCircle(150, 230, 30);
+    lcd.FillCircle(150, 230, 30);
+    
+    lcd.SetTextColor(LCD_COLOR_WHITE);  //Remettre l'écriture du texte en blanc
+
+
+}
+///////////////////////////////////////Initialisation Bouton//////////////////////////////////
+
+
+
+///////////////////////////////////////Affichage des valeurs//////////////////////////////////
+void Affichage_valeurs(void)
+{
+    
+ if(active==1) //Si flag à 1
+        {
+            
+            tension = 0.8*tension + 0.2*((double)anal.read()*3.3); //Acquisition de la tension en entrée du port A4
+        
+            amp = (23.307*tension) - (38.521);                     //Calcul du courant à l'aide de l'équation generée sur excel //y = 23.307x - 38.521
+            
+        }
+        
+         lcd.ClearStringLine(7);    //Effacement de la ligne pour actualiser la valeur
+         sprintf((char*)text, "Tension   : %.2f",tension);      //Ecriture de la valeur
+         lcd.DisplayStringAt(150, LINE(7),(uint8_t *)&text, LEFT_MODE);     //Affichage de la valeur
+                  
+         lcd.ClearStringLine(8);
+         sprintf((char*)text, "Intensite : %.2f",amp);
+         lcd.DisplayStringAt(150, LINE(8),(uint8_t *)&text, LEFT_MODE);
+
+         wait(0.3);     //Temporisation
+
+
+}
+///////////////////////////////////////Affichage des valeurs//////////////////////////////////
+
+
+
+
+///////////////////////////////////////Action des boutons//////////////////////////////////
+void Action_bouton(void)
+{
+    
+ if ((TS_State.touchDetected) & (x>320&x<380) & (y>200&y<260)) {    //Quand touche détectée à la position du bouton Stop
+           
+           sprintf((char*)text, "     ");       //Efface l'affichage de l'état Start
+           lcd.DisplayStringAt(0, LINE(3), (uint8_t *)&text, LEFT_MODE);    
+           
+           sprintf((char*)text, "Stop");        //Affichage de l'état Stop
+           lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, LEFT_MODE);
+           
+           lcd.ClearStringLine(8);              //Mise à 0  du courant quand la lecture est stoppée
+           sprintf((char*)text, "Intensite : %.2f",amp);                    
+           lcd.DisplayStringAt(150, LINE(8),(uint8_t *)&text, LEFT_MODE);
+           amp = 0;
+           
+           lcd.ClearStringLine(7);              //Mise à 0  de la tension quand la lecture est stoppée
+           sprintf((char*)text, "Tension   : %.2f",tension);
+           lcd.DisplayStringAt(150, LINE(7),(uint8_t *)&text, LEFT_MODE);
+           tension = 0;
+           
+           
+           active=0;    //mise à 0 du drapeau
+
+           
+           lcd.SetTextColor(LCD_COLOR_WHITE);
+        }
+           
+        else if((TS_State.touchDetected) & (x>130&x<180) & (y>200&y<260) ) {    //Quand touche détectée à la position du bouton Start
+         
+           sprintf((char*)text, "           ");     //Efface l'affichage de l'état Stop
+           lcd.DisplayStringAt(0, LINE(2), (uint8_t *)&text, LEFT_MODE);
+         
+           sprintf((char*)text, "Start");           //Affichage de l'état Start
+           lcd.DisplayStringAt(0, LINE(3), (uint8_t *)&text, LEFT_MODE);
+           
+           active=1;    //mise à 1 du drapeau
+
+           lcd.SetTextColor(LCD_COLOR_WHITE);
+         }
+
+
+
+}
+///////////////////////////////////////Action des boutons//////////////////////////////////
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 21 08:16:30 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file