wip: lcd ui for radio

This commit is contained in:
2023-07-02 22:58:01 +02:00
parent a3d7b24d19
commit 3491d39cd8
9 changed files with 527 additions and 144 deletions

View File

@@ -43,7 +43,7 @@ target_link_libraries(ledtest pico_stdlib hardware_pio)
pico_add_extra_outputs(ledtest)
add_executable(lcdtest
src/lcdtest.c src/lcdbus.c src/lcd_ui.c
src/lcdtest.c src/lcdbus.c src/lcd_ui.c src/ui_radio.c
)
pico_generate_pio_header(lcdtest ${CMAKE_CURRENT_LIST_DIR}/src/lcdbus.pio)

258
src/8x12_horizontal_MSB_1.h Normal file
View File

@@ -0,0 +1,258 @@
const char Font8x12[256][12]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00
{0x00,0x7E,0xC3,0x81,0xA5,0x81,0xBD,0x99,0xC3,0x7E,0x00,0x00}, // 0x01
{0x00,0x7E,0xFF,0xFF,0xDB,0xFF,0xC3,0xE7,0xFF,0x7E,0x00,0x00}, // 0x02
{0x00,0x00,0x44,0xEE,0xFE,0xFE,0xFE,0x7C,0x38,0x10,0x00,0x00}, // 0x03
{0x00,0x10,0x38,0x7C,0xFE,0xFE,0x7C,0x38,0x10,0x00,0x00,0x00}, // 0x04
{0x00,0x18,0x3C,0x3C,0xFF,0xE7,0xE7,0x18,0x18,0x7E,0x00,0x00}, // 0x05
{0x00,0x18,0x3C,0x7E,0xFF,0xFF,0x7E,0x18,0x18,0x7E,0x00,0x00}, // 0x06
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A
{0x00,0x3E,0x0E,0x3A,0x72,0xF8,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x0B
{0x00,0x3C,0x66,0x66,0x66,0x3C,0x18,0x7E,0x18,0x18,0x00,0x00}, // 0x0C
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D
{0x00,0x7F,0x63,0x7F,0x63,0x63,0x63,0x67,0xE7,0xE6,0xC0,0x00}, // 0x0E
{0x00,0x00,0x18,0xDB,0x7E,0xE7,0xE7,0x7E,0xDB,0x18,0x00,0x00}, // 0x0F
{0x00,0x80,0xC0,0xE0,0xF8,0xFE,0xF8,0xE0,0xC0,0x80,0x00,0x00}, // 0x10
{0x00,0x02,0x06,0x0E,0x3E,0xFE,0x3E,0x0E,0x06,0x02,0x00,0x00}, // 0x11
{0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00}, // 0x12
{0x00,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00}, // 0x13
{0x00,0x7F,0xDB,0xDB,0xDB,0x7B,0x1B,0x1B,0x1B,0x1B,0x00,0x00}, // 0x14
{0x00,0x7E,0x63,0x30,0x3C,0x66,0x66,0x3C,0x0C,0xC6,0x7E,0x00}, // 0x15
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0xFE,0x00,0x00}, // 0x16
{0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x7E,0x3C,0x18,0x7E,0x00}, // 0x17
{0x00,0x18,0x3C,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00}, // 0x18
{0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x3C,0x18,0x00,0x00}, // 0x19
{0x00,0x00,0x00,0x18,0x0C,0xFE,0x0C,0x18,0x00,0x00,0x00,0x00}, // 0x1A
{0x00,0x00,0x00,0x30,0x60,0xFE,0x60,0x30,0x00,0x00,0x00,0x00}, // 0x1B
{0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xFE,0x00,0x00,0x00,0x00}, // 0x1C
{0x00,0x00,0x00,0x24,0x66,0xFF,0x66,0x24,0x00,0x00,0x00,0x00}, // 0x1D
{0x00,0x00,0x10,0x10,0x38,0x38,0x7C,0x7C,0xFE,0xFE,0x00,0x00}, // 0x1E
{0x00,0x00,0xFE,0xFE,0x7C,0x7C,0x38,0x38,0x10,0x10,0x00,0x00}, // 0x1F
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20
{0x00,0x30,0x78,0x78,0x78,0x30,0x30,0x00,0x30,0x30,0x00,0x00}, // 0x21
{0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x22
{0x00,0x6C,0x6C,0xFE,0x6C,0x6C,0x6C,0xFE,0x6C,0x6C,0x00,0x00}, // 0x23
{0x30,0x30,0x7C,0xC0,0xC0,0x78,0x0C,0x0C,0xF8,0x30,0x30,0x00}, // 0x24
{0x00,0x00,0x00,0xC4,0xCC,0x18,0x30,0x60,0xCC,0x8C,0x00,0x00}, // 0x25
{0x00,0x70,0xD8,0xD8,0x70,0xFA,0xDE,0xCC,0xDC,0x76,0x00,0x00}, // 0x26
{0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x27
{0x00,0x0C,0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x0C,0x00,0x00}, // 0x28
{0x00,0x60,0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x60,0x00,0x00}, // 0x29
{0x00,0x00,0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00}, // 0x2A
{0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00}, // 0x2B
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x60,0x00}, // 0x2C
{0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2D
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x00,0x00}, // 0x2E
{0x00,0x00,0x02,0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,0x00}, // 0x2F
{0x00,0x7C,0xC6,0xCE,0xDE,0xD6,0xF6,0xE6,0xC6,0x7C,0x00,0x00}, // 0x30
{0x00,0x10,0x30,0xF0,0x30,0x30,0x30,0x30,0x30,0xFC,0x00,0x00}, // 0x31
{0x00,0x78,0xCC,0xCC,0x0C,0x18,0x30,0x60,0xCC,0xFC,0x00,0x00}, // 0x32
{0x00,0x78,0xCC,0x0C,0x0C,0x38,0x0C,0x0C,0xCC,0x78,0x00,0x00}, // 0x33
{0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x0C,0x1E,0x00,0x00}, // 0x34
{0x00,0xFC,0xC0,0xC0,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00,0x00}, // 0x35
{0x00,0x38,0x60,0xC0,0xC0,0xF8,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x36
{0x00,0xFE,0xC6,0xC6,0x06,0x0C,0x18,0x30,0x30,0x30,0x00,0x00}, // 0x37
{0x00,0x78,0xCC,0xCC,0xCC,0x78,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x38
{0x00,0x78,0xCC,0xCC,0xCC,0x7C,0x18,0x18,0x30,0x70,0x00,0x00}, // 0x39
{0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x00,0x00,0x00}, // 0x3A
{0x00,0x00,0x00,0x38,0x38,0x00,0x00,0x38,0x38,0x18,0x30,0x00}, // 0x3B
{0x00,0x0C,0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x0C,0x00,0x00}, // 0x3C
{0x00,0x00,0x00,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00,0x00,0x00}, // 0x3D
{0x00,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0x00,0x00}, // 0x3E
{0x00,0x78,0xCC,0x0C,0x18,0x30,0x30,0x00,0x30,0x30,0x00,0x00}, // 0x3F
{0x00,0x7C,0xC6,0xC6,0xDE,0xDE,0xDE,0xC0,0xC0,0x7C,0x00,0x00}, // 0x40
{0x00,0x30,0x78,0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,0x00}, // 0x41
{0x00,0xFC,0x66,0x66,0x66,0x7C,0x66,0x66,0x66,0xFC,0x00,0x00}, // 0x42
{0x00,0x3C,0x66,0xC6,0xC0,0xC0,0xC0,0xC6,0x66,0x3C,0x00,0x00}, // 0x43
{0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00}, // 0x44
{0x00,0xFE,0x62,0x60,0x64,0x7C,0x64,0x60,0x62,0xFE,0x00,0x00}, // 0x45
{0x00,0xFE,0x66,0x62,0x64,0x7C,0x64,0x60,0x60,0xF0,0x00,0x00}, // 0x46
{0x00,0x3C,0x66,0xC6,0xC0,0xC0,0xCE,0xC6,0x66,0x3E,0x00,0x00}, // 0x47
{0x00,0xCC,0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0xCC,0x00,0x00}, // 0x48
{0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00}, // 0x49
{0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x4A
{0x00,0xE6,0x66,0x6C,0x6C,0x78,0x6C,0x6C,0x66,0xE6,0x00,0x00}, // 0x4B
{0x00,0xF0,0x60,0x60,0x60,0x60,0x62,0x66,0x66,0xFE,0x00,0x00}, // 0x4C
{0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0xC6,0xC6,0x00,0x00}, // 0x4D
{0x00,0xC6,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,0xC6,0xC6,0x00,0x00}, // 0x4E
{0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x00,0x00}, // 0x4F
{0x00,0xFC,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0xF0,0x00,0x00}, // 0x50
{0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xCE,0xDE,0x7C,0x0C,0x1E,0x00}, // 0x51
{0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C,0x66,0x66,0xE6,0x00,0x00}, // 0x52
{0x00,0x78,0xCC,0xCC,0xC0,0x70,0x18,0xCC,0xCC,0x78,0x00,0x00}, // 0x53
{0x00,0xFC,0xB4,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00}, // 0x54
{0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x55
{0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00}, // 0x56
{0x00,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0x6C,0x6C,0x6C,0x00,0x00}, // 0x57
{0x00,0xCC,0xCC,0xCC,0x78,0x30,0x78,0xCC,0xCC,0xCC,0x00,0x00}, // 0x58
{0x00,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x30,0x30,0x78,0x00,0x00}, // 0x59
{0x00,0xFE,0xCE,0x98,0x18,0x30,0x60,0x62,0xC6,0xFE,0x00,0x00}, // 0x5A
{0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,0x00}, // 0x5B
{0x00,0x00,0x80,0xC0,0x60,0x30,0x18,0x0C,0x06,0x02,0x00,0x00}, // 0x5C
{0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,0x00}, // 0x5D
{0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x5E
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00}, // 0x5F
{0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x60
{0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0x61
{0x00,0xE0,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0xDC,0x00,0x00}, // 0x62
{0x00,0x00,0x00,0x00,0x78,0xCC,0xC0,0xC0,0xCC,0x78,0x00,0x00}, // 0x63
{0x00,0x1C,0x0C,0x0C,0x7C,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00}, // 0x64
{0x00,0x00,0x00,0x00,0x78,0xCC,0xFC,0xC0,0xCC,0x78,0x00,0x00}, // 0x65
{0x00,0x38,0x6C,0x60,0x60,0xF8,0x60,0x60,0x60,0xF0,0x00,0x00}, // 0x66
{0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78}, // 0x67
{0x00,0xE0,0x60,0x60,0x6C,0x76,0x66,0x66,0x66,0xE6,0x00,0x00}, // 0x68
{0x00,0x18,0x18,0x00,0x78,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x69
{0x00,0x0C,0x0C,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0xCC,0xCC,0x78}, // 0x6A
{0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,0x6C,0x66,0xE6,0x00,0x00}, // 0x6B
{0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x6C
{0x00,0x00,0x00,0x00,0xFC,0xD6,0xD6,0xD6,0xD6,0xC6,0x00,0x00}, // 0x6D
{0x00,0x00,0x00,0x00,0xF8,0xCC,0xCC,0xCC,0xCC,0xCC,0x00,0x00}, // 0x6E
{0x00,0x00,0x00,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x6F
{0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x7C,0x60,0xF0}, // 0x70
{0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0x1E}, // 0x71
{0x00,0x00,0x00,0x00,0xEC,0x6E,0x76,0x60,0x60,0xF0,0x00,0x00}, // 0x72
{0x00,0x00,0x00,0x00,0x78,0xCC,0x60,0x18,0xCC,0x78,0x00,0x00}, // 0x73
{0x00,0x00,0x20,0x60,0xFC,0x60,0x60,0x60,0x6C,0x38,0x00,0x00}, // 0x74
{0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00}, // 0x75
{0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0x78,0x30,0x00,0x00}, // 0x76
{0x00,0x00,0x00,0x00,0xC6,0xC6,0xD6,0xD6,0x6C,0x6C,0x00,0x00}, // 0x77
{0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x38,0x6C,0xC6,0x00,0x00}, // 0x78
{0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x0C,0x18,0xF0}, // 0x79
{0x00,0x00,0x00,0x00,0xFC,0x8C,0x18,0x60,0xC4,0xFC,0x00,0x00}, // 0x7A
{0x00,0x1C,0x30,0x30,0x60,0xC0,0x60,0x30,0x30,0x1C,0x00,0x00}, // 0x7B
{0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00}, // 0x7C
{0x00,0xE0,0x30,0x30,0x18,0x0C,0x18,0x30,0x30,0xE0,0x00,0x00}, // 0x7D
{0x00,0x73,0xDA,0xCE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7E
{0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0x00,0x00,0x00}, // 0x7F
{0x00,0x78,0xCC,0xCC,0xC0,0xC0,0xC0,0xCC,0xCC,0x78,0x30,0x60}, // 0x80
{0x00,0xCC,0xCC,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00}, // 0x81
{0x0C,0x18,0x30,0x00,0x78,0xCC,0xFC,0xC0,0xCC,0x78,0x00,0x00}, // 0x82
{0x30,0x78,0xCC,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0x83
{0x00,0xCC,0xCC,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0x84
{0xC0,0x60,0x30,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0x85
{0x38,0x6C,0x6C,0x38,0xF8,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0x86
{0x00,0x00,0x00,0x00,0x78,0xCC,0xC0,0xC0,0xCC,0x78,0x30,0x60}, // 0x87
{0x30,0x78,0xCC,0x00,0x78,0xCC,0xFC,0xC0,0xC0,0x7C,0x00,0x00}, // 0x88
{0x00,0xCC,0xCC,0x00,0x78,0xCC,0xFC,0xC0,0xC0,0x7C,0x00,0x00}, // 0x89
{0xC0,0x60,0x30,0x00,0x78,0xCC,0xFC,0xC0,0xC0,0x7C,0x00,0x00}, // 0x8A
{0x00,0x6C,0x6C,0x00,0x78,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x8B
{0x10,0x38,0x6C,0x00,0x78,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x8C
{0x60,0x30,0x18,0x00,0x78,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0x8D
{0x00,0xCC,0x00,0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00}, // 0x8E
{0x78,0xCC,0xCC,0x78,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00}, // 0x8F
{0x0C,0x18,0x00,0xFC,0xC4,0xC0,0xF8,0xC0,0xC4,0xFC,0x00,0x00}, // 0x90
{0x00,0x00,0x00,0x00,0xFE,0x1B,0x7F,0xD8,0xD8,0xEF,0x00,0x00}, // 0x91
{0x00,0x3E,0x78,0xD8,0xD8,0xFE,0xD8,0xD8,0xD8,0xDE,0x00,0x00}, // 0x92
{0x30,0x78,0xCC,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x93
{0x00,0xCC,0xCC,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x94
{0xC0,0x60,0x30,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x95
{0x30,0x78,0xCC,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00}, // 0x96
{0xC0,0x60,0x30,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00}, // 0x97
{0x00,0x66,0x66,0x00,0x66,0x66,0x66,0x66,0x3C,0x0C,0x18,0xF0}, // 0x98
{0x00,0xCC,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x99
{0xCC,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0x9A
{0x00,0x00,0x00,0x00,0x78,0xCC,0xDC,0xEC,0xCC,0x78,0x00,0x00}, // 0x9B
{0x3C,0x66,0x60,0x60,0x60,0xFC,0x60,0x60,0xC0,0xFE,0x00,0x00}, // 0x9C
{0x00,0x3A,0x6C,0xCE,0xD6,0xD6,0xD6,0xE6,0x6C,0xB8,0x00,0x00}, // 0x9D
{0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00,0x00}, // 0x9E
{0x0E,0x1B,0x18,0x18,0x7E,0x18,0x18,0x18,0xD8,0x70,0x00,0x00}, // 0x9F
{0x0C,0x18,0x30,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0xA0
{0x0C,0x18,0x30,0x00,0x78,0x18,0x18,0x18,0x18,0x7E,0x00,0x00}, // 0xA1
{0x0C,0x18,0x30,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xA2
{0x0C,0x18,0x30,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00}, // 0xA3
{0x00,0x76,0xDC,0x00,0xF8,0xCC,0xCC,0xCC,0xCC,0xCC,0x00,0x00}, // 0xA4
{0x76,0xDC,0x00,0xC6,0xE6,0xF6,0xDE,0xCE,0xC6,0xC6,0x00,0x00}, // 0xA5
{0x00,0x78,0xCC,0xCC,0x7E,0x00,0xFE,0x00,0x00,0x00,0x00,0x00}, // 0xA6
{0x00,0x78,0xCC,0xCC,0x78,0x00,0xFE,0x00,0x00,0x00,0x00,0x00}, // 0xA7
{0x00,0x30,0x30,0x00,0x30,0x60,0xC0,0xC0,0xCC,0x78,0x00,0x00}, // 0xA8
{0x00,0x38,0x44,0xBA,0xAA,0xBA,0xB2,0xAA,0x44,0x38,0x00,0x00}, // 0xA9
{0x00,0x00,0x00,0x00,0x00,0xFC,0x0C,0x0C,0x0C,0x00,0x00,0x00}, // 0xAA
{0x00,0x62,0xE6,0x6C,0x78,0x30,0x6E,0xC3,0x86,0x0C,0x1F,0x00}, // 0xAB
{0x00,0x63,0xE6,0x6C,0x78,0x37,0x6F,0xDB,0xB3,0x3F,0x03,0x00}, // 0xAC
{0x00,0x30,0x30,0x00,0x30,0x30,0x78,0x78,0x78,0x30,0x00,0x00}, // 0xAD
{0x00,0x00,0x00,0x00,0x33,0x66,0xCC,0xCC,0x66,0x33,0x00,0x00}, // 0xAE
{0x00,0x00,0x00,0x00,0xCC,0x66,0x33,0x33,0x66,0xCC,0x00,0x00}, // 0xAF
{0x24,0x92,0x49,0x24,0x92,0x49,0x24,0x92,0x49,0x24,0x92,0x49}, // 0xB0
{0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA}, // 0xB1
{0x6D,0xDB,0xB6,0x6D,0xDB,0xB6,0x6D,0xDB,0xB6,0x6D,0xDB,0xB6}, // 0xB2
{0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xB3
{0x18,0x18,0x18,0x18,0x18,0xF8,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xB4
{0x0C,0x18,0x00,0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00}, // 0xB5
{0x78,0xCC,0x00,0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00}, // 0xB6
{0x60,0x30,0x00,0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00}, // 0xB7
{0x00,0x38,0x44,0xBA,0xA2,0xA2,0xA2,0xBA,0x44,0x38,0x00,0x00}, // 0xB8
{0x66,0x66,0x66,0x66,0xE6,0x06,0x06,0xE6,0x66,0x66,0x66,0x66}, // 0xB9
{0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66}, // 0xBA
{0x00,0x00,0x00,0x00,0xFE,0x06,0x06,0xE6,0x66,0x66,0x66,0x66}, // 0xBB
{0x66,0x66,0x66,0x66,0xE6,0x06,0x06,0xFE,0x00,0x00,0x00,0x00}, // 0xBC
{0x00,0x30,0x30,0x78,0xCC,0xC0,0xC0,0xCC,0x78,0x30,0x30,0x00}, // 0xBD
{0xCC,0xCC,0xCC,0xCC,0x78,0xFC,0x30,0xFC,0x30,0x30,0x00,0x00}, // 0xBE
{0x00,0x00,0x00,0x00,0x00,0xF8,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xBF
{0x18,0x18,0x18,0x18,0x18,0x1F,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xC0
{0x18,0x18,0x18,0x18,0x18,0xFF,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xC1
{0x00,0x00,0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xC2
{0x18,0x18,0x18,0x18,0x18,0x1F,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xC3
{0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xC4
{0x18,0x18,0x18,0x18,0x18,0xFF,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xC5
{0x00,0x76,0xDC,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0x76,0x00,0x00}, // 0xC6
{0x76,0xDC,0x00,0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,0x00}, // 0xC7
{0x66,0x66,0x66,0x66,0x67,0x60,0x60,0x7F,0x00,0x00,0x00,0x00}, // 0xC8
{0x00,0x00,0x00,0x00,0x7F,0x60,0x60,0x67,0x66,0x66,0x66,0x66}, // 0xC9
{0x66,0x66,0x66,0x66,0xE7,0x00,0x00,0xFF,0x00,0x00,0x00,0x00}, // 0xCA
{0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xE7,0x66,0x66,0x66,0x66}, // 0xCB
{0x66,0x66,0x66,0x66,0x67,0x60,0x60,0x67,0x66,0x66,0x66,0x66}, // 0xCC
{0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0x00,0x00}, // 0xCD
{0x66,0x66,0x66,0x66,0xE7,0x00,0x00,0xE7,0x66,0x66,0x66,0x66}, // 0xCE
{0x00,0x00,0x00,0x00,0x00,0xC6,0x7C,0x6C,0x7C,0xC6,0x00,0x00}, // 0xCF
{0xCC,0x30,0xD8,0x0C,0x06,0x7E,0xC6,0xC6,0xC6,0x7C,0x00,0x00}, // 0xD0
{0x00,0xF8,0x6C,0x66,0x66,0xF6,0x66,0x66,0x6C,0xF8,0x00,0x00}, // 0xD1
{0x78,0xCC,0x00,0xFC,0xC4,0xC0,0xF8,0xC0,0xC4,0xFC,0x00,0x00}, // 0xD2
{0x00,0xCC,0x00,0xFC,0xC4,0xC0,0xF8,0xC0,0xC4,0xFC,0x00,0x00}, // 0xD3
{0x60,0x30,0x00,0xFC,0xC4,0xC0,0xF8,0xC0,0xC4,0xFC,0x00,0x00}, // 0xD4
{0x00,0xF0,0x30,0x30,0x30,0xFC,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xD5
{0x18,0x30,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00}, // 0xD6
{0x78,0xCC,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00}, // 0xD7
{0x00,0xCC,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00}, // 0xD8
{0x18,0x18,0x18,0x18,0x18,0xF8,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xD9
{0x00,0x00,0x00,0x00,0x00,0x1F,0x18,0x18,0x18,0x18,0x18,0x18}, // 0xDA
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, // 0xDB
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, // 0xDC
{0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00}, // 0xDD
{0x60,0x30,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00}, // 0xDE
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xDF
{0x18,0x30,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xE0
{0x00,0x78,0xCC,0xCC,0xD8,0xCC,0xCC,0xCC,0xF8,0xC0,0x60,0x00}, // 0xE1
{0x78,0xCC,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xE2
{0x60,0x30,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xE3
{0x00,0x76,0xDC,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xE4
{0x76,0xDC,0x00,0x78,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xE5
{0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x7B,0x60,0xC0}, // 0xE6
{0x00,0x00,0xE0,0x60,0x7C,0x66,0x66,0x7C,0x60,0xF0,0x00,0x00}, // 0xE7
{0x00,0xF0,0x60,0x7C,0x66,0x66,0x66,0x7C,0x60,0xF0,0x00,0x00}, // 0xE8
{0x18,0x30,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xE9
{0x78,0xCC,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xEA
{0x60,0x30,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00}, // 0xEB
{0x06,0x0C,0x18,0x00,0x66,0x66,0x66,0x66,0x3C,0x0C,0x18,0xF0}, // 0xEC
{0x18,0x30,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x30,0x78,0x00,0x00}, // 0xED
{0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEE
{0x0C,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEF
{0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF0
{0x00,0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0xFC,0x00,0x00,0x00}, // 0xF1
{0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00}, // 0xF2
{0xE0,0x33,0x66,0x3C,0xF8,0x37,0x6F,0xDB,0xB3,0x3F,0x03,0x00}, // 0xF3
{0x00,0x7F,0xDB,0xDB,0xDB,0x7B,0x1B,0x1B,0x1B,0x1B,0x00,0x00}, // 0xF4
{0x00,0x7E,0x63,0x30,0x3C,0x66,0x66,0x3C,0x0C,0xC6,0x7E,0x00}, // 0xF5
{0x00,0x00,0x30,0x30,0x00,0xFC,0x00,0x30,0x30,0x00,0x00,0x00}, // 0xF6
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x70}, // 0xF7
{0x00,0x3C,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF8
{0x00,0xCC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF9
{0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFA
{0x00,0x30,0x70,0x30,0x30,0x78,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFB
{0x00,0x78,0x0C,0x38,0x0C,0x78,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFC
{0x00,0x78,0x0C,0x18,0x30,0x7C,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFD
{0x00,0x00,0x00,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00}, // 0xFE
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF
};

View File

@@ -1,78 +1,33 @@
#include "fonts.h"
//#include "fonts.h"
#include "8x12_horizontal_MSB_1.h"
#include "lcdbus.h"
#include "lcd_ui.h"
#include <pico/stdlib.h>
#include <stdio.h>
#include <string.h>
enum static_type {
none,
enum ui_element_type {
box_full,
box_border,
text,
text_vert,
bar_vert,
};
struct static_element {
unsigned upper, left, lower, right;
enum static_type type;
bool visible;
const char *data;
struct ui_element {
uint16_t upper, lower, color_fg, color_bg;
uint8_t left, right;
enum ui_element_type type;
union {
const char *text_data;
unsigned bar_data;
};
};
struct static_element static_elements[] = {
{ .upper = 0, .left = 119, .right = 121, .lower = 319,
.type = box_full,
.visible = true,
},
{ .upper = 10, .left = 10, .right = 17, .lower = 57,
.type = text_vert,
.visible = true,
.data = "VHF1",
},
{ .upper = 10, .left = 20, .right = 30, .lower = 69,
.type = box_border,
.visible = true,
},
{ .upper = 10, .left = 40, .right = 106, .lower = 22,
.type = text,
.visible = true,
.data = "118.000",
},
{ .upper = 57, .left = 40, .right = 106, .lower = 69,
.type = text,
.visible = true,
.data = "122.800",
},
{ .upper = 79, .left = 0, .right = 239, .lower = 81,
.type = box_full,
.visible = true,
},
{ .upper = 159, .left = 0, .right = 239, .lower = 161,
.type = box_full,
.visible = true,
},
{ .upper = 239, .left = 0, .right = 239, .lower = 241,
.type = box_full,
.visible = true,
},
};
enum ise_ret {
ise_blank = 0,
ise_pixel = 1,
ise_abort,
};
static enum ise_ret in_static_element(unsigned row, unsigned col, struct static_element const * const se)
static uint16_t get_pixel(struct ui_element *const se, unsigned row, unsigned col)
{
// if (row <= se->lower) return ise_abort;
if (!se->visible) return ise_blank;
if (!((row >= se->upper) && (row <= se->lower) && (col >= se->left) && (col <= se->right))) return ise_blank;
switch(se->type) {
case box_full:
return ise_pixel;
case box_border:
return (row == se->upper) || (row == se->lower) ||(col == se->left) || (col == se->right);
return se->color_fg;
case text:
{
// which character to display
@@ -80,9 +35,9 @@ static enum ise_ret in_static_element(unsigned row, unsigned col, struct static_
// position inside char
const int pos_r = (row - se->upper) % 12;
const int pos_c = (col - se->left) % 8;
if (char_c >= strlen(se->data)) return false;
const char data = Font8x12[(se->data[char_c]-0x20)*12 + pos_r];
return (data & (1u << (7-pos_c))) != 0;
if (char_c >= strlen(se->text_data)) return se->color_bg;
const char data = Font8x12[se->text_data[char_c]][pos_r];
return ((data & (1u << (7-pos_c))) != 0) ? se->color_fg : se->color_bg;
}
case text_vert:
{
@@ -91,43 +46,117 @@ static enum ise_ret in_static_element(unsigned row, unsigned col, struct static_
// position inside char
const int pos_r = (row - se->upper) % 12;
const int pos_c = (col - se->left) % 8;
if (char_r >= strlen(se->data)) return false;
const char data = Font8x12[(se->data[char_r]-0x20)*12 + pos_r];
return (data & (1u << (7-pos_c))) != 0;
if (char_r >= strlen(se->text_data)) return se->color_bg;
const char data = Font8x12[se->text_data[char_r]][pos_r];
return ((data & (1u << (7-pos_c))) != 0) ? se->color_fg : se->color_bg;
}
case bar_vert:
{
if ((row == se->upper) || (row == se->lower) ||(col == se->left) || (col == se->right)) {
return se->color_fg;
}
const int height = se->lower - se->upper - 2;
const int fill_h = height * se->bar_data / 100;
if (row < se->lower - fill_h - 1) return se->color_bg;
return se->color_fg;
}
}
return BLACK;
}
static uint16_t get_pixel(unsigned row, unsigned col)
{
for (int se = 0;se < sizeof(static_elements)/sizeof(static_elements[0]);++se) {
switch(in_static_element(row, col, static_elements+se)) {
case ise_pixel:
return 0xffff;
case ise_blank:
continue;
case ise_abort:
return 0x0000;
}
}
return 0x0000;
}
static unsigned cur_row = 0, cur_col = 0;
static int cur_element = 0;
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
bool lcd_ui_process(void)
#define MAX_DRAW_QUEUE 128
static struct ui_element draw_queue[MAX_DRAW_QUEUE];
static int draw_queue_read, draw_queue_write = 0;
static void queue_element(struct ui_element elem) {
const int next = (draw_queue_write + 1) % MAX_DRAW_QUEUE;
while (draw_queue_read == next) {
lcd_ui_process(true);
}
draw_queue[draw_queue_write] = elem;
draw_queue_write = next;
}
void lcd_ui_box(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color)
{
while (!lcd_fifo_full()) {
lcd_data_write(get_pixel(cur_row, cur_col));
cur_col = (cur_col >= LCD_WIDTH - 1) ? 0 : cur_col + 1;
if (cur_col == 0) {
cur_row = (cur_row >= LCD_HEIGHT - 1) ? 0 : cur_row + 1;
if (cur_row == 0) return true;
struct ui_element elem = {
.type = box_full,
.upper = upper, .left = left, .lower = lower, .right = right,
.color_fg = color,
};
queue_element(elem);
}
void lcd_ui_text(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color, bool highlight, const char *string)
{
struct ui_element elem = {
.type = text,
.upper = upper, .left = left, .lower = lower, .right = right,
.color_fg = highlight ? BLACK : color,
.color_bg = highlight ? color : BLACK,
.text_data = string,
};
queue_element(elem);
}
void lcd_ui_text_vert(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color, bool highlight, const char *string)
{
struct ui_element elem = {
.type = text_vert,
.upper = upper, .left = left, .lower = lower, .right = right,
.color_fg = highlight ? BLACK : color,
.color_bg = highlight ? color : BLACK,
.text_data = string,
};
queue_element(elem);
}
void lcd_ui_bar_vert(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color, unsigned percent)
{
struct ui_element elem = {
.type = bar_vert,
.upper = upper, .left = left, .lower = lower, .right = right,
.color_fg = color,
.bar_data = percent,
};
queue_element(elem);
}
static bool draw_element(struct ui_element *const element, bool block)
{
static unsigned cur_row = 0, cur_col = 0;
static struct ui_element *last_element = NULL;
if (element != last_element) {
lcd_set_window(element->upper, element->left, element->lower, element->right);
cur_row = element->upper;
cur_col = element->left;
last_element = element;
}
while (block || !lcd_fifo_full()) {
lcd_data_write(get_pixel(element, cur_row, cur_col));
cur_col = (cur_col >= element->right) ? element->left : cur_col + 1;
if (cur_col == element->left) {
cur_row = (cur_row >= element->lower) ? element->upper : cur_row + 1;
if (cur_row == element->upper) {
return true;
}
}
}
return false;
}
bool lcd_ui_process(bool block)
{
if (draw_queue_read == draw_queue_write) {
return true; // nothing to draw
}
struct ui_element *element = &draw_queue[draw_queue_read];
if (draw_element(element, block)) {
draw_queue_read = (draw_queue_read + 1) % MAX_DRAW_QUEUE;
}
}

View File

@@ -2,4 +2,14 @@
#include <stdbool.h>
bool lcd_ui_process(void);
#define BLACK 0x0000
#define GREEN 0x07e0
#define TEAL 0x0618
#define WHITE 0xffff
bool lcd_ui_process(bool block);
void lcd_ui_box(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color);
void lcd_ui_text(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color, bool highlight, const char *text);
void lcd_ui_text_vert(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color, bool highlight, const char *text);
void lcd_ui_bar_vert(unsigned upper, unsigned left, unsigned lower, unsigned right, uint16_t color, unsigned percent);

View File

@@ -138,3 +138,14 @@ bool lcd_fifo_full(void)
{
return pio_sm_is_tx_fifo_full(pio, sm);
}
void lcd_set_window(uint16_t upper, uint8_t left, uint16_t lower, uint8_t right)
{
uint16_t horiz = (((uint16_t)right) << 8) | left;
lcd_reg_write(0x44, horiz);
lcd_reg_write(0x45, upper & 0x1ff);
lcd_reg_write(0x46, lower & 0x1ff);
lcd_reg_write(0x4e, left);
lcd_reg_write(0x4f, upper & 0x1ff);
lcd_control_write(0x22);
}

View File

@@ -10,3 +10,4 @@ void lcd_init(void);
void lcd_write_init(void);
void lcd_clear(uint16_t val);
bool lcd_fifo_full(void);
void lcd_set_window(uint16_t upper, uint8_t left, uint16_t lower, uint8_t right);

View File

@@ -2,6 +2,7 @@
#include <hardware/pio.h>
#include "lcdbus.h"
#include "lcd_ui.h"
#include "ui_radio.h"
#include <pico/stdlib.h>
#include <stdio.h>
@@ -18,64 +19,22 @@ int main(void)
lcd_write_init();
lcd_clear(0);
/* int color = 0; */
/* while(true) { */
/* const char* const greeting = "Hello, world!"; */
/* const int greeting_len = strlen(greeting); */
/* for (int row = 0;row < 320;++row) { */
/* for (int col = 0; col < 240;++col) { */
/* // which character to display */
/* const int char_r = row / 12; */
/* const int char_c = col / 8; */
/* // position inside char */
/* const int pos_r = row % 12; */
/* const int pos_c = col % 8; */
/* const int index = char_r*30+char_c; */
/* char data = 0; */
/* if (index < greeting_len) { */
/* data = Font8x12[(greeting[index]-0x20)*12 + pos_r]; */
/* } */
/* const bool pixel = (data & (1u << (7-pos_c))) != 0; */
/* if (pixel) { */
/* if (color == 4) { */
/* lcd_data_write(0x0000); */
/* } else { */
/* lcd_data_write(0xffff); */
/* } */
/* } else { */
/* switch(color) { */
/* case 0: */
/* lcd_data_write(0x0000); */
/* break; */
/* case 1: */
/* lcd_data_write(0x001f); */
/* break; */
/* case 2: */
/* lcd_data_write(0x07e0); */
/* break; */
/* case 3: */
/* lcd_data_write(0xf800); */
/* break; */
/* case 4: */
/* lcd_data_write(0xffff); */
/* break; */
/* } */
/* } */
/* } */
/* } */
/* color = (color == 4) ? 0 : color + 1; */
/* sleep_ms(1000); */
/* } */
gpio_init(FRAME_LED);
gpio_set_dir(FRAME_LED, true);
bool frame_led = false;
int freq = 118000;
unsigned last_inc = time_us_32()/1000;
radio_draw_all();
radio_select_input(&radio_vhf1, true);
while(true) {
if (lcd_ui_process()) {
if (lcd_ui_process(false)) {
gpio_put(FRAME_LED, frame_led);
frame_led = !frame_led;
}
if (time_us_32()/1000 - last_inc >= 1000) {
radio_set_standby_freq(&radio_vhf1, freq);
freq += 25;
last_inc += 1000;
}
}
}

94
src/ui_radio.c Normal file
View File

@@ -0,0 +1,94 @@
#include "ui_radio.h"
#include "lcd_ui.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
struct radio_ui radio_vhf1 = {
.name = "VHF1",
.upper = 0,
.left = 0,
.standby_freq = "122.800",
.active_freq = "123.450",
.volume = 75,
}, radio_vhf2 = {
.name = "VHF2",
.upper = 0,
.left = 121,
.standby_freq = "122.800",
.active_freq = "123.450",
.volume = 75,
}, radio_ils1 = {
.name = "ILS1",
.upper = 81,
.left = 0,
.standby_freq = "122.800",
.active_freq = "123.450",
.volume = 75,
}, radio_ils2 = {
.name = "ILS2",
.upper = 81,
.left = 121,
.standby_freq = "122.800",
.active_freq = "123.450",
.volume = 75,
} ;
static void radio_draw_standby_freq(struct radio_ui *const radio)
{
lcd_ui_text(radio->upper + 57, radio->left + 40, radio->upper + 69, radio->left + 106,
TEAL, radio->selected, radio->standby_freq);
}
static void radio_draw_active_freq(struct radio_ui *const radio)
{
lcd_ui_text(radio->upper + 10, radio->left + 40, radio->upper + 22, radio->left + 106,
GREEN, false, radio->active_freq);
}
void radio_draw_radio(struct radio_ui *const radio)
{
lcd_ui_text_vert(radio->upper + 10, radio->left + 10, radio->upper + 57, radio->left + 17,
WHITE, false, radio->name);
radio_draw_active_freq(radio);
radio_draw_standby_freq(radio);
lcd_ui_bar_vert(radio->upper + 10, radio->left + 20, radio->upper + 69, radio->left + 30,
radio->active ? GREEN : WHITE, radio->volume);
}
void radio_set_standby_freq(struct radio_ui *const radio, unsigned freq)
{
sprintf(radio->standby_freq, "%03u.%03u", freq / 1000, freq % 1000);
radio_draw_standby_freq(radio);
}
void radio_select_input(struct radio_ui *const radio, bool active)
{
radio->selected = active;
radio_draw_standby_freq(radio);
}
void radio_swap_freqs(struct radio_ui *const radio)
{
char buf[8];
memcpy(buf, radio->standby_freq, sizeof(buf));
memcpy(radio->standby_freq, radio->active_freq, sizeof(radio->standby_freq));
memcpy(radio->active_freq, buf, sizeof(radio->active_freq));
radio_draw_standby_freq(radio);
radio_draw_active_freq(radio);
}
void radio_draw_all(void)
{
lcd_ui_box(0, 119, 319, 120, WHITE);
lcd_ui_box(79, 0, 80, 239, WHITE);
lcd_ui_box(159, 0, 160, 239, WHITE);
lcd_ui_box(239, 0, 240, 239, WHITE);
radio_draw_radio(&radio_vhf1);
radio_draw_radio(&radio_vhf2);
radio_draw_radio(&radio_ils1);
radio_draw_radio(&radio_ils2);
}

21
src/ui_radio.h Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
struct radio_ui {
const char* name;
uint16_t upper;
uint8_t left;
char standby_freq[8], active_freq[8];
bool selected, active;
uint8_t volume;
};
extern struct radio_ui radio_vhf1, radio_vhf2, radio_ils1, radio_ils2;
void radio_draw_all(void);
void radio_draw(struct radio_ui *const radio);
void radio_set_standby_freq(struct radio_ui *const radio, unsigned freq);
void radio_select_input(struct radio_ui *const radio, bool active);
void radio_swap_freqs(struct radio_ui *const radio);