test board config

test_board
jerome 5 years ago
parent da121e2fdc
commit f9d74db9e1

@ -10,7 +10,6 @@
[platformio]
default_envs = leonardo
; default_envs = stm32-411
[common_env_data]
@ -20,6 +19,9 @@ framework = arduino
platform = atmelavr
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
@ -30,8 +32,10 @@ framework = arduino
board = leonardo
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
@ -43,9 +47,10 @@ 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
@ -57,4 +62,6 @@ 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

@ -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);
@ -269,8 +276,8 @@ int old_cursorX, old_cursorY;
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();
}
}

Loading…
Cancel
Save