Photon SOS 1 red flash with app working on Core

Hi.

I just got my Photons, and tried to flash my app. It’s running a neopixel panel with 512 leds, code is >1000 lines long.
Works perfectly on the Core.
On Photon - compiles, then SOS with single red flash, reboot, and all over again.
Also tried with firmware 0.4.3
I don’t want to cut the app into pieces and disabling part by part to see what causes the problem -
any suggestions what to look for in the code first ?

I can share the code, but it’s rather long…

thanks

We would really have to see it then.

Sure, here is the code, PART1/2 (too long to paste in 1 pcs)

    // This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"


#include "application.h"

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D0
#define PIXEL_COUNT 512
#define PIXEL_TYPE WS2812B


unsigned char alpha[][8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //space
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x0c, 0x0c, //!
0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //"
0x14, 0x14, 0x14, 0x3f, 0x14, 0x3f, 0x14, 0x14, //#
0x0c, 0x3f, 0x2d, 0x0d, 0x3f, 0x2c, 0x2d, 0x3f, //$
0x03, 0x23, 0x10, 0x08, 0x04, 0x02, 0x31, 0x30, //%
0x0c, 0x12, 0x11, 0x0a, 0x24, 0x2a, 0x11, 0x2e, //&
0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //'
0x38, 0x1c, 0x0e, 0x06, 0x06, 0x0e, 0x1c, 0x38, //(
0x07, 0x0e, 0x1c, 0x18, 0x18, 0x1c, 0x0e, 0x07, //)
0x00, 0x00, 0x12, 0x0c, 0x0c, 0x12, 0x00, 0x00, //*
0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, //+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, //,
0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, //-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, //.
0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, // /
0x3f, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, //0
0x1c, 0x1c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //1
0x3f, 0x3f, 0x30, 0x3f, 0x3f, 0x03, 0x3f, 0x3f, //2
0x3f, 0x3f, 0x30, 0x3c, 0x3c, 0x30, 0x3f, 0x3f, //3
0x33, 0x33, 0x33, 0x3f, 0x3f, 0x30, 0x30, 0x30, //4
0x3f, 0x3f, 0x03, 0x3f, 0x3f, 0x30, 0x3f, 0x3f, //5
0x3f, 0x3f, 0x03, 0x3f, 0x3f, 0x33, 0x3f, 0x3f, //6
0x3f, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, //7
0x3f, 0x3f, 0x33, 0x3f, 0x3f, 0x33, 0x3f, 0x3f, //8
0x3f, 0x3f, 0x33, 0x3f, 0x3f, 0x30, 0x3f, 0x3f, //9
0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, //:
0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x04, 0x00, //;
0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, //<
0x00, 0x00, 0x1e, 0x00, 0x00, 0x1e, 0x00, 0x00, //=
0x00, 0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02, //>
0x1e, 0x10, 0x1e, 0x02, 0x1e, 0x00, 0x0c, 0x0c, //?
0x00, 0x1e, 0x21, 0x2d, 0x15, 0x1d, 0x31, 0x3e, //@
0x1e, 0x3f, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, //A
0x1f, 0x3f, 0x33, 0x1f, 0x1f, 0x33, 0x3f, 0x1f, //B
0x3e, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3e, //C 
0x0f, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x1f, 0x0f, //D
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x3f, 0x3f, //E
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x03, 0x03, //F
0x1e, 0x3f, 0x03, 0x03, 0x3b, 0x33, 0x3f, 0x1e, //G
0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, //H
0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, //I
0x3f, 0x3f, 0x30, 0x30, 0x30, 0x33, 0x3f, 0x1e, //J
0x03, 0x33, 0x1b, 0x0f, 0x07, 0x0f, 0x1b, 0x33, //K
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f, //L
0x21, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, 0x33, //M
0x33, 0x37, 0x37, 0x3f, 0x3f, 0x3b, 0x3b, 0x33, //N
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, //O
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x03, 0x03, //P
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x3b, 0x1f, 0x2e, //Q
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x1b, 0x33, //R
0x3e, 0x3f, 0x03, 0x1f, 0x3e, 0x30, 0x3f, 0x1f, //S
0x3f, 0x3f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, //T
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, //U
0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, //V
0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x21, //W
0x21, 0x33, 0x1e, 0x0c, 0x0c, 0x1e, 0x33, 0x21, //X
0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, 0x0c, 0x0c, //Y
0x3f, 0x3f, 0x38, 0x1c, 0x0e, 0x07, 0x3f, 0x3f, //Z
0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, //[
0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, //\
0x00, 0x1e, 0x18, 0x18, 0x18, 0x18, 0x1e, 0x00, //]
0x0e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0e, //]
0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, //^
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, //_
0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //`
0x1e, 0x3f, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, //a
0x1f, 0x3f, 0x33, 0x1f, 0x1f, 0x33, 0x3f, 0x1f, //b
0x3e, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3e, //c 
0x0f, 0x1f, 0x33, 0x33, 0x33, 0x33, 0x1f, 0x0f, //d
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x3f, 0x3f, //e
0x3f, 0x3f, 0x03, 0x0f, 0x0f, 0x03, 0x03, 0x03, //f
0x1e, 0x3f, 0x03, 0x03, 0x3b, 0x33, 0x3f, 0x1e, //g
0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, //h
0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, //i
0x3f, 0x3f, 0x30, 0x30, 0x30, 0x33, 0x3f, 0x1e, //j
0x03, 0x33, 0x1b, 0x0f, 0x07, 0x0f, 0x1b, 0x33, //k
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f, //l
0x21, 0x33, 0x3f, 0x3f, 0x33, 0x33, 0x33, 0x33, //m
0x33, 0x37, 0x37, 0x3f, 0x3f, 0x3b, 0x3b, 0x33, //n
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, //o
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x03, 0x03, //p
0x1e, 0x3f, 0x33, 0x33, 0x33, 0x3b, 0x1f, 0x2e, //q
0x0f, 0x1f, 0x33, 0x33, 0x1f, 0x0f, 0x1b, 0x33, //r
0x3e, 0x3f, 0x03, 0x1f, 0x3e, 0x30, 0x3f, 0x1f, //s
0x3f, 0x3f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, //t
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, //u
0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, //v
0x33, 0x33, 0x33, 0x33, 0x3f, 0x3f, 0x33, 0x21, //w
0x21, 0x33, 0x1e, 0x0c, 0x0c, 0x1e, 0x33, 0x21, //x
0x33, 0x33, 0x33, 0x3f, 0x1e, 0x0c, 0x0c, 0x0c, //y
0x3f, 0x3f, 0x38, 0x1c, 0x0e, 0x07, 0x3f, 0x3f, //z
0x38, 0x0c, 0x04, 0x03, 0x03, 0x04, 0x0c, 0x38, //{
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, //|
0x07, 0x0c, 0x08, 0x30, 0x30, 0x08, 0x0c, 0x07, //}
0x04, 0x2a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00  //~
};


Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);


