From 5ddc65d9fb132bbad52c8ecb6f2dd480729b59e8 Mon Sep 17 00:00:00 2001 From: JbLb Date: Tue, 28 Jan 2020 00:09:25 +0100 Subject: [PATCH] second serial & clean up --- src/build_opt.h | 5 ++--- src/hoverserial.ino | 22 +++++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/build_opt.h b/src/build_opt.h index 78f8159..c60b7a1 100644 --- a/src/build_opt.h +++ b/src/build_opt.h @@ -1,3 +1,2 @@ --DENABLE_HWSERIAL2 --DPIN_SERIAL3_RX=PA10 --DPIN_SERIAL3_TX=PA9 \ No newline at end of file +-DENABLE_HWSERIAL1 +-DPIN_SERIAL1_RX=PA_10 -DPIN_SERIAL1_TX=PA_9 diff --git a/src/hoverserial.ino b/src/hoverserial.ino index 9302541..d9adc18 100644 --- a/src/hoverserial.ino +++ b/src/hoverserial.ino @@ -92,6 +92,7 @@ int motor_test_direction = 1; Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire); // Connect to a Nunchuk Nunchuk nchuk; +HardwareSerial Serial1(PA_10, PA_9); // ########################## SETUP ########################## void setup() @@ -103,14 +104,16 @@ void setup() // Clear the buffer display.clearDisplay(); display.display(); + display.setTextSize(1); // Draw 1X-scale text display.setTextColor(SSD1306_WHITE); display.setCursor(int ((display.width() - (strlen("Hoverboard Serial") * 6)) / 2), 0); display.println("Hoverboard Serial"); - display.setCursor(52, 8); - display.println("v0.2"); + display.setCursor(int + ((display.width() -(strlen("v STM32 0.1") *6))/2), 8); + display.println("v STM32 0.1"); /* display.print("Nunchuk "); nchuk.connect()? display.print("") : display.print("not "); @@ -125,7 +128,7 @@ void setup() Serial.begin(SERIAL_BAUD); if (Serial) { - Serial.println("Hoverboard Serial v1.0"); + Serial.println("Hoverboard Serial v STM32 0.1"); } } @@ -253,6 +256,7 @@ int old_cursorX, old_cursorY; display.print(cmd2); display.display(); +*/ Send(cmd1, cmd2); } @@ -357,18 +361,6 @@ void loop(void) iTimeSend = timeNow + TIME_SEND; Send(0, cmd2); - - display.setCursor(0, 30); - display.setTextSize(1); // Draw 1X-scale text - display.setTextColor(SSD1306_WHITE); - display.print("Speed : "); - old_cursorX = display.getCursorX(); - old_cursorY = display.getCursorY(); - display.fillRect(old_cursorX, old_cursorY, (6 * 5), 8, SSD1306_BLACK); // erase previous display - display.setCursor(old_cursorX, old_cursorY); - display.print(cmd2); - display.display(); - // Calculate test command signal if (motor_test_direction == 1) cmd2 += 1;