From da89ebfa2556406134f882731b5c6f34848c661c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gassmann?= Date: Wed, 17 Apr 2024 19:53:01 +0200 Subject: [+] Nixie and screen test --- main/main.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-) (limited to 'main/main.c') diff --git a/main/main.c b/main/main.c index d42f8ba..c44352c 100644 --- a/main/main.c +++ b/main/main.c @@ -1,6 +1,162 @@ #include +#include +#include "driver/gpio.h" + +struct Nixie +{ + uint8_t digit; + uint8_t D; + uint8_t C; + uint8_t B; + uint8_t A; +}; + +struct Nixie screen[4]; + +#define N0_P0 CONFIG_N0_P0 +#define N0_P1 CONFIG_N0_P1 +#define N0_P2 CONFIG_N0_P2 +#define N0_P3 CONFIG_N0_P3 +#define N1_P0 CONFIG_N1_P0 +#define N1_P1 CONFIG_N1_P1 +#define N1_P2 CONFIG_N1_P2 +#define N1_P3 CONFIG_N1_P3 +#define N2_P0 CONFIG_N2_P0 +#define N2_P1 CONFIG_N2_P1 +#define N2_P2 CONFIG_N2_P2 +#define N2_P3 CONFIG_N2_P3 +#define N3_P0 CONFIG_N3_P0 +#define N3_P1 CONFIG_N3_P1 +#define N3_P2 CONFIG_N3_P2 +#define N3_P3 CONFIG_N3_P3 +#define GPIO_OUTPUT_PIN_SEL ((1ULL<digit) { + case 0: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 0); + gpio_set_level(n->B, 0); + gpio_set_level(n->A, 0); + break; + case 1: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 0); + gpio_set_level(n->B, 0); + gpio_set_level(n->A, 1); + break; + case 2: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 0); + gpio_set_level(n->B, 1); + gpio_set_level(n->A, 0); + break; + case 3: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 0); + gpio_set_level(n->B, 1); + gpio_set_level(n->A, 1); + break; + case 4: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 1); + gpio_set_level(n->B, 0); + gpio_set_level(n->A, 0); + break; + case 5: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 1); + gpio_set_level(n->B, 0); + gpio_set_level(n->A, 1); + break; + case 6: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 1); + gpio_set_level(n->B, 1); + gpio_set_level(n->A, 0); + break; + case 7: + gpio_set_level(n->D, 0); + gpio_set_level(n->C, 1); + gpio_set_level(n->B, 1); + gpio_set_level(n->A, 1); + break; + case 8: + gpio_set_level(n->D, 1); + gpio_set_level(n->C, 0); + gpio_set_level(n->B, 0); + gpio_set_level(n->A, 0); + break; + case 9: + gpio_set_level(n->D, 1); + gpio_set_level(n->C, 0); + gpio_set_level(n->B, 0); + gpio_set_level(n->A, 1); + break; + default: + break; + return; + } +} void app_main(void) { - printf("Hey!\n"); + printf("N1_P3: %i\n", N1_P3); + configure_screen(); + while(1){ + for (uint8_t i = 0; i <= 9; ++i) { + printf("digit: %i\n", i); + screen[0].digit = i; // Update the digit + set_digit(&screen[0]); // Call set_digit function + sleep(1); // Sleep for 2 seconds + } + } } -- cgit v1.2.3