//Projeto_PP
//autor: João Pedro Ripke Dias
class THERMISTOR
{
public:
// Parâmetros do termistor
double beta;
double r0 ;/*nominal resistence */
const double t0 = 273.0/*KELVIN TO CELCIUS*/ + 25.0/*STANDARD OF CALIBRATION*/;
const double rx = r0 * exp(-beta / t0);
int pinTermistor; /*analog pin*/
// Parâmetros do circuito
const double vcc = 5.0;
double R ;/*Serial resistence*/
// Numero de amostras na leitura
const int nAmostras = 3;
THERMISTOR( const int adcPin, const double nomRes, const double bCoef, const double serialRes)
{
pinTermistor = adcPin;
R = nomRes;
beta = bCoef;
r0 = serialRes;
}
int read(void)
{
int soma = 0;
for (int i = 0; i < nAmostras; i++) {
soma += analogRead(pinTermistor);
delay (10);
}
// Determina a resistência do termistor
double v = (vcc * soma) / (nAmostras * 1024.0);
double rt = (vcc * R) / v - R;
// Calcula a temperatura em
double t = (beta / log(rt / rx)) - 273.0;
Serial.println (t + String(pinTermistor));
}
};
class PID {
public:
double error, Sample, lastSample;
double kP, kI, kD;
double P, I, D;
double pid;
double setPoint, lastProcess;
PID(double _kP, double _kI, double _kD)
{
kP = _kP;
kI = _kI;
kD = _kD;
}
void addNewSample(double _Sample)
{
Sample = _Sample;
}
void SetPoint(double _setPoint) {
setPoint = _setPoint;
}
double process()
{
//implementando o PID
error = setPoint - Sample;
float deltaTime = (millis() - lastProcess) / 1000.0 ; /*frequencia da leitura*/
lastProcess = millis();
//P
P = error * kP;
//I
I = I + (error * kI) * deltaTime;
//D
D = (lastProcess - Sample) * kD / deltaTime;
lastSample = Sample;
//PID
pid = P + I + D;
return pid;
}
};
#include <U8g2lib.h>
#include <EEPROM.h>//Para acionar a memoria EEPROM
#include <DallasTemperature.h>//sensor de temperatura
#include <RTClib.h>//Para funcionamento do modulo RTC
#define ENCODER_CLK 2 //clock do encoder
#define PINO_ZC 3
#define ENCODER_SW 4 // botão do encoder
#define led 5 //sinal luminoso
#define buzzer 6 //sinal sonoro
#define Re 7 //interface de potencia da resistencia
#define En555 8 //Enable the 555 to control the a4988 driver
#define Speed 9 //to set the direction of the motor
#define EnA4988 10 //Enable a4988 driver to control the nema 17
#define ENCODER_DT 11 //voltas do encoder
#define SensTemp 12 //pino de leitura do sensor de temperatura "ds18b20"
#define NTC_1 A0
#define NTC_2 A4
#define NTC_3 A2
#define NTC_4 A3
//endereços EEPROM
byte end1 = 0; //tempset1
byte end2 = 1; //i1
byte end3 = 2; //start
byte end4 = 3; //Timer1
byte end5 = 4; //velo1
byte end6 = 5; //heater1
byte end7 = 6; //clock1
byte end8 = 7; //i2
byte end9 = 8; //i3
byte end10 = 9; //Timer2
byte end11 = 10; //velo2
byte end12 = 11; //heater2
byte end13 = 12; //clock2
byte end14 = 13; //tempset2
byte end15 = 14; //timer3
byte end16 = 15; //velo3
byte end17 = 16; //heater3
byte end18 = 17; //clock3
byte end19 = 18; //tempset3
byte end20 = 19; //item_selectedB
//change name
byte letra = 0;
String new_name;
//logica do software
byte tempo = 0; //tempo segurando o botão
bool start = false; //liga ou desliga a maquina
int contagem = 0; //contagem de giros no encoder no menu 1
int contagem2 = 0; //contagem de giros no encoder no menu 2
int contagem3 = 0; //contagem de giros no encoder no menu 2
int contagem4 = 0;
int contagem5 = 0;
int contagemU = 0;
int contagemB = 0;
int anterior0 = 0; //verifica qual o valor anterior da velocidade
int anterior1 = 0; //verifica qual o valor anterior do aquecedor
int anterior2 = 0; //verifica qual o valor anterior do tempo de ciclo
bool sett = false; //se o usuario esta no menu de settings
bool dashb = false; //se o usuario esta no dashboard
//dashboard
bool dash = false; //verifica se o usuario estava na tela de dashboard
//function
bool heater = false; //liga ou desliga o aquecedor
int rotation = 0; //escolha de opções dentro do menu de funções
bool clock = false; //liga ou desliga o ciclo com temporizador
bool Velo = false; /*speed*/
byte screenF = 0;//tela em "funções"
int F_selected = 0;//item selecionado nas funções
bool heater2 = false; //liga ou desliga o aquecedor
bool clock2 = false; //liga ou desliga o ciclo com temporizador
bool Velo2 = false; /*speed*/
bool heater3 = false; //liga ou desliga o aquecedor
bool clock3 = false; //liga ou desliga o ciclo com temporizador
bool Velo3 = false; /*speed*/
bool FV0 = false; //First View
bool FV1 = false; //First View
bool FV2 = false; //First View
bool FV3 = false; //First View
bool FV4 = false; //First View
bool pont = false;
bool FVTimer = false; //First View
bool FVTemp = false; //First View
bool name_FV = false; //first view of the name
//Timer
byte hor = 0; //byte responsavel por definir as horas que ira funcionar o programa
byte minu = 0;//byte responsavel por definir as minutos que ira funcionar o programa
byte Timer = 0;//variavel que contempla o tempo de maneira total em minutos
byte Timer2 = 0;//variavel que contempla o tempo de maneira total em minutos
byte Timer3 = 0;//variavel que contempla o tempo de maneira total em minutos
DateTime future; //variavel que define o momento que ira acabar o ciclo
DateTime now; //variavel que mede o valor do tempo presente
//Temperatura
byte tempSet = 0; /*graus celsius*/
byte tempSet2 = 0; /*graus celsius*/
byte tempSet3 = 0; /*graus celsius*/
byte tempMax = 70; /*graus celsius*/
byte tempMin = 30; /*graus celsius*/
byte i1 = 0;
byte i2 = 0;
byte i3 = 0;
uint8_t temperature;
byte controlePWM;
//ponteiros
bool *Pspeed; //Ponteiro da speed
bool *Pheater; //Ponteiro do heater
byte *PtempSet;
bool *Pclock; //Ponteiro do clock
byte *Ptimer; //Ponteiro do clock
//memoria basic recipes
bool Bspeed; // speed das receitas prontas
bool Bheater; // heater das receitas prontas
byte BtempSet; //SetPoint das receitas basicas
bool Bclock; //Ponteiro do clock das receitas prontas
byte Btimer;
//controle de acionamento unico do buzzer
bool buz1 = false;
bool buz2 = false;
//Sensor de temperatura
bool sens = false;
//encoder
int counter = 0;
//display
unsigned int reset = 0;//usada no SM()
byte tela = 0;//qual tela esta o programa
int item_selected = 0;//item selecionado menu 1
int item_selected2 = 0;//item selecionado menu 2
int item_selected3 = 0;//item selecionado menu de minhas receitas
int item_selected4 = 0;//item selecionado para mudar de nome
int item_selected5 = 0;//mudança de letras
int user_selected = 0;
int item_selectedB = 0;
byte choosed = 0;
byte item_next; //proximo item
byte item_previous; //item anterior
//motor
bool side = false;
RTC_DS1307 rtc;//objeto modulo rtc
OneWire oneWire(SensTemp); // Cria um objeto OneWire
DallasTemperature sensor(&oneWire); // Informa a referencia da biblioteca dallas temperature para Biblioteca onewire
DeviceAddress endereco_temp; // Cria um endereco temporario da leitura do sensor
U8G2_SSD1309_128X64_NONAME2_F_SW_I2C u8g2(/*rotation*/U8G2_R0,/*clock*/ 31,/*data*/ 30, /*reset*/ U8X8_PIN_NONE);
//ou
//U8G2_SSD1309_128X64_NONAME2_F_SW_I2C u8g2(/*rotation*/U8G2_R0,/*clock*/ 21,/*data*/ 20, /*reset*/ U8X8_PIN_NONE);
THERMISTOR manta_1(NTC_1, // Analog pin
100000, // Nominal resistance at 25 ºC
3950, // thermistor's beta coefficient
10000); // Value of the series resistor
THERMISTOR manta_2(NTC_2, // Analog pin
100000, // Nominal resistance at 25 ºC
3950, // thermistor's beta coefficient
10000); // Value of the series resistor
THERMISTOR manta_3(NTC_3, // Analog pin
100000, // Nominal resistance at 25 ºC
3950, // thermistor's beta coefficient
10000); // Value of the series resistor
PID HTIN(1.0, 0.0, 0.0); //objeto pid do sensor interno
PID manta_1_pid(1.0, 0.0, 0.0); //objeto pid do sensor interno
PID manta_2_pid(1.0, 0.0, 0.0); //objeto pid do sensor interno
PID manta_3_pid(1.0, 0.0, 0.0); //objeto pid do sensor interno
PID manta_4_pid(1.0, 0.0, 0.0); //objeto pid do sensor interno
static const unsigned char PROGMEM image_data_WIETECH[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x81, 0xff, 0xff, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xc0, 0x00, 0x07, 0xff, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x81, 0xef, 0xc0, 0x00, 0x3f, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfd, 0xff, 0xff, 0xff, 0x00, 0x07, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xef, 0xff, 0xff, 0xff, 0xe0, 0x07, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0xf0, 0x03, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfb, 0x00, 0x1f, 0xff, 0xfe, 0x01, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x7f, 0xff, 0x01, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x48, 0x00, 0x00, 0x00, 0x0b, 0xff, 0x81, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x43, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xc1, 0xf8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x3f, 0xc1, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0xe1, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x0f, 0xff, 0xff, 0xc0, 0x1f, 0xe1, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x07, 0xe1, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x07, 0xf1, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x03, 0xf1, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x01, 0xf3, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x81, 0xf3, 0x80,
0x1f, 0x07, 0xe0, 0x79, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0xff, 0xc0, 0xf3, 0x80,
0x1f, 0x83, 0xe0, 0x77, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x3f, 0xe1, 0xf7, 0x00,
0x0f, 0x83, 0xf0, 0x77, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x1f, 0xe1, 0xf7, 0x00,
0x0f, 0x83, 0xf0, 0x77, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x0f, 0xf1, 0xfe, 0x00,
0x0f, 0x83, 0xf0, 0xf3, 0x80, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x07, 0xf1, 0xfc, 0x00,
0x0f, 0xc7, 0xf8, 0xf3, 0x80, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x07, 0xf1, 0xfc, 0x00,
0x07, 0xc7, 0xf8, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x03, 0xf1, 0xf8, 0x00,
0x07, 0xc7, 0xf8, 0xe7, 0xc0, 0xf0, 0xff, 0xc1, 0xe0, 0x03, 0xc3, 0xef, 0x01, 0xf9, 0xf0, 0x00,
0x07, 0xce, 0xf9, 0xe7, 0xc1, 0xfc, 0xff, 0xc7, 0xf8, 0x1f, 0xfb, 0xff, 0xc1, 0xfb, 0xe0, 0x00,
0x07, 0xef, 0x7d, 0xe7, 0xc7, 0xfc, 0xff, 0xcf, 0xfc, 0x3f, 0xfb, 0xff, 0xe1, 0xfb, 0xc0, 0x00,
0x03, 0xee, 0x7d, 0xc7, 0xc7, 0x8f, 0x1e, 0x0f, 0x1e, 0x3e, 0x1b, 0xf1, 0xe0, 0xf3, 0x80, 0x00,
0x03, 0xee, 0x7d, 0xc7, 0xcf, 0x07, 0x1e, 0x1e, 0x0e, 0x7c, 0x03, 0xe0, 0xe0, 0xf7, 0x00, 0x00,
0x03, 0xfe, 0x3f, 0x87, 0xdf, 0x07, 0x1e, 0x1e, 0x0f, 0x7c, 0x03, 0xe0, 0xe0, 0xff, 0x00, 0x00,
0x03, 0xfc, 0x3f, 0xc7, 0xde, 0x07, 0x1e, 0x1e, 0x07, 0x78, 0x03, 0xe0, 0xe0, 0xf6, 0x00, 0x00,
0x01, 0xfc, 0x1f, 0x87, 0xde, 0x07, 0x1e, 0x3e, 0x07, 0x78, 0x03, 0xe0, 0xe0, 0xfc, 0x00, 0x00,
0x01, 0xfc, 0x3f, 0x87, 0xdf, 0xff, 0x1e, 0x3f, 0xff, 0x78, 0x03, 0xe0, 0xe1, 0xf0, 0x00, 0x00,
0x01, 0xf8, 0x1f, 0x87, 0xdf, 0xff, 0x1e, 0x3f, 0xff, 0x78, 0x03, 0xe0, 0xe1, 0xe0, 0x00, 0x00,
0x00, 0xf8, 0x1f, 0x87, 0xdf, 0xff, 0x1e, 0x3f, 0xff, 0x78, 0x03, 0xe0, 0xe1, 0xc0, 0x00, 0x00,
0x00, 0xf8, 0x1f, 0x07, 0xde, 0x00, 0x1e, 0x3e, 0x00, 0x78, 0x03, 0xe0, 0xe3, 0x00, 0x00, 0x00,
0x00, 0xf8, 0x0f, 0x07, 0xde, 0x00, 0x1e, 0x3e, 0x00, 0x78, 0x03, 0xe0, 0xe2, 0x00, 0x00, 0x00,
0x00, 0xf0, 0x0f, 0x07, 0xdf, 0x00, 0x1e, 0x1e, 0x00, 0x7c, 0x03, 0xe0, 0xe4, 0x00, 0x00, 0x00,
0x00, 0x70, 0x0f, 0x07, 0xcf, 0x00, 0x1e, 0x1f, 0x00, 0x7c, 0x03, 0xe0, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x70, 0x06, 0x07, 0xdf, 0x01, 0x1f, 0x1f, 0x02, 0x7c, 0x0b, 0xe0, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x20, 0x06, 0x07, 0xcf, 0xc7, 0x1f, 0xdf, 0x8e, 0x3e, 0x3b, 0xe0, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x60, 0x06, 0x07, 0xcf, 0xfe, 0x0f, 0xcf, 0xfe, 0x3f, 0xfb, 0xe0, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x20, 0x02, 0x07, 0xc3, 0xfe, 0x07, 0xc7, 0xfe, 0x0f, 0xfb, 0xe0, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0xc0, 0xf8, 0x01, 0xc1, 0xf8, 0x03, 0xc3, 0xe0, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 272)
const unsigned char epd_bitmap_Camada_2 [] PROGMEM = {
0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01
};
static const unsigned char image_download_bits[] U8X8_PROGMEM = {0x18, 0x3c, 0x7e, 0xff};
static const unsigned char image_download_1_bits[] U8X8_PROGMEM = {0xff, 0x7e, 0x3c, 0x18};
// 'icons8-book-16 (4)', 16x16px
const unsigned char epd_bitmap_icons8_book_16__4_ [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x08, 0x10, 0x08, 0x10, 0xe8, 0x17, 0x08, 0x10, 0x08, 0x10,
0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0xf8, 0x1f, 0x08, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00
};
// 'icons8-edit-16', 16x16px
const unsigned char epd_bitmap_icons8_edit_16 [] PROGMEM = {
0x00, 0x00, 0x00, 0x60, 0x00, 0x48, 0x00, 0x04, 0x00, 0x22, 0x00, 0x11, 0x80, 0x08, 0x40, 0x04,
0x20, 0x02, 0x10, 0x01, 0x88, 0x00, 0x44, 0x00, 0x22, 0x00, 0x16, 0x00, 0x0e, 0x00, 0x00, 0x00
};
// 'icons8-design-16', 16x16px
const unsigned char epd_bitmap_icons8_design_16 [] PROGMEM = {
0x00, 0x00, 0x14, 0x70, 0x32, 0x48, 0x60, 0x44, 0xc2, 0x22, 0x84, 0x11, 0x80, 0x08, 0x50, 0x04,
0x20, 0x0a, 0x10, 0x19, 0x88, 0x30, 0x44, 0x60, 0x22, 0x02, 0x16, 0x40, 0x0e, 0x28, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144)
const int epd_bitmap_allArray_LEN = 3;
const unsigned char* epd_bitmap_allArray_U[3] = {
epd_bitmap_icons8_book_16__4_,
epd_bitmap_icons8_design_16,
epd_bitmap_icons8_edit_16,
};
// 'icons8-rotate-16 (1)', 16x16px
const unsigned char epd_bitmap_icons8_rotate_16__3_ [] PROGMEM = {
0x00, 0x00, 0xe4, 0x07, 0x1c, 0x18, 0x1c, 0x30, 0x3c, 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40,
0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x04, 0x20, 0x0c, 0x30, 0x18, 0x18, 0xe0, 0x07, 0x00, 0x00
};
// 'icons8-restart-16', 16x16px
const unsigned char epd_bitmap_icons8_restart_16 [] PROGMEM = {
0x00, 0x00, 0x1e, 0x07, 0x1c, 0x18, 0x1c, 0x30, 0x14, 0x20, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40,
0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x04, 0x20, 0x0c, 0x30, 0x18, 0x18, 0xe0, 0x07, 0x00, 0x00
};
// 'icons8-rotate-16', 16x16px
static const unsigned char image_icons8_sprint_iteration_16_bits[] U8X8_PROGMEM = {0xc0, 0x01, 0x20, 0x02, 0x90, 0x0f, 0x10, 0x07, 0x10, 0x02, 0x20, 0x00, 0xc0, 0x01, 0x20, 0x02, 0x10, 0x04, 0x7c, 0x04, 0x38, 0x04, 0x10, 0x12, 0x00, 0x31, 0xfe, 0x7f, 0x00, 0x30, 0x00, 0x10};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144)
const unsigned char* menu_rot[3] = {
epd_bitmap_icons8_restart_16,
epd_bitmap_icons8_rotate_16__3_,
image_icons8_sprint_iteration_16_bits
};
// 'icons8-speed-16', 16x16px
const int NUM_ITENS_3 = 2;
char menu_item_3[NUM_ITENS_3][8] = {
{ " High " },
{ " Low " },
};
const int NUM_STATES = 2;
char STATES[NUM_STATES][6] = {
{ " OFF " },
{ " ON " },
};
static const unsigned char image_icons8_fire_16_bits[] U8X8_PROGMEM = {0x40, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x20, 0x02, 0x10, 0x04, 0x90, 0x08, 0x88, 0x11, 0x04, 0x13, 0xa0, 0x24, 0xb2, 0x24, 0x12, 0x24, 0x12, 0x24, 0x22, 0x22, 0x04, 0x10, 0x08, 0x08, 0x30, 0x04};
// 'icons8-analyze-16 (1)', 16x16px
static const unsigned char image_icons8_analyze_16__1__bits[] U8X8_PROGMEM = {0xfc, 0x1f, 0x04, 0x30, 0x04, 0x30, 0xe4, 0x33, 0x04, 0x30, 0x84, 0x0f, 0xe4, 0x18, 0x44, 0x27, 0xa4, 0x6f, 0x24, 0x60, 0xa4, 0x67, 0xe4, 0x2f, 0x44, 0x30, 0xbc, 0x3d, 0x00, 0x67, 0x00, 0x40};
static const unsigned char image_icons8_clock_16__1__bits[] U8X8_PROGMEM = {0xe0, 0x07, 0x78, 0x1e, 0x0c, 0x30, 0x86, 0x60, 0x82, 0x40, 0x83, 0xc0, 0x83, 0xc0, 0x81, 0x80, 0x81, 0x81, 0x03, 0xc3, 0x03, 0xc6, 0x02, 0x4c, 0x06, 0x60, 0x0c, 0x30, 0x78, 0x1e, 0xe0, 0x07};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144)
const int myBitmapallArray_LEN = 3;
const unsigned char* bitmap_icons_2[3] = {
image_icons8_analyze_16__1__bits,
image_icons8_clock_16__1__bits,
image_icons8_fire_16_bits,
};
// Simbolo de graus celcius, 11x8px
const unsigned char celcius [] U8X8_PROGMEM = {
0xc6, 0x03, 0x29, 0x04, 0x29, 0x00, 0x26, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x04, 0xc0, 0x03
};
static const unsigned char image_menu_settings_gear_bits[] U8X8_PROGMEM = {0xc0, 0x03, 0x48, 0x12, 0x34, 0x2c, 0x02, 0x40, 0xc4, 0x23, 0x24, 0x24, 0x13, 0xc8, 0x11, 0x88, 0x11, 0x88, 0x13, 0xc8, 0x24, 0x24, 0xc4, 0x23, 0x02, 0x40, 0x34, 0x2c, 0x48, 0x12, 0xc0, 0x03};
// ' icon_dashboard', 16x16px
static const unsigned char image_chart_bits[] U8X8_PROGMEM = {0x00, 0x00, 0x01, 0x00, 0xc1, 0x01, 0x41, 0x01, 0x41, 0x01, 0x41, 0x1d, 0x41, 0x15, 0x41, 0x15, 0x5d, 0x15, 0x55, 0x15, 0x55, 0x15, 0x55, 0x15, 0xdd, 0x1d, 0x01, 0x00, 0xff, 0x3f, 0x00, 0x00};
// ' icon_run', 16x16px
// 'Camada_2[1]', 16x16px
const unsigned char epd_bitmap__icon_stop [] PROGMEM = {
0xff, 0xff, 0x01, 0x80, 0x01, 0x80, 0x71, 0x8e, 0x51, 0x8a, 0x51, 0x8a, 0x51, 0x8a, 0x51, 0x8a,
0x51, 0x8a, 0x51, 0x8a, 0x51, 0x8a, 0x51, 0x8a, 0x71, 0x8e, 0x01, 0x80, 0x01, 0x80, 0xff, 0xff
};
// 'Camada_2[1]', 16x16px
const unsigned char epd_bitmap__icon_run [] PROGMEM = {
0xff, 0xff, 0x01, 0x80, 0x19, 0x80, 0x29, 0x80, 0xc9, 0x80, 0x09, 0x83, 0x09, 0x8c, 0x09, 0x90,
0x09, 0x90, 0x09, 0x8c, 0x09, 0x83, 0xc9, 0x80, 0x29, 0x80, 0x19, 0x80, 0x01, 0x80, 0xff, 0xff
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 624)
const unsigned char* bitmap_icons[4] = {
image_menu_settings_gear_bits,
image_chart_bits,
epd_bitmap__icon_run,
epd_bitmap__icon_stop,
};
// ' item_sel', 128x21px
static const unsigned char image_logo_2_bits[] U8X8_PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0xf8, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xff, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xfe, 0xff, 0x7f, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf3, 0xff, 0xff, 0xff, 0x03, 0xe0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xff, 0x00, 0xf8, 0xff, 0x3f, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x07, 0xf8, 0x3f, 0x00, 0xc0, 0xff, 0x81, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf8, 0xff, 0xff, 0x0f, 0x00, 0xfe, 0x83, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfc, 0x87, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x80, 0xff, 0xff, 0x07, 0xf0, 0x87, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xe0, 0xff, 0x1f, 0xe0, 0x87, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0xc0, 0x8f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x80, 0xcf, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x81, 0xcf, 0x01, 0xf8, 0xc1, 0x07, 0xce, 0x01, 0x00, 0x78, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xfe, 0x83, 0xef, 0x00, 0xf0, 0xc1, 0x0f, 0xee, 0x03, 0x00, 0x78, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xf8, 0x07, 0xe7, 0x00, 0xf0, 0xc1, 0x0f, 0xee, 0x03, 0x00, 0x78, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xf0, 0x0f, 0x77, 0x00, 0xf0, 0xc1, 0x0f, 0xef, 0x03, 0x00, 0x78, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0, 0x8f, 0x37, 0x00, 0xe0, 0xe3, 0x1f, 0x87, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x8f, 0x1b, 0x00, 0xe0, 0xe3, 0x1f, 0x07, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x80, 0x9f, 0x0f, 0x00, 0xe0, 0xe3, 0x9f, 0xe7, 0xc3, 0x3f, 0xff, 0xe3, 0x1f, 0xf0, 0xcf, 0xff, 0x83, 0x9f, 0x07, 0x00, 0xc0, 0x77, 0xbe, 0xe3, 0xe3, 0x7f, 0xff, 0xf3, 0x7f, 0xfc, 0xdf, 0xff, 0x07, 0xcf, 0x02, 0x00, 0xc0, 0x77, 0xbe, 0xe3, 0xf3, 0xf0, 0x78, 0xf8, 0x70, 0x3c, 0xd0, 0x07, 0x07, 0x6f, 0x01, 0x00, 0xc0, 0x77, 0xbe, 0xe3, 0xf3, 0xe0, 0x78, 0x78, 0xe0, 0x3e, 0xc0, 0x03, 0x07, 0xaf, 0x00, 0x00, 0x80, 0x3f, 0xfc, 0xe1, 0x7b, 0xe0, 0x78, 0x78, 0xe0, 0x1e, 0xc0, 0x03, 0x07, 0x17, 0x00, 0x00, 0x80, 0x3f, 0xfc, 0xe1, 0x7b, 0xc0, 0x78, 0x7c, 0xe0, 0x1e, 0xc0, 0x03, 0x07, 0x0f, 0x00, 0x00, 0x80, 0x3f, 0xf8, 0xe1, 0xfb, 0xff, 0x78, 0xfc, 0xff, 0x1e, 0xc0, 0x03, 0x87, 0x07, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0xe1, 0xfb, 0xff, 0x78, 0xfc, 0xff, 0x1e, 0xc0, 0x03, 0x87, 0x03, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0xe0, 0x7b, 0x00, 0x78, 0x7c, 0x00, 0x1e, 0xc0, 0x03, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0xe0, 0xfb, 0x00, 0x78, 0x7c, 0x00, 0x1e, 0xc0, 0x03, 0x47, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xf0, 0xe0, 0xfb, 0x00, 0x78, 0x78, 0x00, 0x3e, 0xc0, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x60, 0xe0, 0xf3, 0x80, 0x78, 0xf8, 0x00, 0x3c, 0xc0, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x60, 0xe0, 0xf3, 0xe3, 0xf8, 0xf3, 0x71, 0x7c, 0xdc, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x60, 0xe0, 0xe3, 0x7f, 0xf0, 0xf3, 0x7f, 0xf8, 0xdf, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xe0, 0x83, 0x3f, 0xc0, 0x83, 0x1f, 0xe0, 0xc7, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// ' scrollbar', 8x64px
const unsigned char epd_bitmap__scrollbar[] PROGMEM = {
0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00
};
const int NUM_ITENS = 4;
char menu_item[NUM_ITENS][12] = {
{ "Settings" },
{ "Dashboard" },
{ "Run" },
{ "Stop" },
};
const int NUM_ITENS_2 = 3;
char menu_item_2[NUM_ITENS_2][12] = {
{ "Function" },
{ "Timer" },
{ "Temperature" },
};
byte letra_POSI[8] = {
15,
25,
35,
45,
55,
65,
75,
85,
};
const int NUM_POSI = 3;
int menu_POSI[NUM_POSI] = {
0,
22,
43,
};
String myA = " ", myB = "abcdefgh", myC = "C";
const int NUM_Mat = 6;
String material[NUM_Mat] = {
"PLA",
"ABS",
"NYLON",
myA,
myB,
myC,
};
char alphanumerics[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', ' '
};
byte iM[3] {i1, i2, i3};
byte heaterM[3] {heater, heater2, heater3};
byte clockM[3] {clock, clock2, clock3};
byte veloM[3] {Velo, Velo2, Velo3};
byte timerM[3] {Timer, Timer2, Timer3};
byte tempSetM[3] {tempSet, tempSet2, tempSet3};
byte iE[3] {end2, end8, end9};
byte heaterE[3] {end6, end12, end17};
byte clockE[3] {end7, end13, end18};
byte veloE[3] {end5, end11, end16};
byte timerE[3] {end4, end10, end15};
byte tempSetE[3] {end1, end14, end19};
void setup() {
// put your setup code here, to run once:
digitalWrite(EnA4988, HIGH);
u8g2.begin();
delay(250);
Serial.begin(9600);
rtc.begin();//pode causar problemas, verificar no hardware
for (byte u = 0; u < 3; u++)
{
iM[u] = EEPROM.read(iE[u]);
heaterM[u] = EEPROM.read(heaterE[u]);
clockM[u] = EEPROM.read(clockE[u]);
veloM[u] = EEPROM.read(veloE[u]);
timerM[u] = EEPROM.read(timerE[u]);
tempSetM[u] = EEPROM.read(tempSetE[u]);
}
start = EEPROM.read(end3);
choosed = EEPROM.read(end20);
myA = lerStringDaEEPROM(50, myA.length());
myB = lerStringDaEEPROM(100, myB.length());
myC = lerStringDaEEPROM(150, myC.length());
//outputs de sinalizalção
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
//interface de potencias
pinMode(Re, OUTPUT);
//motor
pinMode(En555, OUTPUT);
pinMode(Speed, OUTPUT);
pinMode(EnA4988, OUTPUT);
//encoder
pinMode(ENCODER_CLK, INPUT);
pinMode(ENCODER_DT, INPUT);
pinMode(ENCODER_SW, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(ENCODER_CLK), ZeroCT, FALLING); //maneira facil de apenas ler uma vez
attachInterrupt(digitalPinToInterrupt(ENCODER_CLK), readEncoder, FALLING); //maneira facil de apenas ler uma vez
//inicializa o modulo RTC
if (!rtc.begin())
{
Serial.println("erro na inicialização");
while (1);
}
}
void timer()
{
if (!FVTimer)
{
timerM[item_selected3] = EEPROM.read(timerE[item_selected3]);
FVTimer = true;
}
u8g2.setCursor(45, 0);
u8g2.print("Timer:");
u8g2.setCursor(45, 30);
u8g2.print(timerM[item_selected3]);
u8g2.print(" Min");
u8g2.setCursor(0, 64);
u8g2.print(" DONE ");
}
void Temperature()//função da tela de temperatura que o usuario pode variar
{
if (!FVTemp)
{
tempSetM[item_selected3] = EEPROM.read(tempSetE[item_selected3]);
iM[item_selected3] = EEPROM.read(iE[item_selected3]);
FVTemp = true;
}
tempSetM[item_selected3] = 30 + iM[item_selected3];
if (tempSetM[item_selected3] > 70)
{
tempSetM[item_selected3] = 70;
iM[item_selected3] = 40;
}
u8g2.setCursor(28, 10);
u8g2.print("Temperature:");
byte b;
if (iM[item_selected3] == 0)
{
b = 24;
}
if (iM[item_selected3] > 0)
{
b = 23;
}
u8g2.drawLine(b + (iM[item_selected3] * 2), 17, b + (iM[item_selected3] * 2), 23);
u8g2.setCursor(25 + (iM[item_selected3] * 2) + 2, 17 + 6);
u8g2.print(tempSetM[item_selected3]);
u8g2.drawLine(103, 37, 103, 43);
u8g2.setCursor(106 + 2, 37 + 8);
u8g2.print(tempMax);
u8g2.drawLine(24, 37, 24, 43);
u8g2.setCursor(24 + 2, 37 + 8);
u8g2.print(tempMin);
u8g2.drawFrame(24, 25, 80, 10);//(x, y, largura, altura, cor).
u8g2.drawBox(24, 25, (iM[item_selected3] * 2), 10);
u8g2.setCursor(0, 64);
u8g2.print(" DONE ");
}
void function()//esta função cria o menu onde o usuario escolhe qual parametro ira alterar
{
u8g2.setCursor(40, 8);
u8g2.print("Function:");
u8g2.setCursor(0, 20);
if (screenF == 0)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(" Speed:");
u8g2.setCursor(80, 20);
u8g2.print(menu_item_3[veloM[item_selected3]]);
u8g2.setCursor(0, 35);
if (screenF == 1)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(" Heater: ");
u8g2.setCursor(80, 35);
u8g2.print(STATES[heaterM[item_selected3]]);
u8g2.setCursor(0, 50);
if (screenF == 2)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(" Timer: ");
u8g2.setCursor(80, 50);
u8g2.print(STATES[clockM[item_selected3]]);
u8g2.setCursor(0, 64);
if (screenF == 3)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(" DONE ");
u8g2.setDrawColor(1);
}
void dashboard()//tela onde o usuario pode ver os atuais parametros da maquina
{
String materialL[] = {
myA,
myB,
myC,
};
dash = true;
u8g2.setCursor(0, 8);
u8g2.print(" Dashboard:");
u8g2.print(" ");
if (choosed <= 2)
{
u8g2.print(material[choosed]);//material do processo
}
if (choosed >= 3)
{
u8g2.print(materialL[choosed - 3]); //material do processo
}
u8g2.setCursor(0, 20);
u8g2.print(" Speed:");
u8g2.setCursor(82, 20);
u8g2.print(menu_item_3[*Pspeed]);
u8g2.setCursor(0, 35);
u8g2.print(" Heater: ");
byte t = *PtempSet;
u8g2.print(t);
u8g2.println(" C");
u8g2.setCursor(64, 35);
u8g2.print("-");
u8g2.setCursor(85, 35);
if (*Pheater == 0) {
u8g2.print(STATES[0]);
}
if (*Pheater == 1) {
u8g2.setBitmapMode(0);
u8g2.print(sensor.getTempC(endereco_temp));
u8g2.println(" C");
u8g2.setBitmapMode(1);
}
u8g2.setCursor(0, 50);
u8g2.print(" Timer: ");
byte readT = *Ptimer;
u8g2.setCursor(40, 50);
u8g2.print(readT);
u8g2.setCursor(53, 50);
u8g2.println(" m");
u8g2.setCursor(64, 50);
u8g2.print("-");
u8g2.setCursor(85, 50);
if (*Pclock == 0) {
u8g2.print(STATES[0]);
}
if (*Pclock == 1) {
DateTime future (DateTime(2000, 1, 1, 0, 0, 0) + TimeSpan(0, hor, minu, 0));
if ((future.unixtime() - now.unixtime()) > 60)
{
u8g2.println((future.unixtime() - now.unixtime()) / 60 + String(" m"));
}
if ((future.unixtime() - now.unixtime()) <= 60)
{
u8g2.println(future.unixtime() - now.unixtime() + String(" s"));
}
}
u8g2.setCursor(45, 60);
u8g2.setDrawColor(1);
u8g2.setFont(u8g2_font_t0_11b_tf);
u8g2.print(" DONE ");
u8g2.setFont(u8g2_font_helvR08_te);
}
void menu_standards() //menu onde o usuario pode ver todas as receitas existentes
{
if (!FV4)
{
item_selectedB = choosed;
FV4 = true;
}
u8g2.setCursor(45, 8);
String materialA[] = {
myA,
myB,
myC,
};
if (item_selectedB <= 2)
{
u8g2.print(material[item_selectedB]);//material do processo
}
if (item_selectedB >= 3)
{
u8g2.print(materialA[item_selectedB - 3]); //material do processo
}
u8g2.setCursor(0, 20);
u8g2.print(" Speed:"); //qual a velocidade indicada
u8g2.setCursor(85, 20);
u8g2.print(menu_item_3[*Pspeed]);//qual a velocidade indicada
u8g2.setCursor(0, 35);
u8g2.print(" Heater: ");
u8g2.setCursor(85, 35);
if (*Pheater == 0) {//diz se é desligado
u8g2.print(STATES[*Pheater]);
}
if (*Pheater == 1) {//se ligado, diz a temperatura ideal
u8g2.print(*PtempSet);//temperatura ideal
u8g2.println(" C");
}
u8g2.setCursor(0, 50);
u8g2.print(" Timer: ");
u8g2.setCursor(85, 50);
if (*Pclock == 0) {//diz se o timer é desligado
u8g2.print(STATES[0]);
}
if ( *Pclock == 1) {//diz se o timer é ligado, se sim, o tempo do processo
u8g2.println( *Ptimer + String(" m"));
}
u8g2.setCursor(0, 64);
u8g2.setDrawColor(1);
u8g2.setFont(u8g2_font_t0_11b_tf);
u8g2.print(" DONE ");
u8g2.setFont(u8g2_font_helvR08_te);
}
void menu_2()//menu de configuração
{
u8g2.drawXBMP( 4, 2, 16, 16, bitmap_icons_2[0]);
//.drawBitmap(4, 2, bitmap_icons_2[0], 16, 16, 1); antigo
u8g2.setCursor(26, 15 ); // Cursor pode ir de 0,0 a 128,64
u8g2.print(menu_item_2[0]);
u8g2.drawXBMP( 4, 24, 16, 16, bitmap_icons_2[1]);
//drawBitmap(4, 24, bitmap_icons_2[1], 16, 16, 1);
u8g2.setCursor(26, 37); // Cursor pode ir de 0,0 a 128,64
u8g2.print(menu_item_2[1]);
u8g2.drawXBMP( 4, 46, 16, 16, bitmap_icons_2[2]);
//drawBitmap(4, 46, bitmap_icons_2[2], 16, 16, 1);
u8g2.setCursor(26, 59); // Cursor pode ir de 0,0 a 128,64
u8g2.print(menu_item_2[2]);
u8g2.drawXBMP( 0, menu_POSI[item_selected2], 128, 21, epd_bitmap_Camada_2);
}
void menu()
//primeira tela de menu
{
u8g2.drawXBMP( 4, 2, 16, 16, bitmap_icons[0]);
u8g2.setCursor(26, 15 ); // Cursor pode ir de 0,0 a 128,64
if (item_selected == 0)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(menu_item[0]);
u8g2.drawXBMP( 4, 24, 16, 16, bitmap_icons[1]);
u8g2.setCursor(26, 37 ); // Cursor pode ir de 0,0 a 128,64
if (item_selected == 1)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(menu_item[1]);
if (item_selected == 2)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
if (!start)
{
u8g2.drawXBMP( 4, 46, 16, 16, bitmap_icons[2]);
//drawBitmap(4, 46, bitmap_icons[2], 16, 16, 1);
u8g2.setCursor(26, 59 ); // Cursor pode ir de 0,0 a 128,64
if (item_selected == 2)
{
u8g2.setFont(u8g2_font_t0_11b_tf);
}
else
{
u8g2.setFont(u8g2_font_helvR08_te);
}
u8g2.print(menu_item[2]);
}
if (start)
{
u8g2.drawXBMP( 4, 46, 16, 16, bitmap_icons[3]);
u8g2.setCursor(26, 59); // Cursor pode ir de 0,0 a 128,64
u8g2.print(menu_item[3]);
}
u8g2.drawXBMP( 0, menu_POSI[item_selected], 128, 21, epd_bitmap_Camada_2);
if (item_selected == 0) {
sett = true;
dashb = false;
}
if (item_selected == 1) {
dashb = true;
sett = false;
}
if (item_selected == 2) {
dashb = false;
sett = false;
}
}
void recipes_u()
//tela em que o usuario escolhe qual receita ele irá configurar
{
u8g2.setCursor(26, 15 ); // Cursor pode ir de 0,0 a 128,64
u8g2.print(myA);
u8g2.setCursor(26, 37); // Cursor pode ir de 0,0 a 128,64
u8g2.print(myB);
u8g2.setCursor(26, 59); // Cursor pode ir de 0,0 a 128,64
u8g2.print(myC);
if (user_selected == 0)
{
u8g2.drawXBMP( 0, menu_POSI[item_selected3], 128, 21, epd_bitmap_Camada_2);
}
if (user_selected == 2)
{
u8g2.drawXBMP( 0, menu_POSI[item_selected4], 128, 21, epd_bitmap_Camada_2);
}
}
void buzz() //led e buzzer são acionados por determinado periodo
{
//sinalização visual e sonora para o usuario
digitalWrite(led, HIGH);
delay(100);
tone(6, 750, 100);
digitalWrite(led, LOW);
}
void name()//usuario seleciona qual receita ira receber novo nome
{
recipes_u();
}
void action()//função que realiza o direcionamento
{
if (dashb)
{
tela = 1;
dashb = false;
}
if (tela != 1)
{
if (!start)
{
if (user_selected == 0)
{
recipes_u();
select_recipes();
}
if (user_selected == 1)
{
menu_standards();
select_standards();
}
if (user_selected == 2)
{
name();
select_name();
}
}
}
}
void action_2()//função que realiza o segundo direcionamento
{
if (user_selected == 0)
{
menu_2();
select_2();
}
if (user_selected == 1)
{
tela = 6;
}
if (user_selected == 2)
{
change();
select_letters();
}
}
void change()//função que realiza a mudança de nome
{
if (!name_FV)
{
new_name = material[item_selected4 + 3];
name_FV = true;
}
u8g2.setCursor(0, 8);
u8g2.print("Recipe's name:");
u8g2.print(material[item_selected4 + 3]);
new_name[letra] = alphanumerics[item_selected5];
item_previous = item_selected5 - 1;
item_next = item_selected5 + 1;
if (item_previous == 255)
{
item_previous = 36;
}
if (item_next == 37)
{
item_next = 0;
}
u8g2.setCursor(letra_POSI[0], 32 + 10);
u8g2.print(new_name[0]);
u8g2.setCursor(letra_POSI[1], 32 + 10);
u8g2.print(new_name[1]);
u8g2.setCursor(letra_POSI[2], 32 + 10);
u8g2.print(new_name[2]);
u8g2.setCursor(letra_POSI[3], 32 + 10);
u8g2.print(new_name[3]);
u8g2.setCursor(letra_POSI[4], 32 + 10);
u8g2.print(new_name[4]);
u8g2.setCursor(letra_POSI[5], 32 + 10);
u8g2.print(new_name[5]);
u8g2.setCursor(letra_POSI[6], 32 + 10);
u8g2.print(new_name[6]);
u8g2.setCursor(letra_POSI[7], 32 + 10);
u8g2.print(new_name[7]);
u8g2.setCursor(letra_POSI[8], 32 + 10);
u8g2.print(new_name[8]);
u8g2.print(" ");
u8g2.setCursor(letra_POSI[letra], 15 + 9);
u8g2.print(alphanumerics[item_previous]);
u8g2.drawXBMP(letra_POSI[letra], 18 + 10, 8, 4, image_download_bits); //mira pra cima
u8g2.setCursor(letra_POSI[letra], 44 + 11 + 5);
u8g2.print(alphanumerics[item_next]);
u8g2.drawXBMP(letra_POSI[letra], 34 + 12, 8, 4, image_download_1_bits); //mira para baixo
}
void SPEED() //altera a velocidade
{
if (start)
{
digitalWrite(EnA4988, LOW);
digitalWrite(En555, HIGH);
if (*Pspeed == 0)
{
digitalWrite(Speed, HIGH);
}
if (*Pspeed == 1)
{
digitalWrite(Speed, LOW);
}
}
if (!start)
{
digitalWrite(En555, LOW);
digitalWrite(EnA4988, HIGH);
}
}
void bt()//função de logica de botão e o que ele ira acionar
{
if (!digitalRead(ENCODER_SW)) {
reset = 0;
tempo++;
Serial.println(tempo + String("Contagem botao"));
}
if (tempo >= 3 && tempo <= 6 && digitalRead(ENCODER_SW)) {
if (tela == 1 && item_selected == 2)//Local onde liga e desliga a rotina
{
start = !start;
EEPROM.write(end3, start);
}
else if (tela == 5 && item_selected2 == 0)//Local onde liga e desliga a rotina
{
screenF++;
if (screenF == 4)
{
tela++;
screenF = 0;
FV0 = false;
FV1 = false;
FV2 = false;
FV3 = false;
}
}
else if (tela == 4 && user_selected == 2)
{
letra++;
item_selected5 = 0;
if (letra == 8)
{
tela++;
}
}
else {
tela++;
}
}
if (tempo > 3) {
if (!buz1) {
buzz();
buz1 = true;
}
}
if (tempo >= 7 && digitalRead(ENCODER_SW)) {
if (tela == 5 && item_selected2 == 0)//Local onde liga e desliga a rotina
{
if (tela == 5 && screenF == 0)//Local onde liga e desliga a rotina
{
tela--;
}
else {
screenF--;
}
}
else if (tela == 4 && user_selected == 2)
{
if (tela == 5 && screenF == 0)//Local onde liga e desliga a rotina
{
tela--;
}
letra--;
item_selected5 = 0;
if (letra < 0)
{
letra = 0;
}
if (letra == 0)
{
tela--;
}
}
else {
if (tela > 1) {
tela--;
}
}
}
if (tempo > 6) {
if (!buz2) {
buzz();
buz2 = true;
}
}
if (digitalRead(ENCODER_SW)) {
tempo = 0;
buz1 = false;
buz2 = false;
}
}
int getCounter() {
int result;
noInterrupts();
result = counter;
interrupts();
return result;
}
void readEncoder() //le o ky-040
{
reset = 0;
int dtValue = digitalRead(ENCODER_DT);
if (dtValue == HIGH) {
counter++; // Clockwise
if (tela == 1)
{
contagem++;
}
if (tela == 2)
{
contagemU++;
}
if (tela == 4 && item_selected == 0)
{
contagem2++;
}
if (tela == 3 && item_selected == 0)
{
contagem3++;
}
if (tela == 3 && user_selected == 1)
{
contagemB++;
}
if (tela == 3 && user_selected == 2)
{
contagem4++;
}
if (tela == 4 && user_selected == 2)
{
contagem5++;
}
if (tela == 5 && item_selected == 0)
{
if (tela == 5 && item_selected2 == 2)
{
if (iM[item_selected3] != 80 || iM[item_selected3] < 80)
{
iM[item_selected3]++;
}
}
if (tela == 5 && item_selected2 == 1)
{
timerM[item_selected3]++;
}
if (tela == 5 && item_selected2 == 0)
{
rotation++;
}
}
}
if (dtValue == LOW) {
counter--; // Counterclockwise
if (tela == 1)
{
contagem--;
}
if (tela == 2)
{
contagemU--;
}
if (tela == 4 && item_selected == 0)
{
contagem2--;
}
if (tela == 3 && item_selected == 0)
{
contagem3--;
}
if (tela == 3 && user_selected == 1)
{
contagemB--;
}
if (tela == 3 && user_selected == 2)
{
contagem4--;
}
if (tela == 4 && user_selected == 2)
{
contagem5--;
}
if (tela == 5 && item_selected == 0)
{
if (tela == 5 && item_selected2 == 2)
{
if (iM[item_selected3] != 0)
{
iM[item_selected3]--;
}
}
if (tela == 5 && item_selected2 == 1)
{
timerM[item_selected3]--;
if (timerM[item_selected3] == 0)
{
timerM[item_selected3] = 1;
}
}
if (tela == 5 && item_selected2 == 0)
{
rotation--;
}
}
}
}
void SM()//Sleep Mode
{
if (tela != 0)
{
reset++;
delay(1);
if (reset > 150)
{
tela = 0;
reset = 0;
}
}
}
uint8_t Temp()
{
sensor.setWaitForConversion(false);//retira o delay do comando, porem, pode ocorrer erros
if (!sensor.getAddress(endereco_temp, 0)) { // Encontra o endereco do sensor no barramento
if (sens == false)
{
sens = true;
}
} else {
sensor.requestTemperatures();
temperature = sensor.getTempC(endereco_temp);
}
return temperature;
}
void select_U() //seleção do menu_u
{
if (contagemU >= 10) {
if (user_selected != 3) {
user_selected++;
}
if (user_selected == 3) {
user_selected = 0;
}
contagemU = 0;
buzz();
}
if (contagemU <= -10) {
if (user_selected == 0) {
user_selected = 3;
}
if (user_selected != 0) {
user_selected--;
}
contagemU = 0;
buzz();
}
}
void select_recipes() //seleção do menu de receitas
{
if (contagem3 >= 10) {
if (item_selected3 != 3) {
item_selected3++;
}
if (item_selected3 == 3) {
item_selected3 = 0;
}
contagem3 = 0;
buzz();
}
if (contagem3 <= -10) {
if (item_selected3 == 0) {
item_selected3 = 3;
}
if (item_selected3 != 0) {
item_selected3--;
}
contagem3 = 0;
buzz();
}
}
void select_name() //seleção do menu de nomes
{
if (contagem4 >= 10) {
if (item_selected4 != 3) {
item_selected4++;
}
if (item_selected4 == 3) {
item_selected4 = 0;
}
contagem4 = 0;
buzz();
}
if (contagem4 <= -10) {
if (item_selected4 == 0) {
item_selected4 = 3;
}
if (item_selected4 != 0) {
item_selected4--;
}
contagem4 = 0;
buzz();
}
}
void select_2() //seleção do segundo menu
{
if (contagem2 >= 10) {
if (item_selected2 != 3) {
item_selected2++;
}
if (item_selected2 == 3) {
item_selected2 = 0;
}
contagem2 = 0;
buzz();
}
if (contagem2 <= -10) {
if (item_selected2 == 0) {
item_selected2 = 3;
}
if (item_selected2 != 0) {
item_selected2--;
}
contagem2 = 0;
buzz();
}
}
void select_letters() //seleção dos caracteres do novo nome
{
if (contagem5 >= 10) {
if (item_selected5 != 38) {
item_selected5++;
}
if (item_selected5 == 38) {
item_selected5 = 0;
}
contagem5 = 0;
buzz();
}
if (contagem5 <= -10) {
if (item_selected5 == 0) {
item_selected5 = 37;
}
if (item_selected5 != 0) {
item_selected5--;
}
contagem5 = 0;
buzz();
}
}
void select_standards() //seleção da receita que será utilizada
{
if (contagemB >= 10) {
if (item_selectedB != 6) {
item_selectedB++;
}
if (item_selectedB >= 6) {
item_selectedB = 0;
}
contagemB = 0;
buzz();
}
if (contagemB <= -10) {
if (item_selectedB != 0) {
item_selectedB--;
}
if (item_selectedB <= 0) {
item_selectedB = 5;
}
contagemB = 0;
buzz();
}
}
void select_mode()
{
if (!FV0)
{
veloM[item_selected3] = EEPROM.read(veloE[item_selected3]);
heaterM[item_selected3] = EEPROM.read(heaterE[item_selected3]);
clockM[item_selected3] = EEPROM.read(clockE[item_selected3]);
FV0 = true;
}
if (screenF == 0)
{
if (!FV1)
{
FV1 = true;
FV2 = false;
FV3 = false;
anterior0 = F_selected;
}
if (F_selected != anterior1)
{
veloM[item_selected3] = !veloM[item_selected3];
anterior1 = F_selected;
}
}
if (screenF == 1)
{
if (!FV2)
{
FV1 = false;
FV2 = true;
FV3 = false;
anterior1 = F_selected;
}
if (F_selected != anterior1)
{
heaterM[item_selected3] = !heaterM[item_selected3];
anterior1 = F_selected;
}
}
if (screenF == 2)
{
if (!FV3)
{
FV1 = false;
FV2 = false;
FV3 = true;
anterior2 = F_selected;
}
if (F_selected != anterior2)
{
clockM[item_selected3] = !clockM[item_selected3];
anterior2 = F_selected;
}
}
if (rotation >= 10) {
if (F_selected != 3) {
F_selected++;
}
if (F_selected == 3) {
F_selected = 0;
}
rotation = 0;
buzz();
}
if (rotation <= -10) {
if (F_selected == 0) {
F_selected = 3;
}
if (F_selected != 0) {
F_selected--;
}
rotation = 0;
buzz();
}
}
void select_1() {
if (contagem >= 10) {
if (item_selected != 3) {
item_selected++;
}
if (item_selected >= 3) {
item_selected = 0;
}
contagem = 0;
buzz();
}
if (contagem <= -10) {
if (item_selected <= 0) {
item_selected = 3;
}
if (item_selected != 0) {
item_selected--;
}
contagem = 0;
buzz();
}
}
void save()//função de salvar
{
if (user_selected == 0)
{
if (item_selected2 == 0)
{
EEPROM.write(veloE[item_selected3], veloM[item_selected3]);
EEPROM.write(heaterE[item_selected3], heaterM[item_selected3]);
EEPROM.write(clockE[item_selected3], clockM[item_selected3]);
tela = 4;
}
if (item_selected2 == 1)
{
EEPROM.write(timerE[item_selected3], timerM[item_selected3]);
tela = 4;
}
if (item_selected2 == 2)
{
EEPROM.write(tempSetE[item_selected3], tempSetM[item_selected3]);
EEPROM.write(iE[item_selected3], iM[item_selected3]);
tela = 4;
}
}
if (user_selected == 1)
{
if (choosed != item_selectedB)
{
choosed = item_selectedB;
EEPROM.write(end20, choosed);
}
choosed = item_selectedB;
FV4 = false;
tela = 2;
}
if (user_selected == 2)
{
if (item_selected4 == 0)
{
myA = new_name;
escreverStringNaEEPROM(50, myA);
}
if (item_selected4 == 1)
{
myB = new_name;
escreverStringNaEEPROM(100, myB);
}
if (item_selected4 == 2)
{
myC = new_name;
escreverStringNaEEPROM(150, myC);
}
item_selected5 = 0;
letra = 0;
tela = 3;
}
}
void user()
{
if (*Pheater == 1) //heater
{
u8g2.setCursor(0, 60);
byte t = *PtempSet;
u8g2.print(t);
u8g2.print("-");
u8g2.print(sensor.getTempC(endereco_temp));
u8g2.print(" C");
}
if (*Pclock == 1) //timer
{
DateTime future (DateTime(2000, 1, 1, 0, 0, 0) + TimeSpan(0, hor, minu, 0));
u8g2.setCursor(80, 60);
u8g2.print(*Ptimer);
u8g2.print("-");
u8g2.println((future.unixtime() - now.unixtime()) / 60 + String(" m"));
}
}
void escreverStringNaEEPROM(int endereco, String str) {
for (int w = 0; w < str.length(); w++) {
EEPROM.write(endereco + w, str[w]);
}
EEPROM.write(endereco + str.length(), '\0'); // Escreve o terminador de string
}
String lerStringDaEEPROM(int endereco, int tamanho) {
String str = "";
char c;
for (int w = 0; w < tamanho; w++) {
c = EEPROM.read(endereco + w);
if (c == '\0') break; // Para ao encontrar o terminador de string
str += c;
}
return str;
}
void action_3()
{
if (user_selected == 0)
{
if (item_selected2 == 0)
{
select_mode();
function();
}
if (item_selected2 == 1)
{
timer();
}
if (item_selected2 == 2 )
{
Temperature();
}
}
if ( user_selected == 2)
{
tela = 6;
name_FV = false;
}
}
void telas()//maquina de estado de telas
{
u8g2.clearBuffer();
//u8g2.setFont(u8g2_font_5x8_tr);
u8g2.setFont(u8g2_font_helvR08_te);
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
switch (tela)
{
case 0:
u8g2.drawXBMP( 0, 0, 128, 64, image_logo_2_bits);
user();
break;
case 1:
select_1();
menu();
break;
case 2:
if (sett)
{
menu_sett();
}
if (dashb)
{
dashboard();
}
break;
case 3:
action();
break;
case 4:
action_2();
break;
case 5:
action_3();
break;
case 6:
save();
break;
}
u8g2.sendBuffer();
}
void menu_sett() //menu de configurações
{
if (start)
{
u8g2.clearBuffer();
u8g2.setCursor(0, 5);
u8g2.print("The process");
u8g2.setCursor(64, 15);
u8g2.print("is running...");
u8g2.setCursor(0, 40);
u8g2.print("Turn off to join here");
u8g2.sendBuffer();
tela = 1;
delay(5000);
}
if (!start)
{
select_U();
u8g2.drawXBMP( 4, 2, 16, 16, epd_bitmap_allArray_U[2]);
//.drawBitmap(4, 2, bitmap_icons_2[0], 16, 16, 1); antigo
u8g2.setCursor(26, 15 ); // Cursor pode ir de 0,0 a 128,64
u8g2.print("Edit my recipes");
u8g2.drawXBMP( 4, 24, 16, 16, epd_bitmap_allArray_U[0]);
//drawBitmap(4, 24, bitmap_icons_2[1], 16, 16, 1);
u8g2.setCursor(26, 37); // Cursor pode ir de 0,0 a 128,64
u8g2.print("Choose a recipe");
u8g2.drawXBMP( 4, 46, 16, 16, epd_bitmap_allArray_U[1]);
//drawBitmap(4, 46, bitmap_icons_2[2], 16, 16, 1);
u8g2.setCursor(26, 59); // Cursor pode ir de 0,0 a 128,64
u8g2.print("Change the names");
u8g2.drawXBMP( 0, menu_POSI[user_selected], 128, 21, epd_bitmap_Camada_2);
}
}
void cycle () //como o ciclo de funcionamento ira se comportar
{
if (*Pclock)
{
byte convert = *Ptimer;
hor = (convert / 60);
minu = (convert % 60);
DateTime future (DateTime(2000, 1, 1, 0, 0, 0) + TimeSpan(0, hor, minu, 0));
if (start) {
now = rtc.now();
}
if (!start) {
rtc.adjust(DateTime(2000, 1, 1, 0, 0, 0));
}
if (now.unixtime() >= future.unixtime())
{
rtc.adjust(DateTime(2000, 1, 1, 0, 0, 0));
now = rtc.now();
start = false;
EEPROM.write(end3, start);
buzz();
delay(100);
buzz();
delay(100);
buzz();
}
}
}
void mantaControl() //controle de manta /*não esta sendo usado ainda*/
{
byte tempManta = 100;
byte M1PWM = 0;
if (*Pheater)
{
if (start) {
manta_1_pid.SetPoint(tempManta); //cria o setpoint baseado na temperatura escolhida pelo usuario
manta_1_pid.addNewSample(manta_1.read() / 10/*função responsavel pela leitura da temperatura*/);
M1PWM = map(manta_1_pid.process(), 0, tempManta, 153, 255);
if (Temp() > tempManta)
{
M1PWM = 0;
}
analogWrite(Re, M1PWM);
}
if (!start) {
digitalWrite(Re, LOW);
}
}
}
void HTcontrol()//controle do aquecimento
{
if (*Pheater)
{
Temp();//função responsavel pela leitura da temperatura
if (start) {
byte t = *PtempSet;
HTIN.SetPoint(t); //cria o setpoint baseado na temperatura escolhida pelo usuario
HTIN.addNewSample(Temp()/*função responsavel pela leitura da temperatura*/);
controlePWM = map(HTIN.process(), 0, *PtempSet, 153, 255);
if ((Temp() > *PtempSet) /*|| (manta_1.read()) >= 100*/ || (manta_2.read()) >= 100 /*|| (manta_3.read()) >= 100 || (manta_4.read()) >= 100*/) //PRECISA DE AUTOMAÇÃO FUTURAMENTE, VER "mantaControl()"
{
controlePWM = 0;
}
analogWrite(Re, controlePWM);
}
if (!start) {
digitalWrite(Re, LOW);
}
}
}
void Ponteiros()
{
Pspeed = &Bspeed;
Pheater = &Bheater;
PtempSet = &BtempSet;
Pclock = &Bclock;
Ptimer = &Btimer;
if (tela != 3)
{
if ( EEPROM.read(end20) == 0) //pla
{
Bspeed = true;
Bheater = false;
BtempSet = 45;
Bclock = false;
Btimer = 30;
}
if (EEPROM.read(end20) == 1) //pla
{
Bspeed = false;
Bheater = true;
BtempSet = 50;
Bclock = false;
Btimer = 0;
}
if (EEPROM.read(end20) == 2) //pla
{
Bspeed = true;
Bheater = true;
BtempSet = 50;
Bclock = true;
Btimer = 80;
}
if (EEPROM.read(end20) == 3) //receita 1
{
Bspeed = EEPROM.read(veloE[0]);
Bheater = EEPROM.read(heaterE[0]);
BtempSet = EEPROM.read(tempSetE[0]);
Bclock = EEPROM.read(clockE[0]);
Btimer = EEPROM.read(timerE[0]);
}
if (EEPROM.read(end20) == 4) //receita 2
{
Bspeed = EEPROM.read(veloE[1]);
Bheater = EEPROM.read(heaterE[1]);
BtempSet = EEPROM.read(tempSetE[1]);
Bclock = EEPROM.read(clockE[1]);
Btimer = EEPROM.read(timerE[1]);
}
if (EEPROM.read(end9) == 20) //receita 3
{
Bspeed = EEPROM.read(veloE[2]);
Bheater = EEPROM.read(heaterE[2]);
BtempSet = EEPROM.read(tempSetE[2]);
Bclock = EEPROM.read(clockE[2]);
Btimer = EEPROM.read(timerE[2]);
}
}
if (tela == 3)
{
if ( item_selectedB == 0) //pla
{
Bspeed = true;
Bheater = false;
BtempSet = 45;
Bclock = false;
Btimer = 30;
}
if (item_selectedB == 1) //pla
{
Bspeed = false;
Bheater = true;
BtempSet = 50;
Bclock = false;
Btimer = 0;
}
if (item_selectedB == 2) //pla
{
Bspeed = true;
Bheater = true;
BtempSet = 50;
Bclock = true;
Btimer = 80;
}
if (item_selectedB == 3) //receita 1
{
Bspeed = EEPROM.read(veloE[0]);
Bheater = EEPROM.read(heaterE[0]);
BtempSet = EEPROM.read(tempSetE[0]);
Bclock = EEPROM.read(clockE[0]);
Btimer = EEPROM.read(timerE[0]);
}
if (item_selectedB == 4) //receita 2
{
Bspeed = EEPROM.read(veloE[1]);
Bheater = EEPROM.read(heaterE[1]);
BtempSet = EEPROM.read(tempSetE[1]);
Bclock = EEPROM.read(clockE[1]);
Btimer = EEPROM.read(timerE[1]);
}
if (item_selectedB == 20) //receita 3
{
Bspeed = EEPROM.read(veloE[2]);
Bheater = EEPROM.read(heaterE[2]);
BtempSet = EEPROM.read(tempSetE[2]);
Bclock = EEPROM.read(clockE[2]);
Btimer = EEPROM.read(timerE[2]);
}
}
}
void ZeroCT()/*não esta sendo utilizado*/// zeroCrossing control
{
unsigned long pulse_count = 0; // contador de pulsos
unsigned long start_time = 0; // tempo inicial da contagem
unsigned long sample_time = 1000; // tempo de amostragem em milissegundos
float ts = 0;
pulse_count++; // incrementa o contador de pulsos
if (millis() - start_time >= sample_time) { // verifica se o tempo de amostragem acabou
float frequency = (float)pulse_count / ((float)sample_time / 1000.0); // calcula a frequência em hertz
Serial.print("Frequencia: ");
Serial.print(frequency / 2);
Serial.println(" Hz");
ts = (1 / (frequency / 2)) * 1000;
pulse_count = 0; // zera o contador de pulsos
start_time = millis(); // reinicia o tempo inicial da contagem
}
byte ajuste = map(controlePWM, 0, 255, 0, 100);
unsigned long t1 = ts * ((100 - ajuste ) / 100) ;
if (*Pheater)
{
Temp();//função responsavel pela leitura da temperatura
if (start) {
byte t = *PtempSet;
HTIN.SetPoint(t); //cria o setpoint baseado na temperatura escolhida pelo usuario
HTIN.addNewSample(Temp()/*função responsavel pela leitura da temperatura*/);
controlePWM = map(HTIN.process(), 0, *PtempSet, 153, 255);
if (Temp() > *PtempSet)
{
digitalWrite(Re, LOW);
}
else {
delayMicroseconds(t1);
digitalWrite(Re, HIGH);
delayMicroseconds(6); // t2
digitalWrite(Re, LOW);
}
}
if (!start) {
digitalWrite(Re, LOW);
}
}
}
void StartStop()//maquina de estado do ciclo de funcionamento
{
Ponteiros();
SPEED();
cycle();
HTcontrol();//controle de tipo PWM
//ZeroCT();//controle de tipo dimmer
}
void FV_all()//firt view, da a logica de primeira visão de alguma informação salva anteriormente
{
if (tela != 3)
{
FV4 = false;
if (tela != 6)
{
item_selectedB = choosed;
}
}
if (tela != 4)
{
name_FV = false;
}
if (tela != 5)
{
FV0 = false;
FV1 = false;
FV2 = false;
FV3 = false;
FVTimer = false;
FVTemp = false;
}
if (tela == 5)
{
if (user_selected = ! 1)
{
FVTimer = false;
}
if (user_selected = ! 2)
{
FVTemp = false;
}
}
}
void loop() {
StartStop();//função responsavel pelo chaveamento logico da interface de potencia da resistencia
bt();//função resposavel pelo Switch do encoder
SM();//função responsavel pelo sleep mode
telas();//função responsavel pelas telas existentes
FV_all();// controla as memorias de primeira visualização
}