restructured Folders and Files
This commit is contained in:
		| @@ -1,67 +0,0 @@ | ||||
|  | ||||
| #ifndef _COMMON_H_ | ||||
| #define _COMMON_H_ | ||||
|  | ||||
| #include <stdint.h> | ||||
|  | ||||
| #define Q(x) #x | ||||
| #define QUOTE(x) Q(x) | ||||
|  | ||||
| #define TRUE 1 | ||||
| #define FALSE 0 | ||||
|  | ||||
| #define HOST_NAME "AirsoftTimer_%08X" | ||||
|  | ||||
| #define SHUTDOWN_DELAY_MS 5000 | ||||
| #define RESETABLE_AFTER_STARTUP_MS 30000 | ||||
|  | ||||
| #define GPIO_LORA_TX D3 | ||||
| #define GPIO_LORA_RX D4 | ||||
| #define GPIO_LORA_AUX D0 | ||||
|  | ||||
| #define GPIO_7SEG_EN_FAC1 D7 | ||||
| #define GPIO_7SEG_EN_FAC2 D6 | ||||
| #define GPIO_7SEG_EN_FAC3 D5 | ||||
| #define GPIO_7SEG_CLK D8 | ||||
|  | ||||
| #define I2C_IO_BTN_FAC1 0 | ||||
| #define FAC_1_TRG_PRESSED LOW | ||||
| #define I2C_IO_BTN_FAC2 1 | ||||
| #define FAC_2_TRG_PRESSED LOW | ||||
| #define I2C_IO_BTN_FAC3 2 | ||||
| #define FAC_3_TRG_PRESSED LOW | ||||
|  | ||||
| #define I2C_IO_LORA_M0 4 | ||||
| #define I2C_IO_LORA_M1 3 | ||||
|  | ||||
| #define EEPROM_TYPE 24LC64 | ||||
|  | ||||
| #define I2C_IO_ADDRESS 0x38 | ||||
| #define I2C_POWER_ADDRESS 0x40 | ||||
| #define I2C_EEPROM_ADDRESS 0x50 | ||||
|  | ||||
| #define SW_VERSION 1.0 | ||||
| #define FLASH_FS_VERSION 1.0 | ||||
|  | ||||
| #ifndef OTA_DELAY | ||||
| #define OTA_DELAY 50 // ticks -> 10ms / tick | ||||
| #endif | ||||
|  | ||||
| #ifndef ADMIN_PASSWORD | ||||
| #error "You need to define ADMIN_PASSWORD for OTA-Update" | ||||
| #endif | ||||
| #ifndef WIFI_PASSWORD | ||||
| #error "You must define an WIFI_PASSWORD for OTA-Update" | ||||
| #endif | ||||
| #ifndef WIFI_SSID | ||||
| #error "You must define an WIFI_SSID for OTA-Update" | ||||
| #endif | ||||
| #ifndef WIFI_AP_SSID | ||||
| #warning "No WIFI_AP_SSID defined. Using DeviceName" | ||||
| #define WIFI_AP_SSID DEVICE_NAME | ||||
| #endif | ||||
| #ifndef WIFI_AP_PASSWORD | ||||
| #error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode" | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -1,72 +0,0 @@ | ||||
| #ifndef _CONFIG_H_ | ||||
| #define _CONFIG_H_ | ||||
|  | ||||
| #include <Arduino.h> | ||||
| #include <Wire.h> | ||||
| #include <I2C_eeprom.h> | ||||
|  | ||||
| #include "globals.h" | ||||
| #include "dtc.h" | ||||
| #include "common.h" | ||||
|  | ||||
| #define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC01 | ||||
| #define EEPROM_ENDURANCE 1000000 | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
|   NONE, | ||||
|   FACTION_1, | ||||
|   FACTION_2, | ||||
|   FACTION_3 | ||||
| } factions_t; | ||||
|  | ||||
| typedef struct | ||||
| { | ||||
|   uint32_t writeCycleCounter = 0; | ||||
|   uint32_t faction_1_timer = 0; | ||||
|   uint32_t faction_2_timer = 0; | ||||
|   uint32_t faction_3_timer = 0; | ||||
|   factions_t activeFaction = NONE; | ||||
|   uint32_t checksum = 0; | ||||
| } persistenceData_t; | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
|   BATTERY_UNDEFINED, | ||||
|   BATTERY_LIPO_2S, | ||||
|   BATTERY_LIPO_3S | ||||
| } batteryType_t; | ||||
|  | ||||
| const char BatteryString[][10]{ | ||||
|   "Undefined", | ||||
|   "LiPo 2S", | ||||
|   "LiPo 3S" | ||||
| }; | ||||
|  | ||||
| typedef struct | ||||
| { | ||||
|   uint8_t EEPROM_Version = 1; | ||||
|   batteryType_t batteryType = BATTERY_UNDEFINED; | ||||
|   uint32_t checksum = 0; | ||||
| } configData_t; | ||||
|  | ||||
| const configData_t ConfigData_defaults = { | ||||
|  0, BATTERY_LIPO_3S, 0 | ||||
| }; | ||||
|  | ||||
| void InitEEPROM(); | ||||
| void EEPROM_Process(); | ||||
| void StoreConfig_EEPROM(); | ||||
| void GetConfig_EEPROM(); | ||||
| void StorePersistence_EEPROM(); | ||||
| void GetPersistence_EEPROM(); | ||||
| void FormatConfig_EEPROM(); | ||||
| void FormatPersistence_EEPROM(); | ||||
| uint32_t Checksum_EEPROM(uint8_t const *data, size_t len); | ||||
| void dumpEEPROM(uint16_t memoryAddress, uint16_t length); | ||||
| void MovePersistencePage_EEPROM(boolean reset); | ||||
| uint32_t ConfigSanityCheck(bool autocorrect = false); | ||||
|  | ||||
| extern configData_t ConfigData; | ||||
| extern persistenceData_t PersistenceData; | ||||
| #endif // _CONFIG_H_ | ||||
| @@ -1,48 +0,0 @@ | ||||
| #ifndef _DEFAULTS_H_ | ||||
| #define _DEFAULTS_H_ | ||||
|  | ||||
| #ifndef WIFI_CLIENT | ||||
| #define WIFI_ACCESSPOINT | ||||
| #endif | ||||
|  | ||||
| #if defined(WIFI_CLIENT) && defined(WIFI_ACCESSPOINT) | ||||
| #error "You can't define AP and CLIENT at the same Time!" | ||||
| #endif | ||||
|  | ||||
| #ifndef WIFI_SSID | ||||
| #define WIFI_SSID "3 Factions CTF Timer" | ||||
| #endif | ||||
|  | ||||
| #ifndef WIFI_PASS | ||||
| #define WIFI_PASS "CaptureTheFlag" | ||||
| #endif | ||||
|  | ||||
| #ifndef OTA_PASS | ||||
| #define OTA_PASS "UploadTheFlag" | ||||
| #endif | ||||
|  | ||||
| #ifndef OTA_HOST | ||||
| #define OTA_HOST "ESP_OTA" | ||||
| #endif | ||||
|  | ||||
| #ifndef DEVICE_NAME | ||||
| #define DEVICE_NAME WIFI_SSID | ||||
| #endif | ||||
|  | ||||
| #ifndef BAT_LOW_PERCENT | ||||
| #define BAT_LOW_PERCENT 10 | ||||
| #endif | ||||
|  | ||||
| #ifndef FACTION_1_NAME | ||||
| #define FACTION_1_NAME "Team A"  | ||||
| #endif | ||||
|  | ||||
| #ifndef FACTION_2_NAME | ||||
| #define FACTION_2_NAME "Team B"  | ||||
| #endif | ||||
|  | ||||
| #ifndef FACTION_3_NAME | ||||
| #define FACTION_3_NAME "Team C"  | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
| @@ -1,53 +0,0 @@ | ||||
| #ifndef _DTC_H_ | ||||
| #define _DTC_H_ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| #define MAX_DTC_STORAGE 6 | ||||
|  | ||||
| typedef enum DTCNums_e | ||||
| { | ||||
|   DTC_NO_EEPROM_FOUND, | ||||
|   DTC_EEPROM_CFG_BAD, | ||||
|   DTC_EEPROM_PDS_BAD, | ||||
|   DTC_EEPROM_PDSADRESS_BAD, | ||||
|   DTC_EEPROM_VERSION_BAD, | ||||
|   DTC_FLASHFS_ERROR, | ||||
|   DTC_FLASHFS_VERSION_ERROR, | ||||
|   DTC_EEPROM_CFG_SANITY, | ||||
|   DTC_NO_LORA_FOUND, | ||||
|   DTC_NO_BATMNON_FOUND, | ||||
|   DTC_LAST_DTC | ||||
| } DTCNums_t; | ||||
|  | ||||
| typedef enum DTCActive_e | ||||
| { | ||||
|   DTC_ACTIVE, | ||||
|   DTC_PREVIOUS, | ||||
|   DTC_NONE | ||||
| } DTCActive_t; | ||||
|  | ||||
| typedef enum DTCSeverity_e | ||||
| { | ||||
|   DTC_INFO, | ||||
|   DTC_WARN, | ||||
|   DTC_CRITICAL | ||||
| } DTCSeverity_t; | ||||
|  | ||||
| typedef struct DTCEntry_s | ||||
| { | ||||
|   DTCNums_t Number; | ||||
|   uint32_t timestamp; | ||||
|   DTCActive_t active; | ||||
|   DTCSeverity_t severity; | ||||
|   uint32_t debugVal; | ||||
| } DTCEntry_t; | ||||
|  | ||||
| void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active, uint32_t DebugValue = 0); | ||||
| void ClearDTC(DTCNums_t DTC_no); | ||||
| void ClearAllDTC(); | ||||
| DTCNums_t getlastDTC(boolean only_active); | ||||
| DTCNums_t getlastDTC_Severity(boolean only_active, DTCSeverity_t severity); | ||||
|  | ||||
| extern DTCEntry_s DTCStorage[MAX_DTC_STORAGE]; | ||||
| #endif | ||||
| @@ -1,45 +0,0 @@ | ||||
| #ifndef _GLOBALS_H_ | ||||
| #define _GLOBALS_H_ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| typedef enum eSystem_Status | ||||
| { | ||||
|   sysStat_Startup, | ||||
|   sysStat_Normal, | ||||
|   sysStat_Error, | ||||
|   sysStat_Shutdown | ||||
| } tSystem_Status; | ||||
|  | ||||
| typedef enum eEERequest | ||||
| { | ||||
|   EE_IDLE, | ||||
|   EE_CFG_SAVE, | ||||
|   EE_CFG_LOAD, | ||||
|   EE_CFG_FORMAT, | ||||
|   EE_PDS_SAVE, | ||||
|   EE_PDS_LOAD, | ||||
|   EE_PDS_FORMAT, | ||||
|   EE_FORMAT_ALL, | ||||
|   EE_ALL_SAVE | ||||
|  | ||||
| } tEERequest; | ||||
|  | ||||
| typedef struct Globals_s | ||||
| { | ||||
|   char DeviceName[33]; | ||||
|   char DeviceName_ID[43]; | ||||
|   char FlashVersion[10]; | ||||
|   tSystem_Status systemStatus = sysStat_Startup; | ||||
|   tSystem_Status resumeStatus = sysStat_Startup; | ||||
|   char systemStatustxt[16] = ""; | ||||
|   eEERequest requestEEAction = EE_IDLE; | ||||
|   uint16_t eePersistanceAdress; | ||||
|   bool hasDTC; | ||||
|   int loadvoltage_mV = 0; | ||||
|   int battery_level = 0; | ||||
| } Globals_t; | ||||
|  | ||||
| extern Globals_t globals; | ||||
|  | ||||
| #endif | ||||
| @@ -1,21 +0,0 @@ | ||||
| #ifndef _LORA_NET_H_ | ||||
| #define _LORA_NET_H_ | ||||
|  | ||||
| #include <Arduino.h> | ||||
| #include <LoRa_E220.h> | ||||
|  | ||||
| // local includes | ||||
| #include "lora_messages.h" | ||||
| #include "defaults.h" | ||||
| #include "config.h" | ||||
| #include "globals.h" | ||||
| #include "dtc.h" | ||||
| #include "common.h" | ||||
|  | ||||
| #define FREQUENCY_868 | ||||
|  | ||||
| bool InitLoRa(void (*MPinHelper)(int, int)); | ||||
| void LoRa_Process(); | ||||
| void sendStatus_LoRa(); | ||||
|  | ||||
| #endif | ||||
| @@ -1,20 +0,0 @@ | ||||
| #ifndef _OLED_DISPLAY_H_ | ||||
| #define _OLED_DISPLAY_H_ | ||||
|  | ||||
| #include <Arduino.h> | ||||
| #include <Wire.h> | ||||
| #include <Adafruit_GFX.h> | ||||
| #include <Adafruit_SSD1306.h> | ||||
| #include "globals.h" | ||||
| #include "config.h" | ||||
|  | ||||
| #define OLED_SDA 4 | ||||
| #define OLED_SCL 15 | ||||
| #define OLED_RST 16 | ||||
| #define SCREEN_WIDTH 128 // OLED display width, in pixels | ||||
| #define SCREEN_HEIGHT 64 // OLED display height, in pixels | ||||
|  | ||||
| void OLED_Init(); | ||||
| void OLED_Process(); | ||||
|  | ||||
| #endif | ||||
| @@ -1,21 +0,0 @@ | ||||
| #ifndef _WEBUI_H_ | ||||
| #define _WEBUI_H_ | ||||
|  | ||||
| #include <Arduino.h> | ||||
| #include <FS.h> | ||||
| #include <LittleFS.h> | ||||
| #include <ESPAsyncTCP.h> | ||||
| #include <ESPAsyncWebServer.h> | ||||
| #include <Updater.h> | ||||
| #include <ESP8266mDNS.h> | ||||
| #include <AsyncJson.h> | ||||
| #include <ArduinoJson.h> | ||||
|  | ||||
| #include "config.h" | ||||
| #include "globals.h" | ||||
| #include "dtc.h" | ||||
| #include "common.h" | ||||
|  | ||||
| void initWebUI(); | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user