/*
composant :
- boutons poussoir *4
- résistance 1kOhm *4
- écran OLED board-grove-oled-sh1107
- carte ESP32
*/
#include <Wire.h>
#include <SPI.h>
#include <U8g2lib.h>
#include <RTClib.h>
#include <Arduino.h>
//Déclaration de l'écran
U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0);
//Déclaration du module RTC
RTC_DS1307 rtc;
//pins des boutons
#define pin_button_1 19
#define pin_button_2 18
#define pin_button_3 5
#define pin_button_4 17
//paramètre de l'affichage
#define screen_width 128
#define screen_height 128
#define corner_radius 3
#define date_width 80 //implatation de la détection automatique de la taille des str dans le futur
#define time_width 60
//variables mémoire de l'état des boutons
char mem_button_1 = LOW;
char mem_button_2 = LOW;
char mem_button_3 = LOW;
char mem_button_4 = LOW;
char in_settings = LOW; //si in_settings = 1 alors on est dans le menu paramètre sinon non
char in_settings_2 = LOW;
//variables des menus
char menu = 0;
const char menu_max = 1;
char menu_settings = 0;
const char menu_settings_max = 2;
//niveau de la batterie
char battery_level = 60; //niveau de charge renvoyé par la batterie
char battery_level_1[4]; // % de batterie affiché à l'écran
//variable de l'horloge
int millisecond = 0;
char second = 0;
char minute = 0;
char hour = 0;
char day = 0;
char month = 0;
int year = 0;
char time_[9];
char date[12];
//BitMap deu logo paramètre
const unsigned char logo_parameter [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f,
0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00,
0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8,
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0x00, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0xc0, 0xff, 0x03,
0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x07, 0xf8, 0x0f, 0x00, 0xf0, 0x1f, 0xe0, 0xff, 0x07, 0x00,
0x00, 0x00, 0x00, 0xf0, 0xff, 0x0f, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0xf0, 0xff, 0x0f, 0x00, 0x00,
0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
0x00, 0xfc, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
0xfe, 0xff, 0xff, 0xff, 0x07, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff,
0xc3, 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x81,
0xff, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x81, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xfe,
0x0f, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0xff, 0x03, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0xfc, 0x03,
0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0xfe, 0x07, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0xf8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x30, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0c, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f,
0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00,
0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00,
0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xc0,
0x7f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0x80, 0xff,
0x00, 0x00, 0x00, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, 0xff, 0x01,
0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00,
0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xe0,
0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xf0, 0xff,
0xff, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0xff,
0xff, 0x1f, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0xfe,
0x3f, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0xf0, 0x7f,
0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0xff, 0x03, 0x00, 0xc0, 0xff, 0x00,
0x00, 0xfc, 0x03, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x80, 0xff, 0x01, 0x00, 0x80, 0xff, 0x01, 0x00,
0xf8, 0x03, 0x00, 0x00, 0xff, 0x1f, 0x00, 0xc0, 0xff, 0x00, 0x00, 0x00, 0xff, 0x03, 0x00, 0xf8,
0xff, 0x00, 0xc0, 0xff, 0x1f, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0xf8, 0xff,
0x03, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0xf0, 0xff, 0x0f,
0xf8, 0xff, 0x0f, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0xf0, 0xff, 0x1f, 0xfc,
0xff, 0x0f, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0xff, 0x3f, 0xfc, 0xff,
0x07, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0xff, 0x3f, 0xfe, 0xff, 0x03,
0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xc0, 0xff, 0x7f, 0xfe, 0x03, 0x00, 0x00,
0xf8, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x7f, 0xff, 0x00, 0x00, 0x00, 0xf8,
0x03, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x03,
0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00,
0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00,
0x80, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80,
0x3f, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3f,
0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00,
0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00,
0x00, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00,
0xfe, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0xfe,
0x7f, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x7f,
0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00,
0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x03, 0x00,
0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x7f, 0xfe, 0xff, 0x03, 0x00,
0xf8, 0x07, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xc0, 0xff, 0x7f, 0xfc, 0xff, 0x07, 0x00, 0xf0,
0x07, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0xff, 0x3f, 0xfc, 0xff, 0x0f, 0x00, 0xf0, 0x0f,
0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0xff, 0x3f, 0xf8, 0xff, 0x0f, 0x00, 0xe0, 0x1f, 0x00,
0x00, 0x00, 0xf8, 0x07, 0x00, 0xf0, 0xff, 0x1f, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0x3f, 0x00, 0x00,
0x00, 0xfc, 0x07, 0x00, 0xf0, 0xff, 0x0f, 0xc0, 0xff, 0x1f, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00,
0xfe, 0x03, 0x00, 0xf8, 0xff, 0x03, 0x00, 0xff, 0x1f, 0x00, 0xc0, 0xff, 0x00, 0x00, 0x00, 0xff,
0x03, 0x00, 0xf8, 0xff, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x80, 0xff, 0x01, 0x00, 0x80, 0xff, 0x01,
0x00, 0xf8, 0x03, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0xff, 0x03, 0x00, 0xc0, 0xff, 0x00, 0x00,
0xfc, 0x03, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xfc,
0x01, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0xfe, 0x01,
0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0x01, 0x00,
0x00, 0x00, 0xff, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0xff, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0xff, 0x01, 0x00, 0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
0x01, 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x00,
0x00, 0x00, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
0x00, 0xc0, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f,
0x00, 0x00, 0xf0, 0x1f, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0xf8, 0x0f, 0x00,
0x00, 0xe0, 0x3f, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xfc, 0x07, 0x00, 0x00,
0xe0, 0x7f, 0x00, 0xfe, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0xfe, 0x07, 0x00, 0x00, 0xc0,
0xff, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0xff, 0x03, 0x00, 0x00, 0x80, 0xff,
0x81, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x81, 0xff, 0x01, 0x00, 0x00, 0x00, 0xff, 0xc3,
0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff,
0xff, 0x07, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff,
0x0f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x0f,
0x00, 0xf0, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x0f, 0xff, 0x0f, 0x00,
0xf0, 0xff, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x07, 0xf8, 0x0f, 0x00, 0xf0,
0x1f, 0xe0, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xe0, 0x0f, 0x00, 0xf0, 0x07,
0xc0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0x00,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup()
{
pinMode(pin_button_1,INPUT);
pinMode(pin_button_2,INPUT);
pinMode(pin_button_3,INPUT);
pinMode(pin_button_4,INPUT);
u8g2.begin();
rtc.begin();
Serial.begin(115200);
}
void loop()
{
DateTime now = rtc.now();
hour = now.hour();
minute = now.minute();
second = now.second();
day = now.day();
month = now.month();
year = now.year();
//incrémentation des variables de menu
if (digitalRead(pin_button_1) != mem_button_1 && digitalRead(pin_button_1) == HIGH)
{
if (menu == 1 && in_settings == HIGH)
{
if (menu_settings < menu_settings_max)
{
menu_settings++;
}
else
{
menu_settings = 0;
}
}
else
{
if (menu < menu_max)
{
menu++;
}
else
{
menu = 0;
}
}
}
mem_button_1 = digitalRead(pin_button_1);
//décrémentation des variables de menu
if (digitalRead(pin_button_2) != mem_button_1 && digitalRead(pin_button_2) == HIGH)
{
if (menu == 1 && in_settings == HIGH)
{
if (menu_settings > 0)
{
menu_settings--;
}
else
{
menu_settings = menu_settings_max;
}
}
else
{
if (menu > 0)
{
menu--;
}
else
{
menu = menu_max;
}
}
}
mem_button_2 = digitalRead(pin_button_2);
//détection des actions "valider" (bouton 3) et "retour" (bouton 4)
if (digitalRead(pin_button_4) != HIGH && digitalRead(pin_button_3) == HIGH && menu == 1 && in_settings_2 == 0)
{
in_settings = 1;
mem_button_3 = 1;
}
mem_button_3 = 0;
if (digitalRead(pin_button_3) != HIGH && digitalRead(pin_button_4) == HIGH && menu == 1 && in_settings_2 == 0)
{
in_settings = 0;
mem_button_4 = 1;
}
mem_button_4 = 0;
//rentrer ou sortir du paramètre
if (digitalRead(pin_button_3) == 0)
{
if (digitalRead(pin_button_4) != HIGH && digitalRead(pin_button_3) == HIGH && in_settings == 1)
{
in_settings_2 = 1;
}
if (digitalRead(pin_button_3) != HIGH && digitalRead(pin_button_4) == HIGH && in_settings == 1)
{
in_settings_2 = 0;
}
}
//affichage menu horloge (0)
if (menu == 0)
{
u8g2.firstPage();
do
{
u8g2.drawRFrame(0,0,screen_width,14,corner_radius);
u8g2.drawRFrame(0,15,screen_width,49,corner_radius);
u8g2.drawRFrame(0,65,screen_width,63,corner_radius);
u8g2.setFont(u8g2_font_logisoso28_tf); // police d'écriture taille grande
sprintf_P(time_,PSTR("%02d:%02d"),hour,minute);
u8g2.drawStr((screen_width - time_width)/2-4,45,time_);
u8g2.setFont(u8g2_font_7x14B_tf); //police d'écriture taille moyenne
sprintf_P(date,PSTR("%02d/%02d/%04d"),day,month,year);
u8g2.drawStr((screen_width - date_width)/2,60,date);
u8g2.drawLine((screen_width - time_width)/2,47,(screen_width - time_width)/2 + (float(time_width)/60)*second,47);
//affichage du feedback sur l'utilisation du bras
u8g2.drawStr(10,80,"feedback du bras");
//dessin de la batterie
u8g2.drawLine(120,10,124,10);
u8g2.drawLine(120,10,120,3);
u8g2.drawLine(124,10,124,3);
u8g2.drawLine(123,3,123,2);
u8g2.drawLine(121,3,121,2);
u8g2.drawLine(122,2,122,2);
//affichage du % de batterie
sprintf_P(battery_level_1,PSTR("%3d"),battery_level);
u8g2.drawStr(95,10,battery_level_1);
u8g2.drawStr(112,10,"%");
if (battery_level >= 10)
{
u8g2.drawLine(121,9,123,9);
if (battery_level >= 25)
{
u8g2.drawLine(121,8,123,8);
if (battery_level >= 45)
{
u8g2.drawLine(121,7,123,7);
if (battery_level >= 60)
{
u8g2.drawLine(121,6,123,6);
if (battery_level >= 70)
{
u8g2.drawLine(121,5,123,5);
if (battery_level >= 80)
{
u8g2.drawLine(121,4,123,4);
if (battery_level >= 90)
{
u8g2.drawLine(122,3,122,3);
}
}
}
}
}
}
}
}while(u8g2.nextPage());
}
//affichage menu 1 (paramètres)
if (menu == 1 && in_settings == 0 && in_settings_2 == 0)
{
u8g2.firstPage();
do
{
u8g2.drawRFrame(0,0,screen_width,screen_height,corner_radius);
u8g2.drawXBMP(4,4,120,120,logo_parameter);
}while(u8g2.nextPage());
}
//affichage de la lise des paramètres
if (in_settings == 1 && menu == 1 && in_settings_2 == 0)
{
u8g2.firstPage();
do
{
u8g2.setFont(u8g2_font_bpixel_tr);
u8g2.drawStr(0,8,"para1");
u8g2.drawStr(0,16,"para2");
u8g2.drawStr(0,24,"para3");
u8g2.setCursor(0,100);
u8g2.print(menu_settings);
if (menu_settings == 0)
{
u8g2.drawStr(60,8,"ok");
}
if (menu_settings == 1)
{
u8g2.drawStr(60,16,"ok");
}
if (menu_settings == 2)
{
u8g2.drawStr(60,24,"ok");
}
}while(u8g2.nextPage());
}
//affichage du paramètre "changenment d'heure"
if (in_settings_2 == 1 && menu_settings == 0 && menu == 1)
{
u8g2.firstPage();
do
{
u8g2.setFont(u8g2_font_bpixel_tr);
u8g2.drawStr(0,8,"changement heure");
}while(u8g2.nextPage());
}
//affichage du paramètre "12h ou 24h"
if (in_settings_2 == 1 && menu_settings == 1 && menu == 1)
{
u8g2.firstPage();
do
{
u8g2.setFont(u8g2_font_bpixel_tr);
u8g2.drawStr(0,8,"12h ou 24h");
}while(u8g2.nextPage());
}
//affichage du paramètre "changer la date"
if (in_settings_2 == 1 && menu_settings == 2 && menu == 1)
{
u8g2.firstPage();
do
{
u8g2.setFont(u8g2_font_bpixel_tr);
u8g2.drawStr(0,8,"changer la date");
}while(u8g2.nextPage());
}
}