code clean up

master
JbLb 6 years ago
parent ebb87fc624
commit 45d989464d

@ -86,10 +86,10 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// ########################## SETUP ########################## // ########################## SETUP ##########################
void setup() void setup()
{ {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64)
// Clear the buffer // Clear the buffer
display.clearDisplay(); display.clearDisplay();
display.display(); display.display();
display.setCursor(0, 0); display.setCursor(0, 0);
display.println("Hello World!"); display.println("Hello World!");
@ -97,12 +97,7 @@ 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);
pinMode (2,INPUT_PULLUP); // pin 2 to GNd to start Serial.begin(SERIAL_BAUD);
while (digitalRead(2))
{
/* code */
}
Serial.begin(SERIAL_BAUD);
if (Serial) { if (Serial) {
Serial.println("Hoverboard Serial v1.0"); Serial.println("Hoverboard Serial v1.0");
} }
@ -190,23 +185,18 @@ int iTestMax = SPEED_MAX_TEST;
int iTest = 0; int iTest = 0;
void loop(void) void loop(void)
{ {
unsigned long timeNow = millis(); unsigned long timeNow = millis();
// Check for new received data
Receive();
// Send commands // Check for new received data
if (iTimeSend > timeNow) return; Receive();
iTimeSend = timeNow + TIME_SEND;
Send(0, abs(iTest));
// Calculate test command signal // Calculate test command signal
iTest += 10; iTest += 10;
if (iTest > iTestMax) iTest = -iTestMax; if (iTest > iTestMax) iTest = -iTestMax;
// Blink the LED // Blink the LED
digitalWrite(LED_BUILTIN, (timeNow%2000)<1000); digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000);
} }
// ########################## END ########################## // ########################## END ##########################

Loading…
Cancel
Save