1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 01:18:28 +00:00

add hw button to msg.select, build 32-bit unix port by default

This commit is contained in:
Pavol Rusnak 2016-04-29 16:02:18 +02:00
parent 8c3ebf3956
commit 9856f96cf7
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 23 additions and 152 deletions

View File

@ -6,12 +6,15 @@ help: ## show this help
update: ## update git submodules update: ## update git submodules
git submodule update git submodule update
build: update build_stmhal build_unix ## build both stmhal and unix micropython ports build: build_stmhal build_unix ## build both stmhal and unix micropython ports
build_stmhal: ## build stmhal port build_stmhal: update ## build stmhal port
make -C vendor/micropython/stmhal make -C vendor/micropython/stmhal
build_unix: ## build unix port build_unix: update ## build unix port (32-bit)
make -C vendor/micropython/unix MICROPY_FORCE_32BIT=1
build_unix64: update ## build unix port (64-bit)
make -C vendor/micropython/unix make -C vendor/micropython/unix
run_unix: ## run unix port run_unix: ## run unix port
@ -41,8 +44,8 @@ gdb: ## start remote gdb session which connects to the openocd
load: ## load contents of src into mass storage of trezor load: ## load contents of src into mass storage of trezor
rm -rf /run/media/${USER}/PYBFLASH/* rm -rf /run/media/${USER}/PYBFLASH/*
cp -a src/apps /run/media/${USER}/PYBFLASH/
cp -a src/lib /run/media/${USER}/PYBFLASH/ cp -a src/lib /run/media/${USER}/PYBFLASH/
cp -a src/playground /run/media/${USER}/PYBFLASH/
cp -a src/trezor /run/media/${USER}/PYBFLASH/ cp -a src/trezor /run/media/${USER}/PYBFLASH/
cp -a src/*.py /run/media/${USER}/PYBFLASH/ cp -a src/*.py /run/media/${USER}/PYBFLASH/
sync sync

View File

@ -1,3 +1,5 @@
#include <usrsw.h>
void msg_init(void) void msg_init(void)
{ {
} }
@ -14,5 +16,18 @@ int msg_send(uint8_t *buf, size_t len)
uint32_t msg_poll_ui_event(void) uint32_t msg_poll_ui_event(void)
{ {
return 0; static int lp = 0;
uint32_t r = 0;
int p = switch_get();
if (lp == 0 && p == 1) {
r = 0x00010000; // touch start
} else
if (lp == 1 && p == 1) {
r = 0x00020000; // touch move
}
if (lp == 1 && p == 0) {
r = 0x00030000; // touch end
}
lp = p;
return r;
} }

View File

@ -1,147 +0,0 @@
# import time
import sys
sys.path.append('lib')
import utime
import math
import gc
# import transport_pipe as pipe
# 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
logging.basicConfig(level=logging.INFO)
def perf_info():
mem_alloc = gc.mem_alloc()
gc.collect()
print("mem_alloc: %s/%s, last_sleep: %d" % \
(mem_alloc, gc.mem_alloc(), loop.last_sleep))
loop.call_later(1000000, perf_info)
'''
def animate():
col = 0
# hawcons gesture
f = open('playground/tap_64.toig', 'r')
while True:
col %= 0xff
col += 0x0f
ui.display.icon(190, 170, f.read(), ui.rgbcolor(col, 0, 0), 0xffff)
f.seek(0)
yield loop.Sleep(int(0.5 * 1000000))
sec = 0
event = None
def sekunda(x):
global sec
print('Sekunda %d' % sec)
if sec == 0:
# if loop.button_cb:
# loop.call_soon(loop.button_cb, 'levy')
# loop.button_cb = None
return
sec += 1
loop.call_later(1, sekunda, x)
def wait_for():
print("Jsem tady")
ktery = yield loop.IOButton()
print(ktery)
print("Po cekani na event")
'''
def tap_to_confirm(address, amount, currency):
loop.call_later(5 * 1000000, layout.change(homescreen()))
ui.display.bar(0, 0, 240, 40, ui.GREEN)
ui.display.bar(0, 40, 240, 200, ui.WHITE)
ui.display.text(10, 28, 'Sending', ui.BOLD, ui.WHITE, ui.GREEN)
ui.display.text(10, 80, '%f %s' % (amount, currency), ui.BOLD, ui.BLACK, ui.WHITE)
ui.display.text(10, 110, 'to this address:', ui.NORMAL, ui.BLACK, ui.WHITE)
ui.display.text(10, 140, address[:18], ui.MONO, ui.BLACK, ui.WHITE)
ui.display.text(10, 160, address[18:], ui.MONO, ui.BLACK, ui.WHITE)
f = open('playground/tap_64.toig', 'r')
_background = ui.rgbcolor(255, 255, 255)
def func(foreground):
ui.display.text(68, 212, 'TAP TO CONFIRM', 2, foreground, _background)
f.seek(0)
ui.display.icon(3, 170, f.read(), _background, foreground)
yield from ui.animate_pulse(func, ui.BLACK, ui.GREY) # , delay=10000)
'''
def on_read():
print("READY TO READ")
print(msg.read())
'''
@unimport_func
def zprava():
from _io import BytesIO
from trezor.messages.GetAddress import GetAddress
m = GetAddress()
m.address_n = [1, 2, 3]
m.show_display = True
print(m.__dict__)
f = BytesIO()
m.dump(f)
data = f.getvalue()
f.close()
print(data)
# m2 = GetAddress.load(BytesIO(data))
# print(m2.__dict__)
def homescreen():
print("Homescreen layout!")
loop.call_later(5 * 1000000, layout.change(tap_to_confirm('1BitkeyP2nDd5oa64x7AjvBbbwST54W5Zmx2', 110.126967, 'BTC')))
ui.display.bar(0, 0, 240, 240, ui.WHITE)
f = open('playground/trezor.toig', 'r')
def func(foreground):
f.seek(0)
ui.display.icon(0, 0, f.read(), foreground, ui.BLACK)
yield from ui.animate_pulse(func, ui.WHITE, ui.GREY, speed=400000)
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)
zprava()
loop.call_soon(perf_info)
loop.call_soon(layout.set_main(homescreen()))
# loop.call_later(10 * 1000000, layout.change(tap_to_confirm('1BitkeyP2nDd5oa64x7AjvBbbwST54W5Zmx2', 110.126967, 'BTC')))
# loop.call_soon(animate())
loop.run_forever()
loop.close()