mirror of
https://github.com/anklimov/lighthub
synced 2025-12-12 06:39:51 +03:00
mass refactoring
sd_card_code not affects ram and firmware if not enabled
This commit is contained in:
173
lighthub/main.h
173
lighthub/main.h
@@ -1,56 +1,181 @@
|
||||
//
|
||||
// Created by livello on 13.03.18.
|
||||
//
|
||||
#include "options.h"
|
||||
|
||||
#ifndef LIGHTHUB_MAIN_H
|
||||
#define LIGHTHUB_MAIN_H
|
||||
|
||||
#define TXEnablePin 13
|
||||
|
||||
#ifndef SERIAL_BAUD
|
||||
#define SERIAL_BAUD 115200
|
||||
#if defined(__SAM3X8E__)
|
||||
#define wdt_res() watchdogReset()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
#ifndef CUSTOM_FIRMWARE_MAC
|
||||
#define FIRMWARE_MAC {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0}
|
||||
#if defined(__AVR__)
|
||||
#define wdt_en() wdt_enable(WDTO_8S)
|
||||
#define wdt_dis() wdt_disable()
|
||||
#define wdt_res() wdt_reset()
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#define wdt_res()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
#if defined(WATCH_DOG_TICKER_DISABLE) && defined(__AVR__)
|
||||
#define wdt_en() wdt_disable()
|
||||
#define wdt_dis() wdt_disable()
|
||||
#define wdt_res() wdt_disable()
|
||||
#endif
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DallasTemperature.h"
|
||||
#include <PubSubClient.h>
|
||||
#include <SPI.h>
|
||||
#include "utils.h"
|
||||
#include <string.h>
|
||||
#include <ModbusMaster.h>
|
||||
#include "aJSON.h"
|
||||
#include <Cmd.h>
|
||||
#include "stdarg.h"
|
||||
#include "item.h"
|
||||
#include "inputs.h"
|
||||
#include "Dhcp.h"
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
|
||||
#include <DueFlashStorage.h>
|
||||
#include <watchdog.h>
|
||||
#include <ArduinoHttpClient.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#include "HTTPClient.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <EEPROM.h>
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#include "esp.h"
|
||||
#include <EEPROM.h>
|
||||
#include <ArduinoHttpClient.h>
|
||||
#endif
|
||||
|
||||
#ifdef _owire
|
||||
|
||||
#include "owTerm.h"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_dmxin) || defined(_dmxout) || defined (_artnet)
|
||||
|
||||
#include "dmx.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef Wiz5500
|
||||
#include <Ethernet2.h>
|
||||
#else
|
||||
|
||||
#include <Ethernet.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _artnet
|
||||
#include <Artnet.h>
|
||||
#endif
|
||||
|
||||
#ifdef SD_CARD_INSERTED
|
||||
#include "sd_card_w5100.h"
|
||||
#endif
|
||||
|
||||
#ifdef _artnet
|
||||
extern Artnet *artnet;
|
||||
#endif
|
||||
|
||||
void watchdogSetup(void);
|
||||
void callback(char* topic, byte* payload, unsigned int length);
|
||||
|
||||
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
||||
|
||||
#ifndef __ESP__
|
||||
|
||||
void printIPAddress();
|
||||
|
||||
#endif
|
||||
|
||||
void printMACAddress();
|
||||
|
||||
void restoreState();
|
||||
int lanLoop();
|
||||
void Changed (int i, DeviceAddress addr, int val);
|
||||
|
||||
int lanLoop();
|
||||
|
||||
void Changed(int i, DeviceAddress addr, int val);
|
||||
|
||||
void modbusIdle(void);
|
||||
void _handleHelp(int arg_cnt, char **args);
|
||||
void _kill(int arg_cnt, char **args);
|
||||
|
||||
void cmdFunctionHelp(int arg_cnt, char **args);
|
||||
|
||||
void cmdFunctionKill(int arg_cnt, char **args);
|
||||
|
||||
void applyConfig();
|
||||
void _loadConfig (int arg_cnt, char **args);
|
||||
|
||||
void cmdFunctionLoad(int arg_cnt, char **args);
|
||||
|
||||
int loadConfigFromEEPROM(int arg_cnt, char **args);
|
||||
void _mqttConfigRequest(int arg_cnt, char **args);
|
||||
|
||||
void cmdFunctionReq(int arg_cnt, char **args);
|
||||
|
||||
int mqttConfigRequest(int arg_cnt, char **args);
|
||||
int mqttConfigResp (char * as);
|
||||
void _saveConfigToEEPROM(int arg_cnt, char **args);
|
||||
void _setMacAddress(int arg_cnt, char **args);
|
||||
void _getConfig(int arg_cnt, char **args);
|
||||
void printBool (bool arg);
|
||||
void saveFlash(short n, char* str);
|
||||
void loadFlash(short n, char* str);
|
||||
int getConfig (int arg_cnt, char **args);
|
||||
|
||||
int mqttConfigResp(char *as);
|
||||
|
||||
void cmdFunctionSave(int arg_cnt, char **args);
|
||||
|
||||
void cmdFunctionSetMac(int arg_cnt, char **args);
|
||||
|
||||
void cmdFunctionGet(int arg_cnt, char **args);
|
||||
|
||||
void printBool(bool arg);
|
||||
|
||||
void saveFlash(short n, char *str);
|
||||
|
||||
void loadFlash(short n, char *str);
|
||||
|
||||
int getConfig(int arg_cnt, char **args);
|
||||
|
||||
void preTransmission();
|
||||
|
||||
void postTransmission();
|
||||
|
||||
void setup_main();
|
||||
|
||||
void loop_main();
|
||||
|
||||
void owIdle(void);
|
||||
|
||||
void modbusIdle(void);
|
||||
|
||||
void inputLoop(void);
|
||||
|
||||
void modbusLoop(void);
|
||||
|
||||
void thermoLoop(void);
|
||||
short thermoSetCurTemp(char * name, short t);
|
||||
|
||||
short thermoSetCurTemp(char *name, short t);
|
||||
|
||||
void modbusIdle(void);
|
||||
|
||||
void printConfigSummary();
|
||||
|
||||
void setupCmdArduino();
|
||||
|
||||
void setupMacAddress();
|
||||
|
||||
int getConfig(int arg_cnt, char **args);
|
||||
|
||||
void printFirmwareVersionAndBuildOptions();
|
||||
|
||||
#endif //LIGHTHUB_MAIN_H
|
||||
Reference in New Issue
Block a user