Skip to content

Commit d24cddb

Browse files
committed
Adding some example SDK interaction with projects
1 parent c99ac3e commit d24cddb

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

src/config.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ mode = ASIC_RP_CONTROL
2929
# - INFO
3030
# - WARN
3131
# - ERROR
32-
log_level = WARN
32+
log_level = INFO
3333

34+
35+
# default RP2040 system clock
3436
rp_clock_frequency = 125e6
3537

3638
#### PROJECT OVERRIDES ####

src/examples/__init__.py

Whitespace-only changes.

src/examples/neptune.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'''
2+
Created on Apr 28, 2024
3+
4+
@author: Pat Deegan
5+
@copyright: Copyright (C) 2024 Pat Deegan, https://psychogenic.com
6+
'''
7+
8+
from ttboard.demoboard import DemoBoard
9+
from ttboard.mode import RPMode
10+
from ttboard.pins.pins import Pins
11+
12+
import ttboard.logging as logging
13+
log = logging.getLogger(__name__)
14+
15+
import ttboard.util.time as time
16+
17+
18+
def die_on_error(msg:str):
19+
log.error(msg)
20+
return False
21+
22+
def run(tt:DemoBoard, loops:int=2, note_delay_ms:int=2000):
23+
24+
if not tt.shuttle.has('tt_um_psychogenic_neptuneproportional'):
25+
return die_on_error("This chip doesn't got neptune on-board!")
26+
27+
if tt.user_config.has_section('tt_um_psychogenic_neptuneproportional'):
28+
log.info('Found a neptune section in config--letting it handle things')
29+
else:
30+
log.info('No neptune section in config--doing it manual style')
31+
tt.mode = RPMode.ASIC_RP_CONTROL
32+
tt.reset_project(True) # hold in reset, in case something else is loaded
33+
# input byte
34+
# clock speed is lower bits, input comes on in5
35+
# display mode single/control are bits 6 and 7
36+
tt.input_byte = 0b11001000
37+
tt.clock_project_PWM(4000)
38+
tt.bidir_mode = [Pins.IN]*8
39+
40+
tt.shuttle.tt_um_psychogenic_neptuneproportional.enable()
41+
tt.reset_project(False) # start her up
42+
43+
notes = [
44+
('E2', 83),
45+
('A2', 110),
46+
('D3', 146),
47+
('E3', 83*2),
48+
('G3', 196),
49+
('A3', 220),
50+
('B3', 247),
51+
('D4', 146*2),
52+
('E4', 330),
53+
('G4', 196*2),
54+
]
55+
56+
pwm = tt.in5.pwm(10)
57+
for _i in range(loops):
58+
for n in notes:
59+
pwm.freq(n[1])
60+
print(f'"Playing" a note: {n[0]} ({n[1]}Hz)')
61+
for _j in range(3):
62+
time.sleep_ms(int(note_delay_ms/3))
63+
reported_count = tt.bidir_byte
64+
ratio = n[1]/reported_count
65+
print(f' Bidir count: {reported_count} (ratio {ratio:.1f}), Outputs {hex(tt.output_byte)}')
66+
67+
68+
69+
pwm.deinit() # shut that down
70+
tt.in5(0) # bring low
71+
72+

src/ttboard/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
@author: Pat Deegan
77
@copyright: Copyright (C) 2024 Pat Deegan, https://psychogenic.com
88
'''
9-
VERSION='0.9.11'
9+
VERSION='0.9.15'

0 commit comments

Comments
 (0)