Skip to content

Commit

Permalink
add board id to lcd, other misc minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
NotQuiteApex committed Oct 10, 2024
1 parent 8bb120e commit d4cadcc
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 49 deletions.
35 changes: 17 additions & 18 deletions firmware/src/lcd.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "lcd.h"

#include <pico/rand.h>
#include <pico/unique_id.h>

// #include <stdarg.h>
#include <string.h>
Expand Down Expand Up @@ -60,11 +61,13 @@ void lcd_print(char * text, uint16_t x, uint16_t y, uint8_t s) {
}

void lcd_print_raw(char * text, uint16_t x, uint16_t y, uint8_t s) {
// TODO: use `s` for scaling text
uint32_t len = strlen(text);
lcd_print_raw2(text, len, x, y, s);
}

void lcd_print_raw2(char * text, uint32_t len, uint16_t x, uint16_t y, uint8_t s) {
uint16_t sx = x, sy = y;

uint16_t len = strlen(text);
for (uint16_t i=0; i<len; i++) {
char t = text[i];
for (uint8_t r=0; r<font_height; r++) {
Expand All @@ -88,23 +91,15 @@ void lcd_print_raw(char * text, uint16_t x, uint16_t y, uint8_t s) {
}
}

// TODO: make an sprintf like function.
// void sfmt(char * buf, char * fmt, ...) {
// va_list args;
// va_start(args, fmt);

// while (*fmt != '\0') {

// }

// va_end(args);
// }
char serial_id[2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1];

inline void lcd_init(void) {
st7789_lcd_init();

previousstate = Unknown;
screenstate = WaitingConnection;

pico_get_unique_board_id_string(serial_id, sizeof(serial_id));
}

void lcd_task(void) {
Expand Down Expand Up @@ -139,14 +134,18 @@ void lcd_task(void) {
uint8_t r1 = (spinner + 1) % 8;
uint8_t r2 = (spinner + 2) % 8;
uint8_t r3 = (spinner + 3) % 8;
lcd_set_color(0, 21, 85); lcd_rect(rects[r1][0] - spinner_mid + st7789_get_height() / 2, rects[r1][1] - spinner_mid + st7789_get_width() / 2 + 80, rect_size, rect_size);
lcd_set_color(0, 42, 170); lcd_rect(rects[r2][0] - spinner_mid + st7789_get_height() / 2, rects[r2][1] - spinner_mid + st7789_get_width() / 2 + 80, rect_size, rect_size);
lcd_set_color(0, 64, 255); lcd_rect(rects[r3][0] - spinner_mid + st7789_get_height() / 2, rects[r3][1] - spinner_mid + st7789_get_width() / 2 + 80, rect_size, rect_size);
lcd_set_color(0, 21, 85); lcd_rect(rects[r1][0] - spinner_mid + st7789_get_height() / 2, rects[r1][1] - spinner_mid + st7789_get_width() / 2 + 55, rect_size, rect_size);
lcd_set_color(0, 42, 170); lcd_rect(rects[r2][0] - spinner_mid + st7789_get_height() / 2, rects[r2][1] - spinner_mid + st7789_get_width() / 2 + 55, rect_size, rect_size);
lcd_set_color(0, 64, 255); lcd_rect(rects[r3][0] - spinner_mid + st7789_get_height() / 2, rects[r3][1] - spinner_mid + st7789_get_width() / 2 + 55, rect_size, rect_size);
spinner = (spinner + 1) % 8;

lcd_set_color(255, 255, 255);
lcd_print_raw("JukeBoxStats", (320-12*12*2)/2, 120, 2);
lcd_print_raw("Waiting for connection...", (320-25*12)/2, 144, 1);
lcd_print_raw("JukeBoxStats", (320-8*12*2)/2, 100-12, 2);
lcd_print_raw("Waiting for connection...", (320-25*8)/2, 124-12, 1);

lcd_print_raw("v1.0", 2, 240-16, 1);
lcd_print_raw2(serial_id+0, 8, 320-8*8-4, 240-32, 1);
lcd_print_raw2(serial_id+8, 8, 320-8*8-4, 240-16, 1);
} else if (screenstate == ShowStats) {
lcd_set_color( 0, 132, 255); lcd_rect(0, st7789_get_height()-50, st7789_get_width(), 20);
lcd_set_color(77, 224, 255); lcd_rect(0, st7789_get_height()-30, st7789_get_width(), 10);
Expand Down
21 changes: 10 additions & 11 deletions hardware-case/case.scad
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ ioHO = cS-cmO-2.5;
// Case connector hole buffer
ioHB = 0.125;

/* [Case top settings] */
// Case top height
ctH = 8;
// Case top wall size
ctW = 2.5;
// Case top mounting plate size
ctM = 9;
// Case top mounting plate height
ctMH = 4;

/* [Case bottom settings] */
// Case bottom lip height
clH = 3;
Expand All @@ -52,18 +62,7 @@ cpFD = 10;
// Case bottom rubber feet spot depth
cpFH = 2;

/* [Case top settings] */
// Case top height
ctH = 8;
// Case top wall size
ctW = 2.5;
// Case top mounting plate size
ctM = 9;
// Case top mounting plate height
ctMH = 4;

/* [Logo settings] */
// TODO
// Logo size scale
logoS = 0.035;
// Logo position (X)
Expand Down
68 changes: 49 additions & 19 deletions hardware-pcb/JukeBox.kicad_sch
Original file line number Diff line number Diff line change
Expand Up @@ -5106,6 +5106,16 @@
)
(uuid "03b17984-8f26-4b33-abb3-33d4ff48cbc0")
)
(wire
(pts
(xy 71.12 33.02) (xy 71.12 34.29)
)
(stroke
(width 0)
(type default)
)
(uuid "03dd504d-3cd7-4a3d-89e9-f1d7dd6f8307")
)
(wire
(pts
(xy 91.44 246.38) (xy 106.68 246.38)
Expand Down Expand Up @@ -6416,6 +6426,16 @@
)
(uuid "8195c09d-04dd-41aa-a31f-e50886856b17")
)
(wire
(pts
(xy 99.06 82.55) (xy 99.06 81.28)
)
(stroke
(width 0)
(type default)
)
(uuid "830557f0-bc4c-484d-81e7-9b7ce517aa7d")
)
(wire
(pts
(xy 166.37 118.11) (xy 168.91 118.11)
Expand Down Expand Up @@ -7456,6 +7476,16 @@
)
(uuid "f6acaf40-4713-4478-9c6c-ca7f7d26975d")
)
(wire
(pts
(xy 72.39 54.61) (xy 71.12 54.61)
)
(stroke
(width 0)
(type default)
)
(uuid "fc472ac7-c7fe-47d8-92b5-ffced4140e06")
)
(wire
(pts
(xy 203.2 264.16) (xy 196.85 264.16)
Expand Down Expand Up @@ -9191,15 +9221,15 @@
)
(symbol
(lib_id "power:GND")
(at 99.06 81.28 0)
(at 99.06 82.55 0)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(uuid "00000000-0000-0000-0000-00005ed9b1cb")
(property "Reference" "#PWR06"
(at 99.06 87.63 0)
(at 99.06 88.9 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -9208,15 +9238,15 @@
)
)
(property "Value" "GND"
(at 99.187 85.6742 0)
(at 99.187 86.9442 0)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Footprint" ""
(at 99.06 81.28 0)
(at 99.06 82.55 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -9225,7 +9255,7 @@
)
)
(property "Datasheet" ""
(at 99.06 81.28 0)
(at 99.06 82.55 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -9234,7 +9264,7 @@
)
)
(property "Description" ""
(at 99.06 81.28 0)
(at 99.06 82.55 0)
(effects
(font
(size 1.27 1.27)
Expand Down Expand Up @@ -15452,7 +15482,7 @@
)
)
)
(property "Value" "200"
(property "Value" "600"
(at 187.96 69.85 90)
(effects
(font
Expand Down Expand Up @@ -16330,15 +16360,15 @@
)
(symbol
(lib_id "power:VBUS")
(at 71.12 34.29 0)
(at 71.12 33.02 0)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(uuid "e1e8d10e-3e8d-48db-9b70-38476f59cd18")
(property "Reference" "#PWR0120"
(at 71.12 38.1 0)
(at 71.12 36.83 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -16347,15 +16377,15 @@
)
)
(property "Value" "VBUS"
(at 71.12 30.48 0)
(at 71.12 29.21 0)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Footprint" ""
(at 71.12 34.29 0)
(at 71.12 33.02 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -16364,7 +16394,7 @@
)
)
(property "Datasheet" ""
(at 71.12 34.29 0)
(at 71.12 33.02 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -16373,7 +16403,7 @@
)
)
(property "Description" ""
(at 71.12 34.29 0)
(at 71.12 33.02 0)
(effects
(font
(size 1.27 1.27)
Expand Down Expand Up @@ -16816,15 +16846,15 @@
)
(symbol
(lib_id "power:GND")
(at 71.12 54.61 90)
(at 72.39 54.61 90)
(unit 1)
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
(dnp no)
(uuid "eda7df96-2094-482a-82aa-ec6fc45ce959")
(property "Reference" "#PWR0109"
(at 77.47 54.61 0)
(at 78.74 54.61 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -16833,15 +16863,15 @@
)
)
(property "Value" "GND"
(at 76.2 54.61 90)
(at 77.47 54.61 90)
(effects
(font
(size 1.27 1.27)
)
)
)
(property "Footprint" ""
(at 71.12 54.61 0)
(at 72.39 54.61 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -16850,7 +16880,7 @@
)
)
(property "Datasheet" ""
(at 71.12 54.61 0)
(at 72.39 54.61 0)
(effects
(font
(size 1.27 1.27)
Expand All @@ -16859,7 +16889,7 @@
)
)
(property "Description" ""
(at 71.12 54.61 0)
(at 72.39 54.61 0)
(effects
(font
(size 1.27 1.27)
Expand Down
2 changes: 1 addition & 1 deletion hardware-pcb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Estimated power usage is 5 volts at 0.1 amps, or 0.5 watts.
| R3, R4 | RMCF0805JT27R0 | 2 | 27 | 0 |
| R6, R7 | RNCP0805FTD5K11 | 2 | 5.11k | 0 |
| R8-11 | RNCP0805FTD10K0 | 4 | 10k | 0 |
| R12 | RMCF0805JT200R | 1 | 200 | 0 |
| R12 | RMCF0805JT600R | 1 | 600 | 0 |
| R13 | RMCF0805JT10R0 | 1 | 10 | 2/3 |
| R14 | RMCF0805FT1K00 | 1 | 1k | 2/3 |
| R15 | RNCP0805FTD10K0 | 1 | 10k | 2/3 |
Expand Down

0 comments on commit d4cadcc

Please sign in to comment.