backup
This commit is contained in:
parent
2e64f4ff6f
commit
1ed2a4cec3
@ -26,3 +26,5 @@ build_flags =
|
|||||||
|
|
||||||
-D PIXEL_PIN=4
|
-D PIXEL_PIN=4
|
||||||
-D PIXEL_COUNT=24
|
-D PIXEL_COUNT=24
|
||||||
|
|
||||||
|
-D RESET_TIME=60000
|
||||||
|
@ -40,6 +40,8 @@ private:
|
|||||||
WiFiUDP* ntpUDP;
|
WiFiUDP* ntpUDP;
|
||||||
NTPClient* timeClient;
|
NTPClient* timeClient;
|
||||||
|
|
||||||
|
ulong lastMillis;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send time to discord
|
* @brief Send time to discord
|
||||||
* the start time is automaticly set to the current time
|
* the start time is automaticly set to the current time
|
||||||
|
@ -11,7 +11,7 @@ public :
|
|||||||
|
|
||||||
// Fonction pour allumer correctement les LEDs en fonction du Rotary
|
// Fonction pour allumer correctement les LEDs en fonction du Rotary
|
||||||
// Function to manage LEDs colors according to the Rotary
|
// Function to manage LEDs colors according to the Rotary
|
||||||
void actLed(int nb);
|
void actLed(int nb, int start = 0);
|
||||||
|
|
||||||
// Fonction qui renvoie le nombre de LEDs allumées
|
// Fonction qui renvoie le nombre de LEDs allumées
|
||||||
// Function that returns the number of LEDs lit
|
// Function that returns the number of LEDs lit
|
||||||
|
@ -13,7 +13,7 @@ LedLib::LedLib(int pixelCount, int pixelPin, int bright){
|
|||||||
|
|
||||||
// Fonction pour allumer correctement les LEDs en fonction du Rotary
|
// Fonction pour allumer correctement les LEDs en fonction du Rotary
|
||||||
// Function to manage LEDs colors according to the Rotary
|
// Function to manage LEDs colors according to the Rotary
|
||||||
void LedLib::actLed(int nb){
|
void LedLib::actLed(int nb, int start){
|
||||||
this->ledNb = nb;
|
this->ledNb = nb;
|
||||||
|
|
||||||
// On éteint tout
|
// On éteint tout
|
||||||
@ -26,11 +26,11 @@ void LedLib::actLed(int nb){
|
|||||||
|
|
||||||
// Boucle dans les LEDs
|
// Boucle dans les LEDs
|
||||||
// Loop in LEDs
|
// Loop in LEDs
|
||||||
for (int i = 0; i < nb+1; i++) {
|
for (int i = start; i < start+nb+1; i++) {
|
||||||
|
|
||||||
// Une LED sur deux est blanche : heure entière, l'autre rouge pour 30m
|
// Une LED sur deux est blanche : heure entière, l'autre rouge pour 30m
|
||||||
// One LED out of two is white: whole hour, the other red for 30m
|
// One LED out of two is white: whole hour, the other red for 30m
|
||||||
if (i%2 == 0) {
|
if (i-start%2 == 0) {
|
||||||
this->strip->setPixelColor(i-1, 255, 255, 255);
|
this->strip->setPixelColor(i-1, 255, 255, 255);
|
||||||
}else{
|
}else{
|
||||||
this->strip->setPixelColor(i-1, 255, 0, 0);
|
this->strip->setPixelColor(i-1, 255, 0, 0);
|
||||||
|
@ -44,6 +44,38 @@ void Program::sendTime(String timeEnd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Program::loop() {
|
void Program::loop() {
|
||||||
|
ulong currentMillis = millis();
|
||||||
|
if (currentMillis + 1000 > this->lastMillis) {
|
||||||
|
this->lastMillis = currentMillis;
|
||||||
|
this->encoder->resetMenu();
|
||||||
|
this->encoder->resetValue();
|
||||||
|
this->ledLib->actLed(0);
|
||||||
|
}
|
||||||
|
if(this->encoder->update()){
|
||||||
|
switch (this->encoder->getMenu()) {
|
||||||
|
case 1:
|
||||||
|
this->encoder->resetValue();
|
||||||
|
this->timeClient->update();
|
||||||
|
int day = this->timeClient->getDay();
|
||||||
|
int hour = this->timeClient->getHours();
|
||||||
|
int halfHourNb = hour > 12 ? hour - 12 : hour;
|
||||||
|
halfHourNb *= 2;
|
||||||
|
int minute = this->timeClient->getMinutes();
|
||||||
|
if(minute > 30){
|
||||||
|
halfHourNb++;
|
||||||
|
}
|
||||||
|
if(day == 2 || day == 5){
|
||||||
|
//TODO: mettre l'heure d'envoie par defaut a 22h
|
||||||
|
}
|
||||||
|
int openTime = this->encoder->getValue();
|
||||||
|
this->ledLib->actLed(openTime,halfHourNb);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this->encoder->resetValue();
|
||||||
|
//this->sendTime();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(this->encoder->update()){
|
if(this->encoder->update()){
|
||||||
Serial.print(this->encoder->getValue());
|
Serial.print(this->encoder->getValue());
|
||||||
this->ledLib->actLed(this->encoder->getValue());
|
this->ledLib->actLed(this->encoder->getValue());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user