Can't use function in setup

Hello Everybody,

I would like to use a function in the setup, but i get the error message :"sketch_apr22a:280: error: 'SetValveSensorTrehsold' was not declared in this scope". I looked after, but didn't find anything about this being forbidden. Am I looking over something?

#define ENTRIES(ARRAY)	(sizeof(ARRAY) / sizeof(ARRAY[0]))

struct MidiMsg
{
  union
  {
    struct { 
      uint8_t D1, D2, D3; 
    };
    uint8_t Raw[3];
  };
};

const uint8_t _Fs3      = 0x2A;
const uint8_t _G3       = 0x2B;
const uint8_t _Gs3      = 0x2C;
const uint8_t _A3       = 0x2D;
const uint8_t _As3      = 0x2E;
const uint8_t _B3       = 0x2F;
const uint8_t _C4       = 0x30;
const uint8_t _Cs4      = 0x31;
const uint8_t _D4       = 0x32;
const uint8_t _Ds4      = 0x33;
const uint8_t _E4       = 0x34;
const uint8_t _F4       = 0x35;
const uint8_t _Fs4      = 0x36;
const uint8_t _G4       = 0x37;
const uint8_t _Gs4      = 0x38;
const uint8_t _A4       = 0x39;
const uint8_t _As4      = 0x3A;
const uint8_t _B4       = 0x3B;
const uint8_t _C5       = 0x3C;
const uint8_t _Cs5      = 0x3D;
const uint8_t _D5       = 0x3E;
const uint8_t _Ds5      = 0x3F;
const uint8_t _E5       = 0x40;
const uint8_t _F5       = 0x41;
const uint8_t _Fs5      = 0x42;
const uint8_t _G5       = 0x43;
const uint8_t _Gs5      = 0x44;
const uint8_t _A5       = 0x45;
const uint8_t _As5      = 0x46;
const uint8_t _B5       = 0x47;
const uint8_t _C6       = 0x48;

const uint8_t Ch1       = 0x00;
const uint8_t Ch2       = 0x01;
const uint8_t Ch3       = 0x02;
const uint8_t Ch4       = 0x03;
const uint8_t Ch5       = 0x04;
const uint8_t Ch6       = 0x05;
const uint8_t Ch7       = 0x06;
const uint8_t Ch8       = 0x07;
const uint8_t Ch9       = 0x08;
const uint8_t Ch10      = 0x09;
const uint8_t Ch11      = 0x0A;
const uint8_t Ch12      = 0x0B;
const uint8_t Ch13      = 0x0C;
const uint8_t Ch14      = 0x0D;
const uint8_t Ch15      = 0x0E;
const uint8_t Ch16      = 0x0F;

const uint8_t MaxVel    = 0x7F;
const uint8_t MinVel    = 0x00;

const uint8_t V1Sens	= A0;
const uint8_t V2Sens	= A1;
const uint8_t V3Sens	= A2;

const uint8_t ModeSens0	= 2;
const uint8_t ModeSens1	= 3;
const uint8_t ModeSens2	= 4;

const uint8_t Button1	= 8;
const uint8_t Button2	= 9;

int V1Treshold;
int V2Treshold;
int V3Treshold;

uint8_t LastValveState	= 8;

