//DEV_CCS
struct {
  bool      connection  = false;
  bool      work        = false;
  uint32_t  period      = 0;    //Период опроса датчика, миллисекунд
  bool      flagStart   = false;

  float     TVOC        = 0;
  float     ECO2        = 0;

  bool      arrays      = false;

  bool      arrays_tbl    [12];
  uint8_t   arrays_tbl_h  [12];
  uint8_t   arrays_tbl_m  [12];
  float     arrays_tbl_v1 [12];
  float     arrays_tbl_v2 [12];
} d_ccs;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello, ESP32-S3!");

  for (int i = 12; i > 0; i--) {
    Serial.print("true i: ");    Serial.print(i);
    Serial.print("true i-1: ");    Serial.println(i - 1);

    d_ccs.arrays_tbl    [i] = d_ccs.arrays_tbl    [i - 1];
    d_ccs.arrays_tbl_h  [i] = d_ccs.arrays_tbl_h  [i - 1];
    d_ccs.arrays_tbl_m  [i] = d_ccs.arrays_tbl_m  [i - 1];
    d_ccs.arrays_tbl_v1 [i] = d_ccs.arrays_tbl_v1 [i - 1];
    d_ccs.arrays_tbl_v2 [i] = d_ccs.arrays_tbl_v2 [i - 1];
  }

  d_ccs.arrays_tbl    [0] = false;
  d_ccs.arrays_tbl_h  [0] = 0;
  d_ccs.arrays_tbl_m  [0] = 0;
  d_ccs.arrays_tbl_v1 [0] = 0;
  d_ccs.arrays_tbl_v2 [0] = 0;

  //ntp_getHM(64557);

  Serial.print("ntp_getHM(64557): ");    Serial.println(ntp_setSecond(64557));

  Serial.print("ntp_getHM(64557): ");    Serial.println(ntp_getSecond(ntp_setSecond(64557)));
}

uint32_t ntp_setSecond(uint32_t second) {
  uint32_t _hour = second / 3600;
  uint32_t _minute = (second - (_hour * 3600)) / 60;

  return (uint32_t) (_hour * 3600) + (_minute * 60);
}

String ntp_getSecond(uint32_t second) {
  uint32_t _hour = second / 3600;
  uint32_t _minute = (second - (_hour * 3600)) / 60;

  String lol = "";
  if (_hour < 10) lol += "0";
  lol += _hour;
  lol += ":";
  if (_minute < 10) lol += "0";
  lol += _minute;
  return (String) lol;
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10); // this speeds up the simulation
}