7
mirror of https://github.com/Hack-a-Day/Vectorscope.git synced 2025-02-16 08:48:00 +00:00
Vectorscope/demos/csvdemo.py
2023-11-03 23:12:02 -05:00

311 lines
2.8 KiB
Python

# simple Vectorscope "Slot"
import math
import time
from vectorscope import Vectorscope
from random_walk import RW
import vectoros
import keyboardcb
import keyleds
import asyncio
_abort=False
# put your CSV file here.
# It should have 256 samples
# While the theoretical limit is +/-32K, the center of the round display is around +/-10000
csv=[
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
-10000,
10000,
10000,
10000,
10000,
10000,
10000
]
async def kernel(v):
## Minimal example
global _abort
csvlen=len(csv)
if csvlen!=256:
print(f"Warning wrong csv size {csvlen}")
v.wave.packX(range(-2**15,2**15,2**8))
v.wave.packY(csv)
while _abort==False:
await asyncio.sleep_ms(100)
def do_abort(key):
global _abort
_abort=True
async def slot_main(v):
global _abort,_continue
# watch the keys (D to exit)
mykeys=keyboardcb.KeyboardCB({ keyleds.KEY_MENU: do_abort})
await kernel(v)