Local Building - functions not declared

I have been trying to build locally with the develop branch and my user app, but I have been getting the below errors. All the errors pertain to functions within my code.

Does anyone know why the functions do not compile?

Heres my app.cpp code:

#include "application.h"

#define centerPin 4 //Center switch for tray alignment
#define motorPin4 P1S0  // Orange - 28BYJ48 pin 4 Stepper motor control
#define motorPin3 P1S1  // Yellow - 28BYJ48 pin 3 Stepper motor control
#define motorPin2 P1S2  // Pink   - 28BYJ48 pin 2 Stepper motor control
#define motorPin1 P1S3  // Blue   - 28BYJ48 pin 1 Stepper motor control

boolean centerStatus = FALSE;
int motorSpeed = 1700;
int currStep = 1;

//SYSTEM_MODE(SEMI_AUTOMATIC);

void setup() {
    pinMode(centerPin, INPUT_PULLUP); //Battery volage readings
    pinMode(motorPin1, OUTPUT); //stepper mortor pin
    pinMode(motorPin2, OUTPUT); //stepper mortor pin
    pinMode(motorPin3, OUTPUT); //stepper mortor pin
    pinMode(motorPin4, OUTPUT); //stepper mortor pin
    
    setMotor(0,0,0,0,0);    //Turns stepper motor off
    attachInterrupt(centerPin, centerTriggered, FALLING);

    while (centerStatus == false){
        nextStep();
    }
}

void loop(void) {

}

void nextStep(){

     switch (currStep) {
        case 1:
            setMotor(1,0,0,0,motorSpeed);
          break;
        case 2:
          setMotor(1,1,0,0,motorSpeed);
          break;
        case 3:
          setMotor(0,1,0,0,motorSpeed);
          break;
        case 4:
          setMotor(0,1,1,0,motorSpeed);
          break;
        case 5:
          setMotor(0,0,1,0,motorSpeed);
          break;
        case 6:
          setMotor(0,0,1,1,motorSpeed);
          break;
        case 7:
          setMotor(0,0,0,1,motorSpeed);
          break;
        case 8:
          setMotor(1,0,0,1,motorSpeed);
          break;
      }

      setMotor(0,0,0,0,0);    //Turns stepper motor off


      currStep++;
      if(currStep > 8){
        currStep = 1;
      }
}

void setMotor(int8_t pin1, int8_t pin2, int8_t pin3, int8_t pin4, int theDelay){

    if(pin1 == 1){
        digitalWrite(motorPin1, HIGH);
    } else {
        digitalWrite(motorPin1, LOW);
    }
    if(pin2 == 1){
        digitalWrite(motorPin2, HIGH);
    } else {
        digitalWrite(motorPin2, LOW);
    }
    if(pin3 == 1){
        digitalWrite(motorPin3, HIGH);
    } else {
        digitalWrite(motorPin3, LOW);
    }
    if(pin4 == 1){
        digitalWrite(motorPin4, HIGH);
    } else {
        digitalWrite(motorPin4, LOW);
    }

    delayMicroseconds(theDelay);
}

void centerTriggered(){
    centerStatus = true;
}
applications/testing/app.cpp: In function 'void setup()':
applications/testing/app.cpp:23:23: error: 'setMotor' was not declared in this s
cope
     setMotor(0,0,0,0,0);    //Turns stepper motor off
                       ^
applications/testing/app.cpp:24:32: error: 'centerTriggered' was not declared in
 this scope
     attachInterrupt(centerPin, centerTriggered, FALLING);
                                ^
applications/testing/app.cpp:27:18: error: 'nextStep' was not declared in this s
cope
         nextStep();
                  ^
applications/testing/app.cpp: In function 'void nextStep()':
applications/testing/app.cpp:39:40: error: 'setMotor' was not declared in this s
cope
             setMotor(1,0,0,0,motorSpeed);
                                        ^
applications/testing/app.cpp:64:25: error: 'setMotor' was not declared in this s
cope
       setMotor(0,0,0,0,0);    //Turns stepper motor off
                         ^
make[2]: *** [../build/target/user/platform-8-m/applications/testing/application
s/testing/app.o] Error 1
make[1]: *** [user] Error 2
make: *** [c:/firmware/modules/photon/user-part/makefile] Error 2

@wesner0019, declare your functions before using them

Like:

#include "application.h"


void centerTriggered();
void setMotor(int8_t pin1, int8_t pin2, int8_t pin3, int8_t pin4, int theDelay);
void nextStep();
2 Likes

Thanks! worked.
Now I have access to the spare pins on the P1. yeah!

Just a question why does this not need to be done in the web IDE? Declaring functions before hand?

Cos you are enjoying an Arduino thing… .ino files are pre-processed to handle such stuff :wink:

2 Likes

@kennethlimcp, I’ve wondered why the application extension had to be .cpp instead on .ino.

Thanks