This commit is contained in:
Bluedragon 2022-04-26 17:25:12 +07:00
parent cf5f1986dc
commit 60fa3d9a3f
3 changed files with 3785 additions and 29 deletions

3743
backup/wmain2.dcpx Normal file

File diff suppressed because it is too large Load Diff

View File

@ -16,20 +16,17 @@ monitor_speed = 115200
lib_deps = lib_deps =
ottowinter/ESPAsyncWebServer-esphome@^2.1.0 ottowinter/ESPAsyncWebServer-esphome@^2.1.0
esphome/AsyncTCP-esphome@^1.2.2 esphome/AsyncTCP-esphome@^1.2.2
;SPIFFS SPIFFS
bblanchon/ArduinoJson@^6.19.4 bblanchon/ArduinoJson@^6.19.4
khoih-prog/ESPAsync_WiFiManager@^1.12.2 khoih-prog/ESPAsync_WiFiManager@^1.12.2
rodan/ds3231@^1.0 rodan/ds3231@^1.0
;fmalpartida/LiquidCrystal@^1.5.0 ;fmalpartida/LiquidCrystal@^1.5.0
https://github.com/cyberp/AT24Cx.git https://github.com/cyberp/AT24Cx.git
https://github.com/JChristensen/JC_Button.git https://github.com/JChristensen/JC_Button.git
Wire
;arduino-libraries/LiquidCrystal@^1.0.7 ;arduino-libraries/LiquidCrystal@^1.0.7
https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library.git https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library.git
;https://github.com/mathertel/LiquidCrystal_PCF8574.git ;https://github.com/mathertel/LiquidCrystal_PCF8574.git
;LiquidCrystal_PCF8574
[env:env1]
lib_deps =
khoih-prog/ESPAsync_WiFiManager@^1.12.2
rodan/ds3231@^1.0
arduino-libraries/LiquidCrystal@^1.0.7

View File

