Skip to content

Instantly share code, notes, and snippets.

@AndBondStyle
Created April 5, 2024 18:15
Show Gist options
  • Save AndBondStyle/fc6703e017b5125dd4db2663a78e9983 to your computer and use it in GitHub Desktop.
Save AndBondStyle/fc6703e017b5125dd4db2663a78e9983 to your computer and use it in GitHub Desktop.
#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();
}
[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