nunchunk stuff

master
JbLb 6 years ago
parent ef0b4eefbd
commit 1b0b2fa685

@ -41,7 +41,7 @@
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <NintendoExtensionCtrl.h>
#include <NintendoExtensionCtrl.h> // https://github.com/dmadison/NintendoExtensionCtrl
// #include <SoftwareSerial.h>
@ -239,6 +239,49 @@ void Nunchuk_display()
}
// ########################## nunchuk ##########################
void show_dot()
{
int old_cursorX, old_cursorY;
char text[22];
if (nchuk.update()) {
display.setCursor(0, 20);
display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE);
display.print("X : ");
old_cursorX = display.getCursorX();
old_cursorY = display.getCursorY();
display.fillRect(old_cursorX, old_cursorY, (6 * 4), 8, SSD1306_BLACK); // erase previous display
display.setCursor(old_cursorX, old_cursorY);
display.print(nchuk.joyX());
display.setCursor(0, 50);
display.setTextSize(1); // Draw 1X-scale text
display.setTextColor(SSD1306_WHITE);
display.print("Y : ");
old_cursorX = display.getCursorX();
old_cursorY = display.getCursorY();
display.fillRect(old_cursorX, old_cursorY, (6 * 4), 8, SSD1306_BLACK); // erase previous display
display.setCursor(old_cursorX, old_cursorY);
display.print(nchuk.joyY());
int y_d = int(41 + (44*(nchuk.joyY()-128))/256);
int x_d = int(80 + (44*(nchuk.joyX()-128))/256);
if (Serial) {
sprintf (text,"y_d : %d | x_d : %d", y_d , x_d );
Serial.println(text);
}
display.drawPixel(x_d,y_d,SSD1306_WHITE);
}
else {
nchuk.reconnect();
}
}
// ########################## LOOP ##########################
unsigned long iTimeSend = 0;
@ -253,7 +296,11 @@ void loop(void)
// Check for new received data
Receive();
Nunchuk_display();
// Nunchuk_display();
// show_dot();
// display.display();
// Send commands
if (iTimeSend > timeNow)
return;

Loading…
Cancel
Save