Add static
and const
declarations and spaces
Add `static` keyword for consistency and `const` where it makes sense. Also add spaces when declaring enums.
This commit is contained in:
parent
a5d88e879c
commit
f9f131a6da
1 changed files with 26 additions and 23 deletions
|
@ -16,8 +16,8 @@
|
||||||
#define ENC_A (PINB & (1 << PB6))
|
#define ENC_A (PINB & (1 << PB6))
|
||||||
#define ENC_B (PINB & (1 << PB7))
|
#define ENC_B (PINB & (1 << PB7))
|
||||||
|
|
||||||
uint8_t EEMEM eeprom_contrast = 8;
|
static uint8_t EEMEM eeprom_contrast = 8;
|
||||||
uint8_t EEMEM eeprom_backlight = 1;
|
static uint8_t EEMEM eeprom_backlight = 1;
|
||||||
|
|
||||||
static const uint8_t sacred_chao[200] = { 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00,
|
static const uint8_t sacred_chao[200] = { 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x80, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0xC3, 0xE3, 0x73, 0x37, 0x17, 0x07, 0x0F, 0x1E, 0x3C, 0xF0, 0x80,
|
0x80, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0xC3, 0xE3, 0x73, 0x37, 0x17, 0x07, 0x0F, 0x1E, 0x3C, 0xF0, 0x80,
|
||||||
|
@ -104,26 +104,26 @@ static volatile uint8_t enc = 0;
|
||||||
static volatile uint8_t value_contrast;
|
static volatile uint8_t value_contrast;
|
||||||
static volatile uint8_t value_backlight;
|
static volatile uint8_t value_backlight;
|
||||||
|
|
||||||
void spi_init(void) {
|
static void spi_init(void) {
|
||||||
SPI_DDR |= (1 << SPI_SCK) | (1 << SPI_MOSI) | (1 << SPI_SS);
|
SPI_DDR |= (1 << SPI_SCK) | (1 << SPI_MOSI) | (1 << SPI_SS);
|
||||||
SPI_PORT |= (1 << SPI_SS);
|
SPI_PORT |= (1 << SPI_SS);
|
||||||
SPCR = (1 << SPE) | (1 << MSTR);
|
SPCR = (1 << SPE) | (1 << MSTR);
|
||||||
SPSR = (1 << SPI2X);
|
SPSR = (1 << SPI2X);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t spi_byte(uint8_t data) {
|
static uint8_t spi_byte(const uint8_t data) {
|
||||||
SPDR = data;
|
SPDR = data;
|
||||||
while(!(SPSR & (1 << SPIF)));
|
while(!(SPSR & (1 << SPIF)));
|
||||||
return SPDR;
|
return SPDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_write(uint8_t data) {
|
static void lcd_write(const uint8_t data) {
|
||||||
SPI_PORT &= ~(1 << SPI_SS);
|
SPI_PORT &= ~(1 << SPI_SS);
|
||||||
spi_byte(data);
|
spi_byte(data);
|
||||||
SPI_PORT |= (1 << SPI_SS);
|
SPI_PORT |= (1 << SPI_SS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_init(void) {
|
static void lcd_init(void) {
|
||||||
SPI_DDR |= (1 << LCD_CD) | (1 << LCD_RST);
|
SPI_DDR |= (1 << LCD_CD) | (1 << LCD_RST);
|
||||||
_delay_ms(1);
|
_delay_ms(1);
|
||||||
SPI_PORT |= (1 << LCD_RST);
|
SPI_PORT |= (1 << LCD_RST);
|
||||||
|
@ -141,14 +141,14 @@ void lcd_init(void) {
|
||||||
lcd_write(0xAF); // (12) Set Display Enable: Display on
|
lcd_write(0xAF); // (12) Set Display Enable: Display on
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_update_contrast(void) {
|
static void lcd_update_contrast(void) {
|
||||||
SPI_PORT &= ~(1 << LCD_CD);
|
SPI_PORT &= ~(1 << LCD_CD);
|
||||||
lcd_write(0x81); // (9) Set Electronic Volume: Set Contrast
|
lcd_write(0x81); // (9) Set Electronic Volume: Set Contrast
|
||||||
lcd_write(value_contrast); // (9) Set Electronic Volume: Set Contrast
|
lcd_write(value_contrast); // (9) Set Electronic Volume: Set Contrast
|
||||||
SPI_PORT |= (1 << LCD_CD);
|
SPI_PORT |= (1 << LCD_CD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_update_backlight(void) {
|
static void lcd_update_backlight(void) {
|
||||||
switch (value_backlight) {
|
switch (value_backlight) {
|
||||||
case 0:
|
case 0:
|
||||||
DDRD &= (0 << PD5);
|
DDRD &= (0 << PD5);
|
||||||
|
@ -160,7 +160,7 @@ void lcd_update_backlight(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_fill(uint8_t data) {
|
static void lcd_fill(const uint8_t data) {
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
SPI_PORT &= ~(1 << LCD_CD);
|
SPI_PORT &= ~(1 << LCD_CD);
|
||||||
lcd_write(0x00);
|
lcd_write(0x00);
|
||||||
|
@ -183,8 +183,8 @@ static void lcd_write_kerning(const uint8_t length,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcd_write_symbol_page(const struct symbol* sym,
|
static void lcd_write_symbol_page(const struct symbol* sym,
|
||||||
uint8_t page,
|
const uint8_t page,
|
||||||
bool invert) {
|
const bool invert) {
|
||||||
for (uint8_t i = 0; i < sym->length; i++)
|
for (uint8_t i = 0; i < sym->length; i++)
|
||||||
if (invert)
|
if (invert)
|
||||||
lcd_write(~sym->symbol[page * sym->length + i]);
|
lcd_write(~sym->symbol[page * sym->length + i]);
|
||||||
|
@ -192,8 +192,9 @@ static void lcd_write_symbol_page(const struct symbol* sym,
|
||||||
lcd_write(sym->symbol[page * sym->length + i]);
|
lcd_write(sym->symbol[page * sym->length + i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcd_write_digit_page(uint8_t digit, uint8_t page,
|
static void lcd_write_digit_page(const uint8_t digit,
|
||||||
bool invert) {
|
const uint8_t page,
|
||||||
|
const bool invert) {
|
||||||
switch (digit) {
|
switch (digit) {
|
||||||
case 0:
|
case 0:
|
||||||
lcd_write_symbol_page(&sym_0, page, invert);
|
lcd_write_symbol_page(&sym_0, page, invert);
|
||||||
|
@ -228,8 +229,10 @@ static void lcd_write_digit_page(uint8_t digit, uint8_t page,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcd_write_integer_page(uint8_t integer, uint8_t digits,
|
static void lcd_write_integer_page(const uint8_t integer,
|
||||||
uint8_t page, bool invert) {
|
const uint8_t digits,
|
||||||
|
const uint8_t page,
|
||||||
|
const bool invert) {
|
||||||
if (digits != 0 || integer != 0) {
|
if (digits != 0 || integer != 0) {
|
||||||
uint8_t input_digits = 0;
|
uint8_t input_digits = 0;
|
||||||
uint16_t comperator = 1;
|
uint16_t comperator = 1;
|
||||||
|
@ -248,7 +251,7 @@ static void lcd_write_integer_page(uint8_t integer, uint8_t digits,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_splash(void) {
|
static void lcd_splash(void) {
|
||||||
lcd_fill(0x00);
|
lcd_fill(0x00);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 5; i++) {
|
for (uint8_t i = 0; i < 5; i++) {
|
||||||
|
@ -483,7 +486,7 @@ static void lcd_setup(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void change_state(enum state new_state) {
|
static void change_state(const enum state new_state) {
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
case home:
|
case home:
|
||||||
lcd_home();
|
lcd_home();
|
||||||
|
@ -503,7 +506,7 @@ static void change_state(enum state new_state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_home(enum input event) {
|
static void update_home(const enum input event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case cw:
|
case cw:
|
||||||
home_state++;
|
home_state++;
|
||||||
|
@ -525,7 +528,7 @@ static void update_home(enum input event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_setup(enum input event) {
|
static void update_setup(const enum input event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case cw:
|
case cw:
|
||||||
switch (setup_state) {
|
switch (setup_state) {
|
||||||
|
@ -624,7 +627,7 @@ static void update_setup(enum input event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_state(enum input event) {
|
static void update_state(const enum input event) {
|
||||||
switch (current_state) {
|
switch (current_state) {
|
||||||
case home:
|
case home:
|
||||||
update_home(event);
|
update_home(event);
|
||||||
|
|
Loading…
Reference in a new issue