1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 10:58:21 +00:00

introduce trezor module

This commit is contained in:
Pavol Rusnak 2016-03-31 18:45:15 +02:00
parent 4a9b60a0f3
commit 8493da5f97
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
6 changed files with 19 additions and 22 deletions

2
emu.sh
View File

@ -1,3 +1,3 @@
#!/bin/bash
cd `dirname $0`/src
../vendor/micropython/unix/micropython -m main
../vendor/micropython/unix/micropython main.py

View File

@ -155,11 +155,8 @@ typedef struct _mp_obj_Display_t {
// def Display.__init__(self):
STATIC mp_obj_t mod_TrezorUi_Display_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_Display_t *o = 0; // singleton
if (!o) {
display_init();
o = m_new_obj(mp_obj_Display_t);
}
display_init();
mp_obj_Display_t *o = m_new_obj(mp_obj_Display_t);
o->base.type = type;
return MP_OBJ_FROM_PTR(o);
}

View File

@ -1,4 +1,4 @@
from TrezorUi import Display
from trezor import ui
def rgb2color(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
@ -29,16 +29,11 @@ MONO = 0
NORMAL = 1
BOLD = 2
d = Display()
class Layout(object):
@staticmethod
def show_send(address, amount, currency='BTC'):
d.bar(0, 0, 240, 40, GREEN)
d.bar(0, 40, 240, 200, WHITE)
d.text(10, 28, 'Sending', BOLD, WHITE, GREEN)
d.text(10, 80, '%f %s' % (amount, currency), BOLD, BLACK, WHITE)
d.text(10, 110, 'to this address:', NORMAL, BLACK, WHITE)
d.text(10, 140, address[:18], MONO, BLACK, WHITE)
d.text(10, 160, address[18:], MONO, BLACK, WHITE)
def show_send(address, amount, currency='BTC'):
ui.display.bar(0, 0, 240, 40, GREEN)
ui.display.bar(0, 40, 240, 200, WHITE)
ui.display.text(10, 28, 'Sending', BOLD, WHITE, GREEN)
ui.display.text(10, 80, '%f %s' % (amount, currency), BOLD, BLACK, WHITE)
ui.display.text(10, 110, 'to this address:', NORMAL, BLACK, WHITE)
ui.display.text(10, 140, address[:18], MONO, BLACK, WHITE)
ui.display.text(10, 160, address[18:], MONO, BLACK, WHITE)

View File

@ -1,3 +1,5 @@
from layout import Layout
import layout
Layout.show_send('1BitkeyP2nDd5oa64x7AjvBbbwST54W5Zmx2', 110.126967)
layout.show_send('1BitkeyP2nDd5oa64x7AjvBbbwST54W5Zmx2', 110.126967)
while True: pass

0
src/trezor/__init__.py Normal file
View File

3
src/trezor/ui.py Normal file
View File

@ -0,0 +1,3 @@
from TrezorUi import Display
display = Display()