Build-Defines and stuff updated
This commit is contained in:
parent
01ecf5a4a4
commit
435a0e1f5a
@ -17,16 +17,18 @@ platform = espressif8266
|
|||||||
board = d1_mini
|
board = d1_mini
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
upload_port = 10.0.1.90
|
upload_protocol = esptool
|
||||||
upload_protocol = espota
|
;upload_port = 10.0.1.90
|
||||||
upload_flags =
|
;upload_protocol = espota
|
||||||
--auth = ${wifi_cred.admin_pass}
|
;upload_flags =
|
||||||
|
; --auth=${wifi_cred.admin_pass}
|
||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
!python git_rev_macro.py
|
!python git_rev_macro.py
|
||||||
-DWIFI_SSID=${wifi_cred.wifi_ssid}
|
-DWIFI_SSID=${wifi_cred.wifi_ssid}
|
||||||
-DWIFI_PASSWORD=${wifi_cred.wifi_password}
|
-DWIFI_PASSWORD=${wifi_cred.wifi_password}
|
||||||
-DADMIN_PASS=${wifi_cred.admin_pass}
|
-DADMIN_PASSWORD=${wifi_cred.admin_password}
|
||||||
|
-DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password}
|
||||||
|
|
||||||
;-DDEBUG
|
;-DDEBUG
|
||||||
-fexceptions
|
-fexceptions
|
||||||
@ -44,3 +46,4 @@ lib_deps =
|
|||||||
olikraus/U8g2 @ ^2.28.8
|
olikraus/U8g2 @ ^2.28.8
|
||||||
joaolopesf/RemoteDebug @ ^2.1.2
|
joaolopesf/RemoteDebug @ ^2.1.2
|
||||||
fastled/FastLED @ ^3.5.0
|
fastled/FastLED @ ^3.5.0
|
||||||
|
sstaub/Ticker @ ^4.2.0
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef _COMMON_H_
|
#ifndef _COMMON_H_
|
||||||
#define _COMMON_H_
|
#define _COMMON_H_
|
||||||
|
|
||||||
|
#define Q(x) #x
|
||||||
|
#define QUOTE(x) Q(x)
|
||||||
|
|
||||||
#define GPIO_BUTTON 14
|
#define GPIO_BUTTON 14
|
||||||
#define GPIO_LED D6
|
#define GPIO_LED D6
|
||||||
#define GPIO_TRIGGER 2
|
#define GPIO_TRIGGER 2
|
||||||
@ -14,8 +17,8 @@
|
|||||||
#define OTA_DELAY 50 // ticks -> 10ms / tick
|
#define OTA_DELAY 50 // ticks -> 10ms / tick
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ADMIN_PASS
|
#ifndef ADMIN_PASSWORD
|
||||||
#error "You need to define ADMIN_PASS for OTA-Update"
|
#error "You need to define ADMIN_PASSWORD for OTA-Update"
|
||||||
#endif
|
#endif
|
||||||
#ifndef WIFI_PASSWORD
|
#ifndef WIFI_PASSWORD
|
||||||
#error "You must define an WIFI_PASSWORD for OTA-Update"
|
#error "You must define an WIFI_PASSWORD for OTA-Update"
|
||||||
@ -23,5 +26,8 @@
|
|||||||
#ifndef WIFI_SSID
|
#ifndef WIFI_SSID
|
||||||
#error "You must define an WIFI_SSID for OTA-Update"
|
#error "You must define an WIFI_SSID for OTA-Update"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef WIFI_AP_PASSWORD
|
||||||
|
#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
6
Software/ChainLube/src/lubeapp.cpp
Normal file
6
Software/ChainLube/src/lubeapp.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
void RunLubeApp()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -7,12 +7,15 @@
|
|||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <RemoteDebug.h>
|
#include <RemoteDebug.h>
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
|
#include <Ticker.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "rmtdbghelp.h"
|
#include "rmtdbghelp.h"
|
||||||
|
|
||||||
const char *ssid = WIFI_SSID;
|
const char *ssid = QUOTE(WIFI_SSID);
|
||||||
const char *password = WIFI_PASSWORD;
|
const char *password = QUOTE(WIFI_PASSWORD);
|
||||||
|
|
||||||
|
const uint32_t connectTimeoutMs = 5000;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const bool debug_flag = true;
|
const bool debug_flag = true;
|
||||||
@ -23,17 +26,37 @@ const bool debug_flag = false;
|
|||||||
bool startSetupMode = false;
|
bool startSetupMode = false;
|
||||||
char DeviceName[33];
|
char DeviceName[33];
|
||||||
|
|
||||||
|
volatile uint32_t wheel_pulse = 0;
|
||||||
|
|
||||||
|
typedef struct tLubeConfig
|
||||||
|
{
|
||||||
|
uint32_t DistancePerLube_Default = 0;
|
||||||
|
uint32_t DistancePerLube_Rain = 0;
|
||||||
|
uint32_t tankCapacity_ml = 320;
|
||||||
|
uint32_t amountPerDose_µl = 0;
|
||||||
|
uint32_t tankRemain_µl = 0;
|
||||||
|
uint8_t TankRemindAtPercentage = 30;
|
||||||
|
uint8_t PulsePerRevolution = 1;
|
||||||
|
uint32_t DistancePerRevolution_mm = 2000;
|
||||||
|
|
||||||
|
} sLubeConfig;
|
||||||
|
|
||||||
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
|
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
|
||||||
RemoteDebug Debug;
|
RemoteDebug Debug;
|
||||||
ESP8266WiFiMulti wifiMulti;
|
ESP8266WiFiMulti wifiMulti;
|
||||||
|
CRGB leds[1];
|
||||||
|
|
||||||
// Function-Prototypes
|
// Function-Prototypes
|
||||||
String IpAddress2String(const IPAddress &ipAddress);
|
String IpAddress2String(const IPAddress &ipAddress);
|
||||||
void processCmdRemoteDebug();
|
void processCmdRemoteDebug();
|
||||||
void RemotDebug_printSystemInfo();
|
void RemotDebug_printSystemInfo();
|
||||||
void RemoteDebug_printWifiInfo();
|
void RemoteDebug_printWifiInfo();
|
||||||
|
void wifiMaintainConnectionTicker_callback();
|
||||||
|
void IRAM_ATTR trigger_ISR();
|
||||||
|
extern void RunLubeApp();
|
||||||
|
extern void initWebUI();
|
||||||
|
|
||||||
CRGB leds[1];
|
Ticker WiFiMaintainConnectionTicker(wifiMaintainConnectionTicker_callback, 1000, 0, MILLIS);
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -44,19 +67,23 @@ void setup()
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.setDebugOutput(true);
|
Serial.setDebugOutput(true);
|
||||||
|
|
||||||
Serial.println("Souko's ChainOiler Mk1");
|
Serial.println("Souko's ChainLube Mk1");
|
||||||
Serial.println(DeviceName);
|
Serial.println(DeviceName);
|
||||||
|
|
||||||
u8x8.begin();
|
u8x8.begin();
|
||||||
u8x8.setFont(u8x8_font_chroma48medium8_r);
|
u8x8.setFont(u8x8_font_chroma48medium8_r);
|
||||||
|
|
||||||
|
FastLED.addLeds<WS2811, GPIO_LED, GRB>(leds, 1); // GRB ordering is assumed
|
||||||
|
|
||||||
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
|
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
|
||||||
pinMode(GPIO_BUTTON, INPUT_PULLUP);
|
pinMode(GPIO_BUTTON, INPUT_PULLUP);
|
||||||
pinMode(GPIO_PUMP, OUTPUT);
|
pinMode(GPIO_PUMP, OUTPUT);
|
||||||
|
|
||||||
|
attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING);
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.setHostname(DeviceName);
|
WiFi.setHostname(DeviceName);
|
||||||
wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD);
|
wifiMulti.addAP(QUOTE(WIFI_SSID), QUOTE(WIFI_PASSWORD));
|
||||||
|
|
||||||
Serial.println("Connecting Wifi...");
|
Serial.println("Connecting Wifi...");
|
||||||
if (wifiMulti.run() == WL_CONNECTED)
|
if (wifiMulti.run() == WL_CONNECTED)
|
||||||
@ -67,6 +94,8 @@ void setup()
|
|||||||
Serial.print(WiFi.localIP());
|
Serial.print(WiFi.localIP());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WiFiMaintainConnectionTicker.start();
|
||||||
|
|
||||||
if (MDNS.begin(DeviceName))
|
if (MDNS.begin(DeviceName))
|
||||||
MDNS.addService("telnet", "tcp", 23);
|
MDNS.addService("telnet", "tcp", 23);
|
||||||
|
|
||||||
@ -74,13 +103,14 @@ void setup()
|
|||||||
Debug.setResetCmdEnabled(true); // Enable the reset command
|
Debug.setResetCmdEnabled(true); // Enable the reset command
|
||||||
Debug.showProfiler(true); // Profiler (Good to measure times, to optimize codes)
|
Debug.showProfiler(true); // Profiler (Good to measure times, to optimize codes)
|
||||||
Debug.showColors(true); // Colors
|
Debug.showColors(true); // Colors
|
||||||
|
Debug.setPassword(QUOTE(ADMIN_PASSWORD));
|
||||||
|
|
||||||
Debug.setHelpProjectsCmds(helpCmd);
|
Debug.setHelpProjectsCmds(helpCmd);
|
||||||
Debug.setCallBackProjectCmds(&processCmdRemoteDebug);
|
Debug.setCallBackProjectCmds(&processCmdRemoteDebug);
|
||||||
|
|
||||||
ArduinoOTA.setPort(8266);
|
ArduinoOTA.setPort(8266);
|
||||||
ArduinoOTA.setHostname(DeviceName);
|
ArduinoOTA.setHostname(DeviceName);
|
||||||
ArduinoOTA.setPassword(ADMIN_PASS);
|
ArduinoOTA.setPassword(QUOTE(ADMIN_PASSWORD));
|
||||||
|
|
||||||
ArduinoOTA.onStart([]()
|
ArduinoOTA.onStart([]()
|
||||||
{
|
{
|
||||||
@ -111,17 +141,20 @@ void setup()
|
|||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
|
|
||||||
u8x8.clearDisplay();
|
u8x8.clearDisplay();
|
||||||
u8x8.drawString(4, 4, "Souko's");
|
u8x8.drawString(4, 0, "Souko's");
|
||||||
u8x8.drawString(1, 5, "ChainLube Mk1");
|
u8x8.drawString(1, 1, "ChainLube Mk1");
|
||||||
u8x8.refreshDisplay();
|
u8x8.refreshDisplay();
|
||||||
|
|
||||||
FastLED.addLeds<WS2811, GPIO_LED, GRB>(leds, 1); // GRB ordering is assumed
|
initWebUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
leds[0] = digitalRead(GPIO_BUTTON) ? CRGB::Green : CRGB::Red;
|
leds[0] = digitalRead(GPIO_BUTTON) ? CRGB::Green : CRGB::Red;
|
||||||
|
|
||||||
|
RunLubeApp();
|
||||||
|
|
||||||
|
WiFiMaintainConnectionTicker.update();
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
Debug.handle();
|
Debug.handle();
|
||||||
@ -157,8 +190,41 @@ void RemotDebug_printSystemInfo()
|
|||||||
debugA("Boot Mode: %u", ESP.getBootMode());
|
debugA("Boot Mode: %u", ESP.getBootMode());
|
||||||
debugA("CPU Frequency: %u MHz", ESP.getCpuFreqMHz());
|
debugA("CPU Frequency: %u MHz", ESP.getCpuFreqMHz());
|
||||||
debugA("Reset reason: %s", ESP.getResetReason().c_str());
|
debugA("Reset reason: %s", ESP.getResetReason().c_str());
|
||||||
|
|
||||||
|
debugA("OTA-Pass: %s", QUOTE(ADMIN_PASSWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteDebug_printWifiInfo()
|
void RemoteDebug_printWifiInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wifiMaintainConnectionTicker_callback()
|
||||||
|
{
|
||||||
|
static uint32_t WiFiFailCount = 0;
|
||||||
|
const uint32_t WiFiFailMax = 20;
|
||||||
|
|
||||||
|
if (wifiMulti.run(connectTimeoutMs) == WL_CONNECTED)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (WiFiFailCount < WiFiFailMax)
|
||||||
|
{
|
||||||
|
WiFiFailCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("WiFi not connected! - Start AP");
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
WiFi.softAP(DeviceName, QUOTE(WIFI_AP_PASSWORD));
|
||||||
|
WiFiMaintainConnectionTicker.stop();
|
||||||
|
Serial.println("WiFi AP started, stopped Maintain-Timer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trigger_ISR()
|
||||||
|
{
|
||||||
|
wheel_pulse++;
|
||||||
|
}
|
@ -7,144 +7,24 @@ uint16_t status;
|
|||||||
|
|
||||||
void initWebUI();
|
void initWebUI();
|
||||||
|
|
||||||
void numberCall( Control* sender, int type ) {
|
|
||||||
Serial.println( sender->value );
|
|
||||||
}
|
|
||||||
|
|
||||||
void textCall( Control* sender, int type ) {
|
|
||||||
Serial.print("Text: ID: ");
|
|
||||||
Serial.print(sender->id);
|
|
||||||
Serial.print(", Value: ");
|
|
||||||
Serial.println( sender->value );}
|
|
||||||
|
|
||||||
void slider( Control* sender, int type ) {
|
void slider( Control* sender, int type ) {
|
||||||
Serial.print("Slider: ID: ");
|
Serial.print("Slider: ID: ");
|
||||||
Serial.print(sender->id);
|
Serial.print(sender->id);
|
||||||
Serial.print(", Value: ");
|
Serial.print(", Value: ");
|
||||||
Serial.println( sender->value );}
|
|
||||||
|
|
||||||
void buttonCallback( Control* sender, int type ) {
|
|
||||||
switch ( type ) {
|
|
||||||
case B_DOWN:
|
|
||||||
Serial.println( "Button DOWN" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_UP:
|
|
||||||
Serial.println( "Button UP" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void buttonExample( Control* sender, int type ) {
|
|
||||||
switch ( type ) {
|
|
||||||
case B_DOWN:
|
|
||||||
Serial.println( "Status: Start" );
|
|
||||||
ESPUI.updateControlValue( status, "Start" );
|
|
||||||
|
|
||||||
ESPUI.getControl( button1 )->color = ControlColor::Carrot;
|
|
||||||
ESPUI.updateControl( button1 );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_UP:
|
|
||||||
Serial.println( "Status: Stop" );
|
|
||||||
ESPUI.updateControlValue( status, "Stop" );
|
|
||||||
|
|
||||||
ESPUI.getControl( button1 )->color = ControlColor::Peterriver;
|
|
||||||
ESPUI.updateControl( button1 );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void padExample( Control* sender, int value ) {
|
|
||||||
switch ( value ) {
|
|
||||||
case P_LEFT_DOWN:
|
|
||||||
Serial.print( "left down" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_LEFT_UP:
|
|
||||||
Serial.print( "left up" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_RIGHT_DOWN:
|
|
||||||
Serial.print( "right down" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_RIGHT_UP:
|
|
||||||
Serial.print( "right up" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_FOR_DOWN:
|
|
||||||
Serial.print( "for down" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_FOR_UP:
|
|
||||||
Serial.print( "for up" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_BACK_DOWN:
|
|
||||||
Serial.print( "back down" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_BACK_UP:
|
|
||||||
Serial.print( "back up" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_CENTER_DOWN:
|
|
||||||
Serial.print( "center down" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_CENTER_UP:
|
|
||||||
Serial.print( "center up" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.print( " " );
|
|
||||||
Serial.println( sender->id );
|
|
||||||
}
|
|
||||||
|
|
||||||
void switchExample( Control* sender, int value ) {
|
|
||||||
switch ( value ) {
|
|
||||||
case S_ACTIVE:
|
|
||||||
Serial.print( "Active:" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case S_INACTIVE:
|
|
||||||
Serial.print( "Inactive" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.print( " " );
|
|
||||||
Serial.println( sender->id );
|
|
||||||
}
|
|
||||||
|
|
||||||
void selectExample( Control* sender, int value ) {
|
|
||||||
Serial.print("Select: ID: ");
|
|
||||||
Serial.print(sender->id);
|
|
||||||
Serial.print(", Value: ");
|
|
||||||
Serial.println( sender->value );
|
Serial.println( sender->value );
|
||||||
}
|
|
||||||
|
|
||||||
void otherSwitchExample( Control* sender, int value ) {
|
|
||||||
switch ( value ) {
|
|
||||||
case S_ACTIVE:
|
|
||||||
Serial.print( "Active:" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case S_INACTIVE:
|
|
||||||
Serial.print( "Inactive" );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.print( " " );
|
|
||||||
Serial.println( sender->id );
|
|
||||||
}
|
|
||||||
|
|
||||||
void initWebUI (void){
|
void initWebUI (void){
|
||||||
|
|
||||||
uint16_t tab1 = ESPUI.addControl( ControlType::Tab, "Settings 1", "Settings 1" );
|
uint16_t tab_lube = ESPUI.addControl( ControlType::Tab, "Schmierung", "Schmierung" );
|
||||||
uint16_t tab2 = ESPUI.addControl( ControlType::Tab, "Settings 2", "Settings 2" );
|
uint16_t tab_tank = ESPUI.addControl( ControlType::Tab, "Tank", "Tank" );
|
||||||
uint16_t tab3 = ESPUI.addControl( ControlType::Tab, "Settings 3", "Settings 3" );
|
uint16_t tab_wifi = ESPUI.addControl( ControlType::Tab, "WiFi", "WiFi" );
|
||||||
|
|
||||||
|
ESPUI.addControl( ControlType::Slider, "Distanz Normal", "10000", ControlColor::Alizarin, tab_lube, &slider );
|
||||||
|
ESPUI.addControl( ControlType::Slider, "Distanz Regen", "10000", ControlColor::Alizarin, tab_lube, &slider );
|
||||||
|
/*
|
||||||
// shown above all tabs
|
// shown above all tabs
|
||||||
status = ESPUI.addControl( ControlType::Label, "Status:", "Stop", ControlColor::Turquoise );
|
status = ESPUI.addControl( ControlType::Label, "Status:", "Stop", ControlColor::Turquoise );
|
||||||
|
|
||||||
@ -166,7 +46,10 @@ void initWebUI (void){
|
|||||||
ESPUI.addControl( ControlType::Slider, "Slider one", "30", ControlColor::Alizarin, tab1, &slider );
|
ESPUI.addControl( ControlType::Slider, "Slider one", "30", ControlColor::Alizarin, tab1, &slider );
|
||||||
ESPUI.addControl( ControlType::Slider, "Slider two", "100", ControlColor::Alizarin, tab3, &slider );
|
ESPUI.addControl( ControlType::Slider, "Slider two", "100", ControlColor::Alizarin, tab3, &slider );
|
||||||
ESPUI.addControl( ControlType::Number, "Number:", "50", ControlColor::Alizarin, tab3, &numberCall );
|
ESPUI.addControl( ControlType::Number, "Number:", "50", ControlColor::Alizarin, tab3, &numberCall );
|
||||||
|
*/
|
||||||
|
|
||||||
ESPUI.begin("ESPUI Control");
|
ESPUI.begin("ESPUI Control");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
[wifi_cred]
|
[wifi_cred]
|
||||||
admin_pass = 'adminpass'
|
admin_password = adminpass
|
||||||
wifi_ssid = 'wifi-ssid'
|
wifi_ap_password = wifiappass
|
||||||
wifi_password = 'wifi-pass'
|
wifi_ssid = wifi-ssid
|
||||||
|
wifi_password = wifi-pass
|
Loading…
x
Reference in New Issue
Block a user