Merge branch 'master' of github.com:satoshilabs/trezor-os

This commit is contained in:
slush0 2016-04-01 17:24:57 +02:00 committed by Pavol Rusnak
commit 9cb42cc88d
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 55 additions and 55 deletions

View File

@ -37,16 +37,27 @@ static int HandleEvents(void *ptr)
{
SDL_Event event;
int x, y;
bool down;
while (SDL_WaitEvent(&event) >= 0) {
switch (event.type) {
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONUP:
x = event.button.x - DISPLAY_BORDER;
y = event.button.y - DISPLAY_BORDER;
if (x < 0 || y < 0 || x >= RESX || y >= RESY) continue;
down = (event.type == SDL_MOUSEBUTTONDOWN);
printf("CLICK %s: %d %d\n", down ? "DOWN" : "UP", x, y);
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
printf("TOUCH START: %d %d\n", x, y);
break;
case SDL_MOUSEMOTION:
if (event.motion.state) {
printf("TOUCH MOVE: %d %d\n", x, y);
}
break;
case SDL_MOUSEBUTTONUP:
printf("TOUCH END: %d %d\n", x, y);
break;
}
break;
}
}

View File

@ -1,39 +1,10 @@
from trezor import ui
def rgb2color(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
RED = rgb2color(0xF4, 0x43, 0x36)
PINK = rgb2color(0xE9, 0x1E, 0x63)
PURPLE = rgb2color(0x9C, 0x27, 0xB0)
DEEP_PURPLE = rgb2color(0x67, 0x3A, 0xB7)
INDIGO = rgb2color(0x3F, 0x51, 0xB5)
BLUE = rgb2color(0x21, 0x96, 0xF3)
LIGHT_BLUE = rgb2color(0x03, 0xA9, 0xF4)
CYAN = rgb2color(0x00, 0xBC, 0xD4)
TEAL = rgb2color(0x00, 0x96, 0x88)
GREEN = rgb2color(0x4C, 0xAF, 0x50)
LIGHT_GREEN = rgb2color(0x8B, 0xC3, 0x4A)
LIME = rgb2color(0xCD, 0xDC, 0x39)
YELLOW = rgb2color(0xFF, 0xEB, 0x3B)
AMBER = rgb2color(0xFF, 0xC1, 0x07)
ORANGE = rgb2color(0xFF, 0x98, 0x00)
DEEP_ORANGE = rgb2color(0xFF, 0x57, 0x22)
BROWN = rgb2color(0x79, 0x55, 0x48)
GREY = rgb2color(0x9E, 0x9E, 0x9E)
BLUE_GRAY = rgb2color(0x60, 0x7D, 0x8B)
BLACK = rgb2color(0x00, 0x00, 0x00)
WHITE = rgb2color(0xFF, 0xFF, 0xFF)
MONO = 0
NORMAL = 1
BOLD = 2
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)
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)

View File

@ -9,12 +9,7 @@ import gc
from uasyncio import core
from trezor import ui
from .import utils
if __debug__:
import logging
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.INFO)
loop = core.get_event_loop()
def perf_info():
@ -33,8 +28,7 @@ def animate():
col %= 0xff
col += 0x0f
ui.display.icon(170, 170, f.read(), 0xffff, utils.rgb2color(col, 0, 0))
# ui.display.icon(100, 100, f.read(), 0xffff, utils.rgb2color(col, 0, 0))
ui.display.icon(190, 170, f.read(), ui.rgbcolor(col, 0, 0), 0xffff)
f.seek(0)
yield core.Sleep(0.5)
@ -70,10 +64,7 @@ def tap_to_confirm():
MIN_COLOR = 0x00
MAX_COLOR = 0xB0
_background = utils.rgb2color(255, 255, 255)
f = open('playground/tap_64.toi', 'r')
_background = ui.rgbcolor(255, 255, 255)
x = math.pi
while True:
x += STEP_X
@ -85,7 +76,7 @@ def tap_to_confirm():
# Normalize color from interval 0:2 to MIN_COLOR:MAX_COLOR
col = int((MAX_COLOR - MIN_COLOR) / 2 * y) + MIN_COLOR
foreground = utils.rgb2color(BASE_COLOR[0] + col, BASE_COLOR[1] + col, BASE_COLOR[2] + col)
foreground = ui.rgbcolor(BASE_COLOR[0] + col, BASE_COLOR[1] + col, BASE_COLOR[2] + col)
ui.display.text(68, 212, 'TAP TO CONFIRM', 2, foreground, _background)

View File

@ -1,2 +0,0 @@
def rgb2color(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)

View File

@ -2,3 +2,32 @@ from TrezorUi import Display, Touch
display = Display()
touch = Touch()
def rgbcolor(r, g, b):
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)
RED = rgbcolor(0xF4, 0x43, 0x36)
PINK = rgbcolor(0xE9, 0x1E, 0x63)
PURPLE = rgbcolor(0x9C, 0x27, 0xB0)
DEEP_PURPLE = rgbcolor(0x67, 0x3A, 0xB7)
INDIGO = rgbcolor(0x3F, 0x51, 0xB5)
BLUE = rgbcolor(0x21, 0x96, 0xF3)
LIGHT_BLUE = rgbcolor(0x03, 0xA9, 0xF4)
CYAN = rgbcolor(0x00, 0xBC, 0xD4)
TEAL = rgbcolor(0x00, 0x96, 0x88)
GREEN = rgbcolor(0x4C, 0xAF, 0x50)
LIGHT_GREEN = rgbcolor(0x8B, 0xC3, 0x4A)
LIME = rgbcolor(0xCD, 0xDC, 0x39)
YELLOW = rgbcolor(0xFF, 0xEB, 0x3B)
AMBER = rgbcolor(0xFF, 0xC1, 0x07)
ORANGE = rgbcolor(0xFF, 0x98, 0x00)
DEEP_ORANGE = rgbcolor(0xFF, 0x57, 0x22)
BROWN = rgbcolor(0x79, 0x55, 0x48)
GREY = rgbcolor(0x9E, 0x9E, 0x9E)
BLUE_GRAY = rgbcolor(0x60, 0x7D, 0x8B)
BLACK = rgbcolor(0x00, 0x00, 0x00)
WHITE = rgbcolor(0xFF, 0xFF, 0xFF)
MONO = 0
NORMAL = 1
BOLD = 2