Use this code to check your inputs (faders, encoders and push buttons).
#include <Arduino.h>
#include <CircuitOS.h>
#include <JayD.h>
#include <Loop/LoopManager.h>
#include <Input/InputJayD.h>
boolean pushENCmid;
boolean pushENCR1;
boolean pushENCR2;
boolean pushENCR3;
boolean pushENCL3;
boolean pushENCL2;
boolean pushENCL1;
boolean push1True;
boolean push2True;
int valuePotLrec;
int valuePotRrec;
int valuePotMrec;
int valENCleft3;
int valENCleft2;
int valENCleft1;
int valENCright3;
int valENCright1;
int valENCright2;
int valENCmid;
Display* display;
Sprite* sprite;
void button_BTN_MID_press(){
pushENCmid = true;
testala();
}
void button_BTN_R1_press(){
pushENCR1 = true;
testala();
}
void button_BTN_R2_press(){
pushENCR2 = true;
testala();
}
void button_BTN_R3_press(){
pushENCR3 = true;
testala();
}
void button_BTN_MID_release(){
pushENCmid = false;
testala();
}
void button_BTN_R1_release(){
pushENCR1 = false;
testala();
}
void button_BTN_R2_release(){
pushENCR2 = false;
testala();
}
void button_BTN_R3_release(){
pushENCR3 = false;
testala();
}
void potentiometer_POT_L_moved(uint8_t value){
valuePotLrec = value;
testala();
}
void button_BTN_L3_press(){
pushENCL3 = true;
testala();
}
void potentiometer_POT_R_moved(uint8_t value){
valuePotRrec = value;
testala();
}
void potentiometer_POT_MID_moved(uint8_t value){
valuePotMrec = value;
testala();
}
void button_BTN_L3_release(){
pushENCL3 = false;
testala();
}
void encoder_ENC_L3_moved(int8_t amount){
valENCleft3 += amount;
testala();
}
void button_BTN_L2_press(){
pushENCL2 = true;
testala();
}
void encoder_ENC_L2_moved(int8_t amount){
valENCleft2 += amount;
testala();
}
void encoder_ENC_L1_moved(int8_t amount){
valENCleft1 += amount;
testala();
}
void button_BTN_L2_release(){
pushENCL2 = false;
testala();
}
void encoder_ENC_R3_moved(int8_t amount){
valENCright3 += amount;
testala();
}
void button_BTN_L1_press(){
pushENCL1 = true;
testala();
}
void encoder_ENC_R1_moved(int8_t amount){
valENCright1 += amount;
testala();
}
void encoder_ENC_R2_moved(int8_t amount){
valENCright2 += amount;
testala();
}
void button_BTN_L1_release(){
pushENCL1 = false;
testala();
}
void encoder_ENC_MID_moved(int8_t amount){
valENCmid += amount;
testala();
}
void button_BTN_L_release(){
push1True = false;
testala();
}
void button_BTN_L_press(){
push1True = true;
testala();
}
void button_BTN_R_release(){
push2True = false;
testala();
}
void button_BTN_R_press(){
push2True = true;
testala();
}
int testala() {
sprite->clear(TFT_BLACK);
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_GREEN);
sprite->drawString((String("Value POT L: ") + String(valuePotLrec)), 10, 0);
sprite->drawString((String("Value POT R: ") + String(valuePotRrec)), 10, 23);
sprite->drawString((String("Value POT M: ") + String(valuePotMrec)), 10, 12);
sprite->setTextColor(TFT_YELLOW);
sprite->drawString((String("Value ENC L 3: ") + String(valENCleft3)), 10, 56);
sprite->drawString((String("Value ENC L 2: ") + String(valENCleft2)), 10, 45);
sprite->drawString((String("Value ENC L 1: ") + String(valENCleft1)), 10, 34);
sprite->setTextColor(TFT_RED);
sprite->drawString((String("Value ENC R 1: ") + String(valENCright1)), 10, 78);
sprite->drawString((String("Value ENC R 2: ") + String(valENCright2)), 10, 89);
sprite->drawString((String("Value ENC R 3: ") + String(valENCright3)), 10, 101);
sprite->setTextColor(TFT_ORANGE);
sprite->drawString((String("Value ENC Mid: ") + String(valENCmid)), 10, 67);
if (pushENCL1) {
sprite->setTextColor(TFT_YELLOW);
sprite->drawString("ON", 137, 34);
display->commit();
} else {
sprite->setTextColor(TFT_YELLOW);
sprite->drawString("OFF", 137, 34);
display->commit();
}
if (pushENCL3) {
sprite->setTextColor(TFT_YELLOW);
sprite->drawString("ON", 137, 45);
display->commit();
} else {
sprite->setTextColor(TFT_YELLOW);
sprite->drawString("OFF", 137, 45);
display->commit();
}
if (pushENCL3) {
sprite->setTextColor(TFT_YELLOW);
sprite->drawString("ON", 137, 56);
display->commit();
} else {
sprite->setTextColor(TFT_YELLOW);
sprite->drawString("OFF", 137, 56);
display->commit();
}
if (pushENCR1) {
sprite->setTextColor(TFT_RED);
sprite->drawString("ON", 137, 78);
display->commit();
} else {
sprite->setTextColor(TFT_RED);
sprite->drawString("OFF", 137, 78);
display->commit();
}
if (pushENCR2) {
sprite->setTextColor(TFT_RED);
sprite->drawString("ON", 137, 89);
display->commit();
} else {
sprite->setTextColor(TFT_RED);
sprite->drawString("OFF", 137, 89);
display->commit();
}
if (pushENCR3) {
sprite->setTextColor(TFT_RED);
sprite->drawString("ON", 137, 101);
display->commit();
} else {
sprite->setTextColor(TFT_RED);
sprite->drawString("OFF", 137, 101);
display->commit();
}
if (push1True) {
sprite->setTextColor(TFT_DARKGREY);
sprite->drawString((String("Push L: ") + String("ON")), 10, 112);
display->commit();
} else {
sprite->setTextColor(TFT_DARKGREY);
sprite->drawString((String("Push L: ") + String("OFF")), 10, 112);
display->commit();
}
if (push2True) {
sprite->setTextColor(TFT_LIGHTGREY);
sprite->drawString((String("Push R: ") + String("ON")), 83, 112);
display->commit();
} else {
sprite->setTextColor(TFT_LIGHTGREY);
sprite->drawString((String("Push R: ") + String("OFF")), 83, 112);
display->commit();
}
if (pushENCmid) {
sprite->setTextColor(TFT_ORANGE);
sprite->drawString("ON", 137, 67);
display->commit();
} else {
sprite->setTextColor(TFT_ORANGE);
sprite->drawString("OFF", 137, 67);
display->commit();
}
display->commit();
}
void setup() {
Serial.begin(115200);
Serial.println();
JayD.begin();
pinMode(PIN_BL, OUTPUT); digitalWrite(PIN_BL, LOW);
display = &JayD.getDisplay();
sprite = display->getBaseSprite();
InputJayD::getInstance()->setBtnPressCallback(BTN_MID, button_BTN_MID_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_R1, button_BTN_R1_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_R2, button_BTN_R2_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_R3, button_BTN_R3_press);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_MID, button_BTN_MID_release);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_R1, button_BTN_R1_release);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_R2, button_BTN_R2_release);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_R3, button_BTN_R3_release);
InputJayD::getInstance()->setPotMovedCallback(POT_L, potentiometer_POT_L_moved);
InputJayD::getInstance()->setBtnPressCallback(BTN_L3, button_BTN_L3_press);
InputJayD::getInstance()->setPotMovedCallback(POT_R, potentiometer_POT_R_moved);
InputJayD::getInstance()->setPotMovedCallback(POT_MID, potentiometer_POT_MID_moved);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L3, button_BTN_L3_release);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_L3, encoder_ENC_L3_moved);
InputJayD::getInstance()->setBtnPressCallback(BTN_L2, button_BTN_L2_press);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_L2, encoder_ENC_L2_moved);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_L1, encoder_ENC_L1_moved);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L2, button_BTN_L2_release);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_R3, encoder_ENC_R3_moved);
InputJayD::getInstance()->setBtnPressCallback(BTN_L1, button_BTN_L1_press);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_R1, encoder_ENC_R1_moved);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_R2, encoder_ENC_R2_moved);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L1, button_BTN_L1_release);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_MID, encoder_ENC_MID_moved);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L, button_BTN_L_release);
InputJayD::getInstance()->setBtnPressCallback(BTN_L, button_BTN_L_press);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_R, button_BTN_R_release);
InputJayD::getInstance()->setBtnPressCallback(BTN_R, button_BTN_R_press);
pushENCL3 = false;
pushENCL2 = false;
pushENCL1 = false;
pushENCR3 = false;
pushENCR2 = false;
pushENCR1 = false;
pushENCmid = false;
push1True = false;
push2True = false;
testala();
}
void loop() {
LoopManager::loop();
}