#include <MD_MAX72xx.h>
MD_MAX72XX mx = MD_MAX72XX(MD_MAX72XX::PAROLA_HW, 10, 1);
// Joystick
bool joystickPress = false;
void setup()
{
// Joystick
pinMode(2, INPUT);
digitalWrite(2, HIGH);
Serial.begin(115200);
// Screen
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, MAX_INTENSITY / 2);
mx.clear();
}
void loop()
{
// Joystick
float joystickX = analogRead(0) / 1023.0 * 2 - 1;
float joystickY = analogRead(1) / 1023.0 * 2 - 1;
bool joystickPressed = digitalRead(2) == 0 ? true : false;
// Screen
mx.clear(false);
mx.setPoint(joystickY * -7, joystickX * 7, true);
if (joystickPressed)
mx.setPoint(joystickY * -7, joystickX * 7 + 1, true);
mx.update();
// Click
if (joystickPress != joystickPressed)
{
if (joystickPress == false)
click();
joystickPress = joystickPressed;
}
}
void click()
{
}