1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
radex b8aa12aac5
firmware: faster 2024-04-15 00:46:50 +02:00
radex 69c6ab51aa
firmware: improvements 2024-04-15 00:29:16 +02:00
radex b54dcc93c3
firmware: make it work on the 40x40px screen 2024-04-14 22:26:15 +02:00
radex e352544e82
pcb: main board - contd 2024-04-14 22:26:03 +02:00
5 changed files with 4465 additions and 6143 deletions

View File

@ -2,39 +2,40 @@
#include "gfx_png.h"
#include "lodepng.h"
#include "pico/multicore.h"
#include "hardware/gpio.h"
#include "mbed_wait_api.h"
#define Serial Serial1
#define COL_SER 2
#define COL_OE 26
#define COL_RCLK 27
#define COL_SRCLK 28
#define COL_SRCLR 29
#define COL_SER 20
#define COL_OE 21
#define COL_RCLK 22
#define COL_SRCLK 26
#define COL_SRCLR 27
#define ROW_SER 8
#define ROW_OE 7
#define ROW_RCLK 6
#define ROW_SRCLK 5
#define ROW_SRCLR 4
#define ROW_SER 14
#define ROW_OE 13
#define ROW_RCLK 12
#define ROW_SRCLK 11
#define ROW_SRCLR 10
inline void pulsePin(uint8_t pin) {
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);
gpio_put(pin, HIGH);
gpio_put(pin, LOW);
}
void clearShiftReg(uint8_t srclk, uint8_t srclr) {
digitalWrite(srclr, LOW);
gpio_put(srclr, LOW);
pulsePin(srclk);
digitalWrite(srclr, HIGH);
gpio_put(srclr, HIGH);
}
inline void outputEnable(uint8_t pin, bool enable) {
digitalWrite(pin, !enable);
gpio_put(pin, !enable);
}
#define ROW_COUNT 20 //24
#define COL_COUNT 20 //21
#define ROW_COUNT 40
#define COL_COUNT 40
#define FPS 30
#define MS_PER_FRAME 1000 / FPS
@ -46,7 +47,7 @@ unsigned long frameLastChangedAt;
// we have 4-bit color depth, so 16 levels of brightness
// we go from phase 0 to phase 3
uint8_t brightnessPhase = 0;
uint8_t brightnessPhaseDelays[] = {2, 20, 60, 200};
uint8_t brightnessPhaseDelays[] = {1, 10, 30, 100};
uint8_t framebuffer[ROW_COUNT * COL_COUNT] = {0};
@ -57,6 +58,10 @@ void setup() {
memset(framebuffer, 0, sizeof(framebuffer));
// disable output
outputEnable(COL_OE, false);
outputEnable(ROW_OE, false);
// set up col pins
pinMode(COL_SER, OUTPUT);
pinMode(COL_OE, OUTPUT);
@ -72,20 +77,13 @@ void setup() {
pinMode(ROW_SRCLR, OUTPUT);
// clear output - cols
digitalWrite(COL_SER, LOW);
outputEnable(COL_OE, false);
clearShiftReg(COL_SRCLK, COL_SRCLR);
pulsePin(COL_RCLK);
outputEnable(COL_OE, true);
// clear output - rows
digitalWrite(ROW_SER, LOW);
outputEnable(ROW_OE, false);
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
outputEnable(ROW_OE, true);
pulsePin(ROW_RCLK);
// clear frames
frameIndex = 0;
@ -142,48 +140,66 @@ void loop() {
// hide output
outputEnable(ROW_OE, false);
// clear columns
clearShiftReg(COL_SRCLK, COL_SRCLR);
// clear rows
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
// start selecting columns
digitalWrite(COL_SER, HIGH);
// start selecting rows
digitalWrite(ROW_SER, HIGH);
for (int x = 0; x < COL_COUNT; x++) {
for (int yCount = 0; yCount < ROW_COUNT; yCount++) {
int y = ROW_COUNT - 1 - yCount;
// brigthness - pushing data takes 40us, so to maximize brightness (at high brightness phases)
// we want to keep the matrix on during update (except during latch). At low brightness phases,
// we want it off to actually be dim
bool brightPhase = brightnessPhase >= 2;
digitalWrite(ROW_OE, !brightPhase);
// digitalWrite(ROW_OE, !brightPhase);
// next column
pulsePin(COL_SRCLK);
// only one column
digitalWrite(COL_SER, LOW);
// we use 7/8 stages on shift registers for columns
if (x % 7 == 0) {
pulsePin(COL_SRCLK);
}
// next row
pulsePin(ROW_SRCLK);
// only one row
digitalWrite(ROW_SER, LOW);
// clear row
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
// set column with rows' data
for (int y = 0; y < ROW_COUNT; y++) {
// get value
uint8_t pxValue = framebuffer[y * COL_COUNT + x];
// apply brightness
bool gotLight = (pxValue >> (4 + brightnessPhase)) & 1;
digitalWrite(ROW_SER, gotLight);
// push value
// we use 7/8 stages on shift registers + 1 is unused
int moduleY = yCount % 20;
if (moduleY == 0) {
pulsePin(ROW_SRCLK);
}
// disable rows before latch
if (moduleY == 7 || moduleY == 14 || (moduleY == 0 && yCount != 0)) {
pulsePin(ROW_SRCLK);
}
// clear columns
clearShiftReg(COL_SRCLK, COL_SRCLR);
// set row data
for (int x = 0; x < COL_COUNT; x++) {
// get value
// NOTE: values are loaded right-left
uint8_t pxValue = framebuffer[y * ROW_COUNT + x];
// apply brightness
bool gotLight = (pxValue >> (4 + brightnessPhase)) & 1;
// set value (note: inverted logic)
gpio_put(COL_SER, !gotLight);
// push value
pulsePin(COL_SRCLK);
// we use 7/8 stages on shift registers + 1 is unused
int moduleX = x % 20;
if (moduleX == 0) {
pulsePin(COL_SRCLK);
}
if (moduleX == 6 || moduleX == 13 || moduleX == 19) {
pulsePin(COL_SRCLK);
}
}
// disable columns before latch
outputEnable(ROW_OE, false);
// latch columns and rows
pulsePin(COL_RCLK);
// latch rows and columns
pulsePin(ROW_RCLK);
// enable rows after latch
outputEnable(ROW_OE, brightPhase);
pulsePin(COL_RCLK);
// show for a certain period
outputEnable(ROW_OE, true);
@ -211,7 +227,7 @@ void loop2() {
free(buffer);
multicore_fifo_push_blocking(error);
return;
} else if (width != COL_COUNT || height != ROW_COUNT) {
} else if (width != ROW_COUNT || height != COL_COUNT) {
free(buffer);
multicore_fifo_push_blocking(21372137);
return;
@ -220,11 +236,7 @@ void loop2() {
// copy to framebuffer
// TODO: mutex? double buffer? or something...
// TODO: learn to use memcpy lmao
for (int y = ROW_COUNT - 1; y >= 0; y--) {
for (int x = 0; x < COL_COUNT; x++) {
framebuffer[y * COL_COUNT + x] = buffer[(ROW_COUNT - 1 - y) * COL_COUNT + x];
}
}
memcpy(framebuffer, buffer, ROW_COUNT * COL_COUNT);
free(buffer);

View File

@ -5,7 +5,7 @@
(uuid "358d64ad-a131-4f0e-8329-6cb0cf45b576")
(paper "A4")
(lib_symbols
(symbol "Connector_Audio:AudioJack3_Ground"
(symbol "Connector_Audio:AudioJack3"
(exclude_from_sim no)
(in_bom yes)
(on_board yes)
@ -17,7 +17,7 @@
)
)
)
(property "Value" "AudioJack3_Ground"
(property "Value" "AudioJack3"
(at 0 6.35 0)
(effects
(font
@ -43,7 +43,7 @@
(hide yes)
)
)
(property "Description" "Audio Jack, 3 Poles (Stereo / TRS), Grounded Sleeve"
(property "Description" "Audio Jack, 3 Poles (Stereo / TRS)"
(at 0 0 0)
(effects
(font
@ -70,10 +70,10 @@
(hide yes)
)
)
(symbol "AudioJack3_Ground_0_1"
(symbol "AudioJack3_0_1"
(rectangle
(start -5.08 -2.54)
(end -6.35 -5.08)
(start -5.08 -5.08)
(end -6.35 -2.54)
(stroke
(width 0.254)
(type default)
@ -130,25 +130,7 @@
)
)
)
(symbol "AudioJack3_Ground_1_1"
(pin passive line
(at 0 -7.62 90)
(length 2.54)
(name "~"
(effects
(font
(size 1.27 1.27)
)
)
)
(number "G"
(effects
(font
(size 1.27 1.27)
)
)
)
)
(symbol "AudioJack3_1_1"
(pin passive line
(at 5.08 0 180)
(length 2.54)
@ -583,12 +565,6 @@
(color 0 0 0 0)
(uuid "8ff6cac3-628c-45c8-a01f-989fdf656d70")
)
(junction
(at 130.81 52.07)
(diameter 0)
(color 0 0 0 0)
(uuid "a4eba287-cd6b-4d2a-b680-92839eb30a40")
)
(junction
(at 77.47 60.96)
(diameter 0)
@ -611,16 +587,6 @@
)
(uuid "08bcdb7e-d619-42bf-81ab-a452b382e7f5")
)
(wire
(pts
(xy 130.81 41.91) (xy 130.81 52.07)
)
(stroke
(width 0)
(type default)
)
(uuid "1fb7651a-10bf-4180-bd69-bf5ed4e788e9")
)
(wire
(pts
(xy 83.82 60.96) (xy 104.14 60.96)
@ -631,16 +597,6 @@
)
(uuid "2db310db-65d5-40af-b050-364be1568f9e")
)
(wire
(pts
(xy 140.97 41.91) (xy 130.81 41.91)
)
(stroke
(width 0)
(type default)
)
(uuid "309e60a1-c51c-4449-9a87-406bd4051207")
)
(wire
(pts
(xy 133.35 46.99) (xy 135.89 46.99)
@ -831,25 +787,6 @@
)
(uuid "e5922f6b-454e-4ae4-8eea-d9bb45efbb04")
)
(text_box "TODO: select footprint"
(exclude_from_sim no)
(at 134.62 34.29 0)
(size 30.48 3.81)
(stroke
(width -0.0001)
(type default)
)
(fill
(type none)
)
(effects
(font
(size 1.27 1.27)
)
(justify left top)
)
(uuid "50ecc89c-ce59-4bac-bbbc-b64990221378")
)
(text "Taken from \"Hardware design with RP2040\""
(exclude_from_sim no)
(at 89.916 30.48 0)
@ -972,7 +909,7 @@
)
)
(symbol
(lib_id "Connector_Audio:AudioJack3_Ground")
(lib_id "Connector_Audio:AudioJack3")
(at 140.97 49.53 180)
(unit 1)
(exclude_from_sim no)
@ -998,7 +935,7 @@
(justify right)
)
)
(property "Footprint" ""
(property "Footprint" "led-matrix:3.5mm-audio-jack"
(at 140.97 49.53 0)
(effects
(font
@ -1016,7 +953,7 @@
(hide yes)
)
)
(property "Description" "Audio Jack, 3 Poles (Stereo / TRS), Grounded Sleeve"
(property "Description" "Audio Jack, 3 Poles (Stereo / TRS)"
(at 140.97 49.53 0)
(effects
(font
@ -1028,9 +965,6 @@
(pin "R"
(uuid "78b63f25-550b-4b26-ba9f-5607e724a4a2")
)
(pin "G"
(uuid "b39ca047-7dcc-4205-967a-7e227d5f4d12")
)
(pin "S"
(uuid "2b15e620-abde-41d5-9936-7bc10bfa876b")
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
(footprint "3.5mm-audio-jack"
(version 20240108)
(generator "pcbnew")
(generator_version "8.0")
(layer "F.Cu")
(property "Reference" "REF**"
(at 0 -13 0)
(unlocked yes)
(layer "F.SilkS")
(uuid "b1fba4b8-9fa6-4744-baa9-0c6dd28ae830")
(effects
(font
(size 1 1)
(thickness 0.15)
)
)
)
(property "Value" "3.5mm-audio-jack"
(at 0 -11.5 0)
(unlocked yes)
(layer "F.Fab")
(uuid "a9f74b99-4aec-4719-ae28-cc73fbbfd5e8")
(effects
(font
(size 1 1)
(thickness 0.15)
)
)
)
(property "Footprint" ""
(at 0 -12.5 0)
(unlocked yes)
(layer "F.Fab")
(hide yes)
(uuid "e1566540-eea5-4fba-9390-e518098be26f")
(effects
(font
(size 1 1)
(thickness 0.15)
)
)
)
(property "Datasheet" ""
(at 0 -12.5 0)
(unlocked yes)
(layer "F.Fab")
(hide yes)
(uuid "5ad99417-0dbc-4927-934b-47a2a8c33710")
(effects
(font
(size 1 1)
(thickness 0.15)
)
)
)
(property "Description" ""
(at 0 -12.5 0)
(unlocked yes)
(layer "F.Fab")
(hide yes)
(uuid "8b934734-2578-4d0d-9643-1dc5b1921a5a")
(effects
(font
(size 1 1)
(thickness 0.15)
)
)
)
(attr through_hole)
(fp_rect
(start 3.25 -7.25)
(end -3.25 4.25)
(stroke
(width 0.12)
(type default)
)
(fill none)
(layer "F.SilkS")
(uuid "3cf81a18-bb35-42ae-95e1-e928d0fb6845")
)
(fp_rect
(start 4 -8)
(end -4 7.5)
(stroke
(width 0.05)
(type default)
)
(fill none)
(layer "F.CrtYd")
(uuid "675460d3-ddbc-49d9-8acd-77b67fcb16d2")
)
(fp_rect
(start 3 -7)
(end -3 7)
(stroke
(width 0.1)
(type default)
)
(fill none)
(layer "F.Fab")
(uuid "efd69446-f60c-4a37-a44c-8009403a692b")
)
(fp_text user "${REFERENCE}"
(at 0 -10 0)
(unlocked yes)
(layer "F.Fab")
(uuid "fbc31591-f486-480e-b815-c3394df95aea")
(effects
(font
(size 1 1)
(thickness 0.15)
)
)
)
(pad "R" thru_hole circle
(at -2.25 0)
(size 2.2 2.2)
(drill 1.3)
(layers "*.Cu" "*.Mask")
(remove_unused_layers no)
(uuid "94a70353-5764-470d-87b4-36b02bdd25b1")
)
(pad "S" thru_hole circle
(at 2.25 2)
(size 2.2 2.2)
(drill 1.3)
(layers "*.Cu" "*.Mask")
(remove_unused_layers no)
(uuid "e7e8afd9-bdbb-46cc-a270-561a77498412")
)
(pad "T" thru_hole circle
(at 2.25 -5)
(size 2.2 2.2)
(drill 1.3)
(layers "*.Cu" "*.Mask")
(remove_unused_layers no)
(uuid "a628b23c-0e25-4a20-b970-d48f4b101c91")
)
)