Hello, since I’ve problems with my JAY-D I’ve wrote this code for testing the values incoming from the inputs - encoders, buttons, faders.
Could someone try it and tell if it works? Thanks!
Attached a photo of what it should be like.
#include <Arduino.h>
#include <CircuitOS.h>
#include <JayD.h>
#include <Loop/LoopManager.h>
#include <Input/InputJayD.h>
boolean pushENCL3;
boolean pushENCL2;
boolean pushENCL1;
boolean pushENCR1;
boolean pushENCmid;
boolean pushENCR2;
boolean pushENCR3;
boolean push1True;
boolean push2True;
int valENCmid;
int valuePotMrec;
int valENCleft1;
int valENCright1;
int valuePotRrec;
int valENCleft2;
int valENCright2;
int valuePotLrec;
int valENCleft3;
int valENCright3;
Display* display;
Sprite* sprite;
void button_BTN_L3_press(){
pushENCL3 = true;
valuePushENCL3();
}
void button_BTN_L2_press(){
pushENCL2 = true;
valuePushENCL2();
}
void button_BTN_L1_press(){
pushENCL1 = true;
valuePushENCL1();
}
void button_BTN_L3_release(){
pushENCL3 = false;
valuePushENCL3();
}
void button_BTN_L2_release(){
pushENCL2 = false;
valuePushENCL2();
}
void button_BTN_L1_release(){
pushENCL1 = false;
valuePushENCL1();
}
void button_BTN_R1_press(){
pushENCR1 = true;
valuePushENCR1();
}
void button_BTN_MID_press(){
pushENCmid = true;
valuePUSHencMID();
}
void button_BTN_R2_press(){
pushENCR2 = true;
valuePushENCR2();
}
void button_BTN_R3_press(){
pushENCR3 = true;
valuePushENCR3();
}
void button_BTN_MID_release(){
pushENCmid = false;
valuePUSHencMID();
}
void button_BTN_R1_release(){
pushENCR1 = false;
valuePushENCR1();
}
void button_BTN_R2_release(){
pushENCR2 = false;
valuePushENCR2();
}
void button_BTN_L_release(){
push1True = false;
valuePUSH1();
}
void button_BTN_R_release(){
push2True = false;
valuePUSH2();
}
void button_BTN_L_press(){
push1True = true;
valuePUSH1();
}
void button_BTN_R_press(){
push2True = true;
valuePUSH2();
}
void encoder_ENC_MID_moved(int8_t amount){
valENCmid += amount;
valueENCmid();
}
void potentiometer_POT_MID_moved(uint8_t value){
valuePotMrec += value;
valuePotM();
}
void encoder_ENC_L1_moved(int8_t amount){
valENCright3 += amount;
valueENCright3();
}
void potentiometer_POT_R_moved(uint8_t value){
valuePotRrec += value;
valuePotR();
}
void potentiometer_POT_L_moved(uint8_t value){
valuePotLrec += value;
valuePotL();
}
int valuePushENCL3() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_BLUE);
if (true) {
sprite->drawString("ON", 137, 56);
display->commit();
} else {
sprite->drawString("OFF", 137, 56);
display->commit();
}
}
int valuePushENCL2() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_BLUE);
if (true) {
sprite->drawString("ON", 137, 45);
display->commit();
} else {
sprite->drawString("OFF", 137, 45);
display->commit();
}
}
int valuePushENCL1() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_BLUE);
if (true) {
sprite->drawString("ON", 137, 34);
display->commit();
} else {
sprite->drawString("OFF", 137, 34);
display->commit();
}
}
int valuePushENCR1() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_ORANGE);
if (true) {
sprite->drawString("ON", 137, 78);
display->commit();
} else {
sprite->drawString("OFF", 137, 78);
display->commit();
}
}
int valuePushENCR2() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_ORANGE);
if (true) {
sprite->drawString("ON", 137, 89);
display->commit();
} else {
sprite->drawString("OFF", 137, 89);
display->commit();
}
}
int valuePUSHencMID() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_RED);
if (true) {
sprite->drawString("ON", 137, 67);
display->commit();
} else {
sprite->drawString("OFF", 137, 67);
display->commit();
}
}
int valuePushENCR3() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_ORANGE);
if (true) {
sprite->drawString("ON", 137, 101);
display->commit();
} else {
sprite->drawString("OFF", 137, 101);
display->commit();
}
}
int valuePUSH1() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_LIGHTGREY);
if (push1True) {
sprite->drawString((String("Push L: ") + String("ON")), 10, 112);
display->commit();
} else {
sprite->drawString((String("Push L: ") + String("OFF")), 10, 112);
display->commit();
}
}
int valuePUSH2() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_WHITE);
if (push1True) {
sprite->drawString((String("Push R: ") + String("ON")), 83, 112);
display->commit();
} else {
sprite->drawString((String("Push R: ") + String("OFF")), 83, 112);
display->commit();
}
}
int valueENCmid() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_RED);
sprite->drawString((String("Value ENC Mid: ") + String(valENCmid)), 10, 67);
display->commit();
}
int valuePotM() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_GREEN);
sprite->drawString((String("Value POT M: ") + String(valuePotMrec)), 10, 12);
display->commit();
}
int valueENCleft1() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_BLUE);
sprite->drawString((String("Value ENC L 1: ") + String(valENCleft1)), 10, 34);
display->commit();
}
int valueENCright1() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_ORANGE);
sprite->drawString((String("Value ENC R 1: ") + String(valENCright1)), 10, 78);
display->commit();
}
int valuePotR() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_GREEN);
sprite->drawString((String("Value POT R: ") + String(valuePotRrec)), 10, 23);
display->commit();
}
int valueENCleft2() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_BLUE);
sprite->drawString((String("Value ENC L 2: ") + String(valENCleft2)), 10, 45);
display->commit();
}
int valueENCright2() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_ORANGE);
sprite->drawString((String("Value ENC R 2: ") + String(valENCright2)), 10, 89);
display->commit();
}
int valuePotL() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_GREEN);
sprite->drawString((String("Value POT L: ") + String(valuePotLrec)), 10, 0);
display->commit();
}
int valueENCleft3() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_BLUE);
sprite->drawString((String("Value ENC L 3: ") + String(valENCleft3)), 10, 56);
display->commit();
}
int valueENCright3() {
sprite->setTextSize(1);
sprite->setTextFont(2);
sprite->setTextColor(TFT_ORANGE);
sprite->drawString((String("Value ENC R 3: ") + String(valENCright3)), 10, 101);
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_L3, button_BTN_L3_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_L2, button_BTN_L2_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_L1, button_BTN_L1_press);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L3, button_BTN_L3_release);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L2, button_BTN_L2_release);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_L1, button_BTN_L1_release);
InputJayD::getInstance()->setBtnPressCallback(BTN_R1, button_BTN_R1_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_MID, button_BTN_MID_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_L, button_BTN_L_release);
InputJayD::getInstance()->setBtnReleaseCallback(BTN_R, button_BTN_R_release);
InputJayD::getInstance()->setBtnPressCallback(BTN_L, button_BTN_L_press);
InputJayD::getInstance()->setBtnPressCallback(BTN_R, button_BTN_R_press);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_MID, encoder_ENC_MID_moved);
InputJayD::getInstance()->setPotMovedCallback(POT_MID, potentiometer_POT_MID_moved);
InputJayD::getInstance()->setEncoderMovedCallback(ENC_L1, encoder_ENC_L1_moved);
InputJayD::getInstance()->setPotMovedCallback(POT_R, potentiometer_POT_R_moved);
InputJayD::getInstance()->setPotMovedCallback(POT_L, potentiometer_POT_L_moved);
pushENCL3 = false;
pushENCL2 = false;
pushENCL1 = false;
pushENCR3 = false;
pushENCR2 = false;
pushENCR1 = false;
pushENCmid = false;
push1True = false;
push2True = false;
sprite->clear(TFT_BLACK);
valuePotL();
valuePotR();
valuePotM();
valueENCleft1();
valuePushENCL1();
valueENCleft2();
valuePushENCL2();
valueENCleft3();
valuePushENCL3();
valueENCmid();
valuePUSHencMID();
valueENCright1();
valuePushENCR1();
valueENCright2();
valuePushENCR2();
valueENCright3();
valuePushENCR3();
valuePUSH1();
valuePUSH2();
}
void loop() {
LoopManager::loop();
}