Hello to all... I have an issue trying to get a function recognised in this piece of code. My compilation error is "'sendCC' was not declared in this scope".
Can someone please tell me if the function "Void sendCC" can be placed where it is and if it is a question of curly braces causing the error?
Much appreciated for any help.
#include "TM1637.h" // include TM1637 library
#include <EEPROM.h>
#include <PinButton.h>
#include <MIDI.h>
#include <Control_Surface.h>
const int expPin = A0;
const int CCNum = 4;
int newExpVal = 0;
int lastExpVal = 0;
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
byte midi_clock = 0xf8;
#define CLK 2 // define TM1637 clock pin
#define DIO 3 // define TM1637 data pin
// initialize the TM1637 library
TM1637 tm1637(CLK, DIO);
//myButtonDN single click (de-increment preset)
//myButtonUP single click (increment preset)
//myButtonDN double click (increment bank)
//myButtonUP long click (save preset)
PinButton myButtonUP(4);
PinButton myButtonDN(5);
int num = 0, prev_num = 1;
int let = 0, prev_let = 1;
int i = 0, prev_i = 1;
const unsigned int numReadings = 3;
int storedValues[numReadings];
int Saves[numReadings];
int address1 = 0; // bank A // adresses need two spaces for ints! One for bytes
int address2 = 2; // bank B
int address3 = 4; // bank C
void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
// initialize the TM1637 display
tm1637.init();
// set display brightness (from 0 to 7)
tm1637.set(3);
EEPROM.get(address1, Saves[0]); // bank A
EEPROM.get(address2, Saves[1]); // bank B
EEPROM.get(address3, Saves[2]); // bank C
MIDI.sendRealTime(midi_clock);
}
/*
void sendCC(int val) {
usbMIDI.sendControlChange(CCNum, val, 3);
MIDI.sendControlChange(CCNum, val, 3);
}
*/
void loop() {
(MIDI.read());
myButtonUP.update();
myButtonDN.update();
int channel = let; // A B or C, midi chan, 1, 2 or 3! (pedal 1 2 or 3!)
int program = num;
if (num != prev_num) {
// if the displayed (current) number was changed
prev_num = num; // save current value of 'num'
//int program = num;
// print all data
//Serial.println(Saves[let]);
MIDI.sendProgramChange(program, (channel + 1)); // +1 means A = 1 etc!
tm1637.display(2, num / 10 % 10); // print tens digit
tm1637.display(3, num % 10); // print ones digit
//delay(200); // wait 200 milliseconds
}
if (let != prev_let) {
// if the displayed (current) number was changed
prev_let = let; // save current value of 'let'
// print all data
tm1637.display(0, (let + 10)); //this gives me 10, 11 & 12 (A,b & C)
}
if (i != prev_i) {
// if the displayed (current) number was changed
prev_i = i; // save current value of 'let'
tm1637.display(2, (Saves[let]) / 10 % 10); // print tens digit
tm1637.display(3, (Saves[let]) % 10); // print ones digit
MIDI.sendProgramChange(Saves[let], (channel + 1));
}
if (myButtonUP.isSingleClick()) {
// if the UP button is presses
num++; // increment 'num'
if (num > 99) //99
num = 0;
//Serial.println(num);
}
if (myButtonDN.isSingleClick()) {
// if the DN button is presses
num--; // decrement 'num'
if (num < 0)
num = 99; //99
//Serial.println(num);
}
if (myButtonDN.isDoubleClick()) {
//Serial.println("double");
let++; // increment 'let'
if (let > 2) // >= 3
let = 0;
num = Saves[let];
//Serial.println(Saves[let]);
}
if (myButtonUP.isLongClick()) {
//Serial.println("long");
Saves[let] = num;
i++;
if (let > 2) // >= 3
let = 0;
//Serial.println(F("Saving presets to EEPROM"));
//******** add serial print show what will be saved
for (byte i = 0; i < 3; i++) {
//Serial.println(Saves[i]);
}
newExpVal = analogRead(expPin);
newExpVal = map(newExpVal, 0, 1023, 0, 127);
newExpVal = constrain(newExpVal, 0, 127);
if (newExpVal != lastExpVal) {
sendCC(newExpVal);
}
lastExpVal = newExpVal;
}
void sendCC(int val) {
usbMIDI.sendControlChange(CCNum, val, 3);
MIDI.sendControlChange(CCNum, val, 3);
}
EEPROM.put(address3, Saves[2]); // bank C
EEPROM.put(address2, Saves[1]); // bank B
EEPROM.put(address1, Saves[0]); // bank A
}
