-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSY Remote through UDP - Client side
(cherry picked from commit 85ca5ebf2db38d352a125cdbb6eaac46fb14e323)
- Loading branch information
1 parent
07e24e6
commit b757b34
Showing
7 changed files
with
775 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Language: Cpp | ||
BasedOnStyle: LLVM | ||
|
||
AccessModifierOffset: -2 | ||
AlignConsecutiveMacros: true | ||
AllowAllArgumentsOnNextLine: false | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLambdasOnASingleLine: Inline | ||
BinPackArguments: false | ||
ColumnLimit: 0 | ||
ContinuationIndentWidth: 2 | ||
FixNamespaceComments: false | ||
IndentAccessModifiers: true | ||
IndentCaseLabels: true | ||
IndentPPDirectives: BeforeHash | ||
IndentWidth: 2 | ||
NamespaceIndentation: All | ||
PointerAlignment: Left | ||
ReferenceAlignment: Left | ||
TabWidth: 2 | ||
UseTab: Never |
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,5 +1,7 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
/.pio | ||
/.vscode/.browse.c_cpp.db* | ||
/.vscode/c_cpp_properties.json | ||
/.vscode/launch.json | ||
/.vscode/ipch | ||
/*.cpp | ||
/logs |
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,34 +1,35 @@ | ||
#include <Arduino.h> | ||
#include <ArduinoJson.h> | ||
#include <MycilaJSY.h> | ||
#include <MycilaLogger.h> | ||
|
||
Mycila::JSY jsy; | ||
Mycila::Logger logger; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
continue; | ||
|
||
logger.setLevel(ARDUHAL_LOG_LEVEL_DEBUG); | ||
logger.forwardTo(&Serial); | ||
|
||
// read JSY on pins 17 (JSY RX / Serial TX) and 16 (JSY TX / Serial RX) | ||
jsy.begin(Serial2, 16, 17, true); | ||
jsy.begin(Serial2, 16, 17); | ||
if (jsy.isEnabled() && jsy.getBaudRate() != Mycila::JSYBaudRate::BAUD_38400) | ||
jsy.setBaudRate(Mycila::JSYBaudRate::BAUD_38400); | ||
} | ||
|
||
Mycila::JSYBaudRate target = Mycila::JSYBaudRate::BAUD_38400; | ||
|
||
void loop() { | ||
if (!jsy.isEnabled()) { | ||
delay(1000); | ||
return; | ||
} | ||
jsy.read(); | ||
|
||
delay(1000); | ||
|
||
JsonDocument doc; | ||
jsy.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
if (jsy.isEnabled()) { | ||
Serial.println((int)jsy.getBaudRate()); | ||
|
||
if (jsy.getBaudRate() != target) { | ||
jsy.setBaudRate(target); | ||
JsonDocument doc; | ||
jsy.toJson(doc.to<JsonObject>()); | ||
serializeJson(doc, Serial); | ||
Serial.println(); | ||
} | ||
delay(1000); | ||
} |
Oops, something went wrong.