Skip to content

Commit

Permalink
Merge pull request #25 from mp-se/dev
Browse files Browse the repository at this point in the history
Update to 0.7.1
  • Loading branch information
mp-se committed Aug 4, 2023
2 parents 5f36072 + 33bfe59 commit c52bf94
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 56 deletions.
Binary file modified bin/firmware.bin
Binary file not shown.
Binary file modified bin/firmware32s2.bin
Binary file not shown.
7 changes: 7 additions & 0 deletions part32_coredump.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Name,Type,SubType,Offset,Size,Flags
nvs,data,nvs,0x9000,0x5000
otadata,data,ota,0xe000,0x2000
app0,app,ota_0,0x10000,0x1c0000
app1,app,ota_1,0x1d0000,0x1c0000
spiffs,data,spiffs,0x390000,0x60000
coredump,data,coredump,0x3F0000,0x10000
68 changes: 50 additions & 18 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ include_dir = lib
[common_env_data]
upload_speed = 921600
monitor_speed = 115200
platform = espressif8266 @ 4.1.0
platform32 = espressif32 @ 5.3.0
platform = espressif8266 @ 4.2.0
platform32 = espressif32 @ 6.3.2
framework = arduino
build_unflags =
build_flags =
-D BAUD=${common_env_data.monitor_speed}
-D USER_SSID=\""\"" # =\""myssid\""
-D USER_SSID_PWD=\""\"" # =\""mypwd\""
-D USE_LITTLEFS=true
-D CFG_APPVER="\"0.7.0\""
-D CFG_APPVER="\"0.7.1\""
#-D PERF_ENABLE
-D PERF_INFLUX_TARGET=\""\""
-D PERF_INFLUX_BUCKET=\""\""
Expand All @@ -35,7 +35,7 @@ build_flags =
-D PUSH_INFLUX_BUCKET=\""\""
-D PUSH_INFLUX_ORG=\""\""
-D PUSH_INFLUX_TOKEN=\""\""
#-D CFG_GITREV=\""beta1\""
#-D CFG_GITREV=\""alfa3\""
!python script/git_rev.py
lib_deps =
https://github.com/mp-se/SimpleKalmanFilter#v0.2
Expand All @@ -51,6 +51,7 @@ lib_deps =
https://github.com/mp-se/tinyexpr#v1.0.0
https://github.com/mp-se/NAU7802_Arduino_Library#v1.0.4
https://github.com/mp-se/LiquidCrystal_I2C#1.0.0
https://github.com/mp-se/espframework#0.6.3

[env:kegmon-debug]
upload_speed = ${common_env_data.upload_speed}
Expand All @@ -67,10 +68,9 @@ build_flags =
#-DDEBUG_ESP_WIFI
#-DDEBUG_ESP_SSL
#-DDEBUG_ESP_CORE
${common_env_data.build_flags}
${common_env_data.build_flags}
-D LOG_LEVEL=6
lib_deps =
https://github.com/mp-se/espframework#0.6.1
${common_env_data.lib_deps}
board = d1_mini
build_type = release
Expand All @@ -86,11 +86,10 @@ extra_scripts =
script/copy_firmware.py
build_unflags = ${common_env_data.build_unflags}
build_flags =
${common_env_data.build_flags}
${common_env_data.build_flags}
-D LOG_LEVEL=5
-D USE_ASYNC_WEB
lib_deps =
https://github.com/mp-se/espframework#0.6.1
https://github.com/mp-se/ESPAsyncWebServer
https://github.com/mp-se/ESPAsyncTCP
${common_env_data.lib_deps}
Expand All @@ -106,10 +105,9 @@ framework = ${common_env_data.framework}
platform = ${common_env_data.platform}
build_unflags = ${common_env_data.build_unflags}
build_flags =
${common_env_data.build_flags}
${common_env_data.build_flags}
-D LOG_LEVEL=5
lib_deps =
https://github.com/mp-se/espframework#0.6.0
${common_env_data.lib_deps}
board = d1_mini
build_type = release
Expand All @@ -123,10 +121,9 @@ framework = ${common_env_data.framework}
platform = ${common_env_data.platform}
build_unflags = ${common_env_data.build_unflags}
build_flags =
${common_env_data.build_flags}
${common_env_data.build_flags}
-D LOG_LEVEL=6
lib_deps =
https://github.com/mp-se/espframework#0.6.0
${common_env_data.lib_deps}
board = d1_mini
build_type = release
Expand All @@ -140,10 +137,9 @@ framework = ${common_env_data.framework}
platform = ${common_env_data.platform}
build_unflags = ${common_env_data.build_unflags}
build_flags =
${common_env_data.build_flags}
${common_env_data.build_flags}
-D LOG_LEVEL=6
lib_deps =
https://github.com/mp-se/espframework#0.6.0
https://github.com/bxparks/AUnit#v1.6.1
${common_env_data.lib_deps}
board = d1_mini
Expand All @@ -161,20 +157,56 @@ build_unflags = ${common_env_data.build_unflags}
extra_scripts =
script/copy_firmware.py
build_flags =
-D ESP32S2
-D ESP32S2
-D ARDUINO_ESP32S2_DEV
#-D USE_SERIAL_PINS
-D LOG_LEVEL=5
-D USE_ASYNC_WEB
#-D CORE_DEBUG_LEVEL=2
${common_env_data.build_flags}
#-D CORE_DEBUG_LEVEL=5
${common_env_data.build_flags}
lib_deps =
https://github.com/mp-se/espframework#0.6.0
https://github.com/mp-se/ESPAsyncWebServer
https://github.com/mp-se/AsyncTCP
${common_env_data.lib_deps}
build_type = release
board_build.partitions = part32.csv
#board_build.partitions = part32_coredump.csv
board_build.embed_txtfiles =
html/upload.min.htm
html/config.min.htm
html/about.min.htm
html/index.min.htm
html/beer.min.htm
html/calibration.min.htm
html/graph.min.htm
html/stability.min.htm
html/backup.min.htm
html/ws.min.htm
html/dashboard.min.htm

