From 6c117bc4c2265a75fc5a52eb257454d097c6a87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 6 May 2017 16:45:17 +0200 Subject: [PATCH] display numbers --- main.c | 58 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/main.c b/main.c index c79a9fb..0b6b52d 100644 --- a/main.c +++ b/main.c @@ -81,6 +81,9 @@ volatile uint8_t frame_count = 0; /**< number of frames passed */ #define MUX_S2_PORT B /**< port to select multiplexer output */ #define MUX_S2_PIN 5 /**< pin to select multiplexer output */ +/** episode, scene, take, video 1, audio 1, video 2, audio 2 number (does not have to be in this order) */ +uint16_t numbers[7] = {0}; + #define POWER_SWITCH_PORT B /**< port to switch power of all devices (including this micro-controller) */ #define POWER_SWITCH_PIN 8 /**< pin to switch power of all devices (including this micro-controller) */ #define POWER_BUTTON_PORT B /**< port to detect power switching activity (to keep alive) */ @@ -438,6 +441,11 @@ void main(void) nvic_enable_irq(NVIC_EXTI_IRQ(SQUARE_WAVE_PIN)); // enable interrupt printf("OK\n"); + // verify is external RTC is running + if (rtc_ds1307_oscillator_disabled()) { + printf("/!\\ RTC oscillator is disabled: the battery may be empty\n"); + rtc_ds1307_oscillator_enable(); // enable oscillator again + } // display date uint8_t* rtc_ds1307_time = rtc_ds1307_read_time(); // get time/date from external RTC if (rtc_ds1307_time==NULL) { @@ -446,41 +454,38 @@ void main(void) rtc_seconds = rtc_ds1307_time[0]; // remember seconds of minute printf("current date: 20%02u-%02u-%02u %02u:%02u:%02u\n", rtc_ds1307_time[6], rtc_ds1307_time[5], rtc_ds1307_time[4], rtc_ds1307_time[2], rtc_ds1307_time[1], rtc_ds1307_time[0]); } - // verify is external RTC is running - if (rtc_ds1307_oscillator_disabled()) { - printf("/!\\ RTC oscillator is disabled: the battery may be empty\n"); - rtc_ds1307_oscillator_enable(); // enable oscillator again - } // setup analog multiplexer for TM1637 clock printf("setup multiplexer: "); - rcc_periph_clock_enable(RCC_GPIO(MUX_EN_PORT)); - gpio_set_mode(GPIO(MUX_EN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_EN_PIN)); + rcc_periph_clock_enable(RCC_GPIO(MUX_EN_PORT)); // enable clock for GPIO port domain + gpio_set_mode(GPIO(MUX_EN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_EN_PIN)); // to enable/disable the multiplexer gpio_set(GPIO(MUX_EN_PORT), GPIO(MUX_EN_PIN)); // disable multiplexer - rcc_periph_clock_enable(RCC_GPIO(MUX_S0_PORT)); - gpio_set_mode(GPIO(MUX_S0_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_S0_PIN)); - rcc_periph_clock_enable(RCC_GPIO(MUX_S1_PORT)); - gpio_set_mode(GPIO(MUX_S1_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_S1_PIN)); - rcc_periph_clock_enable(RCC_GPIO(MUX_S2_PORT)); - gpio_set_mode(GPIO(MUX_S2_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_S2_PIN)); + rcc_periph_clock_enable(RCC_GPIO(MUX_S0_PORT)); // enable clock for GPIO port domain + gpio_set_mode(GPIO(MUX_S0_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_S0_PIN)); // to select output channel + rcc_periph_clock_enable(RCC_GPIO(MUX_S1_PORT)); // enable clock for GPIO port domain + gpio_set_mode(GPIO(MUX_S1_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_S1_PIN)); // to select output channel + rcc_periph_clock_enable(RCC_GPIO(MUX_S2_PORT)); // enable clock for GPIO port domain + gpio_set_mode(GPIO(MUX_S2_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(MUX_S2_PIN)); // to select output channel printf("OK\n"); - // setup TM1637 and MAX7219 7-segments displays + // setup TM1637 4-digit 7-segment displays to display the numbers printf("setup 7-segment displays: "); led_tm1637_setup(); // setup TM1637 - for (uint8_t tm1637=0; tm1637<7; tm1637++) { + for (uint8_t tm1637=0; tm1637