Compare commits
7 commits
c0f8cac065
...
953649725b
Author | SHA1 | Date | |
---|---|---|---|
953649725b | |||
dada6fe5d4 | |||
22095d6e78 | |||
a34a58535b | |||
45bfe04537 | |||
144da8d7f2 | |||
2beecbe722 |
1 changed files with 60 additions and 53 deletions
|
@ -22,7 +22,7 @@
|
|||
#define TWI_SDA PC4
|
||||
#define TWI_SCL PC5
|
||||
|
||||
#define SI5351_ADDRESS (0x60 << 1)
|
||||
#define SI5351_ADDRESS 0x60
|
||||
|
||||
#define SYM_ENTRY(SYM) { SYM, sizeof(SYM) / 2 }
|
||||
|
||||
|
@ -68,6 +68,8 @@ static const __flash uint8_t sym_b[] = { 0xFC, 0xFC, 0x8C, 0x8C, 0xFC, 0x78,
|
|||
0x3F, 0x3F, 0x31, 0x31, 0x3F, 0x1E };
|
||||
static const __flash uint8_t sym_c[] = { 0xF8, 0xFC, 0x0C, 0x1C, 0x18,
|
||||
0x1F, 0x3F, 0x30, 0x38, 0x18 };
|
||||
static const __flash uint8_t sym_d[] = { 0xFC, 0xFC, 0x0C, 0x1C, 0xF8, 0xF0,
|
||||
0x3F, 0x3F, 0x30, 0x38, 0x1F, 0x0F };
|
||||
static const __flash uint8_t sym_e[] = { 0xFC, 0xFC, 0x8C, 0x8C, 0x0C,
|
||||
0x3F, 0x3F, 0x31, 0x31, 0x30 };
|
||||
static const __flash uint8_t sym_g[] = { 0xF8, 0xFC, 0x0C, 0x0C, 0x3C, 0x38,
|
||||
|
@ -80,6 +82,8 @@ static const __flash uint8_t sym_k[] = { 0xFC, 0xFC, 0xC0, 0xF0, 0x7C, 0x1C,
|
|||
0x3F, 0x3F, 0x03, 0x0F, 0x3E, 0x38 };
|
||||
static const __flash uint8_t sym_l[] = { 0xFC, 0xFC, 0x00, 0x00, 0x00,
|
||||
0x3F, 0x3F, 0x30, 0x30, 0x30 };
|
||||
static const __flash uint8_t sym_m[] = { 0xFC, 0xFC, 0x38, 0x70, 0xE0, 0x70, 0x38, 0xFC, 0xFC,
|
||||
0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F };
|
||||
static const __flash uint8_t sym_n[] = { 0xFC, 0xFC, 0xF0, 0xC0, 0x00, 0xFC, 0xFC,
|
||||
0x3F, 0x3F, 0x00, 0x03, 0x0F, 0x3F, 0x3F };
|
||||
static const __flash uint8_t sym_o[] = { 0xF8, 0xFC, 0x0C, 0x0C, 0xFC, 0xF8,
|
||||
|
@ -93,7 +97,7 @@ static const __flash uint8_t sym_s[] = { 0xF8, 0xFC, 0x8C, 0x8C, 0x9C, 0x18,
|
|||
static const __flash uint8_t sym_t[] = { 0x0C, 0x0C, 0xFC, 0xFC, 0x0C, 0x0C,
|
||||
0x00, 0x00, 0x3F, 0x3F, 0x00, 0x00 };
|
||||
static const __flash uint8_t sym_u[] = { 0xFC, 0xFC, 0x00, 0x00, 0xFC, 0xFC,
|
||||
0x3F, 0x3F, 0x30, 0x30, 0x3F, 0x3F };
|
||||
0x1F, 0x3F, 0x30, 0x30, 0x3F, 0x1F };
|
||||
|
||||
static const __flash uint8_t sym_underscore[] = { 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20 };
|
||||
|
@ -126,7 +130,7 @@ static const struct symbol symbol_table[] = { SYM_ENTRY(sym_0),
|
|||
SYM_ENTRY(sym_a),
|
||||
SYM_ENTRY(sym_b),
|
||||
SYM_ENTRY(sym_c),
|
||||
SYM_ENTRY(sym_invalid),
|
||||
SYM_ENTRY(sym_d),
|
||||
SYM_ENTRY(sym_e),
|
||||
SYM_ENTRY(sym_invalid),
|
||||
SYM_ENTRY(sym_g),
|
||||
|
@ -135,7 +139,7 @@ static const struct symbol symbol_table[] = { SYM_ENTRY(sym_0),
|
|||
SYM_ENTRY(sym_invalid),
|
||||
SYM_ENTRY(sym_k),
|
||||
SYM_ENTRY(sym_l),
|
||||
SYM_ENTRY(sym_invalid),
|
||||
SYM_ENTRY(sym_m),
|
||||
SYM_ENTRY(sym_n),
|
||||
SYM_ENTRY(sym_o),
|
||||
SYM_ENTRY(sym_p),
|
||||
|
@ -285,15 +289,16 @@ static void lcd_write_character_page(const char character,
|
|||
}
|
||||
|
||||
static void lcd_write_string_page(const char* string,
|
||||
const uint8_t kerning,
|
||||
const uint8_t page,
|
||||
const bool invert) {
|
||||
for (uint8_t i = 0; string[i] != 0; i++) {
|
||||
lcd_write_kerning(2, invert);
|
||||
lcd_write_kerning(kerning, invert);
|
||||
lcd_write_character_page(string[i], page, invert);
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_write_integer_page(const uint8_t integer,
|
||||
static void lcd_write_integer_page(const uint32_t integer,
|
||||
const uint8_t digits,
|
||||
const uint8_t page,
|
||||
const bool invert) {
|
||||
|
@ -316,40 +321,24 @@ static void lcd_write_integer_page(const uint8_t integer,
|
|||
}
|
||||
}
|
||||
|
||||
static void lcd_splash(void) {
|
||||
lcd_fill(0x00);
|
||||
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
lcd_move_cursor(31, 1 + i);
|
||||
|
||||
for (uint8_t j = 0; j < 40; j++)
|
||||
lcd_write(sacred_chao[i * 40 + j]);
|
||||
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(26, 6 + i);
|
||||
|
||||
for (uint8_t j = 0; j < 48; j++)
|
||||
lcd_write(onders_org[i * 48 + j]);
|
||||
}
|
||||
}
|
||||
|
||||
static void twi_error(void) {
|
||||
lcd_fill(0xFF);
|
||||
static void twi_error(bool inverted) {
|
||||
if (inverted)
|
||||
lcd_fill(0xFF);
|
||||
else
|
||||
lcd_fill(0x00);
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(0, i);
|
||||
lcd_write_string_page("TW_STATUS:\0", i, true);
|
||||
lcd_write_kerning(2, true);
|
||||
lcd_write_integer_page(TW_STATUS, 3, i, true);
|
||||
lcd_write_string_page("TW_STATUS:\0", 2, i, inverted);
|
||||
lcd_write_kerning(2, inverted);
|
||||
lcd_write_integer_page(TW_STATUS, 3, i, inverted);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(0, i + 2);
|
||||
lcd_write_string_page("TW_DATA:\0", i, true);
|
||||
lcd_write_kerning(16, true);
|
||||
lcd_write_integer_page(TWDR, 3, i, true);
|
||||
lcd_write_string_page("TW_DATA:\0", 2, i, inverted);
|
||||
lcd_write_kerning(16, inverted);
|
||||
lcd_write_integer_page(TWDR, 3, i, inverted);
|
||||
}
|
||||
|
||||
for (;;);
|
||||
|
@ -360,7 +349,7 @@ static void twi_start(void) {
|
|||
while (!(TWCR & (1 << TWINT))); // Wait until start is transmitted
|
||||
|
||||
if (TW_STATUS != TW_START) // Check status
|
||||
twi_error();
|
||||
twi_error(true);
|
||||
}
|
||||
|
||||
static uint8_t twi_transmit(const uint8_t data) {
|
||||
|
@ -386,11 +375,11 @@ static uint8_t twi_read_register(const uint8_t address,
|
|||
const uint8_t reg) {
|
||||
twi_start();
|
||||
|
||||
if (twi_transmit(address) != TW_MT_SLA_ACK)
|
||||
twi_error();
|
||||
if (twi_transmit(address << 1) != TW_MT_SLA_ACK)
|
||||
twi_error(true);
|
||||
|
||||
if (twi_transmit(reg) != TW_MT_DATA_ACK)
|
||||
twi_error();
|
||||
twi_error(true);
|
||||
|
||||
twi_stop();
|
||||
|
||||
|
@ -398,11 +387,11 @@ static uint8_t twi_read_register(const uint8_t address,
|
|||
|
||||
twi_start();
|
||||
|
||||
if (twi_transmit(address + 1) != TW_MR_SLA_ACK)
|
||||
twi_error();
|
||||
if (twi_transmit((address << 1) + 1) != TW_MR_SLA_ACK)
|
||||
twi_error(true);
|
||||
|
||||
if (twi_receive() != TW_MR_DATA_NACK)
|
||||
twi_error();
|
||||
twi_error(true);
|
||||
|
||||
twi_stop();
|
||||
|
||||
|
@ -414,18 +403,36 @@ static void twi_write_register(const uint8_t address,
|
|||
const uint8_t data) {
|
||||
twi_start();
|
||||
|
||||
if (twi_transmit(address) != TW_MT_SLA_ACK)
|
||||
twi_error();
|
||||
if (twi_transmit(address << 1) != TW_MT_SLA_ACK)
|
||||
twi_error(true);
|
||||
|
||||
if (twi_transmit(reg) != TW_MT_DATA_ACK)
|
||||
twi_error();
|
||||
twi_error(true);
|
||||
|
||||
if (twi_transmit(data) != TW_MT_DATA_ACK)
|
||||
twi_error();
|
||||
twi_error(true);
|
||||
|
||||
twi_stop();
|
||||
}
|
||||
|
||||
static void draw_splash(void) {
|
||||
lcd_fill(0x00);
|
||||
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
lcd_move_cursor(31, 1 + i);
|
||||
|
||||
for (uint8_t j = 0; j < 40; j++)
|
||||
lcd_write(sacred_chao[i * 40 + j]);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(26, 6 + i);
|
||||
|
||||
for (uint8_t j = 0; j < 48; j++)
|
||||
lcd_write(onders_org[i * 48 + j]);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_home(void) {
|
||||
lcd_fill(0x00);
|
||||
|
||||
|
@ -451,19 +458,19 @@ static void draw_home(void) {
|
|||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(0, i);
|
||||
lcd_write_string_page("CH1\0", i, ch1_selected);
|
||||
lcd_write_string_page("CH1\0", 2, i, ch1_selected);
|
||||
lcd_write_kerning(2, ch1_selected);
|
||||
|
||||
lcd_move_cursor(0, 2 + i);
|
||||
lcd_write_string_page("CH2\0", i, ch2_selected);
|
||||
lcd_write_string_page("CH2\0", 2, i, ch2_selected);
|
||||
lcd_write_kerning(2, ch2_selected);
|
||||
|
||||
lcd_move_cursor(0, 4 + i);
|
||||
lcd_write_string_page("CH3\0", i, ch3_selected);
|
||||
lcd_write_string_page("CH3\0", 2, i, ch3_selected);
|
||||
lcd_write_kerning(2, ch3_selected);
|
||||
|
||||
lcd_move_cursor(33, 6 + i);
|
||||
lcd_write_string_page("SETUP\0", i, setup_selected);
|
||||
lcd_write_string_page("SETUP\0", 2, i, setup_selected);
|
||||
lcd_write_kerning(2, setup_selected);
|
||||
}
|
||||
}
|
||||
|
@ -498,13 +505,13 @@ static void draw_setup(void) {
|
|||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(0, i);
|
||||
lcd_write_kerning(30, true);
|
||||
lcd_write_string_page("SETUP\0", i, true);
|
||||
lcd_write_string_page("SETUP\0", 2, i, true);
|
||||
lcd_write_kerning(33, true);
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(0, 2 + i);
|
||||
lcd_write_string_page("CONTRAST:\0", i, contrast_selected);
|
||||
lcd_write_string_page("CONTRAST:\0", 2, i, contrast_selected);
|
||||
lcd_write_kerning(2, contrast_selected);
|
||||
lcd_write_kerning(16, false);
|
||||
lcd_write_integer_page(value_contrast, 2, i,
|
||||
|
@ -514,7 +521,7 @@ static void draw_setup(void) {
|
|||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(0, 4 + i);
|
||||
lcd_write_string_page("BACKLIGHT:\0", i, backlight_selected);
|
||||
lcd_write_string_page("BACKLIGHT:\0", 2, i, backlight_selected);
|
||||
lcd_write_kerning(2, backlight_selected);
|
||||
lcd_write_kerning(5, false);
|
||||
lcd_write_integer_page(value_backlight, 3, i,
|
||||
|
@ -524,7 +531,7 @@ static void draw_setup(void) {
|
|||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
lcd_move_cursor(33, 6 + i);
|
||||
lcd_write_string_page("BACK:\0", i, back_selected);
|
||||
lcd_write_string_page("BACK\0", 2, i, back_selected);
|
||||
lcd_write_kerning(2, back_selected);
|
||||
}
|
||||
}
|
||||
|
@ -790,7 +797,7 @@ int main(void) {
|
|||
TIMSK1 |= (1 << OCIE1A); // Enable match compare A
|
||||
|
||||
// Show splash screen
|
||||
lcd_splash();
|
||||
draw_splash();
|
||||
_delay_ms(2000);
|
||||
|
||||
// Load the menu
|
||||
|
|
Loading…
Reference in a new issue