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: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
Horloges/horloge.cpp
- Committer:
- Luca1996
- Date:
- 2019-05-16
- Revision:
- 32:8ad4b5555e6e
- Parent:
- 29:55d27fb3eb34
- Child:
- 33:31271a36a9a4
File content as of revision 32:8ad4b5555e6e:
#include "horloge.h"
char VRGL_AFFICHAGE_ELEMENTS = 1; //Cette variable globale vaut 1 si on affiche les éléments et vaut 0 sinon
void H_ChangeHour(temps* moment,int mod){
if(mod){
if(mod==1){
if((*moment).heure==23){
(*moment).heure=0;
}else{
(*moment).heure=(*moment).heure+1;
}
}else{
if((*moment).heure==0){
(*moment).heure=23;
}else{
(*moment).heure=(*moment).heure-1;
}
}
}
}
void H_ChangeMinute(temps* moment,int mod){
if(mod){
if(mod==1){
if((*moment).minute==59){
(*moment).minute=0;
H_ChangeHour(moment,1);
}else{
(*moment).minute=(*moment).minute+1;
}
}else{
if((*moment).minute==0){
(*moment).minute=59;
H_ChangeHour(moment,-1);
}else{
(*moment).minute=(*moment).minute-1;
}
}
}
}
void H_afficheHorlogeElemClean(temps mnt,int x,int y,int taille,long long int couleur,long long int fond){
if(VRGL_AFFICHAGE_ELEMENTS){
DisplayMatrixClean(x,y,BS_ElemHeure(mnt.heure),taille,couleur,fond);
DisplayMatrixClean(x + 11 * taille,y,BS_dotdot(),taille,couleur,fond);
DisplayMatrixClean(x + 19 * taille,y,BS_ElemMinute(mnt.minute),taille,couleur,fond);
}else{
BS_displayChiffre10Clean(x,y,mnt.heure,taille,couleur,fond);
DisplayMatrixClean(x + 11 * taille,y,BS_dotdot(),taille,couleur,fond);
BS_displayChiffre10Clean(x + 19 * taille,y,mnt.minute,taille,couleur,fond);
}
}
void H_reglage(temps* mnt,int x,int y,int taille,long long int couleur,long long int fond){
H_afficheHorlogeElemClean(*mnt,x,y,taille,couleur,fond);
int tamponClick=1; //Cette valeur sert à faire la distinction entre les moments où on veut changer l'heure et les moments où on veut passer au nombre suivant.
while(tamponClick){ //réglage des minutes
tamponClick=CdRelatif();
H_ChangeMinute(mnt,tamponClick);
H_afficheHorlogeElemClean(*mnt,x,y,taille,couleur,fond);
wait(0.05); //réduit les problèmes de rebond
}
wait(0.3);//evite le double-click
tamponClick=1;
while(tamponClick){ //téglage de l'heure
tamponClick=CdRelatif();
H_ChangeHour(mnt,tamponClick);
H_afficheHorlogeElemClean(*mnt,x,y,taille,couleur,fond);
wait(0.05);
}
}
void H_test1(){
temps tempsTest;
tempsTest.heure = 15;
tempsTest.minute = 01;
for(int i=0;i<48;i++){
for(int j=0;j<60;j++){
H_ChangeMinute(&tempsTest,1);
H_afficheHorlogeElemClean(tempsTest,50,50,4,0xFFA000E3,0xFFFFFFFF);
wait(1);
}
}
}
void H_test2(){
temps tempsTest;
tempsTest.heure = 15;
tempsTest.minute = 01;
H_reglage(&tempsTest,50,50,4,0xFFA000E3,0xFFFFFFFF);
H_afficheHorlogeElemClean(tempsTest,50,50,4,0xFF0000FF,0xFFFFFFFF);
}
