2022-04-03 10:59:45 +03:00
|
|
|
|
#include <Wire.h>
|
|
|
|
|
//// Not work with Gyver Lib - EncButton
|
|
|
|
|
//const int sda=D1, scl=D2;
|
|
|
|
|
// #include <SoftwareWire.h> //make sure to not use beyond version 1.5.0
|
|
|
|
|
// // Check for "new" SoftwareWire that breaks things
|
|
|
|
|
// #if defined(TwoWire_h)
|
|
|
|
|
// #error incompatible version of SoftwareWire library (use version 1.5.0)
|
|
|
|
|
// #endif
|
|
|
|
|
// SoftwareWire Wire(D1,D2); // Create Wire object using desired Arduino pins
|
|
|
|
|
//////
|
2022-03-30 20:03:36 +03:00
|
|
|
|
#include <hd44780.h>
|
|
|
|
|
#include <hd44780ioClass/hd44780_I2Cexp.h>
|
|
|
|
|
hd44780_I2Cexp lcd; // declare lcd object and let it auto-configure everything.
|
2022-03-19 21:09:26 +03:00
|
|
|
|
|
2022-04-03 10:59:45 +03:00
|
|
|
|
#define L_BTN D0 // left button
|
|
|
|
|
#define R_BTN D3 // right button
|
|
|
|
|
#define E_BTN D4 // enter button
|
2022-03-19 21:09:26 +03:00
|
|
|
|
// Make custom characters:
|
|
|
|
|
byte motor_char_1[] = {
|
|
|
|
|
B00111,
|
|
|
|
|
B01000,
|
|
|
|
|
B10110,
|
|
|
|
|
B10101,
|
|
|
|
|
B10100,
|
|
|
|
|
B10100,
|
|
|
|
|
B01000,
|
|
|
|
|
B00111
|
|
|
|
|
};
|
|
|
|
|
byte motor_char_2[] = {
|
|
|
|
|
B11100,
|
|
|
|
|
B00010,
|
|
|
|
|
B01101,
|
|
|
|
|
B10101,
|
|
|
|
|
B00101,
|
|
|
|
|
B00101,
|
|
|
|
|
B00010,
|
|
|
|
|
B11100
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-17 23:20:14 +03:00
|
|
|
|
//enable NTC thermistor
|
|
|
|
|
#include <GyverNTC.h>
|
|
|
|
|
// термистор на пине А0
|
|
|
|
|
// сопротивление резистора 10к
|
|
|
|
|
// тепловой коэффициент 3950
|
|
|
|
|
GyverNTC therm(0, 100000, 3950);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
|
2022-03-17 23:20:14 +03:00
|
|
|
|
//enable button lib and define buttons array
|
2022-03-11 22:44:25 +03:00
|
|
|
|
#define BTN_AMOUNT 5
|
2022-03-12 16:37:22 +03:00
|
|
|
|
#define EB_HOLD 1000
|
2022-03-11 22:44:25 +03:00
|
|
|
|
#include <EncButton2.h>
|
|
|
|
|
EncButton2<EB_BTN> btn[BTN_AMOUNT];
|
|
|
|
|
|
2022-03-17 23:20:14 +03:00
|
|
|
|
//define vars
|
|
|
|
|
int cursor=1; //позиция курсора
|
2022-03-11 22:44:25 +03:00
|
|
|
|
int t_current=230;
|
2022-03-12 16:37:22 +03:00
|
|
|
|
int t_current_temp=230;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
int t_set=230;
|
2022-03-12 16:37:22 +03:00
|
|
|
|
int t_set_temp=230;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
int motor_speed=100;
|
2022-03-12 16:37:22 +03:00
|
|
|
|
int motor_speed_temp=100;
|
2022-03-19 21:09:26 +03:00
|
|
|
|
int motor_state = 0;//0 - off, 1 - on
|
|
|
|
|
String motor_state_text = "OFF";
|
|
|
|
|
int motor_state_temp = 0;
|
|
|
|
|
String motor_state_temp_text = "OFF";
|
|
|
|
|
int motor_dir = 0;//0 - forward, 1 - backward (FWD, BWD)
|
|
|
|
|
String motor_dir_text = "FWD";
|
|
|
|
|
int motor_dir_temp = 0;
|
|
|
|
|
String motor_dir_temp_text = "FWD";
|
|
|
|
|
|
2022-03-17 23:20:14 +03:00
|
|
|
|
int save=100; //режим работы меню. 100- режим выбора. 1,2,3 - выбранное значение
|
|
|
|
|
float filT = 0; //фильтрованное значение датчика
|
|
|
|
|
long previousMillis = 0; // храним время последнего переключения светодиода
|
|
|
|
|
long interval = 1000; // интервал между включение/выключением светодиода (1 секунда)
|
2022-04-03 10:59:45 +03:00
|
|
|
|
|
2022-03-11 22:44:25 +03:00
|
|
|
|
void setup()
|
|
|
|
|
{
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
int istatus;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
|
2022-03-30 20:03:36 +03:00
|
|
|
|
istatus = lcd.begin(20,4);
|
|
|
|
|
if(istatus)
|
|
|
|
|
{
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("-----Err init screen\n");
|
2022-03-30 20:03:36 +03:00
|
|
|
|
lcd.fatalError(istatus); // blinks error code on built in LED
|
|
|
|
|
}
|
|
|
|
|
//lcd.init(); // initialize the lcd
|
2022-03-11 22:44:25 +03:00
|
|
|
|
// Print a message to the LCD.
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//lcd.backlight();
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.createChar(0, motor_char_1);
|
|
|
|
|
lcd.createChar(1, motor_char_2);
|
|
|
|
|
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.setCursor(5,0);
|
|
|
|
|
lcd.print("Welcome to");
|
|
|
|
|
lcd.setCursor(0,1);
|
|
|
|
|
lcd.print("PetFilament Machine");
|
|
|
|
|
lcd.setCursor(2,2);
|
|
|
|
|
lcd.print("Firmware ver 0.1");
|
|
|
|
|
lcd.setCursor(0,3);
|
|
|
|
|
lcd.print("Powered By Mirivlad");
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("+++++Welcome screen ok");
|
|
|
|
|
delay(1000);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.clear();
|
|
|
|
|
lcd.setCursor(0,0);
|
|
|
|
|
lcd.print("Tc: ");//4,0 - set Temperature current
|
|
|
|
|
lcd.setCursor(4,0);
|
|
|
|
|
lcd.print(t_current);
|
2022-03-19 21:09:26 +03:00
|
|
|
|
|
|
|
|
|
lcd.setCursor(0,1);
|
|
|
|
|
lcd.print("Ts: ");//4,1 - set Temperature setting
|
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.print(t_set);
|
2022-03-19 21:09:26 +03:00
|
|
|
|
|
|
|
|
|
lcd.setCursor(9,0);
|
|
|
|
|
lcd.write(0);
|
|
|
|
|
lcd.write(1);
|
|
|
|
|
lcd.setCursor(11,0);
|
|
|
|
|
lcd.print("spd: 100");//16,0 - Motor speed
|
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.print(motor_speed);
|
|
|
|
|
|
2022-03-19 21:09:26 +03:00
|
|
|
|
if(motor_state==0){
|
|
|
|
|
motor_state_text="OFF";
|
|
|
|
|
}else{
|
|
|
|
|
motor_state_text=" ON";
|
|
|
|
|
}
|
|
|
|
|
lcd.setCursor(9,1);
|
|
|
|
|
lcd.write(0);
|
|
|
|
|
lcd.write(1);
|
|
|
|
|
lcd.setCursor(11,1);
|
|
|
|
|
lcd.print("act: OFF");//16,1 - Motor speed
|
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(motor_state_text);
|
|
|
|
|
|
|
|
|
|
if(motor_dir==0){
|
|
|
|
|
motor_dir_text="FWD";
|
|
|
|
|
}else{
|
|
|
|
|
motor_dir_text=" BWD";
|
|
|
|
|
}
|
|
|
|
|
lcd.setCursor(9,2);
|
|
|
|
|
lcd.write(0);
|
|
|
|
|
lcd.write(1);
|
|
|
|
|
lcd.setCursor(11,2);
|
|
|
|
|
lcd.print("dir: FWD");//16,2 - Motor speed
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(motor_dir_text);
|
|
|
|
|
|
2022-04-03 10:59:45 +03:00
|
|
|
|
btn[0].setPins(INPUT_PULLUP, L_BTN);
|
|
|
|
|
btn[1].setPins(INPUT_PULLUP, R_BTN);
|
|
|
|
|
btn[2].setPins(INPUT_PULLUP, E_BTN);
|
|
|
|
|
|
|
|
|
|
Serial.println("+++++Menu screen ok");
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-19 22:00:49 +03:00
|
|
|
|
void change_params(int save, int plus, int step_val){
|
2022-03-12 16:37:22 +03:00
|
|
|
|
//change current temperature
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//save - value change params.
|
|
|
|
|
// 0 - current temperature
|
|
|
|
|
// 1 - needed temperature
|
|
|
|
|
// 2 - motor speed
|
|
|
|
|
// 3 - motor start|stop
|
|
|
|
|
// 4 - motor direction
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (save==0){
|
2022-03-11 22:44:25 +03:00
|
|
|
|
if (plus==1){
|
2022-03-12 16:37:22 +03:00
|
|
|
|
t_current_temp++;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (plus==0){
|
|
|
|
|
t_current_temp--;
|
|
|
|
|
}
|
2022-03-11 22:44:25 +03:00
|
|
|
|
if (t_current>=300 || t_current<=0){
|
|
|
|
|
//stop heating
|
|
|
|
|
}
|
2022-03-17 23:20:14 +03:00
|
|
|
|
lcd.noBlink();
|
|
|
|
|
lcd.noCursor();
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.setCursor(4,0);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(4,0);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(t_current_temp);
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("+++++Set current temp ok");
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
//change needed temperature
|
|
|
|
|
if (save==1){
|
2022-03-19 22:00:49 +03:00
|
|
|
|
|
2022-03-11 22:44:25 +03:00
|
|
|
|
if (plus==1){
|
2022-03-19 22:00:49 +03:00
|
|
|
|
t_set_temp+=step_val;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (plus==0){
|
2022-03-19 22:00:49 +03:00
|
|
|
|
t_set_temp-=step_val;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (t_set_temp>=300){
|
|
|
|
|
t_set_temp=300;
|
|
|
|
|
}
|
|
|
|
|
if (t_set_temp<=0){
|
|
|
|
|
t_set_temp=0;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.print(" ");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(t_set_temp);
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("+++++Set needing temp ok");
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
//change motor speed
|
|
|
|
|
if (save==2){
|
2022-03-11 22:44:25 +03:00
|
|
|
|
if (plus==1){
|
2022-03-19 22:00:49 +03:00
|
|
|
|
motor_speed_temp+=step_val;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (plus==0){
|
2022-03-19 22:00:49 +03:00
|
|
|
|
motor_speed_temp-=step_val;
|
2022-03-12 16:37:22 +03:00
|
|
|
|
}
|
2022-03-19 21:09:26 +03:00
|
|
|
|
if (motor_speed_temp>=100){
|
|
|
|
|
motor_speed_temp=100;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-19 21:09:26 +03:00
|
|
|
|
if (motor_speed_temp<=0){
|
|
|
|
|
motor_speed_temp=0;
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
lcd.print(" ");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(motor_speed_temp);
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("+++++Set motor speed ok");
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-19 21:09:26 +03:00
|
|
|
|
//change motor state
|
|
|
|
|
if (save==3){
|
|
|
|
|
|
|
|
|
|
if (motor_state_temp>=1){
|
|
|
|
|
motor_state_temp=0;
|
|
|
|
|
motor_state_temp_text="OFF";
|
|
|
|
|
}
|
|
|
|
|
if (motor_state_temp<=0){
|
|
|
|
|
motor_state_temp=1;
|
|
|
|
|
motor_state_temp_text="ON";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(motor_state_temp_text);
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("+++++Set motor state ok");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
}
|
|
|
|
|
if (save==4){
|
|
|
|
|
|
|
|
|
|
if (motor_dir_temp>=1){
|
|
|
|
|
motor_dir_temp=0;
|
|
|
|
|
motor_dir_temp_text="FWD";
|
|
|
|
|
}
|
|
|
|
|
if (motor_dir_temp<=0){
|
|
|
|
|
motor_dir_temp=1;
|
|
|
|
|
motor_dir_temp_text="BWD";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(motor_dir_temp_text);
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("+++++Set motor direction ok");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
}
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-17 23:20:14 +03:00
|
|
|
|
|
2022-03-11 22:44:25 +03:00
|
|
|
|
void loop()
|
2022-03-17 23:20:14 +03:00
|
|
|
|
{
|
2022-03-19 22:00:49 +03:00
|
|
|
|
//get temperature with filtration
|
2022-04-03 10:59:45 +03:00
|
|
|
|
//Serial.println("=====Try get temp");
|
|
|
|
|
//filT += (therm.getTemp() - filT) * 0.1;
|
2022-03-19 22:00:49 +03:00
|
|
|
|
t_current_temp=filT;
|
2022-04-03 10:59:45 +03:00
|
|
|
|
//Serial.println("=====Get temp");
|
2022-03-19 22:00:49 +03:00
|
|
|
|
//therm.getTempAverage();
|
2022-03-17 23:20:14 +03:00
|
|
|
|
unsigned long currentMillis = millis();
|
|
|
|
|
|
|
|
|
|
//проверяем не прошел ли нужный интервал, если прошел то
|
|
|
|
|
if(currentMillis - previousMillis > interval) {
|
|
|
|
|
// сохраняем время последнего переключения
|
|
|
|
|
previousMillis = currentMillis;
|
2022-04-03 10:59:45 +03:00
|
|
|
|
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(0,100,0);
|
2022-04-03 10:59:45 +03:00
|
|
|
|
Serial.println("=====Send current temp");
|
|
|
|
|
|
2022-03-17 23:20:14 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-19 22:00:49 +03:00
|
|
|
|
|
2022-03-17 23:20:14 +03:00
|
|
|
|
|
|
|
|
|
if (save==100){
|
|
|
|
|
lcd.noBlink();
|
|
|
|
|
lcd.cursor();
|
|
|
|
|
}
|
2022-03-11 22:44:25 +03:00
|
|
|
|
for (int i = 0; i < BTN_AMOUNT; i++) btn[i].tick();
|
2022-03-12 16:37:22 +03:00
|
|
|
|
//moving cursor
|
2022-03-17 23:20:14 +03:00
|
|
|
|
//if (cursor==0){
|
|
|
|
|
// lcd.setCursor(3, 0);
|
|
|
|
|
//}
|
2022-03-11 22:44:25 +03:00
|
|
|
|
if (cursor==1){
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(3, 1);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
|
|
|
|
if (cursor==2){
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(15, 0);
|
|
|
|
|
}
|
|
|
|
|
if (cursor==3){
|
|
|
|
|
lcd.setCursor(15, 1);
|
|
|
|
|
}
|
|
|
|
|
if (cursor==4){
|
|
|
|
|
lcd.setCursor(15, 2);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
//listen button held
|
|
|
|
|
if (btn[0].held()) {
|
|
|
|
|
Serial.println("hold enter");
|
2022-03-17 23:20:14 +03:00
|
|
|
|
//enter change mode
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (save==100){
|
|
|
|
|
Serial.println("hold enter and save==100");
|
|
|
|
|
save=cursor;
|
2022-03-17 23:20:14 +03:00
|
|
|
|
lcd.blink();
|
|
|
|
|
lcd.cursor();
|
2022-03-12 16:37:22 +03:00
|
|
|
|
}else{
|
2022-03-17 23:20:14 +03:00
|
|
|
|
//enter save mode
|
|
|
|
|
// if(save==0){
|
|
|
|
|
// Serial.println("hold enter and save==0");
|
|
|
|
|
// t_current=t_current_temp;
|
|
|
|
|
// lcd.setCursor(4,0);
|
|
|
|
|
// lcd.print(" ");
|
|
|
|
|
// lcd.setCursor(4,0);
|
|
|
|
|
// lcd.print(t_current);
|
|
|
|
|
// lcd.cursor();
|
|
|
|
|
// lcd.blink();
|
|
|
|
|
// delay(3000);
|
|
|
|
|
// }
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if(save==1){
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("hold enter and save==1");
|
2022-03-12 16:37:22 +03:00
|
|
|
|
t_set=t_set_temp;
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(" ");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(t_set);
|
2022-03-17 23:20:14 +03:00
|
|
|
|
lcd.cursor();
|
|
|
|
|
lcd.blink();
|
|
|
|
|
delay(3000);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if(save==2){
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("hold enter and save==2");
|
2022-03-12 16:37:22 +03:00
|
|
|
|
motor_speed=motor_speed_temp;
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(" ");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(motor_speed);
|
2022-03-17 23:20:14 +03:00
|
|
|
|
lcd.cursor();
|
|
|
|
|
lcd.blink();
|
|
|
|
|
delay(3000);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
}
|
2022-03-19 21:09:26 +03:00
|
|
|
|
if(save==3){
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("hold enter and save==3");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
motor_state=motor_state_temp;
|
|
|
|
|
motor_state_text=motor_state_temp_text;
|
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(motor_state_text);
|
|
|
|
|
lcd.cursor();
|
|
|
|
|
lcd.blink();
|
|
|
|
|
delay(3000);
|
|
|
|
|
}
|
|
|
|
|
if(save==4){
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("hold enter and save==4");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
motor_dir=motor_dir_temp;
|
|
|
|
|
motor_dir_text=motor_dir_temp_text;
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(motor_dir_temp_text);
|
|
|
|
|
lcd.cursor();
|
|
|
|
|
lcd.blink();
|
|
|
|
|
delay(3000);
|
|
|
|
|
}
|
2022-03-17 23:20:14 +03:00
|
|
|
|
lcd.noBlink();
|
|
|
|
|
lcd.cursor();
|
|
|
|
|
//lcd.blink();
|
2022-03-12 16:37:22 +03:00
|
|
|
|
save=100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//listen button click
|
|
|
|
|
if (btn[0].click()) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press enter");
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if(save!=100){
|
|
|
|
|
save=100;
|
|
|
|
|
t_current_temp=t_current;
|
|
|
|
|
t_set_temp=t_set;
|
|
|
|
|
motor_speed_temp=motor_speed;
|
2022-03-19 21:09:26 +03:00
|
|
|
|
motor_state_temp=motor_state;
|
|
|
|
|
motor_state_temp_text=motor_state_text;
|
|
|
|
|
motor_dir_temp=motor_dir;
|
|
|
|
|
motor_dir_temp_text=motor_dir_text;
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.setCursor(4,0);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(4,0);
|
|
|
|
|
lcd.print(t_current);
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(" ");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(4,1);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(t_set);
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(" ");
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,0);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
lcd.print(motor_speed);
|
2022-03-19 21:09:26 +03:00
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(16,1);
|
|
|
|
|
lcd.print(motor_state_text);
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(" ");
|
|
|
|
|
lcd.setCursor(16,2);
|
|
|
|
|
lcd.print(motor_dir_text);
|
2022-03-12 16:37:22 +03:00
|
|
|
|
}
|
|
|
|
|
cursor++;
|
2022-03-19 21:09:26 +03:00
|
|
|
|
if (cursor>4){
|
2022-03-17 23:20:14 +03:00
|
|
|
|
cursor=1;
|
2022-03-12 16:37:22 +03:00
|
|
|
|
}
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-19 22:00:49 +03:00
|
|
|
|
//TODO: how to know how much click done before held?
|
|
|
|
|
//int clicks1 = btn[1].hasClicks();
|
|
|
|
|
//int clicks2 = btn[2].hasClicks();
|
|
|
|
|
if (btn[1].step(2) && save!=100) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press right and save!=100 and HOLD");
|
|
|
|
|
//Serial.println(clicks1);
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(save,1,3);
|
|
|
|
|
}
|
|
|
|
|
if (btn[2].step(2) && save!=100) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press right and save!=100 and HOLD");
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(save,0,3);
|
|
|
|
|
}
|
|
|
|
|
if (btn[1].step(4) && save!=100) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press right and save!=100 and HOLD");
|
|
|
|
|
//Serial.println(clicks1);
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(save,1,4);
|
|
|
|
|
}
|
|
|
|
|
if (btn[2].step(4) && save!=100) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press right and save!=100 and HOLD");
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(save,0,4);
|
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (btn[1].click() && save!=100) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press right and save!=100");
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(save,1,1);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
if (btn[2].click() && save!=100) {
|
2022-03-30 20:03:36 +03:00
|
|
|
|
//Serial.println("press left and save!=100");
|
2022-03-19 22:00:49 +03:00
|
|
|
|
change_params(save,0,1);
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|
2022-03-12 16:37:22 +03:00
|
|
|
|
|
2022-03-11 22:44:25 +03:00
|
|
|
|
}
|