summaryrefslogtreecommitdiff
path: root/components/screen/screen.h
blob: b8b951cdaa81a439aefadd7b67bdb4e2f358fc00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef SC_H
#define SC_H

#include <stdio.h>
#include <unistd.h>
#include "driver/gpio.h"
#include "driver/i2c_master.h"

#define MCP_I2C_ADDR CONFIG_MCP_I2C_ADDR
#define SDA_PIN CONFIG_SDA_PIN
#define SCL_PIN CONFIG_SCL_PIN
#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 MCP_GPIO_OUTPUT 0
#define REG_IODIRA   0x00
#define REG_IODIRB   0x01
#define REG_GPIOA    0x12
#define REG_GPIOB    0x13
#define BV(x) (1 << (x))

struct Nixie
{
    uint8_t digit;
    uint8_t reg;
    uint8_t D;
    uint8_t C;
    uint8_t B;
    uint8_t A;
};

struct Screen
{
    struct Nixie nixies[4];
    i2c_master_bus_handle_t i2c_bus;
    i2c_master_dev_handle_t mcp;
};

void configure_screen(struct Screen* screen);
void test_screen(struct Screen* screen);
void display(struct Screen* screen, char digits[4]);
#endif