-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: do not change the speed of the JSY by default and detect the cur…
…rent speed instead
- Loading branch information
1 parent
5f3f340
commit a316413
Showing
11 changed files
with
359 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <MycilaJSY.h> | ||
#include <MycilaLogger.h> | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
continue; | ||
|
||
Mycila::Logger.forwardTo(&Serial); | ||
|
||
// read JSY on pins 17 (JSY RX) and 16 (JSY TX) | ||
Mycila::JSY.begin(17, 16); | ||
} | ||
|
||
void loop() { | ||
if (Mycila::JSY.read()) { | ||
|
||
JsonDocument doc; | ||
Mycila::JSY.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
|
||
if (Mycila::JSY.energy1 > 0 || Mycila::JSY.energy2 > 0 || Mycila::JSY.energyReturned1 > 0 || Mycila::JSY.energyReturned2 > 0) | ||
Mycila::JSY.resetEnergy(); | ||
} | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <MycilaJSY.h> | ||
#include <MycilaLogger.h> | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
continue; | ||
|
||
Mycila::Logger.forwardTo(&Serial); | ||
|
||
// read JSY on pins 17 (JSY RX) and 16 (JSY TX) | ||
Mycila::JSY.begin(17, 16, &Serial2, true, 60, 0); | ||
} | ||
|
||
void loop() { | ||
if (Mycila::JSY.isEnabled()) { | ||
JsonDocument doc; | ||
Mycila::JSY.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
|
||
if (Mycila::JSY.energy1 > 0 || Mycila::JSY.energy2 > 0 || Mycila::JSY.energyReturned1 > 0 || Mycila::JSY.energyReturned2 > 0) | ||
Mycila::JSY.resetEnergy(); | ||
} | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <MycilaJSY.h> | ||
#include <MycilaLogger.h> | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
continue; | ||
|
||
Mycila::Logger.forwardTo(&Serial); | ||
|
||
// read JSY on pins 17 (JSY RX) and 16 (JSY TX) | ||
Mycila::JSY.begin(17, 16); | ||
|
||
if (Mycila::JSY.isEnabled()) { | ||
Mycila::Logger.info("APP", "JSY is enabled at %d bauds", Mycila::JSY.getBaudRate()); | ||
|
||
if (Mycila::JSY.getBaudRate() != Mycila::JSYBaudRate::BAUD_38400) { | ||
Mycila::Logger.warn("APP", "JSY baud rate wrong"); | ||
|
||
if (Mycila::JSY.updateBaudRate(Mycila::JSYBaudRate::BAUD_38400)) { | ||
Mycila::Logger.info("APP", "JSY baud rate updated"); | ||
ESP.restart(); | ||
|
||
} else { | ||
Mycila::Logger.error("APP", "JSY baud rate update failed"); | ||
} | ||
} | ||
} else { | ||
Mycila::Logger.info("APP", "JSY is disabled"); | ||
} | ||
} | ||
|
||
void loop() { | ||
if (Mycila::JSY.read()) { | ||
JsonDocument doc; | ||
Mycila::JSY.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
} | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,31 @@ | ||
[platformio] | ||
lib_dir = . | ||
; src_dir = examples/JSYRead | ||
; src_dir = examples/JSYReadAsync | ||
; src_dir = examples/EnergyReset | ||
; src_dir = examples/EnergyResetAsync | ||
src_dir = examples/SetSpeed | ||
default_envs = esp32 | ||
|
||
[env] | ||
build_flags = -Wall -Wextra | ||
|
||
build_flags = | ||
-Wall -Wextra | ||
-Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference | ||
-std=c++17 | ||
-std=gnu++17 | ||
-O0 | ||
-ggdb -ggdb3 -g3 | ||
-D CONFIG_ARDUHAL_LOG_COLORS | ||
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG | ||
build_unflags = | ||
-std=gnu++11 | ||
|
||
lib_deps = | ||
bblanchon/ArduinoJson | ||
mathieucarbou/MycilaLogger | ||
lib_compat_mode = strict | ||
lib_ldf_mode = deep+ | ||
|
||
upload_protocol = esptool | ||
upload_port = /dev/cu.usbserial-0001 | ||
|
@@ -11,11 +34,6 @@ monitor_port = /dev/cu.usbserial-0001 | |
monitor_speed = 115200 | ||
monitor_filters = esp32_exception_decoder, log2file | ||
|
||
[platformio] | ||
lib_dir = . | ||
src_dir = examples/JSYRead | ||
; src_dir = examples/JSYReadAsync | ||
|
||
[env:esp32] | ||
platform = [email protected] | ||
board = esp32dev | ||
|
Oops, something went wrong.