Inputs test code - Check it out

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();


}
2 Likes

Hi! :slight_smile:

Sorry for the late reply.

Unfortunately, the batch of Jay-Ds that was sent for you had a minor software issue.

We have detected that the semiconductor on the board needs a longer time to boot, which was unexpected, and this causes a problem while booting the device.

This is a minor software issue that we have solved by publishing a software update.

Hence, when you assemble your Jay-D, you will have to connect it to your PC and update the firmware using the CircuitBlocks.

Please, follow the build guide or FAQ, and you’ll find the instructions on how to do so in the Jay-D build guide.

Sincerely,
Monika from CircuitMess

Hi Monica.

The updated firmware works! Now my Jay-D is working.

  1. It happens that the sound glitches/scatter/lag, it seems the ESP cannot play two songs at the same time without lagging.
1 Like

:grinning: WORKING TEST CODE - USEFULL TO CHECK INPUTS VALUES :grinning:

#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();


}
1 Like

Hi @Feetrikki_Marcon,

thank you for letting me know.

Glad that your Jay-D is now working! :slight_smile:

Enjoy the rest of the build and code, and let us know if you have any further questions or issues.

Sincerely,
Monika