Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
lehrkraefte:blc:informatik:glf20:ivobuttons [2020/12/03 13:09] Ivo Blöchliger |
lehrkraefte:blc:informatik:glf20:ivobuttons [2020/12/07 11:03] Ivo Blöchliger [Beispiele] |
||
---|---|---|---|
Line 3: | Line 3: | ||
Die Bibliothek ist sehr minimalistisch, | Die Bibliothek ist sehr minimalistisch, | ||
+ | ==== Interface ==== | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * Zeichnungsroutinen: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | <WRAP info 40%> | ||
+ | **Anordnung und Werte der Knöpfe** | ||
+ | |IVO_L1=1| | ||
+ | |IVO_L2=2|IVO_L3=4| | ||
+ | </ | ||
===== Verwendung im TigerJython Simulator ===== | ===== Verwendung im TigerJython Simulator ===== | ||
Dazu muss folgende Datei **im gleichen** Ordner gespeichert werden wie Ihre Programmdatei: | Dazu muss folgende Datei **im gleichen** Ordner gespeichert werden wie Ihre Programmdatei: | ||
Line 19: | Line 35: | ||
</ | </ | ||
+ | |||
+ | ===== Beispiele ===== | ||
+ | <hidden Demo 24 neue Pixel pro Frame, läuft mit 30 fps> | ||
+ | <code python ivosdemo.py> | ||
+ | from oxocard import * | ||
+ | from ivobuttons import * | ||
+ | |||
+ | def hsv2rgb(h, | ||
+ | c = v*s | ||
+ | x = c*(1-abs(h*6 % 2 -1)) | ||
+ | m = c-v | ||
+ | rgb = (0,0,0) | ||
+ | if (h<1/6): | ||
+ | rgb = (c,x,0) | ||
+ | elif h<2/6: | ||
+ | rgb = (x,c,0) | ||
+ | elif h<3/6: | ||
+ | rgb = (0,c,x) | ||
+ | elif h<4/6: | ||
+ | rgb = (0,x,c) | ||
+ | elif h<5/6: | ||
+ | rgb = (x,0,c) | ||
+ | else: | ||
+ | rgb = (c,0,x) | ||
+ | rgb = ((int((rgb[0]+m)*255)), | ||
+ | return rgb | ||
+ | |||
+ | clear(BLACK) | ||
+ | |||
+ | dirs = ((0, | ||
+ | x = 0 | ||
+ | y = 0 | ||
+ | d = 0 | ||
+ | h = 0.0 | ||
+ | |||
+ | a = 0 | ||
+ | b = 0 | ||
+ | dd = 0 | ||
+ | ivobuttons.delay=0 | ||
+ | fps = getms() | ||
+ | while True: | ||
+ | for i in range(24): | ||
+ | fastDot(x, | ||
+ | x+=dirs[d][0] | ||
+ | y+=dirs[d][1] | ||
+ | if (x>7 or x<0 or y>7 or y<0): | ||
+ | x-=dirs[d][0] | ||
+ | y-=dirs[d][1] | ||
+ | d=(d+1)%4 | ||
+ | x+=dirs[d][0] | ||
+ | y+=dirs[d][1] | ||
+ | if (i==0): | ||
+ | a = x | ||
+ | b = y | ||
+ | dd = d | ||
+ | fastRepaint() | ||
+ | s = ivobuttons.states() | ||
+ | if (s & IVO_R2): | ||
+ | sleep(0.05) | ||
+ | if (s & IVO_R3): | ||
+ | sleep(0.15) | ||
+ | h = (h+0.005)%1 | ||
+ | x = a | ||
+ | y = b | ||
+ | d = dd | ||
+ | fps2 = getms() | ||
+ | print(" | ||
+ | fps = fps2 | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <hidden 64 neue Pixel pro Bild> | ||
+ | <code python scrolling.py> | ||
+ | from oxocard import * | ||
+ | from ivobuttons import * | ||
+ | |||
+ | for n in range(121): | ||
+ | for y in range(8): | ||
+ | for x in range(8): | ||
+ | if x > y: | ||
+ | fastDot((x+n)%8, | ||
+ | else: | ||
+ | fastDot((x+n)%8, | ||
+ | fastRepaint() | ||
+ | |||
+ | </ | ||
+ | </ |