le test

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Committer:
ascheriit
Date:
Thu May 23 09:42:38 2019 +0000
Revision:
42:53780e5a6acb
Parent:
39:b069cf6be013
la connexion avec le pc est annulee.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ascheriit 35:bda112796505 1 #include "Tick.h"
ascheriit 35:bda112796505 2
ascheriit 39:b069cf6be013 3 int GLOBAL_VALEUR_TICK=0; //Valeur facile d'accès à incrémanter grâce au ticker
ascheriit 35:bda112796505 4 Ticker timer; //
ascheriit 39:b069cf6be013 5 AnalogOut pinHP(PA_5); //Pin pour le reveil
ascheriit 39:b069cf6be013 6 Ticker son; //son utile pour l'alarme
ascheriit 39:b069cf6be013 7 int GLOBAL_BOOL_ALARME=0;
ascheriit 42:53780e5a6acb 8 //extern Serial pc;
ascheriit 35:bda112796505 9
ascheriit 35:bda112796505 10 void T_incermment(){
ascheriit 35:bda112796505 11 GLOBAL_VALEUR_TICK++;
ascheriit 35:bda112796505 12 }
ascheriit 35:bda112796505 13
ascheriit 35:bda112796505 14 int T_checkValue(){
ascheriit 35:bda112796505 15 if(GLOBAL_VALEUR_TICK){
ascheriit 35:bda112796505 16 GLOBAL_VALEUR_TICK--;
ascheriit 35:bda112796505 17 return 1;
ascheriit 35:bda112796505 18 }else{
ascheriit 35:bda112796505 19 return 0;
ascheriit 35:bda112796505 20 }
ascheriit 35:bda112796505 21 }
ascheriit 35:bda112796505 22
ascheriit 39:b069cf6be013 23 void T_initialise(int tempsS){
ascheriit 35:bda112796505 24 timer.attach(&T_incermment,tempsS);
ascheriit 39:b069cf6be013 25 son.attach(&T_sendSon,0.5);
ascheriit 35:bda112796505 26 }
ascheriit 35:bda112796505 27
ascheriit 35:bda112796505 28 void T_test(){
ascheriit 35:bda112796505 29 GLOBAL_VALEUR_TICK=0;
ascheriit 35:bda112796505 30 timer.attach(&T_incermment,2);
ascheriit 35:bda112796505 31 while(1){
ascheriit 35:bda112796505 32 BS_displayChiffre100Clean(35,25,GLOBAL_VALEUR_TICK,5,LCD_COLOR_RED,LCD_COLOR_WHITE);
ascheriit 35:bda112796505 33 wait(0.1);
ascheriit 35:bda112796505 34 }
ascheriit 39:b069cf6be013 35 }
ascheriit 39:b069cf6be013 36
ascheriit 39:b069cf6be013 37 void T_sendSon(){
ascheriit 39:b069cf6be013 38 if(GLOBAL_BOOL_ALARME){
ascheriit 39:b069cf6be013 39 const double pi = 3.141592653589793238462;
ascheriit 39:b069cf6be013 40 const double amplitude = 5.5f;
ascheriit 39:b069cf6be013 41 const double offset = 65535/2;
ascheriit 39:b069cf6be013 42 double rads = 0.0;
ascheriit 39:b069cf6be013 43 uint16_t sample = 0;
ascheriit 42:53780e5a6acb 44 //pc.printf("entree dans la boucle\n");
ascheriit 39:b069cf6be013 45 for (int i = 0; i < 12000; i++) {
ascheriit 39:b069cf6be013 46 rads = (pi * i) / 180.0f;
ascheriit 39:b069cf6be013 47 sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset);
ascheriit 39:b069cf6be013 48 pinHP.write_u16(sample);
ascheriit 39:b069cf6be013 49
ascheriit 39:b069cf6be013 50 }
ascheriit 42:53780e5a6acb 51 //pc.printf("sortie de la boucle\n");
ascheriit 39:b069cf6be013 52 }
ascheriit 39:b069cf6be013 53 }
ascheriit 39:b069cf6be013 54