|
|
|
|
@ -69,6 +69,7 @@ SerialFeedback NewFeedback;
|
|
|
|
|
|
|
|
|
|
int cmd1; // normalized input values. -1000 to 1000
|
|
|
|
|
int cmd2;
|
|
|
|
|
int idx_ledR = 0, idx_ledL = 0;
|
|
|
|
|
|
|
|
|
|
// ########################## colorWipe ##########################
|
|
|
|
|
// Fill strip pixels one after another with a color. Strip is NOT cleared
|
|
|
|
|
@ -123,8 +124,8 @@ void setup()
|
|
|
|
|
2),
|
|
|
|
|
0);
|
|
|
|
|
display.println("Hoverboard Control");
|
|
|
|
|
display.setCursor(int((display.width() - (strlen("v STM32 0.1") * 6)) / 2), 8);
|
|
|
|
|
display.println("v STM32 0.1");
|
|
|
|
|
display.setCursor(int((display.width() - (strlen("v STM32 0.2") * 6)) / 2), 8);
|
|
|
|
|
display.println("v STM32 0.2");
|
|
|
|
|
|
|
|
|
|
// Fill along the length of the strip in various colors...
|
|
|
|
|
|
|
|
|
|
@ -214,7 +215,7 @@ void Receive()
|
|
|
|
|
Serial.print(" 8: ");
|
|
|
|
|
Serial.println(Feedback.boardTemp);
|
|
|
|
|
}
|
|
|
|
|
display.setCursor(0, 30);
|
|
|
|
|
display.setCursor(0, 40);
|
|
|
|
|
display.setTextSize(1); // Draw 1X-scale text
|
|
|
|
|
display.setTextColor(SSD1306_WHITE);
|
|
|
|
|
display.print("V : ");
|
|
|
|
|
@ -246,16 +247,19 @@ void Nunchuk_control()
|
|
|
|
|
if (!nchuk.update())
|
|
|
|
|
{
|
|
|
|
|
nchuk.reconnect();
|
|
|
|
|
cmd1 = 0;
|
|
|
|
|
cmd2 = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (nchuk.buttonC()) {
|
|
|
|
|
idx_ledR = 0;
|
|
|
|
|
idx_ledL = 0;
|
|
|
|
|
}
|
|
|
|
|
cmd1 = map(nchuk.joyX(), 0, 256, 150, -150); // x - axis. Nunchuck joystick readings range 150 -150
|
|
|
|
|
cmd2 = map(nchuk.joyY(), 0, 256, -150, 150); // y - axis
|
|
|
|
|
|
|
|
|
|
Send(cmd1, cmd2);
|
|
|
|
|
}
|
|
|
|
|
display.setCursor(0, 40);
|
|
|
|
|
display.setCursor(0, 48);
|
|
|
|
|
display.setTextSize(1); // Draw 1X-scale text
|
|
|
|
|
display.setTextColor(SSD1306_WHITE);
|
|
|
|
|
display.print("X : ");
|
|
|
|
|
@ -264,7 +268,7 @@ void Nunchuk_control()
|
|
|
|
|
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.setCursor(0, 56);
|
|
|
|
|
display.setTextSize(1); // Draw 1X-scale text
|
|
|
|
|
display.setTextColor(SSD1306_WHITE);
|
|
|
|
|
display.print("Y : ");
|
|
|
|
|
@ -279,7 +283,6 @@ void Nunchuk_control()
|
|
|
|
|
// ########################## LOOP ##########################
|
|
|
|
|
|
|
|
|
|
unsigned long iTimeSendR = 0, iTimeSendL = 0;
|
|
|
|
|
int idx_ledR = 0, idx_ledL = 0;
|
|
|
|
|
int speedR, speedL;
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
|
@ -290,7 +293,7 @@ void loop()
|
|
|
|
|
digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000);
|
|
|
|
|
Receive();
|
|
|
|
|
Nunchuk_control();
|
|
|
|
|
|
|
|
|
|
Send(cmd1, cmd2);
|
|
|
|
|
// ********************* simulation *********************************
|
|
|
|
|
// in final project need to use Feedback.speedR_meas and Feedback.speedL_meas
|
|
|
|
|
//
|
|
|
|
|
|