Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 1.1 #206

Merged
merged 46 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
df792cc
Updated docs and increased formula points removed unused code
mp-se Oct 18, 2024
1654c73
GitHub Action Build
mp-se Oct 18, 2024
34dc200
Formula creator docs
mp-se Oct 21, 2024
fac236a
Adding status for gyro moving
mp-se Nov 24, 2024
cb72c0b
Update docs
mp-se Nov 24, 2024
6da7c24
Added flag for gyro moving in status
mp-se Dec 17, 2024
b553639
Update docs
mp-se Dec 17, 2024
b5fcacf
Update build deps
mp-se Dec 17, 2024
fe92ddd
GitHub Action Build
mp-se Dec 17, 2024
84288c7
Update docs
mp-se Dec 18, 2024
f90e151
Force new build
mp-se Dec 18, 2024
38b6ea7
GitHub Action Build
mp-se Dec 18, 2024
d44e2d6
Update release notes and fix ui bug
mp-se Dec 19, 2024
cab987f
GitHub Action Build
mp-se Dec 19, 2024
e5c3155
Disable retain flag for mqtt in framework
mp-se Dec 20, 2024
dbf59a2
Fix testcase
mp-se Dec 22, 2024
1ff517e
Updating history to log gravity and sleep time
mp-se Dec 22, 2024
40129d5
Remove mqtt retain flag
mp-se Dec 22, 2024
970ef97
Adjust code to match new espfwk
mp-se Dec 22, 2024
11e6a22
Update runtime logging to include gravity and sleep time
mp-se Dec 22, 2024
82a9182
Update unit tests
mp-se Dec 22, 2024
8493d39
Use latest espfwk
mp-se Dec 22, 2024
cce97ed
Force build
mp-se Dec 22, 2024
62a1155
GitHub Action Build
mp-se Dec 22, 2024
777aa34
Read history log at startup only, does not change when in config mode.
mp-se Dec 23, 2024
b16192c
Checking skipSSL flag in push
mp-se Dec 23, 2024
ba00074
Only add to runtimelog when in gravitymode
mp-se Dec 23, 2024
3af12d5
Update frameworks, espfwk, json and async webserver
mp-se Dec 23, 2024
f86c698
Update build for esp32lite
mp-se Dec 23, 2024
f24dba5
GitHub Action Build
mp-se Dec 23, 2024
3874d02
Remove arduino patch for s3 mini
mp-se Dec 26, 2024
f74c6de
Update dependecies
mp-se Dec 26, 2024
ada5aed
Migrate to BLE library 2.x
mp-se Dec 26, 2024
8e9b93d
Update to ble 2.x and precommit fixes
mp-se Dec 26, 2024
6bc3ed1
Fix json 7
mp-se Dec 26, 2024
acb2d63
Update dependecies
mp-se Dec 26, 2024
4efdc83
Fix json and ble bugs
mp-se Dec 26, 2024
3437bdb
Add schetch space
mp-se Dec 26, 2024
f4486d5
GitHub Action Build
mp-se Dec 26, 2024
e7e3c05
Update dependecy
mp-se Dec 28, 2024
e915236
Update build
mp-se Dec 28, 2024
a9742ac
GitHub Action Build
mp-se Dec 28, 2024
387dee1
Update release notes
mp-se Dec 31, 2024
5597e27
Bump to release version
mp-se Jan 13, 2025
87bf38f
Fix default value for formula deviation
mp-se Jan 13, 2025
1a96299
GitHub Action Build
mp-se Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/firmware.bin
Binary file not shown.
Binary file modified bin/firmware32.bin
Binary file not shown.
Binary file modified bin/firmware32c3.bin
Binary file not shown.
Binary file modified bin/firmware32lite.bin
Binary file not shown.
Binary file modified bin/firmware32s2.bin
Binary file not shown.
Binary file modified bin/firmware32s3.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "project":"gravmon", "version":"2.0.1", "html": [ ] }
{ "project":"gravmon", "version":"2.1.0", "html": [ ] }
Binary file modified html/app.js.gz
Binary file not shown.
69 changes: 0 additions & 69 deletions patch/arduino/variants/lolin_s3_mini/pins_arduino.h

This file was deleted.

