#define STARTSCREEN_STEPDELAY 200 
#define STARTSCREEN_HOLDDELAY 2000 

const char str[] = "Start screen";
uint8_t strSize = 0;
int8_t strOffset = 0;
uint32_t timeToNextStep = 0;

AppState StartScreen(LiquidCrystal_I2C* lcd, AppState prevAppState){
  //Init
  if(prevAppState != APPSTATE_START){
    strSize = sizeof(str);
    strOffset = strSize-1;
    timeToNextStep = millis() + STARTSCREEN_STEPDELAY;
    
    lcd->clear();
  }

  //Step 0
  if(millis() >= timeToNextStep && strOffset > 0){
    strOffset--;
    lcd->setCursor(0,0);
    lcd->print(str+strOffset);

    timeToNextStep = millis() + STARTSCREEN_STEPDELAY;
  }
  //Step 1
  if(millis() >= timeToNextStep && strOffset > -2){
    lcd->setCursor(0-strOffset,0);
    lcd->print(" ");
    strOffset--;
    lcd->setCursor(0-strOffset,0);
    lcd->print(str);

    if(strOffset > -2) timeToNextStep = millis() + STARTSCREEN_STEPDELAY;
    else timeToNextStep = millis() + STARTSCREEN_HOLDDELAY;
  }
  //Step 2
  if(millis() >= timeToNextStep && strOffset > -15){
    lcd->setCursor(0-strOffset,0);
    lcd->print(" ");
    strOffset--;
    lcd->setCursor(0-strOffset,0);
    lcd->print(str);

    if(strOffset > -15) timeToNextStep = millis() + STARTSCREEN_STEPDELAY;
    else return APPSTATE_DISPLAY;
  }

  return APPSTATE_START;
}