[env:kegmon32s2-debug]
platform = ${common_env_data.platform32}
framework = arduino
board = esp32-s2-kaluga-1
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
build_unflags = ${common_env_data.build_unflags}
extra_scripts =
debug_tool = esp-prog
build_flags =
-D ESP32S2
-D ARDUINO_ESP32S2_DEV
#-D USE_SERIAL_PINS
-D LOG_LEVEL=5
-D USE_ASYNC_WEB
#-D CORE_DEBUG_LEVEL=5
${common_env_data.build_flags}
lib_deps =
https://github.com/mp-se/ESPAsyncWebServer
https://github.com/mp-se/AsyncTCP
${common_env_data.lib_deps}
build_type = debug
board_build.partitions = part32_coredump.csv
board_build.embed_txtfiles =
html/upload.min.htm
html/config.min.htm
Expand Down
69 changes: 64 additions & 5 deletions src/displayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ void DisplayLayout::showGraph(UnitIndex idx, bool isScaleConnected,
}

void DisplayLayout::showGraphOne(UnitIndex idx, bool isScaleConnected,
float beerVolume) {
float beerVolume, float pour,
float beerWeight) {
// Handle printout to display #1 which will show all the graphs
if (idx == UnitIndex::U1) {
myDisplay.clear(UnitIndex::U1);
myDisplay.setFont(UnitIndex::U1, FontSize::FONT_16);
Expand Down Expand Up @@ -208,9 +210,62 @@ void DisplayLayout::showGraphOne(UnitIndex idx, bool isScaleConnected,
myDisplay.getFontHeight(UnitIndex::U1) * 3,
"No scale");
}

myDisplay.show(UnitIndex::U1);
}

// Handle printout to display #2 which will show all the details (iterating
// between the two displays)
if (isScaleConnected) {
myDisplay.setFont(UnitIndex::U2, FontSize::FONT_16);

switch (_iter) {
case DisplayIterator::ShowTemp:
case DisplayIterator::ShowWeight:
if (idx == UnitIndex::U1) {
myDisplay.clear(UnitIndex::U2);

myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getFontHeight(UnitIndex::U2) * 0,
getFormattedBeerName(idx));
myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getFontHeight(UnitIndex::U2) * 1,
getFormattedPour(pour));
myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getFontHeight(idx) * 2,
getFormattedBeerWeight(beerWeight));

myDisplay.setFont(UnitIndex::U2, FontSize::FONT_10);
myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getDisplayHeight(UnitIndex::U2) -
myDisplay.getFontHeight(UnitIndex::U2),
getFormattedWifiName());
}
break;
case DisplayIterator::ShowGlasses:
case DisplayIterator::ShowPour:
if (idx == UnitIndex::U2) {
myDisplay.clear(UnitIndex::U2);

myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getFontHeight(UnitIndex::U2) * 0,
getFormattedBeerName(idx));
myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getFontHeight(UnitIndex::U2) * 1,
getFormattedPour(pour));
myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getFontHeight(idx) * 2,
getFormattedBeerWeight(beerWeight));

myDisplay.setFont(UnitIndex::U2, FontSize::FONT_10);
myDisplay.printPosition(UnitIndex::U2, -1,
myDisplay.getDisplayHeight(UnitIndex::U2) -
myDisplay.getFontHeight(UnitIndex::U2),
getFormattedIP());
}
break;
}
myDisplay.show(UnitIndex::U2);
}
}

