-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwm.py
22 lines (15 loc) · 1.66 KB
/
pwm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
levels = [
1, 2, 7, 17, 35, 65, 111, 39, 135, 198, 206, 170, 3, 4, 14, 18, 5, 28, 34, 41, 11, 22, 26, 83, 97, 113, 131, 151, 38, 197, 82, 253, 142, 160, 179, 88, 163, 181, 200, 221, 146, 160, 176, 192, 210, 229, 249, 13, 14, 15, 17, 18, 7, 21, 5, 24, 26, 28, 30, 7, 34, 36, 14, 15, 16, 46, 49, 19, 55, 58, 62, 65, 69, 16, 28, 80, 31, 89, 94, 36, 23, 24, 25, 26, 28, 29, 30, 32, 33, 35, 36, 38, 39, 41, 43, 45, 46, 48, 50, 52, 55, 57, 59, 61, 64, 66, 69, 71, 74, 76, 79, 82, 85, 88, 91, 94, 98, 101, 104, 108, 112, 115, 119, 123, 127, 131, 135, 139, 144, 148, 153, 158, 162, 167, 172, 177, 183, 188, 194, 199, 205, 211, 217, 223, 229, 235, 242, 248, 255, 0
]
V05 = 0.5
V11 = 1.1
V15 = 1.5
V25 = 2.5
volts = [
V05, V05, V05, V05, V05, V05, V05, V25, V11, V11, V15, V25, V15, V15, V05, V05, V25, V05, V05, V05, V25, V15, V15, V05, V05, V05, V05, V05, V25, V05, V15, V05, V11, V11, V11, V25, V15, V15, V15, V15, V25, V25, V25, V25, V25, V25, V25, V05, V05, V05, V05, V05, V15, V05, V25, V05, V05, V05, V05, V25, V05, V05, V15, V15, V15, V05, V05, V15, V05, V05, V05, V05, V05, V25, V15, V05, V15, V05, V05, V15, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25, V25
]
adc_out = [(l / 255) * v for l, v in zip(levels, volts)]
for i, (a, b) in enumerate(zip(adc_out, adc_out[1:])):
if b < a:
print(f"Step up: {a:.2} -> {b:.2} [{i}] {a / (b + 0.0000001)}")
print([f"{v:.2}" for v in adc_out])