code cleanup and format

master
JbLb 6 years ago
parent f2bdcc8d76
commit 4e73f59bfd

@ -34,7 +34,7 @@
#define HOVER_SERIAL_BAUD 38400 // [-] 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 START_FRAME 0xAAAA // [-] Start frme definition for reliable serial communication
#define TIME_SEND 100 // [ms] Sending time interval
#define TIME_SEND 1000 // [ms] Sending time interval
#define SPEED_MAX_TEST 300 // [-] Maximum speed for testing
//#define DEBUG_RX // [-] Debug received data. Prints all bytes to serial (comment-out to disable)
@ -80,8 +80,7 @@ SerialFeedback NewFeedback;
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
// ########################## SETUP ##########################
void setup()
@ -99,10 +98,10 @@ void setup()
display.display();
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) {
if (Serial) {
Serial.println("Hoverboard Serial v1.0");
}
}
@ -110,14 +109,14 @@ void setup()
// ########################## SEND ##########################
void Send(int16_t uSteer, int16_t uSpeed)
{
// Create command
Command.start = (uint16_t)START_FRAME;
Command.steer = (int16_t)uSteer;
Command.speed = (int16_t)uSpeed;
Command.checksum = (uint16_t)(Command.start ^ Command.steer ^ Command.speed);
// Write to Serial
Serial1.write((uint8_t *) &Command, sizeof(Command));
// Create command
Command.start = (uint16_t)START_FRAME;
Command.steer = (int16_t)uSteer;
Command.speed = (int16_t)uSpeed;
Command.checksum = (uint16_t)(Command.start ^ Command.steer ^ Command.speed);
// Write to Serial
Serial1.write((uint8_t *) &Command, sizeof(Command));
}
// ########################## RECEIVE ##########################

Loading…
Cancel
Save