beter way to manage command from nunchuck

master
JbLb 6 years ago
parent 4c4d854ebc
commit 2046425984

@ -40,8 +40,6 @@
// ########################## macros ############################
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
@ -226,8 +224,8 @@ int old_cursorX, old_cursorY;
nchuk.reconnect();
} else {
cmd1 = CLAMP((nchuk.joyX() - 128) * 6, -300, 300); // x - axis. Nunchuck joystick readings range 30 - 230
cmd2 = CLAMP((nchuk.joyY() - 128) * 6, 300, -300); // y - axis
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
}
display.setCursor(0, 40);
display.setTextSize(1); // Draw 1X-scale text

Loading…
Cancel
Save