Compare commits

..

No commits in common. "e2d30d705077ff98712832bce71b2e91a53272d7" and "19c0f141a496d1f3b9a7ee62e8c1e5c53a6c794c" have entirely different histories.

View file

@ -104,10 +104,10 @@ void spi_init(void) {
}
uint8_t spi_byte(uint8_t data) {
SPDR = data;
while(!(SPSR & (1 << SPIF)));
return SPDR;
}
SPDR = data;
while(!(SPSR & (1 << SPIF)));
return SPDR;
}
void lcd_write(uint8_t data) {
SPI_PORT &= ~(1 << SPI_SS);
@ -165,62 +165,6 @@ static void lcd_write_symbol_page(const struct symbol* sym,
lcd_write(sym->symbol[page * sym->length + i]);
}
static void lcd_write_digit_page(uint8_t digit, uint8_t page,
bool invert) {
switch (digit) {
case 0:
lcd_write_symbol_page(&sym_0, page, invert);
break;
case 1:
lcd_write_symbol_page(&sym_1, page, invert);
break;
case 2:
lcd_write_symbol_page(&sym_2, page, invert);
break;
case 3:
lcd_write_symbol_page(&sym_3, page, invert);
break;
case 4:
lcd_write_symbol_page(&sym_4, page, invert);
break;
case 5:
lcd_write_symbol_page(&sym_5, page, invert);
break;
case 6:
lcd_write_symbol_page(&sym_6, page, invert);
break;
case 7:
lcd_write_symbol_page(&sym_7, page, invert);
break;
case 8:
lcd_write_symbol_page(&sym_8, page, invert);
break;
case 9:
lcd_write_symbol_page(&sym_9, page, invert);
break;
}
}
static void lcd_write_integer_page(uint8_t integer, uint8_t digits,
uint8_t page, bool invert) {
if (digits != 0 || integer != 0) {
uint8_t input_digits = 0;
uint16_t comperator = 1;
for (; comperator <= integer; comperator *= 10, input_digits++);
for (int8_t i = digits - input_digits; i > 0; i--) {
lcd_write_kerning(2, invert);
lcd_write_digit_page(0, page, invert);
}
for (; comperator >= 10; comperator /= 10) {
lcd_write_kerning(2, invert);
lcd_write_digit_page((integer % comperator) / (comperator / 10),
page, invert);
}
}
}
void lcd_splash(void) {
lcd_fill(0x00);
@ -256,7 +200,7 @@ static void lcd_home(void) {
bool ch3_selected = false;
bool setup_selected = false;
switch (home_state) {
switch(home_state) {
case ch1:
ch1_selected = true;
break;
@ -373,8 +317,7 @@ static void lcd_setup(void) {
lcd_write_symbol_page(&sym_t, i, false);
lcd_write_kerning(2, false);
lcd_write_symbol_page(&sym_colon, i, false);
lcd_write_kerning(11, false);
lcd_write_integer_page(123, 1, i, false);
lcd_write_kerning(13, false);
}
for (uint8_t i = 0; i < 2; i++) {
@ -403,8 +346,7 @@ static void lcd_setup(void) {
lcd_write_symbol_page(&sym_t, i, false);
lcd_write_kerning(2, false);
lcd_write_symbol_page(&sym_colon, i, false);
lcd_write_kerning(7, false);
lcd_write_integer_page(123, 3, i, false);
lcd_write_kerning(9, false);
}
for (uint8_t i = 0; i < 2; i++) {
@ -425,7 +367,7 @@ static void lcd_setup(void) {
}
static void change_state(enum state new_state) {
switch (new_state) {
switch(new_state) {
case home:
lcd_home();
current_state = home;
@ -500,7 +442,7 @@ static void update_state(enum input event) {
ISR(PCINT0_vect) {
cli();
switch (enc) {
switch(enc) {
case 0:
if (ENC_A && !ENC_B)
enc = 1;