diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-12-03 21:52:59 +0100 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-12-03 21:52:59 +0100 |
commit | 7a8c601eec433f7c75d3291d64bb3d41fe50c8ae (patch) | |
tree | 1b1038a4dc80cc496a4c608ea760300f8b6d68f1 /src | |
parent | 08b7ee440269c881546421da6efe1b6ae122b566 (diff) |
Use custom types
Diffstat (limited to 'src')
-rw-r--r-- | src/font.c | 4 | ||||
-rw-r--r-- | src/i2c.c | 14 | ||||
-rw-r--r-- | src/menu.c | 22 | ||||
-rw-r--r-- | src/tft.c | 10 | ||||
-rw-r--r-- | src/tty.c | 20 |
5 files changed, 35 insertions, 35 deletions
@@ -1,6 +1,6 @@ -#include <stdint.h> +#include <zeta.h> -const uint8_t font[97][8] = { +const u8 font[97][8] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SPACE */ {0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00}, /* ! */ {0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00}, /* " */ @@ -5,7 +5,7 @@ #define SCL (1 << 1) void -_delay_ms(uint8_t ms); +_delay_ms(u8 ms); void i2c_start_condition(void) @@ -36,9 +36,9 @@ i2c_stop_condition(void) } void -i2c_send(uint8_t b) +i2c_send(u8 b) { - uint8_t i; + u8 i; for (i = 0; i < 8; ++i) { if (b & 1) @@ -67,11 +67,11 @@ i2c_send(uint8_t b) port_a_ctrl = 0x7C; } -uint8_t -i2c_recv(uint8_t ack) +u8 +i2c_recv(u8 ack) { - uint8_t i; - uint8_t b = 0; + u8 i; + u8 b = 0; port_a_ctrl = PIO_MODE_3; port_a_ctrl = 0x7D; @@ -6,17 +6,17 @@ #include <string.h> struct time { - uint8_t second; - uint8_t minute; - uint8_t hour; - uint8_t wkday; - uint8_t date; - uint8_t month; - uint8_t year; + u8 second; + u8 minute; + u8 hour; + u8 wkday; + u8 date; + u8 month; + u8 year; }; struct value { - uint8_t roll; + u8 roll; int val; int min, max; }; @@ -63,7 +63,7 @@ draw_time(void) void draw_battery(void) { - uint16_t soc = 100; // bat_state_of_charge(); + u16 soc = 100; // bat_state_of_charge(); char buf[16]; sprintf(buf, "%u%%", soc); mvaddstr(7, 1, buf); @@ -73,7 +73,7 @@ void set_time(void); struct item { - uint8_t type; + u8 type; const char *text; union { void (*action)(void); @@ -137,7 +137,7 @@ enum direction { HORIZONTAL }; -static uint8_t dir = HORIZONTAL; +static u8 dir = HORIZONTAL; static int menu_index = 0; static int sub_menu_index = -1; static int edit = 0; @@ -3,7 +3,7 @@ #include <zeta.h> void -_delay_ms(uint8_t ms); +_delay_ms(u8 ms); /* * Driver for the ILI9341 TFT Chip @@ -25,7 +25,7 @@ tft_enable_ext_cmd(void) } static inline void -tft_memory_access_ctrl(uint8_t bits) +tft_memory_access_ctrl(u8 bits) { tft_ctrl = MADCTL; tft_data = bits; @@ -43,7 +43,7 @@ tft_display_on(void) } static inline void -tft_pixel_format(uint8_t dbi, uint8_t dpi) +tft_pixel_format(u8 dbi, u8 dpi) { tft_ctrl = COLMOD; tft_data = (dpi << 4) | dbi; @@ -60,7 +60,7 @@ tft_set_rgb_interface(void) } static inline void -tft_set_col_addr(uint16_t start, uint16_t end) +tft_set_col_addr(u16 start, u16 end) { tft_ctrl = CASET; tft_data = start >> 8; @@ -70,7 +70,7 @@ tft_set_col_addr(uint16_t start, uint16_t end) } static inline void -tft_set_page_addr(uint16_t start, uint16_t end) +tft_set_page_addr(u16 start, u16 end) { tft_ctrl = PASET; tft_data = start >> 8; @@ -6,30 +6,30 @@ struct color { uint8_t r, g, b; }; -static unsigned int row = 0; -static unsigned int col = 0; +static u16 row = 0; +static u16 col = 0; // Index of first row inside buf -static volatile uint8_t head = 0; +static volatile u8 head = 0; // TTY's current contents -static volatile uint8_t buf[TTY_HEIGHT][TTY_WIDTH]; +static volatile u8 buf[TTY_HEIGHT][TTY_WIDTH]; static volatile struct color bg_color = {0x00, 0x00, 0x00}; static volatile struct color fg_color = {0xFF, 0xFB, 0x00}; -extern const uint8_t font[97][8]; +extern const u8 font[97][8]; -static uint8_t cursor = 0; -static uint8_t timer = 0; +static u8 cursor = 0; +static u8 timer = 0; u8 blink = 0; void blink_cursor(void) __critical __interrupt(3) { if (++timer >= 75 && blink) { - uint8_t i; + u8 i; tft_set_area(8 * col, 8 * row, 8, 8); tft_ram_wr(); @@ -73,7 +73,7 @@ draw(u8 c) static void scroll(void) { - uint16_t i, j; + u16 i, j; head = (head + 1) % TTY_HEIGHT; for (i = head; i < TTY_HEIGHT; ++i) { @@ -149,7 +149,7 @@ addch(char c) } void -setcur(unsigned int ncol, unsigned int nrow) +setcur(u16 ncol, u16 nrow) { col = ncol; row = nrow; |