Compare commits

...

7 Commits

@ -1,4 +1,4 @@
;PlatformIO Project Configuration File ; PlatformIO Project Configuration File
; ;
; Build options: build flags, source filter ; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags ; Upload options: custom upload port, speed and extra flags
@ -9,8 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
; default_envs = leonardo default_envs = leonardo
default_envs = stm32-411
[common_env_data] [common_env_data]
@ -18,8 +17,11 @@ default_envs = stm32-411
board = leonardo board = leonardo
framework = arduino framework = arduino
platform = atmelavr platform = atmelavr
lib_deps = lib_deps =
Nintendo Extension Ctrl Nintendo Extension Ctrl
adafruit/Adafruit GFX Library@^1.10.3
adafruit/Adafruit SSD1306@^2.4.1
adafruit/Adafruit BusIO@^1.6.0
monitor_port = /dev/ttyACM* monitor_port = /dev/ttyACM*
upload_port = /dev/ttyACM* upload_port = /dev/ttyACM*
monitor_speed = 115200 monitor_speed = 115200
@ -28,24 +30,27 @@ monitor_speed = 115200
platform = atmelavr platform = atmelavr
framework = arduino framework = arduino
board = leonardo board = leonardo
lib_deps = lib_deps =
Nintendo Extension Ctrl Nintendo Extension Ctrl
adafruit/Adafruit GFX Library@^1.10.3
adafruit/Adafruit SSD1306@^2.4.1
adafruit/Adafruit BusIO@^1.6.0
upload_protocol = usbasp upload_protocol = usbasp
; each flag in a new line upload_flags =
upload_flags = -Pusb
-Pusb
[env:stm32-411] [env:stm32-411]
platform = ststm32 platform = ststm32
framework = arduino framework = arduino
board = nucleo_f411re board = nucleo_f411re
build_flags = build_flags =
-Wno-deprecated -Wno-deprecated
lib_deps = lib_deps =
Nintendo Extension Ctrl Nintendo Extension Ctrl
adafruit/Adafruit GFX Library@^1.10.3
adafruit/Adafruit SSD1306@^2.4.1
adafruit/Adafruit BusIO@^1.6.0
debug_tool = stlink debug_tool = stlink
monitor_port = /dev/ttyACM* monitor_port = /dev/ttyACM*
monitor_speed = 115200 monitor_speed = 115200
@ -53,8 +58,10 @@ monitor_speed = 115200
platform = ststm32 platform = ststm32
framework = arduino framework = arduino
board = nucleo_l031k6 board = nucleo_l031k6
build_flags = build_flags =
-Wno-deprecated -Wno-deprecated
lib_deps = lib_deps =
Nintendo Extension Ctrl Nintendo Extension Ctrl
adafruit/Adafruit GFX Library@^1.10.3
adafruit/Adafruit SSD1306@^2.4.1
adafruit/Adafruit BusIO@^1.6.0

@ -1,2 +0,0 @@
-DENABLE_HWSERIAL1
-DPIN_SERIAL1_RX=PA_10 -DPIN_SERIAL1_TX=PA_9

@ -30,6 +30,9 @@
// // #define DEBUG_SERIAL_USART3 // // #define DEBUG_SERIAL_USART3
// ******************************************************************* // *******************************************************************
#define VERSION_TAG "v test 0.1"
// ########################## DEFINES ########################## // ########################## DEFINES ##########################
#define HOVER_SERIAL_BAUD 38400 // [-] Baud rate for HoverSerial (used to communicate with the hoverboard) #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 SERIAL_BAUD 115200 // [-] Baud rate for built-in Serial (used for the Serial Monitor)
@ -92,13 +95,16 @@ int motor_test_direction = 1;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire); Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
// Connect to a Nunchuk // Connect to a Nunchuk
Nunchuk nchuk; Nunchuk nchuk;
HardwareSerial Serial1(PA_10, PA_9);
// ########################## SETUP ########################## // ########################## SETUP ##########################
void setup() void setup()
{ {
nchuk.begin(); nchuk.begin();
while (!nchuk.connect()) {
Serial.println("nunchuck not connected");
delay(1000);
}
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64) display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64)
// Clear the buffer // Clear the buffer
@ -112,8 +118,8 @@ void setup()
(strlen("Hoverboard Serial") * 6)) / 2), 0); (strlen("Hoverboard Serial") * 6)) / 2), 0);
display.println("Hoverboard Serial"); display.println("Hoverboard Serial");
display.setCursor(int display.setCursor(int
((display.width() -(strlen("v STM32 0.1") *6))/2), 8); ((display.width() -(strlen(VERSION_TAG) *6))/2), 8);
display.println("v STM32 0.1"); display.println(VERSION_TAG);
/* /*
display.print("Nunchuk "); display.print("Nunchuk ");
nchuk.connect()? display.print("") : display.print("not "); nchuk.connect()? display.print("") : display.print("not ");
@ -128,7 +134,7 @@ void setup()
Serial.begin(SERIAL_BAUD); Serial.begin(SERIAL_BAUD);
if (Serial) { if (Serial) {
Serial.println("Hoverboard Serial v STM32 0.1"); Serial.println(VERSION_TAG);
} }
} }
@ -236,18 +242,18 @@ void Nunchuk_control()
int old_cursorX, old_cursorY; int old_cursorX, old_cursorY;
if (!nchuk.update()) { if (!nchuk.update()) {
nchuk.reconnect(); nchuk.connect();
} else { } else {
cmd1 = map(nchuk.joyX(),0,256,150,-150); // x - axis. Nunchuck joystick readings range 30 - 230 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 cmd2 = map(nchuk.joyY(),0,256,-1000,1000); // y - axis
Serial.print("X : "); Serial.println(nchuk.joyX()); Serial.print("X : "); Serial.println(nchuk.joyX());
Serial.print("Y : "); Serial.println(nchuk.joyY()); Serial.print("Y : "); Serial.println(nchuk.joyY());
} }
/*
display.setCursor(0, 40); display.setCursor(0, 40);
display.setTextSize(1); // Draw 1X-scale text display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE); display.setTextColor(SSD1306_WHITE);
@ -257,6 +263,7 @@ int old_cursorX, old_cursorY;
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.setCursor(0, 50); display.setCursor(0, 50);
display.setTextSize(1); // Draw 1X-scale text display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE); display.setTextColor(SSD1306_WHITE);
@ -268,9 +275,9 @@ int old_cursorX, old_cursorY;
display.print(cmd2); display.print(cmd2);
display.display(); display.display();
*/
Send(cmd1, cmd2);
// Send(cmd1, cmd2);
Send(0, cmd2);
} }
// ########################## nunchuk ########################## // ########################## nunchuk ##########################
@ -280,7 +287,7 @@ void Nunchuk_display()
if (Serial) { if (Serial) {
Serial.println("Controller disconnected!"); Serial.println("Controller disconnected!");
} }
nchuk.reconnect(); nchuk.connect();
} else { } else {
if (Serial) { if (Serial) {
// Read a button (on/off, C and Z) // Read a button (on/off, C and Z)
@ -342,7 +349,7 @@ char text[22];
display.drawPixel(x_d,y_d,SSD1306_WHITE); display.drawPixel(x_d,y_d,SSD1306_WHITE);
} }
else { else {
nchuk.reconnect(); nchuk.connect();
} }
} }
@ -359,7 +366,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