made RemoteDebug optional per define

This commit is contained in:
Marcel Peterkau 2022-02-10 09:54:24 +01:00
parent efae15867a
commit e6fa1e1ccd

View File

@ -4,18 +4,26 @@
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
#include <RemoteDebug.h>
#include <FastLED.h>
#include <Ticker.h>
#include "common.h"
#include "rmtdbghelp.h"
#include "lubeapp.h"
#include "webui.h"
#include "config.h"
#include "globals.h"
#include "can.h"
#ifdef REMOTE_DEBUG
#include <RemoteDebug.h>
#include "rmtdbghelp.h"
#else
#define debugV Serial.println
#define debugE Serial.println
#endif
#ifdef WIFI_CLIENT
#include <ESP8266WiFiMulti.h>
@ -26,12 +34,6 @@ const uint32_t connectTimeoutMs = 5000;
ESP8266WiFiMulti wifiMulti;
#endif
#ifdef DEBUG
const bool debug_flag = true;
#else
const bool debug_flag = false;
#endif
bool startSetupMode = false;
char DeviceName[33];
@ -40,19 +42,9 @@ uint32_t TravelDistance_highRes;
volatile uint32_t wheel_pulse = 0;
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
RemoteDebug Debug;
CRGB leds[1];
// Function-Prototypes
String IpAddress2String(const IPAddress &ipAddress);
void processCmdRemoteDebug();
void RemoteDebug_formatCFG();
void RemoteDebug_formatPersistence();
void RemotDebug_printSystemInfo();
void RemoteDebug_printWifiInfo();
void RemoteDebug_CheckEEPOM();
void RemoteDebug_dumpConfig();
void RemoteDebug_dumpPersistance();
void updateWebUITicker_callback();
void IRAM_ATTR trigger_ISR();
void LED_Process(uint8_t override = false, CRGB setColor = CRGB::White);
@ -63,6 +55,19 @@ void SystemShutdown();
uint32_t Process_Impulse_WheelSpeed();
void EEPROMCyclicPDS_callback();
#ifdef REMOTE_DEBUG
RemoteDebug Debug;
String IpAddress2String(const IPAddress &ipAddress);
void processCmdRemoteDebug();
void RemoteDebug_formatCFG();
void RemoteDebug_formatPersistence();
void RemotDebug_printSystemInfo();
void RemoteDebug_printWifiInfo();
void RemoteDebug_CheckEEPOM();
void RemoteDebug_dumpConfig();
void RemoteDebug_dumpPersistance();
#endif
#ifdef WIFI_CLIENT
void wifiMaintainConnectionTicker_callback();
Ticker WiFiMaintainConnectionTicker(wifiMaintainConnectionTicker_callback, 1000, 0, MILLIS);
@ -102,14 +107,33 @@ void setup()
FastLED.addLeds<WS2811, GPIO_LED, GRB>(leds, 1); // GRB ordering is assumed
if (LubeConfig.SpeedSource == SOURCE_IMPULSE)
switch (LubeConfig.SpeedSource)
{
case SOURCE_IMPULSE:
pinMode(GPIO_TRIGGER, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING);
break;
case SOURCE_GPS:
break;
case SOURCE_TIME:
break;
#if PCB_REVISION >= 13
case SOURCE_CAN:
Init_CAN();
break;
#endif
default:
debugE("Source Setting N/A");
break;
}
pinMode(GPIO_BUTTON, INPUT_PULLUP);
pinMode(GPIO_PUMP, OUTPUT);
#ifdef REMOTE_DEBUG
if (MDNS.begin(DeviceName))
MDNS.addService("telnet", "tcp", 23);
@ -123,6 +147,7 @@ void setup()
Debug.setHelpProjectsCmds(helpCmd);
Debug.setCallBackProjectCmds(&processCmdRemoteDebug);
#endif
ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname(DeviceName);
@ -160,10 +185,6 @@ void setup()
u8x8.drawString(0, 0, "KTM ChainLube V1");
u8x8.refreshDisplay();
#if PCB_REVISION >= 13
Init_CAN();
#endif
initWebUI();
UpdateWebUITicker.start();
EEPROMCyclicPDSTicker.start();
@ -197,7 +218,9 @@ void loop()
EEPROM_Process();
ArduinoOTA.handle();
#ifdef REMOTE_DEBUG
Debug.handle();
#endif
#ifdef WIFI_CLIENT
WiFiMaintainConnectionTicker.update();
#endif
@ -214,6 +237,7 @@ String IpAddress2String(const IPAddress &ipAddress)
String(ipAddress[3]);
}
#ifdef REMOTE_DEBUG
void processCmdRemoteDebug()
{
String lastCmd = Debug.getLastCommand();
@ -338,6 +362,7 @@ void RemoteDebug_CheckEEPOM()
}
LubeConfig.checksum = checksum;
}
#endif
#ifdef WIFI_CLIENT
void wifiMaintainConnectionTicker_callback()