/*
### Charlieplexing Simple Clock

Author: Martin Ponson
Version: 1.0 (October 2023)

Base code by: plouc68000
Source: https://projecthub.arduino.cc/plouc68000/simplest-uno-digital-clock-ever-03c185

*/

// Initial time display is 12:59:45 PM
int h = 12;
int m = 59;
int s = 45;
int d = 1; // PM

// Time Set Buttons
int button1;
int button2;

// Pins definition for Time Set Buttons
int hs = A1;// pin A1 for Hours Setting
int ms = A2;// pin A2 for Minutes Setting

// For accurate time reading, use Arduino Real Time Clock (RTC) and not just delay()
static uint32_t last_time, now = 0; // RTC

void setup() {
  pinMode(hs,INPUT); // Button 1
  pinMode(ms,INPUT); // Button 2
}

void loop() {
  // Show initial time >>> LED mapping NEEDED!
  


  // improved replacement of delay(1000) 
  // Much better accuracy, no more dependant of loop execution time
  for (int i=0; i<5; i++) // make 5 time 200ms loop, for faster Button response
  {

    while ((now - last_time) < 200) // delay200ms
    { 
      now = millis(); // millis overflows after ~50 days >>> possible PROBLEM?
    }

    // inner 200ms loop
    last_time = now; // prepare for next loop 

    // Button control and time setting

    // Block frequency
    for (int j=0; j<; j++) {

      // LED phase frequency
      for (int k=0; k<; k++) {

      }

    }


  }

  // outer 1000ms loop
  s = s + 1; // Add 1 second, increment sec. counting
    
  // manage seconds, minutes, hours am/pm overflow
  if(s == 60){
    s = 0;
    m = m + 1;
  }
  if(m == 60){
    m = 0;
    h = h + 1;
  }
  if(h == 13){
    h = 1;
    d = d + 1;
    if(d == 2){
      d = 0;
    } 
  } 

// loop end
}
$abcdeabcde151015202530354045505560fghijfghij
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
led5:A
led5:C
led6:A
led6:C
led7:A
led7:C
led14:A
led14:C
led15:A
led15:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led8:A
led8:C
led9:A
led9:C
led10:A
led10:C
led11:A
led11:C
led12:A
led12:C
led13:A
led13:C
led16:A
led16:C
led17:A
led17:C
led18:A
led18:C
led19:A
led19:C
led20:A
led20:C
led21:A
led21:C
led22:A
led22:C
led23:A
led23:C
led24:A
led24:C
led25:A
led25:C
led26:A
led26:C
led27:A
led27:C
led28:A
led28:C
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
r5:1
r5:2
r6:1
r6:2
r7:1
r7:2
r8:1
r8:2
r9:1
r9:2
r10:1
r10:2
r11:1
r11:2
r12:1
r12:2
r13:1
r13:2
r14:1
r14:2
r15:1
r15:2