@ -15,11 +15,12 @@
#include <AsyncTCP.h> #include <AsyncTCP.h>
#include <AsyncJson.h> #include <AsyncJson.h>
#include <SPIFFS.h> #include <SPIFFS.h>
#else
#include <ESP8266WiFi.h> // #else
#include <ESPAsyncTCP.h> // #include <ESP8266WiFi.h>
#include <Hash.h> // #include <ESPAsyncTCP.h>
#include <FS.h> // #include <Hash.h>
// #include <FS.h>
#endif #endif
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
// #include <ESPmDNS.h> // #include <ESPmDNS.h>
@ -92,9 +93,10 @@ bool gGotRequestConstHTML[REQUESTCOUNT];
#define max(a,b) (((a) > (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b))
#endif #endif
#include <Wire.h> // #include <Wire.h>
#include <ds3231.h> #include <ds3231.h>
#include <LiquidCrystal_I2C.h> #include <LiquidCrystal_I2C.h>
// #include <LiquidCrystal_PCF8574.h>
#include <AT24CX.h> #include <AT24CX.h>
//#define BUFF_MAX 128 //#define BUFF_MAX 128
@ -151,8 +153,9 @@ const int lcdRows = 4;
#define LED_BUILTIN 22 // LED built in pada ESP32 Lolin32 Lite #define LED_BUILTIN 22 // LED built in pada ESP32 Lolin32 Lite
// set LCD address, number of columns and rows // set LCD address, number of columns and rows
// if you don't know your display address, run an I2C scanner sketch // if you don't know your display address, run an I2C scanner sketch
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows); // marcoschwartz. ujungnya jelek ->remark LiquidCrystal_I2C lcd(0x28, lcdColumns, lcdRows); // marcoschwartz. ujungnya jelek ->remark
LiquidCrystal_I2C lcd2(I2C_ADDR, lcdColumns, lcdRows); // marcoschwartz. ujungnya jelek ->remark
// LiquidCrystal_PCF8574 lcd(0.27);
/*-----( Declare objects )-----*/ /*-----( Declare objects )-----*/
//LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); //LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
@ -2137,8 +2140,7 @@ void handleloadConst(AsyncWebServerRequest *request, JsonVariant &json) {
} }
void setup() { void setup() {
getCalibJson.reserve(512);
getRallyJson.reserve(512);
// //
// //
// //
@ -2148,13 +2150,16 @@ getRallyJson.reserve(512);
Serial.println("Starting Rally"); Serial.println("Starting Rally");
//#endif //#endif
// pinMode(ledPin, OUTPUT); // pinMode(ledPin, OUTPUT);
uint32_t freqhx=100000;
// Wire.begin(15, 13, freqhx); //for lolin32lite sda=15; scl=13
pinMode(simulatorPWMPin,OUTPUT); pinMode(simulatorPWMPin,OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
pinMode(interruptPin, INPUT); //Pull down using resistor to ground pinMode(interruptPin, INPUT); //Pull down using resistor to ground
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING); attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
// attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING); // attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
// attachInterrupt(interruptPin, isr, FALLING); // attachInterrupt(interruptPin, isr, FALLING);
Wire.begin(I2C_SDA, I2C_SCL); //for lolin32lite sda=15; scl=13 // Wire.begin(I2C_SDA, I2C_SCL); //for lolin32lite sda=15; scl=13
// Wire.begin(15, 13); //for lolin32lite sda=15; scl=13
// pinMode(UP_pin, INPUT_PULLUP); /// // pinMode(UP_pin, INPUT_PULLUP); ///
// pinMode(DOWN_pin, INPUT_PULLUP); /// // pinMode(DOWN_pin, INPUT_PULLUP); ///
// pinMode(LEFT_pin, INPUT_PULLUP); /// // pinMode(LEFT_pin, INPUT_PULLUP); ///
@ -2168,7 +2173,7 @@ getRallyJson.reserve(512);
btnOK.begin(); btnOK.begin();
btnESC.begin(); btnESC.begin();
//DS3231_init(DS3231_INTCN); //DS3231_init(DS3231_INTCN);
DS3231_init(DS3231_CONTROL_INTCN);
//memset(recv, 0, BUFF_MAX); //memset(recv, 0, BUFF_MAX);
#ifdef DEBUG #ifdef DEBUG
Serial.println("GET time"); Serial.println("GET time");
@ -2193,36 +2198,47 @@ Trip[9].startSec = 58;
// lcd.init(); // lcd.init();
// lcd.backlight(); // lcd.backlight();
// lcd.begin(LCD_COLS, LCD_ROWS); // lcd.begin(20, 4);
// lcd.setBacklight(0xff); // // if(lcd.begin(20, 4))
// Wire.setClock(400000L); // set i2c clock bit rate, if asked // // {
// // // begin() failed so blink the onboard LED if possible
// // return; // this never returns
// // }
// lcd.setBacklight(0xff);
// // Wire.setClock(100000L); // set i2c clock bit rate, if asked
// lcd.print("i2c clock:"); // lcd.print("i2c clock:");
// lcd.setCursor(0,1); // lcd.setCursor(0,1);
// lcd.print(Wire.getClock()); // lcd.print(Wire.getClock());
// lcd.print(" Hz"); // lcd.print(" Hz");
// delay(3000); // delay(3000);
//**************************LCD Setup******************************** //**************************LCD Setup********************************
delay(100);
// lcd.begin (20,4); // initialize the lcd // lcd.begin (20,4); // initialize the lcd
// lcd.init(); // lcd.init();
lcd.begin(); lcd.begin();
lcd2.begin();
// Switch on the backlight // Switch on the backlight
/// lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); /// lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.backlight(); lcd.backlight();
lcd2.backlight();
/// lcd.setBacklight(LED_ON); /// lcd.setBacklight(LED_ON);
lcd2.print("hello rally");
delay(3000);
//***************************END LCD Setup******************************** //***************************END LCD Setup********************************
getCalibJson.reserve(512);
getRallyJson.reserve(512);
#ifdef DEBUG #ifdef DEBUG
Serial.println("Setting time"); Serial.println("Setting time");
#endif #endif
//char a[]="304022129022016"; //char a[]="304022129022016";
DS3231_init(DS3231_CONTROL_INTCN);
DS3231_get(&t); //Get time DS3231_get(&t); //Get time
blinkON=false; blinkON=false;