[SOLVED] Compile Error Pan-Tilt Controller

Hello,

when i try to compile the following code for photon in the WebIDE and i get many compiler errors and i don´t now, the fault…

I need help! :frowning:

Thanks…

The Code:
Source: Hackster.io Pan-Tilt Controller Using Particle Photon and Bluetooth

#define bufferSize 1024
#define panServoPin D0
#define tiltServoPin D1
#define panServoMin 800
#define panServoMax 2255
#define tiltServoMin 755
#define tiltServoMax 2240


byte buffer[bufferSize];
const char delimiters[3] = ",|";
int bytesRead;

USARTSerial& buletoothSerial = Serial1;
Servo panServo;
Servo tiltServo;


void setup() {
    buletoothSerial.begin(9600);
    panServo.attach(panServoPin);
    tiltServo.attach(tiltServoPin);
    
    // Center the Servos
    panServo.writeMicroseconds(1528);
    tiltServo.writeMicroseconds(1498);
}

void loop() {
    
    while (buletoothSerial.available() > 0) {
        byte byt = buffer[bytesRead] = buletoothSerial.read();
        buffer[bytesRead] = byt;
        bytesRead++;
        
        if (byt == 124)
        {
            char* tempPayload = (char*)malloc(bytesRead + 1);
            memcpy(tempPayload, buffer, bytesRead);
            tempPayload[bytesRead] = NULL;
            bytesRead = 0;
            
            double panValue = strtod(strtok(tempPayload, delimiters), NULL);
            double tiltValue = strtod(strtok(NULL, delimiters), NULL);
            free(tempPayload);
            
            panValue = constrain(panValue, panServoMin, panServoMax);
            tiltValue = constrain(tiltValue, tiltServoMin, tiltServoMax);
            panServo.writeMicroseconds(panValue);
            tiltServo.writeMicroseconds(tiltValue);
        }
        
        Particle.process();
    }
}

and the errors:

bluetooth_controller.cpp:1:20: error: expected ',' or '...' before numeric constant
 #define bufferSize 1024
                    ^

../platform/MCU/shared/STM32/inc/flash_access.h:67:69: note: in expansion of macro 'bufferSize'
 int FLASH_Update(const uint8_t *pBuffer, uint32_t address, uint32_t bufferSize);
                                                                     ^
bluetooth_controller.cpp:1:20: error: expected ',' or '...' before numeric constant
 #define bufferSize 1024
                    ^
../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc/hw_config.h:114:57: note: in expansion of macro 'bufferSize'
 uint32_t Compute_CRC32(const uint8_t *pBuffer, uint32_t bufferSize);
                                                         ^
bluetooth_controller.cpp:1:20: error: expected ',' or '...' before numeric constant
 #define bufferSize 1024
                    ^
../hal/inc/core_hal.h:143:66: note: in expansion of macro 'bufferSize'
 uint32_t HAL_Core_Compute_CRC32(const uint8_t *pBuffer, uint32_t bufferSize);
                                                                  ^
bluetooth_controller.cpp: In function 'void loop()':
bluetooth_controller.cpp:40:36: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
         
                                    ^
make[1]: *** [../build/target/user/platform-6bluetooth_controller.o] Error 1
make: *** [user] Error 2
Error: Could not compile. Please review your code.

That seems to be the Wiring preprocessor tripping again.

Try adding a blank line at the top.

2 Likes

Wow!!!

You solved the problem!!! Thank you verry much!!!

It would never have occurred to me.

How do you know all (of) that?

Thanks a lot!!!

1 Like

I seem to be around here way tooooooo much, so I’ve seen a lot already - and some of it just stuck :wink:

3 Likes

And maybe it’s time for these things to be fixed? I could log a bug. Not sure where exactly since I don’t see a github for the web IDE. Does this also happen in Particle Dev?

1 Like

If things were that easy to fix with limited ressources, time and more pressing tasks to finish.

BTW, you might have heard of IDE 2.0 being in the works for a while now - that should bring a cure to a lot of issues but is one of the more pressing tasks. Pulling ressources off there to heal a “dying horse” (excuse the term) doesn’t seem the best of tactics IMHO.