Compare commits

...

7 Commits

@ -1,4 +1,4 @@
;PlatformIO Project Configuration File
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
@ -9,8 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
; default_envs = leonardo
default_envs = stm32-411
default_envs = leonardo
[common_env_data]
@ -18,8 +17,11 @@ default_envs = stm32-411
board = leonardo
framework = arduino
platform = atmelavr
lib_deps =
Nintendo Extension Ctrl
lib_deps =
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*
upload_port = /dev/ttyACM*
monitor_speed = 115200
@ -28,24 +30,27 @@ monitor_speed = 115200
platform = atmelavr
framework = arduino
board = leonardo
lib_deps =
Nintendo Extension Ctrl
lib_deps =
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
; each flag in a new line
upload_flags =
-Pusb
upload_flags =
-Pusb
[env:stm32-411]
platform = ststm32
framework = arduino
board = nucleo_f411re
build_flags =
-Wno-deprecated
lib_deps =
Nintendo Extension Ctrl
build_flags =
-Wno-deprecated
lib_deps =
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
monitor_port = /dev/ttyACM*
monitor_speed = 115200
@ -53,8 +58,10 @@ monitor_speed = 115200
platform = ststm32
framework = arduino
board = nucleo_l031k6
build_flags =
-Wno-deprecated
lib_deps =
Nintendo Extension Ctrl
build_flags =
-Wno-deprecated
lib_deps =
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 VERSION_TAG "v test 0.1"
// ########################## DEFINES ##########################
#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)
@ -92,13 +95,16 @@ 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()
{
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)
// Clear the buffer
@ -112,8 +118,8 @@ void setup()
(strlen("Hoverboard Serial") * 6)) / 2), 0);
display.println("Hoverboard Serial");
display.setCursor(int
((display.width() -(strlen("v STM32 0.1") *6))/2), 8);
display.println("v STM32 0.1");
((display.width() -(strlen(VERSION_TAG) *6))/2), 8);
display.println(VERSION_TAG);
/*
display.print("Nunchuk ");
nchuk.connect()? display.print("") : display.print("not ");
@ -128,7 +134,7 @@ void setup()
Serial.begin(SERIAL_BAUD);
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;
if (!nchuk.update()) {
nchuk.reconnect();
nchuk.connect();
} else {
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("Y : "); Serial.println(nchuk.joyY());
}
/*
display.setCursor(0, 40);
display.setTextSize(1); // Draw 1X-scale text
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.setCursor(old_cursorX, old_cursorY);
display.print(cmd1);
display.setCursor(0, 50);
display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE);
@ -268,9 +275,9 @@ int old_cursorX, old_cursorY;
display.print(cmd2);
display.display();
*/
Send(cmd1, cmd2);
// Send(cmd1, cmd2);
Send(0, cmd2);
}
// ########################## nunchuk ##########################
@ -280,7 +287,7 @@ void Nunchuk_display()
if (Serial) {
Serial.println("Controller disconnected!");
}
nchuk.reconnect();
nchuk.connect();
} else {
if (Serial) {
// Read a button (on/off, C and Z)
@ -342,7 +349,7 @@ char text[22];
display.drawPixel(x_d,y_d,SSD1306_WHITE);
}
else {
nchuk.reconnect();
nchuk.connect();
}
}
@ -359,7 +366,7 @@ void loop(void)
unsigned long timeNow = millis();
// Check for new received data
// Receive();
Receive();
if (iTimeSend > timeNow)
return;

Loading…
Cancel
Save