1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00
This commit is contained in:
slush0 2016-04-28 17:18:33 +02:00 committed by Pavol Rusnak
parent 07abef7ff4
commit 767a41cffd
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 26 additions and 36 deletions

12
src/lib/const_delay.py Normal file
View File

@ -0,0 +1,12 @@
from trezor.loop import Sleep
import utime
class ConstDelay:
def __init__(self, delay):
self.delay = delay
self.last_run = utime.ticks_us()
def wait(self):
delay = 2 * self.delay - (utime.ticks_us() - self.last_run)
self.last_run = utime.ticks_us()
return Sleep(delay)

View File

@ -1,9 +1,2 @@
from trezor import ui
import utime
ui.touch.start(lambda x, y: print('touch start %d %d\n' % (x, y)))
ui.touch.move(lambda x, y: print('touch move %d %d\n' % (x, y)))
ui.touch.end(lambda x, y: print('touch end %d %d\n' % (x, y)))
import playground
playground.run()

View File

@ -12,11 +12,11 @@ import gc
# import transport_pipe as pipe
from trezor import ui
from trezor import msg
# from trezor import msg
from trezor import loop
from trezor.utils import unimport_gen, unimport_func
from trezor import layout
from trezor import ui
if __debug__:
import logging
@ -91,7 +91,7 @@ def tap_to_confirm(address, amount, currency):
f.seek(0)
ui.display.icon(3, 170, f.read(), _background, foreground)
yield from animate_pulse(func, DELAY=10000)
yield from ui.animate_pulse(func) # , DELAY=10000)
'''
def on_read():
@ -118,28 +118,6 @@ def zprava():
# m2 = GetAddress.load(BytesIO(data))
# print(m2.__dict__)
@unimport_gen
def animate_pulse(func, STEP_X=0.05, DELAY=30000, BASE_COLOR=(0x00, 0x00, 0x00), MIN_COLOR=0x00, MAX_COLOR=0x80):
x = math.pi / 3
from const_delay import ConstDelay
delay = ConstDelay(DELAY)
while True:
# print(x)
x += STEP_X
if x > 2 * math.pi:
x -= 2 * math.pi
y = 1 + math.sin(x)
# Normalize color from interval 0:2 to MIN_COLOR:MAX_COLOR
col = int((MAX_COLOR - MIN_COLOR) / 2 * y) + MIN_COLOR
foreground = ui.rgbcolor(BASE_COLOR[0] + col, BASE_COLOR[1] + col, BASE_COLOR[2] + col)
func(foreground)
yield delay.wait()
def homescreen():
print("Homescreen layout!")
@ -153,9 +131,13 @@ def homescreen():
f.seek(0)
ui.display.icon(0, 0, f.read(), foreground, ui.BLACK)
yield from animate_pulse(func, STEP_X=0.035, BASE_COLOR=(0xff, 0xff, 0xff), MIN_COLOR=0xaa, MAX_COLOR=0xff)
yield from ui.animate_pulse(func, SPEED=400000, BASE_COLOR=(0xff, 0xff, 0xff), MIN_COLOR=0xaa, MAX_COLOR=0xff)
def run():
ui.touch.start(lambda x, y: print('touch start %d %d\n' % (x, y)))
ui.touch.move(lambda x, y: print('touch move %d %d\n' % (x, y)))
ui.touch.end(lambda x, y: print('touch end %d %d\n' % (x, y)))
# pipe.init('../pipe', on_read)
# msg.set_notify(on_read)

View File

@ -21,8 +21,11 @@ def set_main(main_layout):
_current_layout = yield from _current_layout
except Exception as e:
sys.print_exception(e)
_current_layout = main_layout
continue
sys.exit()
# if _current_layout == main_layout:
# # Main layout thrown exception, what to do?
# _current_layout = main_layout
# continue
if _new_layout != None:
print("Switching to new layout %s" % _new_layout)

View File

@ -5,7 +5,7 @@ from .utils import type_gen
if __debug__:
import logging
log = logging.getLogger("asyncio")
log = logging.getLogger("trezor.loop")
q = []
cnt = 0