String temp = "";
int effectNumber =100;
byte brightness =50;
String message ="";
byte rotating =0;
boolean rainbow =false;
boolean pulse = false;
boolean letter = false; //true for text, false for graphics, use in rotateL()

byte rotatePixel = 0; //rotate counter used to scroll text 8 pixels per letter
byte charNumber =0;
int flip =1;
byte eff8=0; // effect 8 color counter
byte changeBrightness;
byte changeColor=0;
uint32_t color=0xffffff;
int effectAt=1;
uint32_t file[512];
byte syncDelay = 10;
byte syncExtraDelay = 0;
String masterID = "";



unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long previousMillis4 = 0;
unsigned long previousMillis5 = 0;
unsigned long previousMillis6 = 0;
uint16_t delay1=100;
uint16_t delay2=100;
uint16_t delay3=100;
uint16_t delay4=10000;
uint16_t delay5=2000;
uint16_t delay6=10000;


struct rgbcolor {
    byte r;
    byte g;
    byte b;
};

union {
    rgbcolor rgb;
    uint32_t hexcolor; 
} col;


struct twobytes {
    byte l;
    byte h;
};

union {
    twobytes delaybytes_1;
    uint16_t delay_1;
} del1;
union {
    twobytes delaybytes_2;
    uint16_t delay_2;
} del2;
union {
    twobytes delaybytes_3;
    uint16_t delay_3;
} del3;
union {
    twobytes delaybytes_4;
    uint16_t delay_4;
} del4;
union {
    twobytes delaybytes_5;
    uint16_t delay_5;
} del5;
//----------------------------------------CLOUD VARIABLES
char cloudconfig[] = "dupa";
char cloudIP[] ="";
char cloudTemp[] = "unknown";
char cloudSSID[] = "unknown";
char cloudRSSI[] = "unknown";
char cloudID[] = "";



