133 lines
3.1 KiB
C++
133 lines
3.1 KiB
C++
|
/*
|
||
|
* horlogeLepot.c
|
||
|
*
|
||
|
* Created: 28-11-17 13:18:33
|
||
|
* Author: Adrien
|
||
|
*/
|
||
|
#include "max7219.h"
|
||
|
#include "util.h"
|
||
|
#include "horlogeLepot.h"
|
||
|
#include "global.h"
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#pragma region horloge
|
||
|
|
||
|
horloge::horloge(max7219 *max)
|
||
|
{
|
||
|
this->max = max;
|
||
|
t = millis();
|
||
|
ar[0] = ar[1] = ar[2] = ar[3] = 0;
|
||
|
heures=0;
|
||
|
minutes=0;
|
||
|
HHMM=0;
|
||
|
decalageMinutes=0;
|
||
|
decalageHeures=0; //Pour "synchronis?" sur la fonction millis
|
||
|
}
|
||
|
|
||
|
void horloge::afficherHeur()
|
||
|
{
|
||
|
t = millis();
|
||
|
unsigned long decalageMilis = HH_MMtoHHMM(decalageHeures, decalageMinutes);
|
||
|
decalageMilis = HHMMToMillis(decalageMilis);
|
||
|
millisToHH_MM_Decalage(&heures, &minutes, decalageMilis);
|
||
|
HHMM = HH_MMtoHHMM(heures, minutes);//on fusionne pour n'avoir qu'un chiffre. 11h30 devien 1130
|
||
|
intTo4DigitArray(HHMM, ar, 4);//Decompose chaque digit
|
||
|
if(((t%1000)>500)) //Clignotement des ":"
|
||
|
ar[2] |= _BV(7);
|
||
|
else
|
||
|
ar[2] &= ~(_BV(7));
|
||
|
max->sendDigitFromArray(ar,4);
|
||
|
max->on();
|
||
|
}
|
||
|
void horloge::configMinute()
|
||
|
{
|
||
|
t=millis();
|
||
|
unsigned long decalageMilis = HH_MMtoHHMM(decalageHeures, decalageMinutes);
|
||
|
decalageMilis = HHMMToMillis(decalageMilis);
|
||
|
millisToHH_MM_Decalage(&heures, &minutes, decalageMilis);
|
||
|
HHMM = HH_MMtoHHMM(heures, minutes);//on fusionne pour n'avoir qu'un chiffre. 11h30 devien 1130
|
||
|
intTo4DigitArray(HHMM, ar, 4);//Decompose chaque digit
|
||
|
if(((t%1000)>500) && PINB&_BV(__BP_MOIN__) && PINB&_BV(__BP_PLUS__) && PINB&_BV(__BP_START__) && PINB&_BV(__BP_CONF__)) //Clignotement des ":" et des min (arret du clignotement si on apuie sur un bp)
|
||
|
{
|
||
|
ar[2] |= _BV(7);
|
||
|
ar[0] |= 0x0F;
|
||
|
ar[1] |= 0x0F;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ar[2] &= ~(_BV(7));
|
||
|
}
|
||
|
max->sendDigitFromArray(ar,4);
|
||
|
if(!(PINB&_BV(__BP_PLUS__)) && !appuisBPflag)
|
||
|
{
|
||
|
_delay_ms(10);
|
||
|
++decalageMinutes %= 60;
|
||
|
appuisBPflag = 1;
|
||
|
}
|
||
|
if(!(PINB&_BV(__BP_MOIN__)) && !appuisBPflag)
|
||
|
{
|
||
|
_delay_ms(10);
|
||
|
--decalageMinutes = (decalageMinutes>59)?59:decalageMinutes;
|
||
|
appuisBPflag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void horloge::configHeure()
|
||
|
{
|
||
|
t = millis();
|
||
|
unsigned long decalageMilis = HH_MMtoHHMM(decalageHeures, decalageMinutes);
|
||
|
decalageMilis = HHMMToMillis(decalageMilis);
|
||
|
millisToHH_MM_Decalage(&heures, &minutes, decalageMilis);
|
||
|
HHMM = HH_MMtoHHMM(heures, minutes);//on fusionne pour n'avoir qu'un chiffre. 11h30 devien 1130
|
||
|
intTo4DigitArray(HHMM, ar, 4);//Decompose chaque digit
|
||
|
if(((t%1000)>500) && PINB&_BV(__BP_MOIN__) && PINB&_BV(__BP_PLUS__) && PINB&_BV(__BP_START__) && PINB&_BV(__BP_CONF__)) //Clignotement des ":" et des min (arret du clignotement si on apuie sur un bp)
|
||
|
{
|
||
|
ar[2] |= _BV(7);
|
||
|
ar[2] |= 0x0F;
|
||
|
ar[3] |= 0x0F;
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ar[2] &= ~(_BV(7));
|
||
|
}
|
||
|
max->sendDigitFromArray(ar,4);
|
||
|
if(!(PINB&_BV(__BP_PLUS__)) && !appuisBPflag)
|
||
|
{
|
||
|
_delay_ms(10);
|
||
|
++decalageHeures %= 24;
|
||
|
appuisBPflag = 1;
|
||
|
}
|
||
|
if(!(PINB&_BV(__BP_MOIN__)) && !appuisBPflag)
|
||
|
{
|
||
|
_delay_ms(10);
|
||
|
--decalageHeures = (decalageHeures>23)?23:decalageHeures;
|
||
|
appuisBPflag = 1;
|
||
|
}
|
||
|
}
|
||
|
void afficherHeur()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void configMinute()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void configHeure()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
#pragma endregion horloge
|
||
|
#pragma region minuterie
|
||
|
#pragma endregion minuterie
|
||
|
|
||
|
#pragma region compteur
|
||
|
#pragma endregion compteur
|
||
|
|
||
|
#pragma region reveil
|
||
|
#pragma endregion reveil
|