/* Copyright 2025 by COG9 Enterprises LLC
 * All rights reserved.
 * Title: startup.ino
 * Author: Jed Marti KI7NNP
 * Description: Start up roll screen.
 * Created: Fri Oct 17 10:36:59 2025
 * Revision History:
 */


#include <stdint.h>
#include "powerard.h"

#define LLINE 23

static char lines[LLINE * 6];


void initRoll(void)
/*     Set up for rolling the screen for startup. Not fast or pretty, but only used at startup
 *   which we want to be slow so we can watch.
 * Parameters: none
 * External References:
 *   LLINE: Number of characters per line (constant).
 *   lines[]: The screen characters.
 * Returned values: none
 * Errors detected: none
 */
{
  uint16_t i;
  for (i = 0; i < LLINE * 6; ++i) lines[i] = 0;
  display.clearDisplay();
}



static void roll(void)
/*     Roll lines up and clear line 6. We do this the easy way. Nothing else going on.
 * Parameters: none
 * External References:
 *   LLINE: Number of characters per line (constant).
 *   lines[]: The screen characters.
 * Returned values: none
 * Errors detected: none
 */
{
  uint16_t i;
  for (i = 0; i < 5 * LLINE; ++i) lines[i] = lines[i + LLINE];
  for (i = 5 * LLINE; i < 6 * LLINE; ++i) lines[i] = 0;
}


void rollDisplay(void)
{
  uint8_t  vl;
  display.clearDisplay();
  display.setTextSize(1);
  for (vl = 0; vl < 6; ++vl)
  {
    display.setCursor(0, vl * 10);
    display.print(&lines[vl * LLINE]);
  }
  display.display();
}


void rollString(char *msg)
{
  uint16_t i;

  Serial.println(msg);
  roll();
  for (i = 0; i < LLINE - 1; ++i)
  {
    lines[5 * LLINE + i] = msg[i];
    if (msg[i] == 0) break;
  }
  rollDisplay();
  delay(100);
}


// EOF