void SetValveSensorTreshold()
{
  V1Treshold = analogRead(V1Sens) - 5;
  V2Treshold = analogRead(V2Sens) - 5;
  V3Treshold = analogRead(V3Sens) - 5;
}  
uint8_t GetMode()
{
  uint8_t ModeSelector0 = !digitalRead(ModeSens0);
  uint8_t ModeSelector1 = !digitalRead(ModeSens1) <<1;
  uint8_t ModeSelector2 = !digitalRead(ModeSens2) <<2;

  return (ModeSelector0 | ModeSelector1 | ModeSelector2);
}
uint8_t GetValveState()
{
  int V1Read = analogRead(V1Sens);
  int V2Read = analogRead(V2Sens);
  int V3Read = analogRead(V3Sens);

  uint8_t V1State = 0;
  if (V1Read < V1Treshold) V1State = 1;

  uint8_t V2State = 0;
  if (V2Read < V2Treshold) V2State = 1;

  uint8_t V3State = 0;
  if (V3Read < V3Treshold) V3State = 1;

  V2State = V2State <<1;
  V3State = V3State <<2;

  return (V1State | V2State | V3State);
}
void SendMidiMsg(struct MidiMsg* Message)
{
  Serial.write(Message->Raw,  ENTRIES(Message->Raw));
  //Serial.write(Message->D1);
  //Serial.write(Message->D2);
  //Serial.write(Message->D3);

}
void SendNoteOn(uint8_t Num,uint8_t Ch,uint8_t Vel, ...)
{
  MidiMsg Message;
  va_list pa;
  va_start(pa,Vel);
  for (int i = 0 ; i < Num ; i++)
  {
    Message.D1 = 0x09 <<4 | Ch;
    Message.D2 = va_arg(pa,int);
    Message.D3 = Vel;
    SendMidiMsg(&Message);
  }	
  va_end(pa);
}
void AllNotesOff(uint8_t Ch) 
{
  MidiMsg Message;
  Message.D1 = 0x0B <<4 | Ch;
  Message.D2 = 0x7B;
  Message.D3 = MinVel;
  SendMidiMsg(&Message);
}
void SendPitchBend(uint8_t Ch,uint16_t Val) 
{
  MidiMsg Message;
  Message.D1 = 0xE <<4 | Ch;
  Message.D2 = Val & 0x7F;
  Message.D3 = Val >>7;
  SendMidiMsg(&Message);
}
void SendCC(uint8_t Ch, uint8_t Ctrl, uint8_t Val)
{
  MidiMsg Message;
  Message.D1 = 0x0B <<4 | Ch;
  Message.D2 = Ctrl;
  Message.D3 = Val;
  SendMidiMsg(&Message);
}
void SendScale(uint8_t ValveState,uint8_t Ch)
{
  uint8_t Vel = MaxVel;

  switch(ValveState)
  {
  case 0:
    SendNoteOn(1,Ch,Vel,_C4);
    break;
  case 1:
    SendNoteOn(1,Ch,Vel,_D4);
    break;
  case 2:
    SendNoteOn(1,Ch,Vel,_F4);
    break;
  case 3:
    SendNoteOn(1,Ch,Vel,_E4);
    break;
  case 4:
    SendNoteOn(1,Ch,Vel,_A4);
    break;
  case 5:
    SendNoteOn(1,Ch,Vel,_B4);
    break;
  case 6:
    SendNoteOn(1,Ch,Vel,_G4);
    break;
  case 7:
    SendNoteOn(1,Ch,Vel,_C5);
    break;
  }
}
void PBRestrict (uint8_t ValveState,uint8_t Ch)
{
  uint8_t Vel = MaxVel;

  switch (ValveState) 
  {
  case 0:
    SendNoteOn(3,Ch,Vel,_C5,_G5,_E5);
    break;
  case 1:
    SendNoteOn(3,Ch,Vel,_As5,_F5,_D5);
    break;
  case 2:
    SendNoteOn(3,Ch,Vel,_B5,_Fs5,_Ds5);
    break;
  case 5:
    SendNoteOn(2,Ch,Vel,_G5,_D5);
    break;
  case 6:
    SendNoteOn(2,Ch,Vel,_Gs5,_Ds5); 
    break;
  case 7:
    SendNoteOn(2,Ch,Vel,_Fs5,_Cs5); 
    break;
  default:
    SendNoteOn(3,Ch,Vel,_A5,_E5,_Cs5);
  }
}
void Send2_5Octave (uint8_t ValveState,uint8_t Ch)
{
  uint8_t Vel = MaxVel;

  switch (ValveState) 
  {
  case 0:
    SendNoteOn(6,Ch,Vel,_C4,_G4,_C5,_E5,_G5,_C6);
    break;
  case 2:
    SendNoteOn(6,Ch,Vel,_B3,_Fs4,_B4,_Ds5,_Fs5,_B5);
    break;
  case 3:
    SendNoteOn(4,Ch,Vel,_Gs3,_Ds4,_Gs4,_Gs5);
    break;
  case 4:
    SendNoteOn(6,Ch,Vel,_As3,_F4,_As4,_D5,_F5,_As5);
    break;
  case 5:
    SendNoteOn(2,Ch,Vel,_G3,_D4);
    break;
  case 7:
    SendNoteOn(2,Ch,Vel,_Fs3,_Cs4);
    break;
  default:
    SendNoteOn(5,Ch,Vel,_A3,_E4,_A4,_Cs5,_A5);
  }
}
void KantosRestrict (uint8_t ValveState,uint8_t Ch)
{
  switch (ValveState) 
  {
  case 0:
    SendPitchBend(Ch,4240);
    break;
  case 1:
    SendPitchBend(Ch,1060);
    break;
  case 2:
    SendPitchBend(Ch,584);
    break;
  case 5:
    SendPitchBend(Ch,132);
    break;
  case 6:
    SendPitchBend(Ch,566);
    break;
  case 7:
    SendPitchBend(Ch,8256);
    break;
  default:
    SendPitchBend(Ch,8336);
  }
}
void setup() 
{

  SetValveSensorTrehsold();

  pinMode(ModeSens0,INPUT);
  digitalWrite(ModeSens0,HIGH);
  pinMode(ModeSens1,INPUT);
  digitalWrite(ModeSens1,HIGH);
  pinMode(ModeSens2,INPUT);
  digitalWrite(ModeSens2,HIGH);

  Serial.begin(115200);
}
void loop() 
{
  uint8_t B1Ch = Ch2;
  uint8_t VsCh = Ch1;

  uint8_t Mode = GetMode();
  uint8_t ActualValveState = GetValveState();

  if (ActualValveState != LastValveState)
  {
    delay (50);
    ActualValveState = GetValveState();
    AllNotesOff(VsCh);
    switch (Mode) 
    {
    case 1: 
      Send2_5Octave(ActualValveState,VsCh); 
      break;
    case 2: 
      KantosRestrict(ActualValveState,VsCh); 
      break;
    case 0: 
      PBRestrict(ActualValveState,VsCh); 
      break;
    }
    LastValveState = ActualValveState;
  }
}

The function is spelt differently. You have swapped the s and the h in the call from setup.

marco_c:
The function is spelt differently. You have swapped the s and the h in the call from setup.

What a shame... Thanks for pointing it out!