diff --git a/preload/apps/scope/__init__.py b/preload/apps/scope/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b541d2c283383d821638c01055a218304e1247de --- /dev/null +++ b/preload/apps/scope/__init__.py @@ -0,0 +1,35 @@ +import os +import display +import utime +import buttons +import light_sensor +import math + +WIDTH=160 +HEIGHT=80 + +disp = display.open() + +light_sensor.start() + +history = [] + +while True: + disp.clear() + + value = light_sensor.get_reading() + + history.insert(0, value) + if len(history) > WIDTH: + history.pop() + + disp.print("%i"%value) + + for i in range(0,len(history)): + # Rescale to range 0 <= value < HEIGHT-1 + y = math.floor(history[i]*(HEIGHT-2)/max(history)) + + disp.pixel(WIDTH-i, HEIGHT-y-1) + + disp.update() + utime.sleep(0.1) \ No newline at end of file diff --git a/preload/apps/scope/metadata.json b/preload/apps/scope/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..821fd3bfdfea26d744974f53f00b02f0b283158f --- /dev/null +++ b/preload/apps/scope/metadata.json @@ -0,0 +1 @@ +{"name":"Scope","description":"A very simple egg that reads the light sensor and displays its raw value and a scope. Will be extended to other ADC channels once we have the firmware ready.","category":"hardware","author":"koalo","revision":1} \ No newline at end of file