Hi .
Actually I am using the Particle Photon for last 10 months . I know how to compile and flash .
I am compiling the code on https://build.particle.io
I was using the "Thread" in my code for long time. It was being compiled previously without any problem
But suddenly from last 2 days the same code has started giving error .
==========================================
ledblink.cpp:25:1: error: 'Thread' does not name a type
LED_PARAM ledParams[3] = {
^
==========================================
For example if I compile below code -
==========================================
#include "application.h"
// LED Param, defines pin and delay between blinks
typedef struct {
int pin;
int delay;
} LED_PARAM;
// LED pins
int led1 = D5;
int led2 = D3;
int led3 = D1;
// Defines thread parameters
LED_PARAM ledParams[3] = {
{led1, 500},
{led2, 1000},
{led3, 2000}
};
Thread* led1Thread;
Thread* led2Thread;
Thread* led3Thread;
os_thread_return_t ledBlink(void* param){
LED_PARAM *p = (LED_PARAM*)param;
// Start never ending loop
for(;;) {
Serial.print("Thread Parameters: ");
Serial.print(p->pin);
Serial.print(", ");
Serial.println(p->delay);
// Blink led
digitalWrite(p->pin, HIGH);
delay(p->delay);
digitalWrite(p->pin, LOW);
delay(p->delay);
}
}
void setup() {
Serial.begin(115200);
// Set pin mode
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// Start new threads
led1Thread = new Thread("sample", ledBlink, &ledParams[0]);
led2Thread = new Thread("sample", ledBlink, &ledParams[1]);
led3Thread = new Thread("sample", ledBlink, &ledParams[2]);
}
void loop() {
// Nothing here.
}
==========================================
Then I got below compilation output -
==========================================
32+0 records in
32+0 records out
32 bytes (32 B) copied, 7.6585e-05 s, 418 kB/s
4+0 records in
4+0 records out
4 bytes (4 B) copied, 0.0504288 s, 0.1 kB/s
ledblink.cpp:22:1: error: 'Thread' does not name a type
LED_PARAM ledParams[3] = {
^
ledblink.cpp:23:1: error: 'Thread' does not name a type
{led1, 500},
^
ledblink.cpp:24:1: error: 'Thread' does not name a type
{led2, 1000},
^
ledblink.cpp: In function 'void setup()':
ledblink.cpp:53:5: error: 'led1Thread' was not declared in this scope
// Set pin mode
^
ledblink.cpp:53:22: error: expected type-specifier before 'Thread'
// Set pin mode
^
ledblink.cpp:53:22: error: expected ';' before 'Thread'
ledblink.cpp:54:5: error: 'led2Thread' was not declared in this scope
pinMode(led1, OUTPUT);
^
ledblink.cpp:54:22: error: expected type-specifier before 'Thread'
pinMode(led1, OUTPUT);
^
ledblink.cpp:54:22: error: expected ';' before 'Thread'
ledblink.cpp:55:5: error: 'led3Thread' was not declared in this scope
pinMode(led2, OUTPUT);
^
ledblink.cpp:55:22: error: expected type-specifier before 'Thread'
pinMode(led2, OUTPUT);
^
ledblink.cpp:55:22: error: expected ';' before 'Thread'
make[2]: *** [../build/target/user/platform-0-lledblink.o] Error 1
make[1]: *** [user] Error 2
make: *** [main] Error 2
Error: Could not compile. Please review your code.
==========================================
Anybody can please help me whats wrong ?
I have already tried below steps -
- Clearing the cache
- Creating new App