Created
April 5, 2024 18:15
-
-
Save AndBondStyle/fc6703e017b5125dd4db2663a78e9983 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <Arduino.h> | |
#include <MsgPacketizer.h> | |
#define SERIAL_SPEED 500000 | |
#define MSGPACK_RECV_INDEX 0x01 | |
#define MSGPACK_SEND_INDEX 0x02 | |
#define SERIAL_PORT Serial1 | |
struct ServoCommand { | |
float left; | |
float right; | |
MSGPACK_DEFINE(left, right); | |
}; | |
void handleCommand(const ServoCommand& cmd) { | |
// ... | |
} | |
void setup() { | |
SERIAL_PORT.begin(SERIAL_SPEED); | |
MsgPacketizer::subscribe(SERIAL_PORT, MSGPACK_RECV_INDEX, &handleCommand); | |
} | |
void loop() { | |
MsgPacketizer::update(); | |
} |
This file contains hidden or 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
[env:teensy40] | |
platform = teensy | |
board = teensy40 | |
framework = arduino | |
upload_protocol = teensy-cli | |
lib_deps = hideakitai/MsgPacketizer@^0.5.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment