Disable SoftWire Lib.
SoftWire library not working properly with Gyvers lib - EncButton.
This commit is contained in:
parent
e7ea5f8495
commit
4d6a3b8787
|
@ -1,20 +1,20 @@
|
||||||
//enable 2040 LCD
|
#include <Wire.h>
|
||||||
//#include <LiquidCrystal_I2C.h>
|
//// Not work with Gyver Lib - EncButton
|
||||||
//LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
|
//const int sda=D1, scl=D2;
|
||||||
const int sda=SDA, scl=SCL;
|
// #include <SoftwareWire.h> //make sure to not use beyond version 1.5.0
|
||||||
|
// // Check for "new" SoftwareWire that breaks things
|
||||||
#include <SoftwareWire.h> // make sure to not use beyond version 1.5.0
|
// #if defined(TwoWire_h)
|
||||||
// Check for "new" SoftwareWire that breaks things
|
// #error incompatible version of SoftwareWire library (use version 1.5.0)
|
||||||
#if defined(TwoWire_h)
|
// #endif
|
||||||
#error incompatible version of SoftwareWire library (use version 1.5.0)
|
// SoftwareWire Wire(D1,D2); // Create Wire object using desired Arduino pins
|
||||||
#endif
|
//////
|
||||||
|
|
||||||
SoftwareWire Wire(sda,scl); // Create Wire object using desired Arduino pins
|
|
||||||
|
|
||||||
#include <hd44780.h>
|
#include <hd44780.h>
|
||||||
#include <hd44780ioClass/hd44780_I2Cexp.h>
|
#include <hd44780ioClass/hd44780_I2Cexp.h>
|
||||||
hd44780_I2Cexp lcd; // declare lcd object and let it auto-configure everything.
|
hd44780_I2Cexp lcd; // declare lcd object and let it auto-configure everything.
|
||||||
|
|
||||||
|
#define L_BTN D0 // left button
|
||||||
|
#define R_BTN D3 // right button
|
||||||
|
#define E_BTN D4 // enter button
|
||||||
// Make custom characters:
|
// Make custom characters:
|
||||||
byte motor_char_1[] = {
|
byte motor_char_1[] = {
|
||||||
B00111,
|
B00111,
|
||||||
|
@ -71,16 +71,16 @@ int save=100; //режим работы меню. 100- режим выбора.
|
||||||
float filT = 0; //фильтрованное значение датчика
|
float filT = 0; //фильтрованное значение датчика
|
||||||
long previousMillis = 0; // храним время последнего переключения светодиода
|
long previousMillis = 0; // храним время последнего переключения светодиода
|
||||||
long interval = 1000; // интервал между включение/выключением светодиода (1 секунда)
|
long interval = 1000; // интервал между включение/выключением светодиода (1 секунда)
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
int istatus;
|
int istatus;
|
||||||
|
|
||||||
istatus = lcd.begin(20,4);
|
istatus = lcd.begin(20,4);
|
||||||
if(istatus)
|
if(istatus)
|
||||||
{
|
{
|
||||||
// LCD initalization failed.
|
Serial.println("-----Err init screen\n");
|
||||||
// handle it anyway you want
|
|
||||||
lcd.fatalError(istatus); // blinks error code on built in LED
|
lcd.fatalError(istatus); // blinks error code on built in LED
|
||||||
}
|
}
|
||||||
//lcd.init(); // initialize the lcd
|
//lcd.init(); // initialize the lcd
|
||||||
|
@ -97,7 +97,8 @@ int istatus;
|
||||||
lcd.print("Firmware ver 0.1");
|
lcd.print("Firmware ver 0.1");
|
||||||
lcd.setCursor(0,3);
|
lcd.setCursor(0,3);
|
||||||
lcd.print("Powered By Mirivlad");
|
lcd.print("Powered By Mirivlad");
|
||||||
delay(3000);
|
Serial.println("+++++Welcome screen ok");
|
||||||
|
delay(1000);
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.setCursor(0,0);
|
lcd.setCursor(0,0);
|
||||||
lcd.print("Tc: ");//4,0 - set Temperature current
|
lcd.print("Tc: ");//4,0 - set Temperature current
|
||||||
|
@ -143,10 +144,11 @@ int istatus;
|
||||||
lcd.setCursor(16,2);
|
lcd.setCursor(16,2);
|
||||||
lcd.print(motor_dir_text);
|
lcd.print(motor_dir_text);
|
||||||
|
|
||||||
btn[0].setPins(INPUT_PULLUP, PD2);
|
btn[0].setPins(INPUT_PULLUP, L_BTN);
|
||||||
btn[1].setPins(INPUT_PULLUP, PD3);
|
btn[1].setPins(INPUT_PULLUP, R_BTN);
|
||||||
btn[2].setPins(INPUT_PULLUP, PD4);
|
btn[2].setPins(INPUT_PULLUP, E_BTN);
|
||||||
Serial.begin(115200);
|
|
||||||
|
Serial.println("+++++Menu screen ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
void change_params(int save, int plus, int step_val){
|
void change_params(int save, int plus, int step_val){
|
||||||
|
@ -173,6 +175,7 @@ void change_params(int save, int plus, int step_val){
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(4,0);
|
lcd.setCursor(4,0);
|
||||||
lcd.print(t_current_temp);
|
lcd.print(t_current_temp);
|
||||||
|
Serial.println("+++++Set current temp ok");
|
||||||
}
|
}
|
||||||
//change needed temperature
|
//change needed temperature
|
||||||
if (save==1){
|
if (save==1){
|
||||||
|
@ -194,6 +197,7 @@ void change_params(int save, int plus, int step_val){
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(4,1);
|
lcd.setCursor(4,1);
|
||||||
lcd.print(t_set_temp);
|
lcd.print(t_set_temp);
|
||||||
|
Serial.println("+++++Set needing temp ok");
|
||||||
}
|
}
|
||||||
//change motor speed
|
//change motor speed
|
||||||
if (save==2){
|
if (save==2){
|
||||||
|
@ -214,6 +218,7 @@ void change_params(int save, int plus, int step_val){
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(16,0);
|
lcd.setCursor(16,0);
|
||||||
lcd.print(motor_speed_temp);
|
lcd.print(motor_speed_temp);
|
||||||
|
Serial.println("+++++Set motor speed ok");
|
||||||
}
|
}
|
||||||
//change motor state
|
//change motor state
|
||||||
if (save==3){
|
if (save==3){
|
||||||
|
@ -231,6 +236,7 @@ void change_params(int save, int plus, int step_val){
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(16,1);
|
lcd.setCursor(16,1);
|
||||||
lcd.print(motor_state_temp_text);
|
lcd.print(motor_state_temp_text);
|
||||||
|
Serial.println("+++++Set motor state ok");
|
||||||
}
|
}
|
||||||
if (save==4){
|
if (save==4){
|
||||||
|
|
||||||
|
@ -247,15 +253,17 @@ void change_params(int save, int plus, int step_val){
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.setCursor(16,2);
|
lcd.setCursor(16,2);
|
||||||
lcd.print(motor_dir_temp_text);
|
lcd.print(motor_dir_temp_text);
|
||||||
|
Serial.println("+++++Set motor direction ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
//get temperature with filtration
|
//get temperature with filtration
|
||||||
filT += (therm.getTemp() - filT) * 0.1;
|
//Serial.println("=====Try get temp");
|
||||||
|
//filT += (therm.getTemp() - filT) * 0.1;
|
||||||
t_current_temp=filT;
|
t_current_temp=filT;
|
||||||
|
//Serial.println("=====Get temp");
|
||||||
//therm.getTempAverage();
|
//therm.getTempAverage();
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
|
@ -263,7 +271,10 @@ void loop()
|
||||||
if(currentMillis - previousMillis > interval) {
|
if(currentMillis - previousMillis > interval) {
|
||||||
// сохраняем время последнего переключения
|
// сохраняем время последнего переключения
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
|
|
||||||
change_params(0,100,0);
|
change_params(0,100,0);
|
||||||
|
Serial.println("=====Send current temp");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue