Compare commits
No commits in common. "e2d30d705077ff98712832bce71b2e91a53272d7" and "19c0f141a496d1f3b9a7ee62e8c1e5c53a6c794c" have entirely different histories.
e2d30d7050
...
19c0f141a4
1 changed files with 9 additions and 67 deletions
|
@ -107,7 +107,7 @@ uint8_t spi_byte(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) {
|
void lcd_write(uint8_t data) {
|
||||||
SPI_PORT &= ~(1 << SPI_SS);
|
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]);
|
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) {
|
void lcd_splash(void) {
|
||||||
lcd_fill(0x00);
|
lcd_fill(0x00);
|
||||||
|
|
||||||
|
@ -256,7 +200,7 @@ static void lcd_home(void) {
|
||||||
bool ch3_selected = false;
|
bool ch3_selected = false;
|
||||||
bool setup_selected = false;
|
bool setup_selected = false;
|
||||||
|
|
||||||
switch (home_state) {
|
switch(home_state) {
|
||||||
case ch1:
|
case ch1:
|
||||||
ch1_selected = true;
|
ch1_selected = true;
|
||||||
break;
|
break;
|
||||||
|
@ -373,8 +317,7 @@ static void lcd_setup(void) {
|
||||||
lcd_write_symbol_page(&sym_t, i, false);
|
lcd_write_symbol_page(&sym_t, i, false);
|
||||||
lcd_write_kerning(2, false);
|
lcd_write_kerning(2, false);
|
||||||
lcd_write_symbol_page(&sym_colon, i, false);
|
lcd_write_symbol_page(&sym_colon, i, false);
|
||||||
lcd_write_kerning(11, false);
|
lcd_write_kerning(13, false);
|
||||||
lcd_write_integer_page(123, 1, i, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
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_symbol_page(&sym_t, i, false);
|
||||||
lcd_write_kerning(2, false);
|
lcd_write_kerning(2, false);
|
||||||
lcd_write_symbol_page(&sym_colon, i, false);
|
lcd_write_symbol_page(&sym_colon, i, false);
|
||||||
lcd_write_kerning(7, false);
|
lcd_write_kerning(9, false);
|
||||||
lcd_write_integer_page(123, 3, i, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
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) {
|
static void change_state(enum state new_state) {
|
||||||
switch (new_state) {
|
switch(new_state) {
|
||||||
case home:
|
case home:
|
||||||
lcd_home();
|
lcd_home();
|
||||||
current_state = home;
|
current_state = home;
|
||||||
|
@ -500,7 +442,7 @@ static void update_state(enum input event) {
|
||||||
ISR(PCINT0_vect) {
|
ISR(PCINT0_vect) {
|
||||||
cli();
|
cli();
|
||||||
|
|
||||||
switch (enc) {
|
switch(enc) {
|
||||||
case 0:
|
case 0:
|
||||||
if (ENC_A && !ENC_B)
|
if (ENC_A && !ENC_B)
|
||||||
enc = 1;
|
enc = 1;
|
||||||
|
|
Loading…
Reference in a new issue