#include <stdio.h>
#include "pico/stdlib.h"

#include "TM1637.h"

#define SDA1_BASE     4
#define SDA2_BASE     14

#define MY1637_COLS    4

int main()
{
    char strbuf[MY1637_COLS+1];

    stdio_init_all();
    TM1637_t *tm1, *tm2;

    tm1 = TM1637_init(SDA1_BASE, MY1637_COLS, 2);
    tm2 = TM1637_init(SDA2_BASE, MY1637_COLS, 2);

    
    if( tm1 != NULL && tm2 != NULL) {
    
        TM1637_putchar(tm1, '1',false, 0);
        TM1637_putchar(tm1, '2',true , 1);
        TM1637_putchar(tm1, '3',false, 2);
        TM1637_putchar(tm1, '4',false, 3);

        TM1637_putchar(tm2, '1',false, 0);
        TM1637_putchar(tm2, '2',true , 1);
        TM1637_putchar(tm2, '3',false, 2);
        TM1637_putchar(tm2, '4',false, 3);
        sleep_ms(1000);
        TM1637_putstr(tm1, "12:98");
        TM1637_putstr(tm2, "00:88");
        sleep_ms(1000);
        int i = 0;
        while (true) {
            snprintf(strbuf, sizeof(strbuf),"%4d",i);
            TM1637_putstr(tm1, strbuf);
            TM1637_putstr(tm2, strbuf);
            if(++i > 9999) i =0;
            sleep_ms(1000);
        }
    }
    
}