51 changes: 29 additions & 22 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ lib_dir = lib
include_dir = lib

[common_env_data]
upload_speed = 921600
; upload_speed = 921600
upload_speed = 460800
monitor_speed = 115200
platform = [email protected]
platform32 = espressif32@6.6.0
platform32 = espressif32@6.9.0
build_unflags =
build_flags =
-Wl,-Map,output.map
Expand All @@ -25,26 +26,27 @@ build_flags =
#-D FORCE_GRAVITY_MODE
#-D COLLECT_PERFDATA
-D USE_LITTLEFS=true
-D CFG_APPVER="\"2.0.1\""
#-D CFG_GITREV=\""beta-3\""
-D CFG_APPVER="\"2.1.0\""
; -D CFG_GITREV=\""beta-3\""
#-D ENABLE_REMOTE_UI_DEVELOPMENT
!python script/git_rev.py
-D MAX_SKETCH_SPACE=0x1c0000
lib_deps =
# Using local copy of these libraries
# https://github.com/mp-se/i2cdevlib.git#<document>
# https://github.com/mp-se/OneWire
# https://github.com/mp-se/Arduino-Temperature-Control-Library
https://github.com/mp-se/tinyexpr#v1.0.0
https://github.com/mp-se/Arduino-Log#1.1.2
https://github.com/mp-se/ArduinoJson#v6.21.5
https://github.com/mp-se/arduinoCurveFitting#v1.0.6
https://github.com/mp-se/arduino-mqtt#v2.5.2
https://github.com/mp-se/ESPAsyncWebServer#0.1.1
https://github.com/mp-se/ESPAsyncTCP#0.1.0
https://github.com/mp-se/espframework#1.0.7
https://github.com/mp-se/OneWireNg#0.13.3
https://github.com/bblanchon/ArduinoJson#v7.2.1
https://github.com/256dpi/arduino-mqtt#v2.5.2
https://github.com/mp-se/espframework#1.1.2
https://github.com/pstolarz/OneWireNg#0.13.3
https://github.com/mathieucarbou/ESPAsyncWebServer#v3.4.5
lib_deps8266 =
https://github.com/esphome/ESPAsyncTCP#v2.0.0
lib_deps32 =
https://github.com/mp-se/NimBLE-Arduino#1.4.1
https://github.com/mathieucarbou/AsyncTCP#v3.3.1
lib_ble32 =
https://github.com/h2zero/NimBLE-Arduino#2.1.1
extra_scripts =
script/copy_firmware.py
script/create_versionjson.py
Expand All @@ -64,12 +66,12 @@ build_unflags = ${common_env_data.build_unflags}
build_flags =
${common_env_data.build_flags}
-D LOG_LEVEL=5
-D DISABLE_LED
-D ESPFWK_DISABLE_LED
#-D USE_SERIAL_PINS # Use the TX/RX pins for the serial port
#-D RUN_HARDWARE_TEST # Will run diagnositc setup to validate the GPIO configurations
lib_deps =
https://github.com/mp-se/incbin#v1.0.0
${common_env_data.lib_deps}
${common_env_data.lib_deps8266}
board = d1_mini
build_type = release
board_build.filesystem = littlefs
Expand All @@ -87,9 +89,9 @@ build_flags =
${common_env_data.build_flags}
-D LOG_LEVEL=5
lib_deps =
https://github.com/mp-se/incbin#v1.0.0
https://github.com/bxparks/AUnit#v1.7.1
${common_env_data.lib_deps}
${common_env_data.lib_deps8266}
ESP8266httpUpdate
DNSServer
board = d1_mini
Expand All @@ -116,6 +118,7 @@ build_flags =
lib_deps =
${common_env_data.lib_deps}
${common_env_data.lib_deps32}
${common_env_data.lib_ble32}
lib_ignore =
board = wemos_d1_mini32
build_type = release
Expand All @@ -138,12 +141,13 @@ build_flags =
#-D CORE_DEBUG_LEVEL=6
-D ESP32C3
-D ARDUINO_ESP32C3_DEV
-D DISABLE_LED
-D ESPFWK_DISABLE_LED
#-D ARDUINO_USB_CDC_ON_BOOT=1
#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps =
${common_env_data.lib_deps}
${common_env_data.lib_deps32}
${common_env_data.lib_deps32}
${common_env_data.lib_ble32}
lib_ignore =
board = lolin_c3_mini
build_type = release
Expand Down Expand Up @@ -171,6 +175,7 @@ build_flags =
#-D RUN_HARDWARE_TEST # Will run diagnositc setup to validate the GPIO configurations
lib_deps =
${common_env_data.lib_deps}
${common_env_data.lib_deps32}
lib_ignore =
board = lolin_s2_mini
build_type = release
Expand All @@ -184,7 +189,7 @@ platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
extra_scripts =
pre:script/patch_arduino.py
; pre:script/patch_arduino.py
${common_env_data.extra_scripts}
build_unflags =
${common_env_data.build_unflags}
Expand All @@ -195,12 +200,13 @@ build_flags =
-D CORE_DEBUG_LEVEL=2
-D ESP32S3
-D ARDUINO_ESP32S3_DEV
#-D ARDUINO_USB_CDC_ON_BOOT=1
-D ARDUINO_USB_CDC_ON_BOOT=1
#-D USE_SERIAL_PINS # Use the TX/RX pins for the serial port
#-D RUN_HARDWARE_TEST # Will run diagnositc setup to validate the GPIO configurations
lib_deps =
${common_env_data.lib_deps}
${common_env_data.lib_deps32}
${common_env_data.lib_deps32}
${common_env_data.lib_ble32}
lib_ignore =
board = lolin_s3_mini
build_type = release
Expand Down Expand Up @@ -228,6 +234,7 @@ build_flags =
lib_deps =
${common_env_data.lib_deps}
${common_env_data.lib_deps32}
${common_env_data.lib_ble32}
lib_ignore =
board = lolin32_lite
build_type = release
Expand Down
20 changes: 10 additions & 10 deletions script/patch_arduino.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Import("env")
import shutil
# Import("env")
# import shutil

framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif32")
name = env.get( "PIOENV" )#print(FRAMEWORK_DIR)
dir = env.GetLaunchDir()
# framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif32")
# name = env.get( "PIOENV" )#print(FRAMEWORK_DIR)
# dir = env.GetLaunchDir()

if name == "gravity32s3-release" :
source = dir + "/patch/arduino/variants/lolin_s3_mini/pins_arduino.h"
target = framework_dir + "/variants/lolin_s3_mini/pins_arduino.h"
print( "Copy file : " + source + " -> " + target )
shutil.copyfile( source, target )
# if name == "gravity32s3-release" :
# source = dir + "/patch/arduino/variants/lolin_s3_mini/pins_arduino.h"
# target = framework_dir + "/variants/lolin_s3_mini/pins_arduino.h"
# print( "Copy file : " + source + " -> " + target )
# shutil.copyfile( source, target )
11 changes: 8 additions & 3 deletions src/ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ void BleSender::sendTiltData(String& color, float tempF, float gravSG,

BLEAdvertisementData advData = BLEAdvertisementData();
advData.setFlags(0x04);
advData.setManufacturerData(beacon.getData());
const NimBLEBeacon::BeaconData& beaconData = beacon.getData();
// advData.setManufacturerData(beacon.getData());
advData.setManufacturerData(
std::string(reinterpret_cast<const char*>(&beaconData), sizeof(beaconData)));

_advertising->setAdvertisementData(advData);
_advertising->setAdvertisementType(BLE_GAP_CONN_MODE_NON);
// _advertising->setAdvertisementType(BLE_GAP_CONN_MODE_NON);
_advertising->setConnectableMode(BLE_GAP_CONN_MODE_NON);

_advertising->start();
delay(_beaconTime);
Expand Down Expand Up @@ -194,7 +198,8 @@ void BleSender::sendCustomBeaconData(float battery, float tempC, float gravity,
advData.setManufacturerData(mf);
_advertising->setAdvertisementData(advData);

_advertising->setAdvertisementType(BLE_GAP_CONN_MODE_NON);
// _advertising->setAdvertisementType(BLE_GAP_CONN_MODE_NON);
_advertising->setConnectableMode(BLE_GAP_CONN_MODE_NON);
_advertising->start();
delay(_beaconTime);
_advertising->stop();
Expand Down
90 changes: 1 addition & 89 deletions src/calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,101 +21,13 @@ 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.
*/
#include <curveFitting.h>
#include <tinyexpr.h>

#include <calc.hpp>
#include <cstdio>
#include <log.hpp>
#include <utils.hpp>

int createFormula(RawFormulaData &fd, char *formulaBuffer,
int formulaBufferSize, int order) {
int noAngles = 0;
RawFormulaData fd2;

// Check how many valid values we have got and make sure we have a full
// series.
for (int i = 0; i < FORMULA_DATA_SIZE; i++) {
if (fd.a[i]) {
fd2.a[noAngles] = fd.a[i];
fd2.g[noAngles] = fd.g[i];
noAngles++;
}
}

#if LOG_LEVEL == 6
Log.verbose(
F("CALC: Trying to create formula using order = %d, found %d angles" CR),
order, noAngles);
#endif

if (noAngles < 3) {
writeErrorLog("CALC: Not enough values for deriving formula");
return ERR_FORMULA_NOTENOUGHVALUES;
} else {
double coeffs[order + 1];
int ret = fitCurve(order, noAngles, fd2.a, fd2.g,
sizeof(coeffs) / sizeof(double), coeffs);

// Returned value is 0 if no error
if (ret == 0) {
#if LOG_LEVEL == 6
Log.verbose(F("CALC: Finshied processing data points, order = %d." CR),
order);
#endif

// Print the formula based on 'order'
if (order == 4) {
snprintf(formulaBuffer, formulaBufferSize,
"%.8f*tilt^4+%.8f*tilt^3+%.8f*tilt^2+%.8f*tilt+%.8f",
coeffs[0], coeffs[1], coeffs[2], coeffs[3], coeffs[4]);
} else if (order == 3) {
snprintf(formulaBuffer, formulaBufferSize,
"%.8f*tilt^3+%.8f*tilt^2+%.8f*tilt+%.8f", coeffs[0], coeffs[1],
coeffs[2], coeffs[3]);
} else if (order == 2) {
snprintf(formulaBuffer, formulaBufferSize, "%.8f*tilt^2+%.8f*tilt+%.8f",
coeffs[0], coeffs[1], coeffs[2]);
} else { // order == 1
snprintf(formulaBuffer, formulaBufferSize, "%.8f*tilt+%.8f", coeffs[0],
coeffs[1]);
}

#if LOG_LEVEL == 6
Log.verbose(F("CALC: Formula: %s" CR), formulaBuffer);
#endif

bool valid = true;

for (int i = 0; i < 5; i++) {
if (fd.a[i] == 0 && valid) break;

double g = calculateGravity(fd.a[i], 0, formulaBuffer);
double dev = (g - fd.g[i]) < 0 ? (fd.g[i] - g) : (g - fd.g[i]);

// If the deviation is more than 2 degress we mark it as failed.
if (dev * 1000 > myConfig.getMaxFormulaCreationDeviation()) {
writeErrorLog(
"CALC: Validation failed on angle %.2f, deviation too large %.4f "
"SG, formula order %d",
fd.a[i], dev * 1000, order);
valid = false;
}
}

if (!valid) {
return ERR_FORMULA_UNABLETOFFIND;
}

Log.info(F("CALC: Found formula '%s'." CR), formulaBuffer);
return 0;
}
}

writeErrorLog("CALC: Internal error finding formula.");
return ERR_FORMULA_INTERNAL;
}

double calculateGravity(double angle, double temp, const char *tempFormula) {
const char *formula = myConfig.getGravityFormula();

Expand Down
6 changes: 0 additions & 6 deletions src/calc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ SOFTWARE.

#include <config.hpp>

constexpr auto ERR_FORMULA_NOTENOUGHVALUES = -1;
constexpr auto ERR_FORMULA_INTERNAL = -2;
constexpr auto ERR_FORMULA_UNABLETOFFIND = -3;

double calculateGravity(double angle, double tempC,
const char *tempFormula = 0);
double gravityTemperatureCorrectionC(double gravity, double tempC,
double calTempC);
int createFormula(RawFormulaData &fd, char *formulaBuffer,
int formulaBufferSize, int order);

#endif // SRC_CALC_HPP_

Expand Down
Loading
Loading