/////////////////////////////////////////////////////////////////////////
//
//                                SETUP
//
/////////////////////////////////////////////////////////////////////////
void setup() 
{


col.rgb.r=255;
col.rgb.g=0;
col.rgb.g=0;

Spark.function("effect", effect);
Spark.function("bitmap", bitmap);
Spark.function("config", config);
Spark.function("text", text);
Spark.subscribe("bollard/", setEffect);

Spark.deviceID().toCharArray(cloudID, Spark.deviceID().length()+1);

Spark.variable("cloudconfig", cloudconfig , STRING);
Spark.variable("cloudIP", cloudIP , STRING);
Spark.variable("cloudTemp", cloudTemp , STRING);
Spark.variable("cloudSSID", cloudSSID , STRING);
Spark.variable("cloudRSSI", cloudRSSI , STRING);
Spark.variable("cloudID", cloudID , STRING);

////////////////////////////////////////////////////// EEPROM configuration read
if(EEPROM.read(0)!=255) effectNumber=EEPROM.read(0);
if(EEPROM.read(1)!=255) brightness=EEPROM.read(1);
if(EEPROM.read(2)!=255) rotating=EEPROM.read(2);
if(EEPROM.read(3)!=255) rainbow=EEPROM.read(3);
if(EEPROM.read(4)!=255) pulse=EEPROM.read(4);
if(EEPROM.read(5)!=255) letter=EEPROM.read(5);
if(EEPROM.read(6)!=255) syncDelay=EEPROM.read(6);
if(EEPROM.read(7)!=255) syncExtraDelay=EEPROM.read(7);
byte r=EEPROM.read(10);
byte g=EEPROM.read(11);
byte b=EEPROM.read(12);
color=strip.Color(r,g,b);
del1.delaybytes_1.l =EEPROM.read(13);
del1.delaybytes_1.h =EEPROM.read(14);
delay1=del1.delay_1;

del2.delaybytes_2.l =EEPROM.read(15);
del2.delaybytes_2.h =EEPROM.read(16);
delay2=del2.delay_2;

del3.delaybytes_3.l =EEPROM.read(17);
del3.delaybytes_3.h =EEPROM.read(18);
delay3=del3.delay_3;

del4.delaybytes_4.l =EEPROM.read(19);
del4.delaybytes_4.h =EEPROM.read(20);
delay4=del4.delay_4;

del5.delaybytes_5.l =EEPROM.read(21);
del5.delaybytes_5.h =EEPROM.read(22);
delay5=del5.delay_5;


  strip.begin();
  strip.setBrightness(brightness);
  strip.show(); // Initialize all pixels to 'off'



if(effectNumber ==100 && letter==false) demo();
if(letter==true) 
{
effectNumber=100;
message="test message  ";
}

}
/////////////////////////////////////////////////////////////////////////
//
//                                LOOP
//
/////////////////////////////////////////////////////////////////////////
void loop() 
{
if(!pulse)
{
strip.setBrightness(brightness);
//strip.show();
}  
       if(Time.now()>=effectAt && effectAt >0) 
       {
        effectAt=0;   
       switch (effectNumber)
        {
        case 100:
            break;
        case 0:
           effect0();
            break;
        case 1:
            effect1();
            break;
        case 2:
            effect2();
            break;
        case 3:
            effect3();
            break;
        case 4:
            effect4();
            break;
        case 5:
            effect5();
            break;
        case 6:
            effect6();
            break;
        case 7:
            effect7();
            break;
        case 8:
            effect8();
            break;
        case 9:
            effect9();
            break;
            
        }}


  if(millis() - previousMillis1 >= delay1) //rotating
  {
    if (rotating==1) rotateL(false);
    else if(rotating==2) rotateR();
    else if(rotating==3) rotateU(false);
    else if(rotating==4) rotateD();
    if (letter) //-------------------------------- displaying text
    {
    
    if(rotatePixel==0) 
    {
        paintFont(alpha[message.charAt(charNumber)-32], color);
        charNumber++;
        if (charNumber==message.length()) charNumber=0;
         
    }
    rotatePixel++;
    rotateL(true); //rotating text if letter=true
    if(rotatePixel==8)rotatePixel=0;
    }
  previousMillis1 = millis();
  }
//---------------------------------------  
   if(millis() - previousMillis2 >= delay2) // rainbow
  {
    if (rainbow)
    {
    setRainbow(changeColor);
    changeColor++;
    if (changeColor>255)changeColor=0;
    }
  
  previousMillis2 = millis();
  }

  if(millis() - previousMillis3 >= delay3) // pulse
  {
    if (pulse)
    {
    changeBrightness+=5*flip;
    if(changeBrightness==0 || changeBrightness>=brightness) flip*=-1;
    if(changeBrightness==0)
    {
        if(color==0xffffff)color=0xff0000;
        else if(color==0xff0000)color=0x00ff00;
        else if(color==0x00ff00)color=0x0000ff;
        else if(color==0x0000ff)color=0xffffff;
    }
    fill(color);
    strip.setBrightness(changeBrightness);
    strip.show();
    }

  previousMillis3 = millis();
//---------------------------------------- 
  }

      if(millis() - previousMillis5 >= delay5) // recursive effects
  {
           switch (effectNumber)
        {
        case 100:
            break;
        case 33:
            effect3();
            break;
        case 44:
            effect4();
            break;
        case 88:
            effect8();
            break;
        }
    
    previousMillis5 = millis();
  }
 
 if(millis() - previousMillis6 >= delay6) {
   
   
        temp = "ip add:"+ String(WiFi.localIP()[0])+ "." + String(WiFi.localIP()[1]) +"." +String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]);
        temp.toCharArray(cloudIP, temp.length()+1);
        (String(WiFi.SSID())).toCharArray(cloudSSID, (String(WiFi.SSID())).length()+1);
        (String(WiFi.RSSI())).toCharArray(cloudRSSI, (String(WiFi.RSSI())).length()+1);
        
    

    
    previousMillis6 = millis();
 }
 
 
}

