-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_ledmatrix.py
68 lines (55 loc) · 2.01 KB
/
test_ledmatrix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import unittest
from edg import *
class LedMatrix(JlcBoardTop):
"""A USB-connected WiFi-enabled LED matrix that demonstrates a charlieplexing LED matrix generator.
"""
def contents(self) -> None:
super().contents()
self.usb = self.Block(UsbCReceptacle())
self.vusb = self.connect(self.usb.pwr)
self.gnd = self.connect(self.usb.gnd)
self.tp_vusb = self.Block(VoltageTestPoint()).connected(self.usb.pwr)
self.tp_gnd = self.Block(GroundTestPoint()).connected(self.usb.gnd)
# POWER
with self.implicit_connect(
ImplicitConnect(self.gnd, [Common]),
) as imp:
(self.reg_3v3, self.tp_3v3, self.prot_3v3), _ = self.chain(
self.vusb,
imp.Block(LinearRegulator(output_voltage=3.3*Volt(tol=0.05))),
self.Block(VoltageTestPoint()),
imp.Block(ProtectionZenerDiode(voltage=(3.45, 3.9)*Volt))
)
self.v3v3 = self.connect(self.reg_3v3.pwr_out)
# 3V3 DOMAIN
with self.implicit_connect(
ImplicitConnect(self.v3v3, [Power]),
ImplicitConnect(self.gnd, [Common]),
) as imp:
self.mcu = imp.Block(IoController())
(self.sw1, ), _ = self.chain(imp.Block(DigitalSwitch()), self.mcu.gpio.request('sw1'))
# maximum current draw that is still within the column sink capability of the ESP32
self.matrix = imp.Block(CharlieplexedLedMatrix(6, 5, current_draw=(3.5, 5)*mAmp, color=Led.Yellow))
self.connect(self.mcu.gpio.request_vector('led'), self.matrix.ios)
def refinements(self) -> Refinements:
return super().refinements() + Refinements(
instance_refinements=[
(['mcu'], Esp32c3_Wroom02),
(['reg_3v3'], Ldl1117),
],
instance_values=[
(['mcu', 'pin_assigns'], [
'led_0=3',
'led_1=4',
'led_2=5',
'led_3=6',
'led_4=17',
'led_5=15',
'led_6=10',
'sw1=18',
]),
],
)
class LedMatrixTestCase(unittest.TestCase):
def test_design(self) -> None:
compile_board_inplace(LedMatrix)