1 Commits

Author SHA1 Message Date
5dcb89b339 sync readme 2025-07-21 17:18:26 +02:00
4 changed files with 36 additions and 44 deletions

View File

@ -1,6 +1,24 @@
# Bouton Discord Ouverture LabOuest
# Discord Bouton Bot V2
Code du bouton Lier au Bot D'ouverture du discord du fablab
Dépôt du code du bot Discord d'ouverture du fablab.
_note: voir le fichier SETUP.md pour setup le template dans un nouveau repo_
## Lien utiles :
https://cad.onshape.com/documents/1efe392ee6bbd54d4b454fea/w/b3ba46f4dceddb831002d7e2/e/b878b50122d29c68cc147aa8?renderMode=0&uiState=66c8ccc731a8110e9958fbdf
## Getting Started
### Installation
Description sur la façon dont on installe le logiciel/lib
### Usage
Description rapide de l'usage du logiciel
## Règles de contributions

View File

@ -4,7 +4,6 @@
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <Timezone.h>
#include <WiFiUdp.h>
#include "DiscordAPI.h"
@ -45,12 +44,6 @@ private:
LedLib* ledLib;
WiFiUDP* ntpUDP;
NTPClient* timeClient;
Timezone* timezone;
/**
* Synchronize local using NTP client
*/
void syncTime();
/**
* @brief Send time to discord

View File

@ -54,8 +54,6 @@ lib_deps =
; erropix/ESP32 AnalogWrite@0.2
adafruit/Adafruit NeoPixel@^1.11.0
arduino-libraries/NTPClient@^3.2.1
paulstoffregen/Time @ ^1.6.1
jchristensen/Timezone@^1.2.5
; Checker settings
check_tool = clangtidy, cppcheck

View File

@ -1,7 +1,5 @@
#include "Program.h"
#include <TimeLib.h>
#include <time.h>
#include <Timezone.h>
Program::Program() {
@ -30,15 +28,9 @@ Program::Program() {
this->discord = new DiscordAPI(DISCORD_HOOK);
// startup NTP
this->ntpUDP = new WiFiUDP();
this->timeClient = new NTPClient(*this->ntpUDP, "pool.ntp.org");
this->timeClient = new NTPClient(*this->ntpUDP, "pool.ntp.org", 3600*1);//*2 = gnt+2
// setup Timezone
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; // Central European Summer Time
TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; // Central European Standard Time
this->timezone = new Timezone(CEST, CET);
// define local time
this->syncTime();
this->timeClient->update();
// Startup Rotary
this->encoder = new SwitchableEncodeur(ENCODER_DT, ENCODER_CLK, ENCODER_SWITCH, 3);
@ -52,19 +44,9 @@ Program::Program() {
this->resetMillis = 0;
}
void Program::syncTime() {
if (this->timeClient->update()) {
setTime(
this->timezone->toLocal(
this->timeClient->getEpochTime()
)
);
}
}
void Program::sendTime(String timeEnd) {
String start = (String)hour() + "h";
int startQuater = minute()/15;
void Program::sendTime(String timeEnd){
String start = (String)this->timeClient->getHours() + "h";
int startQuater = this->timeClient->getMinutes()/15;
if (startQuater != 0){
start += (String)(startQuater * 15);
}
@ -81,23 +63,24 @@ void Program::loop() {
break;
case MainMenu::GET_START_HOUR:{ // get NTP Hour
this->syncTime();
int _hour = hour();
int _min = minute();
int _day = day();
if(_hour >= 12){
_hour -= 12;
//TODO: géré heure d'été et d'hiver
this->timeClient->update();
int hour = this->timeClient->getHours();
int min = this->timeClient->getMinutes();
int day = this->timeClient->getDay();
if(hour >= 12){
hour -= 12;
this->pm = true;
}else{
this->pm = false;
}
this->nLedStart = _hour*2;
if(_min >= 30){
this->nLedStart = hour*2;
if(min >= 30){
this->nLedStart++;
}
this->menu=MainMenu::SELECT_END_HOUR;
this->resetMillis = millis();
if(_day == 2 || _day == 5){
if(day == 2 || day == 5){
this->encoder->setValue(21-this->nLedStart);
}else{
this->encoder->setValue(1);