/////////////////////////////////////////////////////////////////////////
//
//                                END LOOP
//
/////////////////////////////////////////////////////////////////////////

//-----------------------------------------------------------
//
//                     SPARK FUNCTIONS
//
//-----------------------------------------------------------
int effect(String data)
{

clear();
    if (data.substring(0,1)=="") effectNumber = 100;
    if (data.substring(0,1)=="0") effectNumber = 0;
    if (data.substring(0,1)=="1") effectNumber = 1;
    if (data.substring(0,1)=="2") effectNumber = 2;
    if (data.substring(0,1)=="3") effectNumber = 3;
    if (data.substring(0,1)=="4") effectNumber = 4;
    if (data.substring(0,1)=="5") effectNumber = 5;
    if (data.substring(0,1)=="6") effectNumber = 6;
    if (data.substring(0,1)=="7") effectNumber = 7;
    if (data.substring(0,1)=="8") effectNumber = 8;
    if (data.substring(0,1)=="9") effectNumber = 9;
    
    effectAt=Time.now()+syncDelay+syncExtraDelay;
    effectAt=1;
    Spark.publish("bollard/"+ Spark.deviceID(), String(effectNumber) +"+"+ String(effectAt));
    saveConf();
    
return(1);
}
//--------------------------------------------------- config
int config(String data)
{
    if (data.substring(0,11)=="rotatespeed") delay1 = data.substring(11).toInt();
    if (data.substring(0,12)=="rainbowspeed") delay2 = data.substring(12).toInt();
    if (data.substring(0,12)=="pulsespeed") delay3 = data.substring(10).toInt();
    if (data.substring(0,10)=="brightness") 
    {
        brightness = data.substring(10).toInt();
        changeBrightness=brightness;
    }
    
    if (data.substring(0,5)=="color") 
    {
    byte r=data.substring(5,8).toInt();
    byte g=data.substring(8,11).toInt();
    byte b=data.substring(11,14).toInt();
    color=strip.Color(r,g,b);
    setColor(color);
    }
    
    if (data.substring(0,7)=="rotatel") rotating=1;
    if (data.substring(0,7)=="rotater") rotating=2;
    if (data.substring(0,7)=="rotateu") rotating=3;
    if (data.substring(0,7)=="rotated") rotating=4;
    if (data.substring(0,7)=="rotate0") rotating=0;
    
    if (data =="clear") clear();
    if (data =="save") save();
    if (data =="saveconf") saveConf();    
    if (data =="load") load();
    if (data =="") 
    {
        cfg();
        String s=cfgGet();
        s.toCharArray(cloudconfig, s.length()+1);
    }
    if (data =="rainbow1") rainbow =true;
    if (data =="rainbow0") rainbow =false;
    if (data =="pulse0") pulse =false;
    if (data =="fill") fill(color);
    if (data =="pulse1") 
    {
        pulse =true;
        changeBrightness=brightness;
        flip=-1;
        save();
    }

    if(data=="reset") System.reset();
    if(data.substring(0,6)=="master") 
    {
        String tmp = data.substring(6);
        masterID = tmp;
    }
    if(data.substring(0,9)=="syncdelay") syncDelay=data.substring(0,9).toInt();
    if(data.substring(0,9)=="syncextradelay") syncExtraDelay=data.substring(0,9).toInt();
    
    saveConf();
    return(1);
}


