Refactored includes
This commit is contained in:
parent
37a1ca6058
commit
35f66e0458
@ -25,9 +25,7 @@ SOFTWARE.
|
|||||||
#include <tinyexpr.h>
|
#include <tinyexpr.h>
|
||||||
|
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <main.hpp>
|
||||||
#include <helper.hpp>
|
|
||||||
#include <tempsensor.hpp>
|
|
||||||
|
|
||||||
#define FORMULA_MAX_DEVIATION 1.6
|
#define FORMULA_MAX_DEVIATION 1.6
|
||||||
|
|
||||||
|
@ -24,14 +24,12 @@ SOFTWARE.
|
|||||||
#ifndef SRC_CALC_HPP_
|
#ifndef SRC_CALC_HPP_
|
||||||
#define SRC_CALC_HPP_
|
#define SRC_CALC_HPP_
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
|
|
||||||
#define ERR_FORMULA_NOTENOUGHVALUES -1
|
#define ERR_FORMULA_NOTENOUGHVALUES -1
|
||||||
#define ERR_FORMULA_INTERNAL -2
|
#define ERR_FORMULA_INTERNAL -2
|
||||||
#define ERR_FORMULA_UNABLETOFFIND -3
|
#define ERR_FORMULA_UNABLETOFFIND -3
|
||||||
|
|
||||||
// Functions
|
|
||||||
double calculateGravity(double angle, double tempC,
|
double calculateGravity(double angle, double tempC,
|
||||||
const char *tempFormula = 0);
|
const char *tempFormula = 0);
|
||||||
double gravityTemperatureCorrectionC(double gravity, double tempC,
|
double gravityTemperatureCorrectionC(double gravity, double tempC,
|
||||||
|
@ -21,10 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <LittleFS.h>
|
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <helper.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
Config myConfig;
|
Config myConfig;
|
||||||
|
|
||||||
|
@ -24,14 +24,8 @@ SOFTWARE.
|
|||||||
#ifndef SRC_CONFIG_HPP_
|
#ifndef SRC_CONFIG_HPP_
|
||||||
#define SRC_CONFIG_HPP_
|
#define SRC_CONFIG_HPP_
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
|
||||||
// defintions
|
|
||||||
#define CFG_JSON_BUFSIZE 3192
|
#define CFG_JSON_BUFSIZE 3192
|
||||||
|
|
||||||
#define CFG_APPNAME "GravityMon " // Name of firmware
|
#define CFG_APPNAME "GravityMon " // Name of firmware
|
||||||
@ -43,7 +37,6 @@ SOFTWARE.
|
|||||||
#define WIFI_PORTAL_TIMEOUT \
|
#define WIFI_PORTAL_TIMEOUT \
|
||||||
120 // Number of seconds until the config portal is closed
|
120 // Number of seconds until the config portal is closed
|
||||||
|
|
||||||
// These are used in API + Savefile
|
|
||||||
#define CFG_PARAM_ID "id"
|
#define CFG_PARAM_ID "id"
|
||||||
#define CFG_PARAM_MDNS "mdns" // Device name
|
#define CFG_PARAM_MDNS "mdns" // Device name
|
||||||
#define CFG_PARAM_OTA "ota-url"
|
#define CFG_PARAM_OTA "ota-url"
|
||||||
@ -79,7 +72,6 @@ SOFTWARE.
|
|||||||
#define CFG_PARAM_FORMULA_DATA \
|
#define CFG_PARAM_FORMULA_DATA \
|
||||||
"formula-calculation-data" // Raw data for the formula calculation
|
"formula-calculation-data" // Raw data for the formula calculation
|
||||||
|
|
||||||
// These are used in API's
|
|
||||||
#define CFG_PARAM_APP_NAME "app-name"
|
#define CFG_PARAM_APP_NAME "app-name"
|
||||||
#define CFG_PARAM_APP_VER "app-ver"
|
#define CFG_PARAM_APP_VER "app-ver"
|
||||||
#define CFG_PARAM_ANGLE "angle"
|
#define CFG_PARAM_ANGLE "angle"
|
||||||
@ -110,7 +102,6 @@ struct RawFormulaData {
|
|||||||
double g[5];
|
double g[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Main configuration class
|
|
||||||
class Config {
|
class Config {
|
||||||
private:
|
private:
|
||||||
bool _saveNeeded;
|
bool _saveNeeded;
|
||||||
@ -348,7 +339,6 @@ class Config {
|
|||||||
void setSaveNeeded() { _saveNeeded = true; }
|
void setSaveNeeded() { _saveNeeded = true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
|
||||||
extern Config myConfig;
|
extern Config myConfig;
|
||||||
|
|
||||||
#endif // SRC_CONFIG_HPP_
|
#endif // SRC_CONFIG_HPP_
|
||||||
|
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
GyroSensor myGyro;
|
GyroSensor myGyro;
|
||||||
MPU6050 accelgyro;
|
MPU6050 accelgyro;
|
||||||
@ -260,7 +260,8 @@ bool GyroSensor::read() {
|
|||||||
|
|
||||||
// The first read value is close to the DS18 value according to my tests, if
|
// The first read value is close to the DS18 value according to my tests, if
|
||||||
// more reads are done then the gyro temp will increase to much
|
// more reads are done then the gyro temp will increase to much
|
||||||
if (_initialSensorTemp == INVALID_TEMPERATURE) _initialSensorTemp = _sensorTemp;
|
if (_initialSensorTemp == INVALID_TEMPERATURE)
|
||||||
|
_initialSensorTemp = _sensorTemp;
|
||||||
|
|
||||||
return _validValue;
|
return _validValue;
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,10 @@ SOFTWARE.
|
|||||||
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
||||||
// #define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_SBWIRE
|
// #define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_SBWIRE
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <MPU6050.h>
|
#include <MPU6050.h>
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
|
|
||||||
// Classes
|
|
||||||
struct RawGyroDataL { // Used for average multiple readings
|
struct RawGyroDataL { // Used for average multiple readings
|
||||||
int32_t ax; // Raw Acceleration
|
int32_t ax; // Raw Acceleration
|
||||||
int32_t ay;
|
int32_t ay;
|
||||||
@ -80,7 +77,6 @@ class GyroSensor {
|
|||||||
void enterSleep();
|
void enterSleep();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
|
||||||
extern GyroSensor myGyro;
|
extern GyroSensor myGyro;
|
||||||
|
|
||||||
#endif // SRC_GYRO_HPP_
|
#endif // SRC_GYRO_HPP_
|
||||||
|
@ -24,8 +24,10 @@ SOFTWARE.
|
|||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
#define SRC_HELPER_HPP_
|
#define SRC_HELPER_HPP_
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
#include <ArduinoLog.h>
|
#include <main.hpp>
|
||||||
|
|
||||||
// Sleep mode
|
// Sleep mode
|
||||||
void deepSleep(int t);
|
void deepSleep(int t);
|
||||||
|
@ -21,12 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <LittleFS.h>
|
|
||||||
|
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <pushtarget.hpp>
|
#include <pushtarget.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <webserver.hpp>
|
#include <webserver.hpp>
|
||||||
|
33
src/main.hpp
Normal file
33
src/main.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021-22 Magnus
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef SRC_MAIN_HPP_
|
||||||
|
#define SRC_MAIN_HPP_
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <ArduinoLog.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#endif // SRC_MAIN_HPP_
|
@ -25,7 +25,8 @@ SOFTWARE.
|
|||||||
#include <MQTT.h>
|
#include <MQTT.h>
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <pushtarget.hpp>
|
#include <pushtarget.hpp>
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
|
@ -24,13 +24,6 @@ SOFTWARE.
|
|||||||
#ifndef SRC_PUSHTARGET_HPP_
|
#ifndef SRC_PUSHTARGET_HPP_
|
||||||
#define SRC_PUSHTARGET_HPP_
|
#define SRC_PUSHTARGET_HPP_
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
|
|
||||||
#include <helper.hpp>
|
|
||||||
|
|
||||||
// Classes
|
|
||||||
class PushTarget {
|
class PushTarget {
|
||||||
private:
|
private:
|
||||||
uint32_t _ms; // Used to check that we do not post to often
|
uint32_t _ms; // Used to check that we do not post to often
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <main.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
|
|
||||||
OneWire myOneWire(D6);
|
OneWire myOneWire(D6);
|
||||||
|
@ -24,9 +24,6 @@ SOFTWARE.
|
|||||||
#ifndef SRC_TEMPSENSOR_HPP_
|
#ifndef SRC_TEMPSENSOR_HPP_
|
||||||
#define SRC_TEMPSENSOR_HPP_
|
#define SRC_TEMPSENSOR_HPP_
|
||||||
|
|
||||||
// definitions
|
|
||||||
|
|
||||||
// classes
|
|
||||||
class TempSensor {
|
class TempSensor {
|
||||||
private:
|
private:
|
||||||
bool _hasSensor = false;
|
bool _hasSensor = false;
|
||||||
@ -41,7 +38,6 @@ class TempSensor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
|
||||||
extern TempSensor myTempSensor;
|
extern TempSensor myTempSensor;
|
||||||
|
|
||||||
#endif // SRC_TEMPSENSOR_HPP_
|
#endif // SRC_TEMPSENSOR_HPP_
|
||||||
|
@ -21,15 +21,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <LittleFS.h>
|
|
||||||
|
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <webserver.hpp>
|
#include <webserver.hpp>
|
||||||
|
#include <wifi.hpp>
|
||||||
|
|
||||||
WebServer myWebServer; // My wrapper class fr webserver functions
|
WebServer myWebServer; // My wrapper class fr webserver functions
|
||||||
extern bool sleepModeActive;
|
extern bool sleepModeActive;
|
||||||
@ -350,7 +349,8 @@ void WebServer::webHandleConfigPush() {
|
|||||||
|
|
||||||
myConfig.setHttpPushUrl(_server->arg(CFG_PARAM_PUSH_HTTP).c_str());
|
myConfig.setHttpPushUrl(_server->arg(CFG_PARAM_PUSH_HTTP).c_str());
|
||||||
myConfig.setHttpPushUrl2(_server->arg(CFG_PARAM_PUSH_HTTP2).c_str());
|
myConfig.setHttpPushUrl2(_server->arg(CFG_PARAM_PUSH_HTTP2).c_str());
|
||||||
myConfig.setBrewfatherPushUrl(_server->arg(CFG_PARAM_PUSH_BREWFATHER).c_str());
|
myConfig.setBrewfatherPushUrl(
|
||||||
|
_server->arg(CFG_PARAM_PUSH_BREWFATHER).c_str());
|
||||||
myConfig.setInfluxDb2PushUrl(_server->arg(CFG_PARAM_PUSH_INFLUXDB2).c_str());
|
myConfig.setInfluxDb2PushUrl(_server->arg(CFG_PARAM_PUSH_INFLUXDB2).c_str());
|
||||||
myConfig.setInfluxDb2PushOrg(
|
myConfig.setInfluxDb2PushOrg(
|
||||||
_server->arg(CFG_PARAM_PUSH_INFLUXDB2_ORG).c_str());
|
_server->arg(CFG_PARAM_PUSH_INFLUXDB2_ORG).c_str());
|
||||||
|
@ -24,13 +24,11 @@ SOFTWARE.
|
|||||||
#ifndef SRC_WEBSERVER_HPP_
|
#ifndef SRC_WEBSERVER_HPP_
|
||||||
#define SRC_WEBSERVER_HPP_
|
#define SRC_WEBSERVER_HPP_
|
||||||
|
|
||||||
// Include
|
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#include <incbin.h>
|
#include <incbin.h>
|
||||||
|
|
||||||
// Binary resouces
|
|
||||||
#if defined(EMBED_HTML)
|
#if defined(EMBED_HTML)
|
||||||
INCBIN_EXTERN(IndexHtm);
|
INCBIN_EXTERN(IndexHtm);
|
||||||
INCBIN_EXTERN(DeviceHtm);
|
INCBIN_EXTERN(DeviceHtm);
|
||||||
@ -41,7 +39,6 @@ INCBIN_EXTERN(AboutHtm);
|
|||||||
INCBIN_EXTERN(UploadHtm);
|
INCBIN_EXTERN(UploadHtm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// classes
|
|
||||||
class WebServer {
|
class WebServer {
|
||||||
private:
|
private:
|
||||||
ESP8266WebServer* _server = 0;
|
ESP8266WebServer* _server = 0;
|
||||||
@ -71,7 +68,8 @@ class WebServer {
|
|||||||
void webReturnOK() { _server->send(200); }
|
void webReturnOK() { _server->send(200); }
|
||||||
#if defined(EMBED_HTML)
|
#if defined(EMBED_HTML)
|
||||||
void webReturnIndexHtm() {
|
void webReturnIndexHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gIndexHtmData, gIndexHtmSize);
|
_server->send_P(200, "text/html", (const char*)gIndexHtmData,
|
||||||
|
gIndexHtmSize);
|
||||||
}
|
}
|
||||||
void webReturnDeviceHtm() {
|
void webReturnDeviceHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gDeviceHtmData,
|
_server->send_P(200, "text/html", (const char*)gDeviceHtmData,
|
||||||
@ -86,7 +84,8 @@ class WebServer {
|
|||||||
gCalibrationHtmSize);
|
gCalibrationHtmSize);
|
||||||
}
|
}
|
||||||
void webReturnAboutHtm() {
|
void webReturnAboutHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gAboutHtmData, gAboutHtmSize);
|
_server->send_P(200, "text/html", (const char*)gAboutHtmData,
|
||||||
|
gAboutHtmSize);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void webReturnUploadHtm() {
|
void webReturnUploadHtm() {
|
||||||
|
@ -26,12 +26,8 @@ SOFTWARE.
|
|||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <incbin.h>
|
#include <incbin.h>
|
||||||
|
|
||||||
#include <ArduinoJson.hpp>
|
|
||||||
#include <calc.hpp>
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <main.hpp>
|
||||||
#include <helper.hpp>
|
|
||||||
#include <tempsensor.hpp>
|
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
// Settings for DRD
|
// Settings for DRD
|
||||||
|
@ -24,8 +24,6 @@ SOFTWARE.
|
|||||||
#ifndef SRC_WIFI_HPP_
|
#ifndef SRC_WIFI_HPP_
|
||||||
#define SRC_WIFI_HPP_
|
#define SRC_WIFI_HPP_
|
||||||
|
|
||||||
// Include
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
// tcp cleanup, to avoid memory crash.
|
// tcp cleanup, to avoid memory crash.
|
||||||
@ -33,7 +31,6 @@ struct tcp_pcb;
|
|||||||
extern struct tcp_pcb* tcp_tw_pcbs;
|
extern struct tcp_pcb* tcp_tw_pcbs;
|
||||||
extern "C" void tcp_abort(struct tcp_pcb* pcb);
|
extern "C" void tcp_abort(struct tcp_pcb* pcb);
|
||||||
|
|
||||||
// classes
|
|
||||||
class WifiConnection {
|
class WifiConnection {
|
||||||
private:
|
private:
|
||||||
// WIFI
|
// WIFI
|
||||||
|
Loading…
Reference in New Issue
Block a user