From a47f055f4e88881488975ed8ffe62df49b3be786 Mon Sep 17 00:00:00 2001 From: jblb Date: Fri, 31 Jan 2020 21:07:18 +0100 Subject: [PATCH] display battery power - change min/max speed --- platformio.ini | 4 ++-- src/hoverserial.ino | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index a88fc5f..b1d6153 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,8 +19,8 @@ framework = arduino platform = atmelavr lib_deps = Nintendo Extension Ctrl -upload_port = /dev/ttyACM* monitor_port = /dev/ttyACM* +upload_port = /dev/ttyACM* ; [env:pro_micro] @@ -46,7 +46,7 @@ platform = ststm32 framework = arduino board = nucleo_l031k6 build_flags = - -Wno-deprecated + -Wno-deprecated lib_deps = Nintendo Extension Ctrl diff --git a/src/hoverserial.ino b/src/hoverserial.ino index e6a69d0..4136aa6 100644 --- a/src/hoverserial.ino +++ b/src/hoverserial.ino @@ -145,7 +145,9 @@ void Send(int16_t uSteer, int16_t uSpeed) // ########################## RECEIVE ########################## void Receive() + { + int old_cursorX, old_cursorY; // Check for new data availability in the Serial buffer if (Serial1.available()) { incomingByte = Serial1.read(); // Read the incoming byte @@ -205,6 +207,16 @@ void Receive() Serial.print(" 8: "); Serial.println(Feedback.boardTemp); } + display.setCursor(0, 30); + display.setTextSize(1); // Draw 1X-scale text + display.setTextColor(SSD1306_WHITE); + display.print("V : "); + 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(Feedback.batVoltage); + display.display(); } else { if (Serial) Serial.println("Non-valid data skipped"); @@ -224,8 +236,8 @@ int old_cursorX, old_cursorY; nchuk.reconnect(); } else { - cmd1 = map(nchuk.joyX(),0,256,-300,300); // x - axis. Nunchuck joystick readings range 30 - 230 - cmd2 = map(nchuk.joyY(),0,256, 300, -300); // y - axis + cmd1 = map(nchuk.joyX(),0,256,150,-150); // x - axis. Nunchuck joystick readings range 30 - 230 + cmd2 = map(nchuk.joyY(),0,256,-150,150); // y - axis } display.setCursor(0, 40); display.setTextSize(1); // Draw 1X-scale text