//-------------------------------------------------- BITMAP
int bitmap(String data)
{
static byte bitmapbitsNumber =0; // numbering of bitmap messages send using bitmap function. every bitmap requires 3 messages. bitmapbitsNumber can be 0,1,2,3
static String bitmapbits ="";
byte sprite[64];
char buffer[129];
byte bitmapbitsStart = data.substring(0,1).toInt();
if (bitmapbitsStart ==1 && bitmapbitsNumber==0)
    {
    bitmapbitsNumber=1;
    bitmapbits += data.substring(1);
    return(1);
    }
if (bitmapbitsStart ==2 && bitmapbitsNumber==1)
    {
    bitmapbitsNumber=2;
    bitmapbits += data.substring(1);
    return(2);
    }  
if (bitmapbitsStart ==3 && bitmapbitsNumber==2)
    {
    bitmapbits += data.substring(1);
    bitmapbits.toCharArray(buffer, 129);

    for(int i = 0; i < 128; i+=2)
        {
        sprite[i/2] = getVal(buffer[i+1]) + (getVal(buffer[i]) << 4);
        
        }
  
    paint(sprite, color);
    bitmapbits="";
    bitmapbitsNumber=0;
    return(3);
    }
return(-1);
}
//-------------------------
byte getVal(char c)
{
   if(c >= '0' && c <= '9')
     return (byte)(c - '0');
   else
     return (byte)(c-'a'+10);
}
//--------------------------------------------------------- TEXT
int text(String line)
{
static byte part = 0; // messageTemp part number
static byte messpart = 0; // message part number - delivered in first character of message
static String messageTemp = ""; // to add message parts
clear();
   if (line=="")
   {
       letter=false;
        part=0;
        messpart=0;
        messageTemp="";
       return(0);
   }

messpart = line.substring(0,1).toInt();
   
    if (messpart ==0) //last part received correctly
        {
        message=messageTemp + line.substring(1) + " ";
        part=0;
        messpart=0;
        messageTemp="";
        letter=true;
        charNumber=0;
        rotatePixel=0;
        delay1=10;
        saveConf();
        }
   
    else if(messpart==1) // resetting just in case no last part arrived previously
        {
        part=1;
        messageTemp += line.substring(1);
        }
    else if(messpart == part +1) // part received in order
        {
        part++;
        messageTemp += line.substring(1);
        }
    else //part out of order - resetting
        {
        part=0;
        messpart=0;
        messageTemp="";
        return 0;
        }

   return(1);
}



//-----------------------------------------------------------
//
//                     END SPARK FUNCTIONS
//
//-----------------------------------------------------------
//----------------------------------------------------------------EFFECTS
void effect0()
{
    
}

