From 2046425984548ef20c19115b42ab1bc109df0ed4 Mon Sep 17 00:00:00 2001 From: JbLb Date: Wed, 15 Jan 2020 22:23:28 +0100 Subject: [PATCH] beter way to manage command from nunchuck --- src/hoverserial.ino | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/hoverserial.ino b/src/hoverserial.ino index 97c6aa3..e6a69d0 100644 --- a/src/hoverserial.ino +++ b/src/hoverserial.ino @@ -40,8 +40,6 @@ // ########################## macros ############################ -#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) - #include #include #include @@ -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