#include "constants.h"
#include "congress.h"

int running_text_pos = 21;

void draw_congress(MatrixPanel_I2S_DMA *matrix, enum Mode mode) {
  uint16_t grid_color = matrix->color565(25, 11, 47);
  matrix->fillScreenRGB888(15, 0, 10);

  matrix->drawFastHLine(0, 0, PANEL_WIDTH, grid_color);
  matrix->drawFastHLine(0, 7, PANEL_WIDTH, grid_color);
  matrix->drawFastHLine(0, 24, PANEL_WIDTH, grid_color);
  matrix->drawFastHLine(0, 31, PANEL_WIDTH, grid_color);

  matrix->drawFastVLine(0, 0, PANEL_HEIGHT, grid_color);
  matrix->drawFastVLine(63, 0, PANEL_HEIGHT, grid_color);
  int v_lines = PANEL_WIDTH / 7;
  for(int v; v < v_lines; v++) {
    matrix->drawFastVLine(v * 7, 0, 7, grid_color);
    matrix->drawFastVLine(v * 7, 24, 7, grid_color);
  }
  matrix->setTextWrap(false);
  matrix->setTextColor(matrix->color565(255, 80, 83));

  if (mode == Stealth) {
    matrix->setCursor(7, 21);
    matrix->print("38C3");
  } else if (mode == LowVis) {
    matrix->setCursor(2, 21);
    matrix->print("Panki");
  } else if (mode == HighVis) {
    matrix->setCursor(running_text_pos, 21);
    String message = "38C3 - Panki - DECT - 3389 - 38C3";
    matrix->print(message);
    if ((running_text_pos == 7) or (running_text_pos == - 70) or (running_text_pos == -146 ) or (running_text_pos == -216) ) {
      delay(2000);
    }
    running_text_pos -= 1;

    if (running_text_pos < - 286 ) { // (0 - (13 * message.length()))) {
      running_text_pos = 7;
    };
    matrix->drawFastVLine(0, 0, PANEL_HEIGHT, grid_color);
    matrix->drawFastVLine(63, 0, PANEL_HEIGHT, grid_color);
    delay(10);
  }
  delay(10);
}