/////////////////////////////// 1 single color
void effect1() 
{
fill(color);
save();
pulse=1;
//effectNumber = 100;

}
//////////////////////////////// 2 lighthouse
void effect2(){
uint8_t bits1[64] = {
   0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
   0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00,
   0x00, 0x00, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
   0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00,
   0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
   0xff, 0x0f, 0x00, 0x00 };
uint8_t bits2[64] = {
   0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
   0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00,
   0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
   0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00,
   0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
   0xff, 0x07, 0x00, 0x00 };
uint8_t bits3[64] = {
   0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
   0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00,
   0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
   0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00,
   0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x03, 0x00, 0x00 };
uint8_t bits4[64] = {
   0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00,
   0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
   0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
   0xff, 0x01, 0x00, 0x00 };
paint(bits1, 0x0a0a0a);
paint(bits2, 0x282828);
paint(bits3, 0x505050);
paint(bits4, 0xffffff);
rotating = 1;

//effectNumber =100;
}
///////////////////////////////// 3 random lights spinning
void effect3(){
    unsigned int x=random(0,492);
    byte r=random(0,162);
    byte g=random(0,162);
    byte b=random(0,162);
    byte y=random(1,20);
    //y=10;
    for(byte z=0; z<y; z++)
    {
    strip.setPixelColor(x+z,r,g,b);
    }
    
    rotating=1;
    strip.show();
    effectNumber =33;
}
///////////////////////////////// 4 theatre spinning rainbow lights
void effect4()
{
  static int j=0;
    for (int q=0; q < 3; q++) {
        for (int i=0; i < 512; i=i+3) {
          strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
        }
       strip.show();
       delay(10);
        for (int i=0; i < 512; i=i+3) {
          strip.setPixelColor(i+q, 0);        //turn every third pixel off
        }
                
    }

  j++;
  if(j==256) j=0;
    effectNumber =44;
}


//////////////////////////////// 5 spinning left arrows
void effect5() {

uint8_t leftarrows[] = {
   0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
   0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
   0x3f, 0x3f, 0x3f, 0x3f, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xc0, 0xc0, 0xc0, 0xc0,
   0xc0, 0xc0, 0xc0, 0xc0 };
 
paint(leftarrows, color);
rainbow=1;
rotating=1;

//effectNumber = 100;
    
}
//////////////////////////////// 6 UP ARROWS
void effect6() 
{
unsigned char uparrows[] = {
   0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c, 0x1c, 0x1c, 0x1c,
   0x1c, 0x1c, 0x1c, 0x1c, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e,
   0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x1c, 0x1c, 0x1c, 0x1c,
   0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
   0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00 };
clear();
paint(uparrows, color);
rainbow=1;
rotating=3;

//effectNumber = 100;

}
//////////////////////////////// 7 rotating rainbow
void effect7()
{

for (int y=0; y<256; y++)
{
    for (int x=y*64; x<y*64+64; x++)
    {
        strip.setPixelColor(x,Wheel(x*4+8));
    }
}
strip.show();
rotating=1;
//effectNumber = 100;

}


//////////////////////////////// 8 up rainbow
void effect8()
{

for (int x=448; x<512; x++)
{
    strip.setPixelColor(x,Wheel(eff8));
}
rotateU(true);
eff8+=5;
if(eff8==255) eff8=0;
strip.show();
effectNumber =88;
}
/////////////////////////////// 9 bitmap
void effect9() 
{
   unsigned char blue[] = {
   0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x10, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x6c, 0x00, 0x00 };
   unsigned char green[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x10, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x07, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f,
   0x08, 0x50, 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1a, 0x08, 0x90, 0x04, 0x00,
   0x00, 0x00, 0x00, 0x02 };
   unsigned char magenta[] = {
   0x00, 0x00, 0x20, 0x00, 0x02, 0x38, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
   0x01, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
   0x01, 0x00, 0x00, 0x00 };
   unsigned char red[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08,
   0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00 };
   unsigned char yellow[] = {
   0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0xff, 0x00, 0x01, 0x01, 0x00,
   0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00,
   0x0c, 0x01, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00 };

paint(red, 0xff0000);
paint(green,0x00ff00);
paint(blue,0x0000ff);
paint(yellow,0xff7800);
paint(magenta,0xff00ff);
strip.show();
rotating=2;
//effectNumber = 100;
}

//-------------------------------------------------------
//
//
//                      TOOL FUNCTIONS
//
//
//--------------------------------------------------------FILL

