new START_FRAME / improve serial receve

test_board
JbLb 5 years ago
parent 2ed66c6325
commit 8c69d15e74

@ -38,7 +38,9 @@
#define HOVER_SERIAL_BAUD 115200 // [-] Baud rate for HoverSerial (used to communicate with the hoverboard) #define HOVER_SERIAL_BAUD 115200 // [-] Baud rate for HoverSerial (used to communicate with the hoverboard)
#define SERIAL_BAUD 115200 // [-] Baud rate for built-in Serial (used for the Serial Monitor) #define SERIAL_BAUD 115200 // [-] Baud rate for built-in Serial (used for the Serial Monitor)
#define START_FRAME 0xAAAA // [-] Start frme definition for reliable serial communication // #define START_FRAME 0xAAAA // [-] Start frme definition for reliable serial communication
#define START_FRAME 0xABCD // [-] Start frme definition for reliable serial communication
#define TIME_SEND 25 // [ms] Sending time interval #define TIME_SEND 25 // [ms] Sending time interval
#define SPEED_MAX_TEST 300 // [-] Maximum speed for testing #define SPEED_MAX_TEST 300 // [-] Maximum speed for testing
//#define DEBUG_RX // [-] Debug received data. Prints all bytes to serial (comment-out to disable) //#define DEBUG_RX // [-] Debug received data. Prints all bytes to serial (comment-out to disable)
@ -101,6 +103,10 @@ Nunchuk nchuk;
// ########################## SETUP ########################## // ########################## SETUP ##########################
void setup() void setup()
{ {
Serial.begin(SERIAL_BAUD);
if (Serial) {
Serial.println(VERSION_TAG);
}
nchuk.begin(); nchuk.begin();
while (!nchuk.connect()) { while (!nchuk.connect()) {
@ -134,10 +140,6 @@ void setup()
Serial1.begin(HOVER_SERIAL_BAUD); // RX, TX from arduino to TX RX on hoverboard board. ! be carreful 3v3 Serial1.begin(HOVER_SERIAL_BAUD); // RX, TX from arduino to TX RX on hoverboard board. ! be carreful 3v3
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(SERIAL_BAUD);
if (Serial) {
Serial.println(VERSION_TAG);
}
} }
// ########################## SEND ########################## // ########################## SEND ##########################
@ -264,7 +266,8 @@ int old_cursorX, old_cursorY;
old_cursorY = display.getCursorY(); old_cursorY = display.getCursorY();
display.fillRect(old_cursorX, old_cursorY, (6 * 5), 8, SSD1306_BLACK); // erase previous display display.fillRect(old_cursorX, old_cursorY, (6 * 5), 8, SSD1306_BLACK); // erase previous display
display.setCursor(old_cursorX, old_cursorY); display.setCursor(old_cursorX, old_cursorY);
display.print(cmd1); // display.print(cmd1);
display.print(cmd2);
/* /*
display.setCursor(0, 50); display.setCursor(0, 50);
display.setTextSize(1); // Draw 1X-scale text display.setTextSize(1); // Draw 1X-scale text
@ -368,7 +371,7 @@ void loop(void)
unsigned long timeNow = millis(); unsigned long timeNow = millis();
// Check for new received data // Check for new received data
// Receive(); Receive();
if (iTimeSend > timeNow) if (iTimeSend > timeNow)
return; return;

Loading…
Cancel
Save