You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-5Lines changed: 39 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -331,16 +331,21 @@ will show you all the i/o ports you can play with.
331
331
332
332
## Initialization
333
333
334
-
When the DemoBoard object is created, you _may_ give it a parameter to indicate how you intend to use it.
335
334
336
-
If not specifed, the value in [config.ini](src/config.ini) DEFAULT section `mode` will be used.
335
+
Since only _one_ demoboard exists, in general it's safer and more efficient to use an accessor method to get ahold of the singleton:
337
336
337
+
```
338
+
tt = DemoBoard.get()
339
+
```
340
+
341
+
The first time this is used, the instance is created, using the `mode` setting in the DEFAULT section of [config.ini](src/config.ini) to define how it's being used (i.e. the RP2 driving the inputs or using external means).
338
342
343
+
When the DemoBoard object is created, you _may_ give it a parameter to indicate how you intend to use it, rather than rely on config.ini.
339
344
Possible values are:
340
345
341
346
```
342
347
# use ini value
343
-
tt = DemoBoard() # whatever was in DEFAULT.mode of config.ini
348
+
tt = DemoBoard.get() # whatever was in DEFAULT.mode of config.ini
# ASIC drives only management pins all else are inputs
358
363
tt = DemoBoard(RPMode.ASIC_MANUAL_INPUTS)
359
364
360
-
361
-
362
365
```
363
366
367
+
and from that point on, you can use the `DemoBoard.get()` to access that object.
368
+
364
369
If you've played with the pin mode (direction), you've loaded a project that modified the mode or you just want to change modes, you can set the attribute
365
370
366
371
```
@@ -369,6 +374,35 @@ If you've played with the pin mode (direction), you've loaded a project that mod
369
374
tt.mode = RPMode.ASIC_RP_CONTROL
370
375
```
371
376
377
+
378
+
### Write Your Own Script
379
+
380
+
The default `main.py` does basic setup, reads the config.ini, loads the default project etc.
381
+
382
+
If you want to have some particular code run on boot, you can write your own script. There's a little bit of required boilerplate to get this working, as the SDK needs to figure out which board it's running on and which carrier/chip is present.
383
+
384
+
A full example that you can use for this is in [custom script main.py](./examples/custom_script_main.py), and you might want to start there.
385
+
386
+
There are some useful hints in there, related to memory, logging and more, but the short of it is that what you really need is:
387
+
388
+
```
389
+
# to load the detector and demoboard modules
390
+
391
+
from ttboard.boot.demoboard_detect import DemoboardDetect
392
+
from ttboard.demoboard import DemoBoard
393
+
394
+
# to first probe the board/breakout
395
+
DemoboardDetect.probe()
396
+
397
+
# and then get a handle to the DemoBoard object
398
+
tt = DemoBoard.get()
399
+
400
+
# pretty much it
401
+
```
402
+
403
+
See the [custom script main.py](./examples/custom_script_main.py) for all the details.
404
+
405
+
372
406
### Automatic Load and Default Config
373
407
374
408
The [config.ini](src/config.ini) file has a **DEFAULT** section that may be used to specify the demo board mode, default project to enable and other things.
0 commit comments