void fill(uint32_t color)
{


for (int x=0; x<512; x++)
    {
    strip.setPixelColor(x,color);
    //setcolor(x,rrr,ggg,bbb);
    }
    strip.show();

}
//---------------------------------------------------------PAINT
void paint(uint8_t sprite[64], uint32_t c)
{



       for (byte y=0; y<8; ++y) 
        {
            for (byte x=0; x<8; ++x)
            {
                byte data = sprite[x+(8*y)];  
                for (byte b=0; b<8; ++b) 
                {
                    if (data & (1<<b)) 
                    {
                    strip.setPixelColor((8*x)+(64*y)+b,c);
                    } 
                }
            }    
        }
strip.show();
}
//------------------------------------------------------------PAINT FONT
void paintFont(uint8_t font[8], uint32_t c)
{
        for (byte y=0; y<8; ++y) 
        {
            byte data = font[y];  
                for (byte b=0; b<6; ++b) 
                {
                    if (data & (1<<b)) 
                    {
                    strip.setPixelColor(56+(64*y)+b,c);
                    } 
                }
                
        }
strip.show();
}

TBC

And PART2/2 follows:

//---------------------------------------------------------ROTATE LEFT
void rotateL(boolean letter) //set letter to true for text, false for graphics
{
uint32_t buffer[64];
strip.setBrightness(255);
if(pulse) load1();
if(!letter) for (int y=0; y<512; y=y+64) //remember 1st column if not displaying letters
    {
    buffer[y/64]=strip.getPixelColor(y);
    }
    
    for (int x=0; x < 63; x++)
    {
        for (int y=0; y<512; y=y+64) 
        {
            strip.setPixelColor(x+y,strip.getPixelColor(x+1+y));
        }
    }
    
if(!letter) for (int y=0; y<512; y=y+64) //drawing 1st column if not displaying letters to have image rotating constantly
    {
    strip.setPixelColor(63+y,buffer[y/64]);
    }
if(pulse) 
{
save();
strip.setBrightness(changeBrightness);
}
if(!pulse) strip.setBrightness(brightness);

strip.show();
return; 
}

//---------------------------------------------------------ROTATE RIGHT
void rotateR() //-- 1 rotate right, 0 rotate left
{
uint32_t buffer[64];
strip.setBrightness(255);
     for (int y=0; y<512; y=y+64) 
    {
  buffer[y/64]=strip.getPixelColor(63+y);
    }
    
    for (int x=63; x > 0; x--)
    {
        for (int y=0; y<512; y=y+64) 
        {
            strip.setPixelColor(x+y,strip.getPixelColor(x-1+y));
        }
    }
    
    for (int y=0; y<512; y=y+64) 
    {
    strip.setPixelColor(y,buffer[y/64]);
    }
strip.setBrightness(brightness);    
strip.show();
return; 
}
//----------------------------------------------------------ROTATE UP
void rotateU(boolean effect6)
{

uint32_t buffer[64];
strip.setBrightness(255);
if(!effect6) for (int x=0; x < 64; x++)
        {
            buffer[x]=strip.getPixelColor(x);
        }
   
    for  (int y=0; y<448; y=y+64)
    {
        for (int x=0; x < 64; x++)
        {
            strip.setPixelColor(x+y,strip.getPixelColor(x+y+64));
        }
    }
if(!effect6)    for (int x=0; x < 64; x++)
        {
            strip.setPixelColor(x+448, buffer[x]);
        }
    
strip.setBrightness(brightness);    
strip.show();
}
//----------------------------------------------------------ROTATE DOWN
void rotateD()
{

uint32_t buffer[64];
strip.setBrightness(255);
for (int x=0; x < 64; x++)
        {
            buffer[x]=strip.getPixelColor(x+448);
        }
   
    for  (int y=511; y>63; y=y-64)
    {
        for (int x=0; x < 64; x++)
        {
            strip.setPixelColor(y-x,strip.getPixelColor(y-x-64));
        }
    }
    for (int x=0; x < 64; x++)
        {
            strip.setPixelColor(x, buffer[x]);
        }
    
strip.setBrightness(brightness);    
strip.show();
}
//----------------------------------------------------------CLEAR