void DisplayLayout::showHardwareStats(UnitIndex idx, bool isScaleConnected) {
Expand All @@ -231,13 +286,17 @@ void DisplayLayout::showHardwareStats(UnitIndex idx, bool isScaleConnected) {
myLevelDetection.getStatsDetection(idx)->min(),
myLevelDetection.getStatsDetection(idx)->max());
myDisplay.printLine(idx, 3, &_buf[0]);

snprintf(&_buf[0], sizeof(_buf), "Raw wgt: %.3f",
myLevelDetection.getTotalRawWeight(idx));
myDisplay.printLine(idx, 4, &_buf[0]);
}

myDisplay.show(idx);
}

void DisplayLayout::showCurrent(UnitIndex idx, bool isScaleConnected,
float beerWeight, float beerVoume,
float beerWeight, float beerVolume,
float glasses, float pour, float temp,
bool stableLevel) {
switch (myConfig.getDisplayLayoutType()) {
Expand All @@ -248,11 +307,11 @@ void DisplayLayout::showCurrent(UnitIndex idx, bool isScaleConnected,
break;

case DisplayLayoutType::Graph:
showGraph(idx, isScaleConnected, beerVoume, pour);
showGraph(idx, isScaleConnected, beerVolume, pour);
break;

case DisplayLayoutType::GraphOne:
showGraphOne(idx, isScaleConnected, beerVoume);
showGraphOne(idx, isScaleConnected, beerVolume, pour, beerWeight);
break;

case DisplayLayoutType::HardwareStats:
Expand Down
3 changes: 2 additions & 1 deletion src/displayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class DisplayLayout {
float glasses, float pour, float temp, bool stableLevel);
void showGraph(UnitIndex idx, bool isScaleConnected, float beerVolume,
float pour);
void showGraphOne(UnitIndex idx, bool isScaleConnected, float beerVolume);
void showGraphOne(UnitIndex idx, bool isScaleConnected, float beerVolume,
float pour, float beerWeight);
void showHardwareStats(UnitIndex idx, bool isScaleConnected);

public:
Expand Down
59 changes: 38 additions & 21 deletions src/homeassist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,63 @@ SOFTWARE.
#include <utils.hpp>

const char *volumeTemplate =
"kegmon/${mdns}_volume${tap}/state:${volume}|"
"kegmon/${mdns}_volume${tap}/"
"attr:{\"glasses\":${glasses}}|"
"homeassistant/sensor/${mdns}_volume${tap}/"
"config:{\"device_class\":\"volume\",\"name\":\"${mdns}_volume${tap}\","
"\"unit_of_measurement\":\"L\",\"state_topic\":\"homeassistant/sensor/"
"${mdns}_volume${tap}/state\",\"json_attributes_topic\":\"homeassistant/"
"sensor/${mdns}_volume${tap}/"
"attr\",\"unique_id\":\"${mdns}_volume${tap}\"}|"
"homeassistant/sensor/${mdns}_volume${tap}/state:${volume}|"
"homeassistant/sensor/${mdns}_volume${tap}/"
"attr:{\"glasses\":${glasses}}|";
"\"unit_of_measurement\":\"L\",\"state_topic\":\"kegmon/"
"${mdns}_volume${tap}/state\",\"json_attributes_topic\":\"kegmon/"
"${mdns}_volume${tap}/"
"attr\",\"unique_id\":\"${mdns}_volume${tap}\","
"\"device\": { \"identifiers\": \"${mdns}_${id}\", \"name\": \"${mdns}\", "
"\"model\": \"kegmon\", \"manufacturer\": \"mp-se\", \"sw_version\": "
"\"${sw-ver}\" } }|";

const char *beerTemplate =
"homeassistant/sensor/${mdns}_beer${tap}/config:"
"{\"name\":\"${mdns}_beer${tap}\",\"state_topic\":\"homeassistant/sensor/"
"${mdns}_beer${tap}/state\",\"json_attributes_topic\":\"homeassistant/"
"sensor/${mdns}_beer${tap}/"
"attr\",\"unique_id\":\"${mdns}_beer${tap}\"}|"
"homeassistant/sensor/${mdns}_beer${tap}/state:${beer-name}|"
"homeassistant/sensor/${mdns}_beer${tap}/"
"kegmon/${mdns}_beer${tap}/state:${beer-name}|"
"kegmon/${mdns}_beer${tap}/"
"attr:{\"abv\":${beer-abv},\"abv\":${beer-abv},\"ibu\":${beer-ibu},\"ebc\":"
"${beer-"
"ebc}}|";
"ebc}}|"
"homeassistant/sensor/${mdns}_beer${tap}/config:"
"{\"name\":\"${mdns}_beer${tap}\",\"state_topic\":\"kegmon/"
"${mdns}_beer${tap}/state\",\"json_attributes_topic\":\"kegmon/"
"${mdns}_beer${tap}/"
"attr\",\"unique_id\":\"${mdns}_beer${tap}\","
"\"device\": { \"identifiers\": \"${mdns}_${id}\", \"name\": \"${mdns}\", "
"\"model\": \"kegmon\", \"manufacturer\": \"mp-se\", \"sw_version\": "
"\"${sw-ver}\" } }|";

const char *pourTemplate =
"kegmon/${mdns}_pour${tap}/state:${pour}|"
"homeassistant/sensor/${mdns}_pour${tap}/config:"
"{\"device_class\":\"volume\",\"name\":\"${mdns}_pour${tap}\",\"unit_of_"
"measurement\":\"L\",\"state_topic\":\"homeassistant/sensor/"
"${mdns}_pour${tap}/state\",\"unique_id\":\"${mdns}_pour${tap}\"}|"
"homeassistant/sensor/${mdns}_pour${tap}/state:${pour}|";
"measurement\":\"L\",\"state_topic\":\"kegmon/"
"${mdns}_pour${tap}/state\",\"unique_id\":\"${mdns}_pour${tap}\", "
"\"device\": { \"identifiers\": \"${mdns}_${id}\", \"name\": \"${mdns}\", "
"\"model\": \"kegmon\", \"manufacturer\": \"mp-se\", \"sw_version\": "
"\"${sw-ver}\" } }|";

const char *tempTemplate =
"kegmon/${mdns}_temp/state:${temp}|"
"homeassistant/sensor/${mdns}_temp/config:"
"{\"device_class\":\"temperature\",\"name\":\"${mdns}_temp\",\"unit_of_"
"measurement\":\"${temp-format}\",\"state_topic\":\"homeassistant/sensor/"
"${mdns}_temp/state\",\"unique_id\":\"${mdns}_temp\"}|"
"homeassistant/sensor/${mdns}_temp/state:${temp}|";
"measurement\":\"${temp-format}\",\"state_topic\":\"kegmon/"
"${mdns}_temp/state\",\"unique_id\":\"${mdns}_temp\", "
"\"device\": { \"identifiers\": \"${mdns}_${id}\", \"name\": \"${mdns}\", "
"\"model\": \"kegmon\", \"manufacturer\": \"mp-se\", \"sw_version\": "
"\"${sw-ver}\" } }|";

void HomeAssist::sendTempInformation(float tempC) {
if (!myConfig.hasTargetMqtt()) return;
if (isnan(tempC)) return;

TemplatingEngine tpl;

tpl.setVal("${mdns}", myConfig.getMDNS());
tpl.setVal("${sw-ver}", CFG_APPVER);
tpl.setVal("${id}", myConfig.getID());

// if (myConfig.isTempFormatC()) {
tpl.setVal("${temp}", tempC);
Expand Down Expand Up @@ -98,6 +113,7 @@ void HomeAssist::sendTapInformation(UnitIndex idx, float stableVol,
TemplatingEngine tpl;

tpl.setVal("${mdns}", myConfig.getMDNS());
tpl.setVal("${sw-ver}", CFG_APPVER);
tpl.setVal("${id}", myConfig.getID());
tpl.setVal("${volume}", stableVol, 3);
tpl.setVal("${glasses}", glasses, 1);
Expand Down Expand Up @@ -131,6 +147,7 @@ void HomeAssist::sendPourInformation(UnitIndex idx, float pourVol) {
TemplatingEngine tpl;

tpl.setVal("${mdns}", myConfig.getMDNS());
tpl.setVal("${sw-ver}", CFG_APPVER);
tpl.setVal("${id}", myConfig.getID());
tpl.setVal("${pour}", pourVol, 3);
tpl.setVal("${tap}", static_cast<int>(idx) + 1);
Expand Down
1 change: 1 addition & 0 deletions src/kegwebhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void KegWebHandler::setupWebHandlers() {
// Note! For the async implementation the order matters
_server->serveStatic("/levels2", LittleFS, LEVELS_FILENAME2);
_server->serveStatic("/levels", LittleFS, LEVELS_FILENAME);
_server->serveStatic("/startup", LittleFS, STARTUP_FILENAME);
WS_BIND_URL("/api/reset", HTTP_GET, &KegWebHandler::webReset);
WS_BIND_URL("/api/scale/tare", HTTP_GET, &KegWebHandler::webScaleTare);
WS_BIND_URL("/api/scale/factor", HTTP_GET, &KegWebHandler::webScaleFactor);
Expand Down

0 comments on commit c52bf94

Please sign in to comment.