add delay beetwen reading nunchuck

debug_i2c
JbLb 6 years ago
parent f81010a24a
commit 7b18af904a

@ -34,7 +34,7 @@
#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 START_FRAME 0xAAAA // [-] Start frme definition for reliable serial communication
#define TIME_SEND 100 // [ms] Sending time interval
#define TIME_SEND 25 // [ms] Sending time interval
#define SPEED_MAX_TEST 300 // [-] Maximum speed for testing
//#define DEBUG_RX // [-] Debug received data. Prints all bytes to serial (comment-out to disable)
@ -224,9 +224,15 @@ int old_cursorX, old_cursorY;
nchuk.reconnect();
} else {
cmd1 = map(nchuk.joyX(),0,256,-300,300); // x - axis. Nunchuck joystick readings range 30 - 230
cmd2 = map(nchuk.joyY(),0,256, 300, -300); // y - axis
Serial.print("X : "); Serial.println(nchuk.joyX());
Serial.print("Y : "); Serial.println(nchuk.joyY());
cmd1 = map(nchuk.joyX(),0,256,300,-300); // x - axis. Nunchuck joystick readings range 300 - -300
cmd2 = map(nchuk.joyY(),0,256,-300, 300); // y - axis
}
/*
display.setCursor(0, 40);
display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE);
@ -336,13 +342,14 @@ void loop(void)
{
unsigned long timeNow = millis();
// Check for new received data
Receive();
// Nunchuk_display();
// show_dot();
// display.display();
// Check for new received data
// Receive();
Nunchuk_control();
if (iTimeSend > timeNow)
return;
iTimeSend = timeNow + TIME_SEND;
// Nunchuk_display();
Nunchuk_control();
/*
// Send commands
if (iTimeSend > timeNow)

Loading…
Cancel
Save