Skip to content

Commit dbf4780

Browse files
Merge pull request #6 from FrameworkComputer/minimal
2 parents bd5f119 + e0f6ed0 commit dbf4780

File tree

8 files changed

+1042
-2
lines changed

8 files changed

+1042
-2
lines changed

Cargo.lock

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ mipidsi = { version = "0.6.0", optional = true }
3636
embedded-graphics = { version = "0.7", optional = true }
3737
tinybmp = { version = "0.4.0", optional = true }
3838

39+
# C1 Minimal
40+
smart-leds = { version = "0.3.0", optional = true }
41+
ws2812-pio = { version = "0.5.0", optional = true }
42+
3943
[lib]
4044
name = "lotus_input"
4145
path = "src/lib.rs"
@@ -48,9 +52,14 @@ required-features = ["ledmatrix"]
4852
name = "b1display"
4953
required-features = ["b1display"]
5054

55+
[[bin]]
56+
name = "c1minimal"
57+
required-features = ["c1minimal"]
58+
5159
[features]
5260
ledmatrix = [ "is31fl3741" ]
5361
b1display = [ "display-interface-spi", "mipidsi", "embedded-graphics", "tinybmp" ]
62+
c1minimal = [ "smart-leds", "ws2812-pio" ]
5463

5564
# cargo build/run
5665
[profile.dev]

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lotus Input Module Firmware
22

3-
See below sections for LED Matrix and LCD Display module details.
3+
See below sections for LED Matrix, LCD Display and C1 Minimal module details.
44

55
Rust project setup based off of: https://github.com/rp-rs/rp2040-project-template
66

@@ -61,6 +61,9 @@ options:
6161
--wpm WPM Demo
6262
--snake Snake
6363
--all-brightnesses Show every pixel in a different brightness
64+
--set-color {white,black,red,green,blue,cyan,yellow,purple}
65+
Set RGB color (C1 Minimal Input Module)
66+
--get-color Get RGB color (C1 Minimal Input Module)
6467
-v, --version Get device version
6568
--serial-dev SERIAL_DEV
6669
Change the serial dev. Probably /dev/ttyACM0 on Linux, COM0 on Windows
@@ -100,13 +103,15 @@ Build:
100103
```sh
101104
cargo build --bin ledmatrix --features=ledmatrix
102105
cargo build --bin b1display --features=b1display
106+
cargo build --bin c1minimal --features=c1minimal
103107
```
104108

105109
Generate UF2 file:
106110

107111
```sh
108112
elf2uf2-rs target/thumbv6m-none-eabi/debug/ledmatrix ledmatrix.uf2
109113
elf2uf2-rs target/thumbv6m-none-eabi/debug/b1display b1dipslay.uf2
114+
elf2uf2-rs target/thumbv6m-none-eabi/debug/b1display c1minimal.uf2
110115
```
111116

112117
## Flashing
@@ -160,3 +165,22 @@ It's a 9x34 (306) LED matrix, controlled by RP2040 MCU and IS31FL3741A LED contr
160165
Connection to the host system is via USB 2.0 and currently there is a USB Serial API to control it without reflashing.
161166

162167
## B1 Display
168+
169+
## C1 Minimal Input Module
170+
171+
It's a very minimal input module. Many GPIO pins are exposed so that headers
172+
can be soldered onto them. Additionally there are pads for a WS2812/Neopixel
173+
compatible RGB LED.
174+
175+
When booting up this LED is lit in green color.
176+
Its color and brightness can be controlled via the commands:
177+
178+
```sh
179+
> ./control.py --brightness 255
180+
> ./control.py --get-brightness
181+
Current brightness: 255
182+
183+
> ./control.py --set-color yellow
184+
> ./control.py --get-color
185+
Current color: RGB:(255, 255, 0)
186+
```

control.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
ARG_2LEFT = 5
4141
ARG_2RIGHT = 6
4242

43+
RGB_COLORS = ['white', 'black', 'red', 'green',
44+
'blue', 'cyan', 'yellow', 'purple']
45+
4346
SERIAL_DEV = None
4447

4548
STOP_THREAD = False
@@ -94,6 +97,10 @@ def main():
9497
help="Pong on the module", action="store_true")
9598
parser.add_argument(
9699
"--all-brightnesses", help="Show every pixel in a different brightness", action="store_true")
100+
parser.add_argument(
101+
"--set-color", help="Set RGB color (C1 Minimal Input Module)", choices=RGB_COLORS)
102+
parser.add_argument(
103+
"--get-color", help="Get RGB color (C1 Minimal Input Module)", action="store_true")
97104
parser.add_argument("-v", "--version",
98105
help="Get device version", action="store_true")
99106
parser.add_argument("--serial-dev", help="Change the serial dev. Probably /dev/ttyACM0 on Linux, COM0 on Windows",
@@ -143,6 +150,11 @@ def main():
143150
image_greyscale(args.image_grey)
144151
elif args.all_brightnesses:
145152
all_brightnesses()
153+
elif args.set_color:
154+
set_color(args.set_color)
155+
elif args.get_color:
156+
(red, green, blue) = get_color()
157+
print(f"Current color: RGB:({red}, {green}, {blue})")
146158
elif args.gui:
147159
gui()
148160
elif args.blink:
@@ -309,6 +321,39 @@ def commit_cols(s):
309321
send_serial(s, command)
310322

311323

324+
def get_color():
325+
command = FWK_MAGIC + [0x13]
326+
res = send_command(command, with_response=True)
327+
return (int(res[0]), int(res[1]), int(res[2]))
328+
329+
330+
def set_color(color):
331+
rgb = None
332+
if color == 'white':
333+
rgb = [0xFF, 0xFF, 0xFF]
334+
elif color == 'black':
335+
rgb = [0x00, 0x00, 0x00]
336+
elif color == 'red':
337+
rgb = [0xFF, 0x00, 0x00]
338+
elif color == 'green':
339+
rgb = [0x00, 0xFF, 0x00]
340+
elif color == 'blue':
341+
rgb = [0x00, 0x00, 0xFF]
342+
elif color == 'yellow':
343+
rgb = [0xFF, 0xFF, 0x00]
344+
elif color == 'cyan':
345+
rgb = [0x00, 0xFF, 0xFF]
346+
elif color == 'purple':
347+
rgb = [0xFF, 0x00, 0xFF]
348+
else:
349+
print(f"Unknown color: {color}")
350+
return
351+
352+
if rgb:
353+
command = FWK_MAGIC + [0x13] + rgb
354+
send_command(command)
355+
356+
312357
def all_brightnesses():
313358
"""Increase the brightness with each pixel.
314359
Only 0-255 available, so it can't fill all 306 LEDs"""

0 commit comments

Comments
 (0)