void clear()
{
    rotating=0;
    letter=false;
    rainbow=false;
    pulse=false;
    eff8=0;
    effectNumber=100;
    for (int x=0; x<512; x++)
    {
    strip.setPixelColor(x,0,0,0);
    }
strip.show();
return;
}

//----------------------------------------------------------SAVE & LOAD
void save()
{

for (int x=0; x<512; x++) 
{
    file[x]=strip.getPixelColor(x);
}


}
void load()
{
for (int x=0; x<512; x++) strip.setPixelColor(x,file[x]);
strip.show();
}
void load1()
{
for (int x=0; x<512; x++) strip.setPixelColor(x,file[x]);
}


//--------------------------------------------------------- GAMMA WRAPPER
//void setcolor(uint16_t x, byte r, byte g, byte b)
//{
//    strip.setPixelColor(x,mygamma[r],mygamma[g],mygamma[b]);
//return;
//}

//--------------------------------------------------------- setRainbow
void setRainbow(byte j) 
{
            for (int i=0; i < 512; i++) 
        {
          if (strip.getPixelColor(i)>0) strip.setPixelColor(i, Wheel( j % 255));
        }
    if(pulse)strip.setBrightness(changeBrightness);
        strip.show();
}
//--------------------------------------------------------- setColor
void setColor(uint32_t color) 
{
        for (int i=0; i < 512; i++) 
        {
          if (strip.getPixelColor(i)>0) strip.setPixelColor(i, color);    //color every active pixel
        }
        strip.show();
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else if(WheelPos < 170) {
    WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }

}
//---------------------------------------------------------- CONFIG
void cfg()
{
color=0xff0000;
text(cfgGet());
return;
}
//-----------
String cfgGet()
{
}
//----------------------------------------------------------- setEffect

void setEffect(const char *event, const char *data)

{
    if(String(event).substring(8)==masterID)
    {
    effectNumber = String(data).substring(0,1).toInt();
    effectAt = String(data).substring(2).toInt();
    }
return;
}


//----------------------------------------------------------saveconf
void saveConf()
{
EEPROM.write(0, effectNumber);
EEPROM.write(1, brightness);
EEPROM.write(2, rotating);
EEPROM.write(3, rainbow);
EEPROM.write(4, pulse);
EEPROM.write(5, letter);
EEPROM.write(6, syncDelay);
EEPROM.write(7, syncExtraDelay);

col.hexcolor = color;
EEPROM.write(10,col.rgb.b);
EEPROM.write(11,col.rgb.g);
EEPROM.write(12,col.rgb.r);

del1.delay_1=delay1;
EEPROM.write(13,del1.delaybytes_1.l);
EEPROM.write(14,del1.delaybytes_1.h);
del2.delay_2=delay2;
EEPROM.write(15,del2.delaybytes_2.l);
EEPROM.write(16,del2.delaybytes_2.h);

del3.delay_3=delay3;
EEPROM.write(17,del3.delaybytes_3.l);
EEPROM.write(18,del3.delaybytes_3.h);

del4.delay_4=delay4;
EEPROM.write(19,del4.delaybytes_4.l);
EEPROM.write(20,del4.delaybytes_4.h);

del5.delay_5=delay5;
EEPROM.write(21,del5.delaybytes_5.l);
EEPROM.write(22,del5.delaybytes_5.h);

}

//----------------------------------------------------------DEMO
void demo()
{
//paint(red_bits, 0xff0000);
//paint(green_bits,0x00ff00);
//paint(blue_bits,0x0000ff);
//paint(yellow_bits,0xff7800);
//paint(magenta_bits,0xff00ff);

//paint(bollard, 0xffffff);
rotating=0;
rainbow=true;
letter=true;
message="bollard ";
effectNumber=100;

}
//////////////////////////////////////////////
//////////////////////////////////////////////
//////////////////////////////////////////////
//////////////////////////////////////////////
//////////////////////////////////////////////
//////////////////////////////////////////////

Thanks !

Rafal

Nothing looks too obviously wrong for now…

Do you know when the SOS flash occur? Right from the beginning?

If you can drop me a PM with a zipped full code, i can try to run through a debugger. Also, let me know the system information of your Photon by placing it in Listening mode, open a serial terminal and hit “s”.

Thanks!