64 lines
1.1 KiB
C++
64 lines
1.1 KiB
C++
#include <Arduino.h>
|
|
|
|
#define SCREEN_WIDTH 320
|
|
#define SCREEN_HEIGHT 240
|
|
|
|
#define ENCODER_BUTTON_PIN = 14;
|
|
#define ENCODER_A_PIN = 12;
|
|
#define ENCODER_B_PIN = 13;
|
|
|
|
#define ANALOG_OUTPUT_PIN = 25;
|
|
|
|
#include <ui/display.hpp>
|
|
#include <input/encoder.hpp>
|
|
#include <audio/tone_generator.hpp>
|
|
|
|
const int ONBOARD_LED_PIN = 2;
|
|
const int ANALOG_INPUT_PIN = 34;
|
|
|
|
void handle_pad_inputs(void *pvParameters);
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
pinMode(ONBOARD_LED_PIN, OUTPUT);
|
|
pinMode(ANALOG_INPUT_PIN, INPUT);
|
|
|
|
|
|
xTaskCreate(handle_pad_inputs, "handle_pad_inputs", 2048, NULL, 1, NULL);
|
|
|
|
Encoder::init();
|
|
Display::init();
|
|
|
|
Serial.println("setup complete");
|
|
Display::setLabelText("Boot complete.");
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
Display::update();
|
|
delay(5);
|
|
}
|
|
|
|
void handle_pad_inputs(void *pvParameters)
|
|
{
|
|
while (true)
|
|
{
|
|
int max = 0;
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
int value = analogRead(ANALOG_INPUT_PIN);
|
|
if (!ToneGenerator::isToneOn() && value > 0)
|
|
{
|
|
ToneGenerator::setToneOn(true);
|
|
}
|
|
if (value > max)
|
|
{
|
|
max = value;
|
|
}
|
|
delay(1);
|
|
}
|
|
}
|
|
}
|
|
|