replaced 7Seg Library
This commit is contained in:
parent
99dc58f3c9
commit
43ab7c6934
@ -49,11 +49,11 @@ build_flags=
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
;xreef/EByte LoRa E220 library@^1.0.6 ;made Lib local, due to changes for I2C-controller M0,M1-Pins
|
;xreef/EByte LoRa E220 library@^1.0.6 ;made Lib local, due to changes for I2C-controller M0,M1-Pins
|
||||||
sstaub/Ticker@^4.4.0
|
sstaub/Ticker@^4.4.0
|
||||||
robtillaart/PCF8574 @ ^0.3.7
|
robtillaart/PCF8574 @ ^0.3.7
|
||||||
adafruit/Adafruit INA219 @ ^1.1.1
|
adafruit/Adafruit INA219 @ ^1.1.1
|
||||||
plerup/EspSoftwareSerial @ 6.8.5 ; needed exactly this Version as newer ones have Problems with compiling
|
plerup/EspSoftwareSerial @ 6.8.5 ; needed exactly this Version as newer ones have Problems with compiling
|
||||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
akj7/TM1637 Driver @ ^2.1.2
|
||||||
me-no-dev/ESPAsyncTCP @ ^1.2.2
|
me-no-dev/ESPAsyncTCP @ ^1.2.2
|
||||||
robtillaart/I2C_EEPROM @ ^1.5.2
|
robtillaart/I2C_EEPROM @ ^1.5.2
|
||||||
sandeepmistry/LoRa @ ^0.8.0
|
sandeepmistry/LoRa @ ^0.8.0
|
||||||
bblanchon/ArduinoJson @ ^6.19.4
|
bblanchon/ArduinoJson @ ^6.19.4
|
@ -1,7 +1,7 @@
|
|||||||
#define FREQUENCY_868
|
#define FREQUENCY_868
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <TM1637Display.h>
|
#include <TM1637.h>
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
@ -39,9 +39,9 @@ PCF8574 i2c_io(I2C_IO_ADDRESS);
|
|||||||
Adafruit_INA219 ina219;
|
Adafruit_INA219 ina219;
|
||||||
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||||
|
|
||||||
TM1637Display disp_FAC_1(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC1);
|
TM1637 disp_FAC_1(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC1);
|
||||||
TM1637Display disp_FAC_2(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC2);
|
TM1637 disp_FAC_2(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC2);
|
||||||
TM1637Display disp_FAC_3(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC3);
|
TM1637 disp_FAC_3(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC3);
|
||||||
|
|
||||||
#ifdef CAPTIVE
|
#ifdef CAPTIVE
|
||||||
DNSServer dnsServer;
|
DNSServer dnsServer;
|
||||||
@ -57,6 +57,7 @@ void SystemShutdown();
|
|||||||
void SetBatteryType(batteryType_t type);
|
void SetBatteryType(batteryType_t type);
|
||||||
void ProcessKeyCombos(bool *btnState);
|
void ProcessKeyCombos(bool *btnState);
|
||||||
void OverrideDisplay(const uint8_t *message, uint32_t time);
|
void OverrideDisplay(const uint8_t *message, uint32_t time);
|
||||||
|
uint32_t getESPChipID();
|
||||||
|
|
||||||
void tmrCallback_StatusSender();
|
void tmrCallback_StatusSender();
|
||||||
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
||||||
@ -74,24 +75,11 @@ void tmrCallback_WiFiMaintainConnection();
|
|||||||
Ticker tmrWiFiMaintainConnection(tmrCallback_WiFiMaintainConnection, 1000, 0, MILLIS);
|
Ticker tmrWiFiMaintainConnection(tmrCallback_WiFiMaintainConnection, 1000, 0, MILLIS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t getESPChipID();
|
|
||||||
|
|
||||||
uint8_t Faction_1_dot = 0;
|
|
||||||
uint8_t Faction_2_dot = 0;
|
|
||||||
uint8_t Faction_3_dot = 0;
|
|
||||||
|
|
||||||
uint32_t DisplayOverrideFlag = 0;
|
uint32_t DisplayOverrideFlag = 0;
|
||||||
uint8_t *DisplayOverrideValue = 0;
|
char DisplayOverrideValue[5] = {0};
|
||||||
|
|
||||||
Globals_t globals;
|
Globals_t globals;
|
||||||
|
|
||||||
const uint8_t sevenSeg_bat[] = {0x00, 0b01111100, 0b01110111, 0b01111000};
|
|
||||||
const uint8_t sevenSeg_low[] = {0b00111000, 0b01011100, 0x00, 0x00};
|
|
||||||
const uint8_t sevenSeg_net[] = {0b01010100, 0b01111001, 0b01111000, 0x00};
|
|
||||||
const uint8_t sevenSeg_ota[] = {0x3F, 0x78, 0x77, 0x00};
|
|
||||||
const uint8_t sevenSeg_flsh[] = {0x71, 0x38, 0x6D, 0x76};
|
|
||||||
const uint8_t sevenSeg_file[] = {0x71, 0x30, 0x38, 0x79};
|
|
||||||
|
|
||||||
void setMPins_Helper(int pin, int status)
|
void setMPins_Helper(int pin, int status)
|
||||||
{
|
{
|
||||||
i2c_io.write(pin, status);
|
i2c_io.write(pin, status);
|
||||||
@ -146,7 +134,7 @@ void setup()
|
|||||||
ResponseStructContainer cMi;
|
ResponseStructContainer cMi;
|
||||||
cMi = e220ttl.getModuleInformation();
|
cMi = e220ttl.getModuleInformation();
|
||||||
// It's important get information pointer before all other operation
|
// It's important get information pointer before all other operation
|
||||||
ModuleInformation mi = *(ModuleInformation *)cMi.data;
|
// ModuleInformation mi = *(ModuleInformation *)cMi.data;
|
||||||
|
|
||||||
Serial.println(cMi.status.getResponseDescription());
|
Serial.println(cMi.status.getResponseDescription());
|
||||||
Serial.println(cMi.status.code);
|
Serial.println(cMi.status.code);
|
||||||
@ -203,31 +191,30 @@ void setup()
|
|||||||
|
|
||||||
ArduinoOTA.onStart([]()
|
ArduinoOTA.onStart([]()
|
||||||
{
|
{
|
||||||
disp_FAC_1.setBrightness(7);
|
disp_FAC_1.setBrightness(5);
|
||||||
disp_FAC_2.setBrightness(7);
|
disp_FAC_2.setBrightness(5);
|
||||||
disp_FAC_3.setBrightness(7);
|
disp_FAC_3.setBrightness(5);
|
||||||
disp_FAC_1.setSegments(sevenSeg_ota);
|
disp_FAC_1.display("OTA ");
|
||||||
disp_FAC_3.clear();
|
disp_FAC_3.clearScreen();
|
||||||
|
|
||||||
if (ArduinoOTA.getCommand() == U_FLASH)
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
{
|
{
|
||||||
disp_FAC_2.setSegments(sevenSeg_flsh);
|
disp_FAC_2.display("FLSH");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disp_FAC_2.setSegments(sevenSeg_file);
|
disp_FAC_2.display("FILE");
|
||||||
LittleFS.end();
|
LittleFS.end();
|
||||||
} });
|
} });
|
||||||
|
|
||||||
ArduinoOTA.onEnd([]()
|
ArduinoOTA.onEnd([]()
|
||||||
{
|
{
|
||||||
const uint8_t seg_done[] = {0x5E, 0x3F, 0x54, 0x79};
|
disp_FAC_1.display("DONE");
|
||||||
disp_FAC_1.setSegments(seg_done);
|
disp_FAC_2.clearScreen();
|
||||||
disp_FAC_2.clear();
|
disp_FAC_3.clearScreen(); });
|
||||||
disp_FAC_3.clear(); });
|
|
||||||
|
|
||||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
|
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
|
||||||
{ disp_FAC_3.showNumberDecEx((progress / (total / 100))); });
|
{ disp_FAC_3.display((progress / (total / 100))); });
|
||||||
|
|
||||||
ArduinoOTA.onError([](ota_error_t error)
|
ArduinoOTA.onError([](ota_error_t error)
|
||||||
{
|
{
|
||||||
@ -250,6 +237,13 @@ void setup()
|
|||||||
|
|
||||||
initWebUI();
|
initWebUI();
|
||||||
|
|
||||||
|
disp_FAC_1.init();
|
||||||
|
disp_FAC_1.setBrightness(5);
|
||||||
|
disp_FAC_2.init();
|
||||||
|
disp_FAC_2.setBrightness(5);
|
||||||
|
disp_FAC_3.init();
|
||||||
|
disp_FAC_3.setBrightness(5);
|
||||||
|
|
||||||
tmrEEPROMCyclicPDS.start();
|
tmrEEPROMCyclicPDS.start();
|
||||||
tmrFactionTicker.start();
|
tmrFactionTicker.start();
|
||||||
tmrInputGetter.start();
|
tmrInputGetter.start();
|
||||||
@ -258,6 +252,7 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (e220ttl.available() > 1)
|
if (e220ttl.available() > 1)
|
||||||
{
|
{
|
||||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||||
@ -279,13 +274,13 @@ void loop()
|
|||||||
tmrEEPROMCyclicPDS.update();
|
tmrEEPROMCyclicPDS.update();
|
||||||
tmrFactionTicker.update();
|
tmrFactionTicker.update();
|
||||||
tmrInputGetter.update();
|
tmrInputGetter.update();
|
||||||
|
tmrStatusSender.update();
|
||||||
|
tmrPowerMonitor.update();
|
||||||
|
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
SevenSeg_Output();
|
SevenSeg_Output();
|
||||||
EEPROM_Process();
|
EEPROM_Process();
|
||||||
|
|
||||||
tmrStatusSender.update();
|
|
||||||
tmrPowerMonitor.update();
|
|
||||||
|
|
||||||
#ifdef CAPTIVE
|
#ifdef CAPTIVE
|
||||||
dnsServer.processNextRequest();
|
dnsServer.processNextRequest();
|
||||||
#endif
|
#endif
|
||||||
@ -294,6 +289,7 @@ void loop()
|
|||||||
#endif
|
#endif
|
||||||
if (globals.systemStatus == sysStat_Shutdown)
|
if (globals.systemStatus == sysStat_Shutdown)
|
||||||
SystemShutdown();
|
SystemShutdown();
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,39 +303,51 @@ String macToString(const unsigned char *mac)
|
|||||||
|
|
||||||
void SevenSeg_Output()
|
void SevenSeg_Output()
|
||||||
{
|
{
|
||||||
|
char sevenSegBuff[5] = "";
|
||||||
|
|
||||||
if (DisplayOverrideFlag > millis())
|
if (DisplayOverrideFlag > millis())
|
||||||
{
|
{
|
||||||
disp_FAC_1.setBrightness(7);
|
disp_FAC_1.setBrightness(5);
|
||||||
disp_FAC_2.setBrightness(7);
|
disp_FAC_2.setBrightness(5);
|
||||||
disp_FAC_3.setBrightness(7);
|
disp_FAC_3.setBrightness(5);
|
||||||
disp_FAC_1.setSegments(DisplayOverrideValue);
|
disp_FAC_1.display(String(DisplayOverrideValue));
|
||||||
disp_FAC_2.clear();
|
disp_FAC_2.clearScreen();
|
||||||
disp_FAC_3.clear();
|
disp_FAC_3.clearScreen();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (globals.battery_level < BAT_LOW_PERCENT && millis() % 10000 > 7000)
|
if (globals.battery_level < BAT_LOW_PERCENT && millis() % 10000 > 7000)
|
||||||
{
|
{
|
||||||
disp_FAC_1.setBrightness(0);
|
|
||||||
disp_FAC_2.setBrightness(0);
|
|
||||||
disp_FAC_3.setBrightness(0);
|
|
||||||
|
|
||||||
disp_FAC_1.setSegments(sevenSeg_bat);
|
|
||||||
disp_FAC_2.setSegments(sevenSeg_low);
|
|
||||||
if (millis() % 3000 < 1500)
|
if (millis() % 3000 < 1500)
|
||||||
disp_FAC_3.showNumberDec(globals.battery_level);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", globals.battery_level);
|
||||||
else
|
else
|
||||||
disp_FAC_3.showNumberDecEx(globals.loadvoltage * 100, 0x40);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4s", String(globals.loadvoltage, 1).c_str());
|
||||||
|
|
||||||
|
disp_FAC_1.setBrightness(1);
|
||||||
|
disp_FAC_1.display(" BAT");
|
||||||
|
|
||||||
|
disp_FAC_2.setBrightness(1);
|
||||||
|
disp_FAC_2.display("LOW ");
|
||||||
|
|
||||||
|
disp_FAC_3.setBrightness(1);
|
||||||
|
disp_FAC_3.display(String(sevenSegBuff));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disp_FAC_1.setBrightness(PersistenceData.activeFaction == FACTION_1 ? 7 : 0);
|
disp_FAC_1.setBrightness(PersistenceData.activeFaction == FACTION_1 ? 5 : 1);
|
||||||
disp_FAC_2.setBrightness(PersistenceData.activeFaction == FACTION_2 ? 7 : 0);
|
disp_FAC_1.refresh();
|
||||||
disp_FAC_3.setBrightness(PersistenceData.activeFaction == FACTION_3 ? 7 : 0);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_1_timer / 60);
|
||||||
|
disp_FAC_1.display(String(sevenSegBuff), false, false);
|
||||||
|
|
||||||
disp_FAC_1.showNumberDecEx(PersistenceData.faction_1_timer / 60, Faction_1_dot, true, 4, 0);
|
disp_FAC_2.setBrightness(PersistenceData.activeFaction == FACTION_2 ? 5 : 1);
|
||||||
disp_FAC_2.showNumberDecEx(PersistenceData.faction_2_timer / 60, Faction_2_dot, true, 4, 0);
|
disp_FAC_2.refresh();
|
||||||
disp_FAC_3.showNumberDecEx(PersistenceData.faction_3_timer / 60, Faction_3_dot, true, 4, 0);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_2_timer / 60);
|
||||||
|
disp_FAC_2.display(String(sevenSegBuff), false, false);
|
||||||
|
|
||||||
|
disp_FAC_3.setBrightness(PersistenceData.activeFaction == FACTION_3 ? 5 : 1);
|
||||||
|
disp_FAC_3.refresh();
|
||||||
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_3_timer / 60);
|
||||||
|
disp_FAC_3.display(String(sevenSegBuff), false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,23 +358,14 @@ void tmrCallback_FactionTicker()
|
|||||||
{
|
{
|
||||||
case FACTION_1:
|
case FACTION_1:
|
||||||
PersistenceData.faction_1_timer++;
|
PersistenceData.faction_1_timer++;
|
||||||
Faction_1_dot = Faction_1_dot == 0x80 || Faction_1_dot == 0x00 ? 0x10 : Faction_1_dot << 1;
|
|
||||||
Faction_2_dot = 0;
|
|
||||||
Faction_3_dot = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FACTION_2:
|
case FACTION_2:
|
||||||
PersistenceData.faction_2_timer++;
|
PersistenceData.faction_2_timer++;
|
||||||
Faction_2_dot = Faction_2_dot == 0x80 || Faction_2_dot == 0x00 ? 0x10 : Faction_2_dot << 1;
|
|
||||||
Faction_1_dot = 0;
|
|
||||||
Faction_3_dot = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FACTION_3:
|
case FACTION_3:
|
||||||
PersistenceData.faction_3_timer++;
|
PersistenceData.faction_3_timer++;
|
||||||
Faction_3_dot = Faction_3_dot == 0x80 || Faction_3_dot == 0x00 ? 0x10 : Faction_3_dot << 1;
|
|
||||||
Faction_1_dot = 0;
|
|
||||||
Faction_2_dot = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -377,7 +376,7 @@ void tmrCallback_FactionTicker()
|
|||||||
void tmrCallback_InputGetter()
|
void tmrCallback_InputGetter()
|
||||||
{
|
{
|
||||||
static bool btnState[3];
|
static bool btnState[3];
|
||||||
static bool btnlastState[3];
|
uint8_t keysPressed = 0;
|
||||||
|
|
||||||
btnState[0] = i2c_io.readButton(I2C_IO_BTN_FAC1);
|
btnState[0] = i2c_io.readButton(I2C_IO_BTN_FAC1);
|
||||||
btnState[1] = i2c_io.readButton(I2C_IO_BTN_FAC2);
|
btnState[1] = i2c_io.readButton(I2C_IO_BTN_FAC2);
|
||||||
@ -385,20 +384,9 @@ void tmrCallback_InputGetter()
|
|||||||
|
|
||||||
ProcessKeyCombos(btnState);
|
ProcessKeyCombos(btnState);
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(btnState); i++)
|
keysPressed = keysPressed + (btnState[0] == FAC_1_TRG_PRESSED ? 1 : 0);
|
||||||
{
|
keysPressed = keysPressed + (btnState[1] == FAC_2_TRG_PRESSED ? 1 : 0);
|
||||||
if (btnlastState[i] != btnState[i])
|
keysPressed = keysPressed + (btnState[2] == FAC_3_TRG_PRESSED ? 1 : 0);
|
||||||
{
|
|
||||||
btnlastState[i] = btnState[i];
|
|
||||||
Serial.printf("Button %d changed to %d\n", i, btnState[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t keysPressed = 0;
|
|
||||||
|
|
||||||
keysPressed = +btnState[0] == FAC_1_TRG_PRESSED ? 1 : 0;
|
|
||||||
keysPressed = +btnState[1] == FAC_2_TRG_PRESSED ? 1 : 0;
|
|
||||||
keysPressed = +btnState[2] == FAC_3_TRG_PRESSED ? 1 : 0;
|
|
||||||
|
|
||||||
if (keysPressed > 1)
|
if (keysPressed > 1)
|
||||||
{
|
{
|
||||||
@ -408,13 +396,31 @@ void tmrCallback_InputGetter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (btnState[0] == FAC_1_TRG_PRESSED)
|
if (btnState[0] == FAC_1_TRG_PRESSED)
|
||||||
|
{
|
||||||
|
if (PersistenceData.activeFaction != FACTION_1)
|
||||||
|
{
|
||||||
|
Serial.println("Faction 1 captured !");
|
||||||
|
}
|
||||||
PersistenceData.activeFaction = FACTION_1;
|
PersistenceData.activeFaction = FACTION_1;
|
||||||
|
}
|
||||||
|
|
||||||
if (btnState[1] == FAC_2_TRG_PRESSED)
|
if (btnState[1] == FAC_2_TRG_PRESSED)
|
||||||
|
{
|
||||||
|
if (PersistenceData.activeFaction != FACTION_2)
|
||||||
|
{
|
||||||
|
Serial.println("Faction 2 captured !");
|
||||||
|
}
|
||||||
PersistenceData.activeFaction = FACTION_2;
|
PersistenceData.activeFaction = FACTION_2;
|
||||||
|
}
|
||||||
|
|
||||||
if (btnState[2] == FAC_3_TRG_PRESSED)
|
if (btnState[2] == FAC_3_TRG_PRESSED)
|
||||||
|
{
|
||||||
|
if (PersistenceData.activeFaction != FACTION_3)
|
||||||
|
{
|
||||||
|
Serial.println("Faction 3 captured !");
|
||||||
|
}
|
||||||
PersistenceData.activeFaction = FACTION_3;
|
PersistenceData.activeFaction = FACTION_3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printParameters(struct Configuration configuration)
|
void printParameters(struct Configuration configuration)
|
||||||
@ -513,15 +519,15 @@ void tmrCallback_PowerMonitor()
|
|||||||
const int bat_max_3s = 1260;
|
const int bat_max_3s = 1260;
|
||||||
|
|
||||||
float shuntvoltage = 0;
|
float shuntvoltage = 0;
|
||||||
//float current_mA = 0;
|
// float current_mA = 0;
|
||||||
float busvoltage = 0;
|
float busvoltage = 0;
|
||||||
//float power_mW = 0;
|
// float power_mW = 0;
|
||||||
int battery_level = 0;
|
int battery_level = 0;
|
||||||
|
|
||||||
shuntvoltage = ina219.getShuntVoltage_mV();
|
shuntvoltage = ina219.getShuntVoltage_mV();
|
||||||
busvoltage = ina219.getBusVoltage_V();
|
busvoltage = ina219.getBusVoltage_V();
|
||||||
//current_mA = ina219.getCurrent_mA();
|
// current_mA = ina219.getCurrent_mA();
|
||||||
//power_mW = ina219.getPower_mW();
|
// power_mW = ina219.getPower_mW();
|
||||||
globals.loadvoltage = busvoltage + (shuntvoltage / 1000);
|
globals.loadvoltage = busvoltage + (shuntvoltage / 1000);
|
||||||
switch (ConfigData.batteryType)
|
switch (ConfigData.batteryType)
|
||||||
{
|
{
|
||||||
@ -607,10 +613,10 @@ void SetBatteryType(batteryType_t type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverrideDisplay(const uint8_t *message, uint32_t time)
|
void OverrideDisplay(const char *message, uint32_t time)
|
||||||
{
|
{
|
||||||
DisplayOverrideFlag = millis() + time;
|
DisplayOverrideFlag = millis() + time;
|
||||||
DisplayOverrideValue = (uint8_t *)message;
|
strcpy(DisplayOverrideValue, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getESPChipID()
|
uint32_t getESPChipID()
|
||||||
@ -629,58 +635,59 @@ uint32_t getESPChipID()
|
|||||||
|
|
||||||
void ProcessKeyCombos(bool *btnState)
|
void ProcessKeyCombos(bool *btnState)
|
||||||
{
|
{
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
KEY_PRESSED,
|
KEY_PRESSED,
|
||||||
KEY_RELEASED
|
KEY_RELEASED
|
||||||
} keyStatus_t;
|
} keyStatus_t;
|
||||||
|
|
||||||
static keyStatus_t keyStatus_Fac1 = KEY_RELEASED;
|
static keyStatus_t keyStatus_Fac1 = KEY_RELEASED;
|
||||||
static uint8_t keyCount_Fac1 = 0;
|
static uint8_t keyCount_Fac1 = 0;
|
||||||
static keyStatus_t keyStatus_Fac2 = KEY_RELEASED;
|
static keyStatus_t keyStatus_Fac2 = KEY_RELEASED;
|
||||||
static uint8_t keyCount_Fac2 = 0;
|
static uint8_t keyCount_Fac2 = 0;
|
||||||
static keyStatus_t keyStatus_Fac3 = KEY_RELEASED;
|
static keyStatus_t keyStatus_Fac3 = KEY_RELEASED;
|
||||||
|
|
||||||
if (btnState[2] == FAC_3_TRG_PRESSED)
|
if (btnState[2] == FAC_3_TRG_PRESSED)
|
||||||
{
|
{
|
||||||
keyStatus_Fac3 = KEY_PRESSED;
|
keyStatus_Fac3 = KEY_PRESSED;
|
||||||
|
|
||||||
// Process FactionKey 1 ComboCounter
|
// Process FactionKey 1 ComboCounter
|
||||||
if (btnState[0] == FAC_1_TRG_PRESSED && keyStatus_Fac1 == KEY_RELEASED)
|
if (btnState[0] == FAC_1_TRG_PRESSED && keyStatus_Fac1 == KEY_RELEASED)
|
||||||
{
|
{
|
||||||
keyStatus_Fac1 = KEY_PRESSED;
|
keyStatus_Fac1 = KEY_PRESSED;
|
||||||
keyCount_Fac1++;
|
keyCount_Fac1++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnState[0] != FAC_1_TRG_PRESSED)
|
if (btnState[0] != FAC_1_TRG_PRESSED)
|
||||||
keyStatus_Fac1 = KEY_RELEASED;
|
keyStatus_Fac1 = KEY_RELEASED;
|
||||||
|
|
||||||
// Process FactionKey 2 ComboCounter
|
// Process FactionKey 2 ComboCounter
|
||||||
if (btnState[1] == FAC_2_TRG_PRESSED && keyStatus_Fac2 == KEY_RELEASED)
|
if (btnState[1] == FAC_2_TRG_PRESSED && keyStatus_Fac2 == KEY_RELEASED)
|
||||||
{
|
{
|
||||||
keyStatus_Fac2 = KEY_PRESSED;
|
keyStatus_Fac2 = KEY_PRESSED;
|
||||||
keyCount_Fac2++;
|
keyCount_Fac2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnState[1] != FAC_2_TRG_PRESSED)
|
if (btnState[1] != FAC_2_TRG_PRESSED)
|
||||||
keyStatus_Fac2 = KEY_RELEASED;
|
keyStatus_Fac2 = KEY_RELEASED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnState[2] != FAC_3_TRG_PRESSED && keyStatus_Fac3 == KEY_PRESSED)
|
if (btnState[2] != FAC_3_TRG_PRESSED && keyStatus_Fac3 == KEY_PRESSED)
|
||||||
{
|
{
|
||||||
Serial.printf("KeyCombo 1: %d | 2: %d\n", keyCount_Fac1, keyCount_Fac2);
|
if (keyCount_Fac1 > 0 || keyCount_Fac2 > 0)
|
||||||
|
Serial.printf("KeyCombo 1: %d | 2: %d\n", keyCount_Fac1, keyCount_Fac2);
|
||||||
|
|
||||||
if (keyCount_Fac1 == 2 && keyCount_Fac2 == 2)
|
if (keyCount_Fac1 == 2 && keyCount_Fac2 == 2)
|
||||||
{
|
{
|
||||||
Serial.println("KeyCombo: WiFi AP ON");
|
Serial.println("KeyCombo: WiFi AP ON");
|
||||||
OverrideDisplay(sevenSeg_net, 5000);
|
OverrideDisplay("NET ", 5000);
|
||||||
toggleWiFiAP(false);
|
toggleWiFiAP(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyCount_Fac1 = 0;
|
keyCount_Fac1 = 0;
|
||||||
keyCount_Fac2 = 0;
|
keyCount_Fac2 = 0;
|
||||||
keyStatus_Fac1 = KEY_RELEASED;
|
keyStatus_Fac1 = KEY_RELEASED;
|
||||||
keyStatus_Fac2 = KEY_RELEASED;
|
keyStatus_Fac2 = KEY_RELEASED;
|
||||||
keyStatus_Fac3 = KEY_RELEASED;
|
keyStatus_Fac3 = KEY_RELEASED;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user