|
|
|
@ -28,7 +28,7 @@ Nunchuk nchuk(Wire2);
|
|
|
|
|
|
|
|
|
|
|
|
// ########################## DEFINES ##########################
|
|
|
|
// ########################## DEFINES ##########################
|
|
|
|
#define LED_BUILTIN PC13
|
|
|
|
#define LED_BUILTIN PC13
|
|
|
|
#define TIME_SEND 20 // [ms] poolling time interval
|
|
|
|
#define TIME_SEND 100 // [ms] time interval
|
|
|
|
#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 START_FRAME 0xAAAA // [-] Start frme definition for reliable serial communication
|
|
|
|
#define START_FRAME 0xAAAA // [-] Start frme definition for reliable serial communication
|
|
|
|
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
|
|
|
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
|
|
|
@ -109,6 +109,7 @@ void setup()
|
|
|
|
Serial1.begin(HOVER_SERIAL_BAUD);
|
|
|
|
Serial1.begin(HOVER_SERIAL_BAUD);
|
|
|
|
|
|
|
|
|
|
|
|
strip.begin(); // INITIALIZE NeoPixel strip object
|
|
|
|
strip.begin(); // INITIALIZE NeoPixel strip object
|
|
|
|
|
|
|
|
strip.clear();
|
|
|
|
strip.show(); // Turn OFF all pixels ASAP
|
|
|
|
strip.show(); // Turn OFF all pixels ASAP
|
|
|
|
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
|
|
|
|
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
|
|
|
|
|
|
|
|
|
|
|
|
@ -280,13 +281,29 @@ void Nunchuk_control()
|
|
|
|
// ########################## LOOP ##########################
|
|
|
|
// ########################## LOOP ##########################
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long iTimeSend = 0;
|
|
|
|
unsigned long iTimeSend = 0;
|
|
|
|
|
|
|
|
int idx_led = 0;
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned long timeNow = millis();
|
|
|
|
unsigned long timeNow = millis();
|
|
|
|
|
|
|
|
|
|
|
|
// Blink the LED
|
|
|
|
// Blink the LED
|
|
|
|
digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000);
|
|
|
|
digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000);
|
|
|
|
Receive();
|
|
|
|
Receive();
|
|
|
|
Nunchuk_control();
|
|
|
|
Nunchuk_control();
|
|
|
|
Serial.println(timeNow);
|
|
|
|
|
|
|
|
|
|
|
|
if (iTimeSend > timeNow)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
iTimeSend = timeNow + TIME_SEND;
|
|
|
|
|
|
|
|
strip.clear();
|
|
|
|
|
|
|
|
strip.setPixelColor(idx_led, strip.Color(128, 0, 0));
|
|
|
|
|
|
|
|
if (idx_led < strip.numPixels() -1 )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
idx_led++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
idx_led = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strip.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|