]> gitweb.factorcode.org Git - factor.git/blob - extra/lcd/lcd.factor
core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota...
[factor.git] / extra / lcd / lcd.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors calendar.format calendar.model fonts fry
4 grouping kernel math models.arrow namespaces sequences ui
5 ui.gadgets.labels ;
6 IN: lcd
7
8 : lcd-digit ( digit row -- str )
9     [ dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if ] dip {
10         "  _       _  _       _   _   _   _   _      "
11         " | |  |   _| _| |_| |_  |_    | |_| |_|  *  "
12         " |_|  |  |_  _|   |  _| |_|   | |_|   |  *  "
13         "                                            "
14     } nth 4 <groups> nth ;
15
16 : lcd-row ( row digit -- string )
17     '[ _ lcd-digit ] { } map-as concat ;
18
19 : lcd ( digit-str -- string )
20     4 <iota> [ lcd-row ] with map "\n" join ;
21
22 : <time-display> ( model -- gadget )
23     [ timestamp>hms lcd ] <arrow> <label-control>
24     "99:99:99" lcd >>string
25     monospace-font >>font ;
26
27 MAIN-WINDOW: time-window { { title "Time" } }
28     time get <time-display> >>gadgets ;