Moving defines to .ini
This commit is contained in:
parent
088a37eaf3
commit
f8e5957045
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,6 @@
|
|||||||
docs/*
|
docs/*
|
||||||
test/*.md
|
test/*.md
|
||||||
test/env/*
|
test/env/*
|
||||||
test/*.py
|
test/configure_*.py
|
||||||
TODO.md
|
TODO.md
|
||||||
data/*.min.htm
|
data/*.min.htm
|
@ -100,7 +100,7 @@
|
|||||||
$('#spinner').show();
|
$('#spinner').show();
|
||||||
$.getJSON(url, function (cfg) {
|
$.getJSON(url, function (cfg) {
|
||||||
console.log( cfg );
|
console.log( cfg );
|
||||||
$("#app-ver").text(cfg["app-ver"] + " (html 0.4.0)");
|
$("#app-ver").text(cfg["app-ver"] + " (html 0.4.9)");
|
||||||
$("#mdns").text(cfg["mdns"]);
|
$("#mdns").text(cfg["mdns"]);
|
||||||
$("#id").text(cfg["id"]);
|
$("#id").text(cfg["id"]);
|
||||||
})
|
})
|
||||||
|
@ -32,6 +32,12 @@ build_flags =
|
|||||||
#-D DEBUG_ESP_CORE
|
#-D DEBUG_ESP_CORE
|
||||||
#-D SKIP_SLEEPMODE
|
#-D SKIP_SLEEPMODE
|
||||||
#-D DOUBLERESETDETECTOR_DEBUG true
|
#-D DOUBLERESETDETECTOR_DEBUG true
|
||||||
|
-D CFG_DISABLE_LOGGING # Turn off verbose logging for some of the parts (too much will cause a crash) but also add space
|
||||||
|
-D GYRO_DISABLE_LOGGING
|
||||||
|
-D PUSH_DISABLE_LOGGING
|
||||||
|
-D TSEN_DISABLE_LOGGING
|
||||||
|
-D WEB_DISABLE_LOGGING
|
||||||
|
-D MAIN_DISABLE_LOGGING
|
||||||
-D USE_LITTLEFS=true
|
-D USE_LITTLEFS=true
|
||||||
-D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded)
|
-D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded)
|
||||||
-D USER_SSID=\""\"" # =\""myssid\""
|
-D USER_SSID=\""\"" # =\""myssid\""
|
||||||
|
@ -25,8 +25,6 @@ SOFTWARE.
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
|
||||||
#define CFG_DISABLE_LOGGING
|
|
||||||
|
|
||||||
Config myConfig;
|
Config myConfig;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -24,8 +24,6 @@ SOFTWARE.
|
|||||||
#include "gyro.h"
|
#include "gyro.h"
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
#define GYRO_DISABLE_LOGGING
|
|
||||||
|
|
||||||
GyroSensor myGyro;
|
GyroSensor myGyro;
|
||||||
|
|
||||||
#define GYRO_USE_INTERRUPT // Use interrupt to detect when new sample is ready
|
#define GYRO_USE_INTERRUPT // Use interrupt to detect when new sample is ready
|
||||||
@ -245,7 +243,7 @@ bool GyroSensor::read() {
|
|||||||
validValue = true;
|
validValue = true;
|
||||||
angle = calculateAngle( lastGyroData );
|
angle = calculateAngle( lastGyroData );
|
||||||
#if !defined( GYRO_DISABLE_LOGGING )
|
#if !defined( GYRO_DISABLE_LOGGING )
|
||||||
Log.notice(F("GYRO: Sensor values %d,%d,%d\t%F" CR), raw.ax, raw.ay, raw.az, angle );
|
Log.notice(F("GYRO: Sensor values %d,%d,%d\t%F" CR), lastGyroData.ax, lastGyroData.ay, lastGyroData.az, angle );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,6 @@ SOFTWARE.
|
|||||||
#include "pushtarget.h"
|
#include "pushtarget.h"
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
|
||||||
#define MAIN_DISABLE_LOGGING
|
|
||||||
|
|
||||||
// Settings for double reset detector.
|
// Settings for double reset detector.
|
||||||
#define ESP8266_DRD_USE_RTC true
|
#define ESP8266_DRD_USE_RTC true
|
||||||
#define DRD_TIMEOUT 2
|
#define DRD_TIMEOUT 2
|
||||||
@ -85,9 +83,7 @@ void checkSleepMode( float angle, float volt ) {
|
|||||||
|
|
||||||
// sleep mode active when flat
|
// sleep mode active when flat
|
||||||
//sleepModeActive = ( angle<85 && angle>5 ) ? true : false;
|
//sleepModeActive = ( angle<85 && angle>5 ) ? true : false;
|
||||||
#if LOG_LEVEL==6 && !defined( MAIN_DISABLE_LOGGING )
|
Log.notice(F("MAIN: Deep sleep mode %s (angle=%F volt=%F)." CR), sleepModeActive ? "true":"false", angle, volt );
|
||||||
Log.verbose(F("MAIN: Deep sleep mode %s (angle=%F volt=%F)." CR), sleepModeActive ? "true":"false", angle, volt );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -25,8 +25,6 @@ SOFTWARE.
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gyro.h" // For testing the tempsensor in the gyro
|
#include "gyro.h" // For testing the tempsensor in the gyro
|
||||||
|
|
||||||
#define PUSH_DISABLE_LOGGING
|
|
||||||
|
|
||||||
PushTarget myPushTarget;
|
PushTarget myPushTarget;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -29,8 +29,6 @@ SOFTWARE.
|
|||||||
#include <DallasTemperature.h>
|
#include <DallasTemperature.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#define TSEN_DISABLE_LOGGING
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Conversion between C and F
|
// Conversion between C and F
|
||||||
//
|
//
|
||||||
|
@ -30,8 +30,6 @@ SOFTWARE.
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
|
||||||
#define WEB_DISABLE_LOGGING
|
|
||||||
|
|
||||||
WebServer myWebServer; // My wrapper class fr webserver functions
|
WebServer myWebServer; // My wrapper class fr webserver functions
|
||||||
extern bool sleepModeActive;
|
extern bool sleepModeActive;
|
||||||
extern bool sleepModeAlwaysSkip;
|
extern bool sleepModeAlwaysSkip;
|
||||||
|
@ -53,7 +53,7 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
showPortal = true;
|
showPortal = true;
|
||||||
} else {
|
} else {
|
||||||
//Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), myConfig.getWifiPass() );
|
//Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), myConfig.getWifiPass() );
|
||||||
Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), "*****" );
|
//Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), "*****" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( strlen(userSSID)==0 && showPortal ) {
|
if( strlen(userSSID)==0 && showPortal ) {
|
||||||
@ -82,13 +82,13 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
// Connect to wifi
|
// Connect to wifi
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
Log.notice(F("WIFI: Connecting to WIFI, mode=%d,persistent=%d,fhy=%d ." CR), WiFi.getMode(), WiFi.getPersistent(), WiFi.getPhyMode() );
|
//Log.notice(F("WIFI: Connecting to WIFI, mode=%d,persistent=%d,fhy=%d ." CR), WiFi.getMode(), WiFi.getPersistent(), WiFi.getPhyMode() );
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
if( strlen(userSSID) ) {
|
if( strlen(userSSID) ) {
|
||||||
Log.notice(F("WIFI: Connecting to wifi using predefined settings %s." CR), userSSID);
|
Log.notice(F("WIFI: Connecting to wifi using hardcoded settings %s." CR), userSSID);
|
||||||
WiFi.begin( userSSID, userPWD );
|
WiFi.begin( userSSID, userPWD );
|
||||||
} else {
|
} else {
|
||||||
Log.notice(F("WIFI: Connecting to wifi using stored settings. %s." CR), myConfig.getWifiSSID());
|
Log.notice(F("WIFI: Connecting to wifi using stored settings %s." CR), myConfig.getWifiSSID());
|
||||||
WiFi.begin(myConfig.getWifiSSID(), myConfig.getWifiPass());
|
WiFi.begin(myConfig.getWifiSSID(), myConfig.getWifiPass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
81
test/configure.py
Normal file
81
test/configure.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
host = "192.168.1.1" # IP adress (or name) of the device to send these settings to
|
||||||
|
id = "ee1bfc" # Device ID (shown in serial console during startup or in UI)
|
||||||
|
|
||||||
|
def set_config( url, json ):
|
||||||
|
headers = { "ContentType": "application/json" }
|
||||||
|
print( url )
|
||||||
|
#print( json )
|
||||||
|
resp = requests.post( url, headers=headers, data=json )
|
||||||
|
if resp.status_code != 200 :
|
||||||
|
print ( "Failed " )
|
||||||
|
else :
|
||||||
|
print ( "Success " )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure the device settings.
|
||||||
|
#
|
||||||
|
url = "http://" + host + "/api/config/device"
|
||||||
|
json = { "id": id,
|
||||||
|
"mdns": "gravmon", # Name of the device
|
||||||
|
"temp-format": "C", # Temperature format C or F
|
||||||
|
"sleep-interval": 30 # Sleep interval in seconds
|
||||||
|
}
|
||||||
|
set_config( url, json )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure the push settings. Blank means that its no used.
|
||||||
|
#
|
||||||
|
url = "http://" + host + "/api/config/push"
|
||||||
|
json = { "id": id,
|
||||||
|
"http-push": "http://192.168.1.1/ispindel", # HTTP endpoint
|
||||||
|
"http-push2": "", # HTTP endpoint2
|
||||||
|
"brewfather-push": "", # Brewfather URL
|
||||||
|
"influxdb2-push": "", # InfluxDB2 settings
|
||||||
|
"influxdb2-org": "",
|
||||||
|
"influxdb2-bucket": "",
|
||||||
|
"influxdb2-auth": ""
|
||||||
|
}
|
||||||
|
set_config( url, json )
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure the gravity settings.
|
||||||
|
#
|
||||||
|
url = "http://" + host + "/api/config/gravity"
|
||||||
|
json = { "id": id,
|
||||||
|
"gravity-formula": "", # If you want to set the gravity formula
|
||||||
|
"gravity-temp-adjustment": "off" # on or off
|
||||||
|
}
|
||||||
|
set_config( url, json )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure the hardware settings.
|
||||||
|
#
|
||||||
|
url = "http://" + host + "/api/config/hardware"
|
||||||
|
json = { "id": id,
|
||||||
|
"voltage-factor": 1.59, # Default value for voltage calculation
|
||||||
|
"temp-adjustment": 0, # If temp sensor needs to be corrected
|
||||||
|
"ota-url": "" # if the device should seach for a new update when active
|
||||||
|
}
|
||||||
|
set_config( url, json )
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure the gravity formula settings. If this is called the formula will be updated based on these measurements (zero angle values will be ignored)
|
||||||
|
#
|
||||||
|
url = "http://" + host + "/api/formula"
|
||||||
|
json = { "id": id,
|
||||||
|
"a1": 22.4,
|
||||||
|
"a2": 54.4,
|
||||||
|
"a3": 58,
|
||||||
|
"a4": 0,
|
||||||
|
"a5": 0,
|
||||||
|
"g1": 1.000,
|
||||||
|
"g2": 1.053,
|
||||||
|
"g3": 1.062,
|
||||||
|
"g4": 1,
|
||||||
|
"g5": 1
|
||||||
|
}
|
||||||
|
set_config( url, json )
|
Loading…
Reference in New Issue
Block a user