]> gitweb.factorcode.org Git - factor.git/blob - extra/lcd/lcd.factor
1801ee2170345d76c65e03625d33e1c46bd276dc
[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 sequences kernel math io calendar grouping
4 calendar.format calendar.model fonts arrays models models.arrow
5 namespaces ui.gadgets ui.gadgets.labels ui ;
6 IN: lcd
7
8 : lcd-digit ( row digit -- str )
9     dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if swap {
10         "  _       _  _       _   _   _   _   _      "
11         " | |  |   _| _| |_| |_  |_    | |_| |_|  *  "
12         " |_|  |  |_  _|   |  _| |_|   | |_|   |  *  "
13         "                                            "
14     } nth 4 <groups> nth ;
15
16 : lcd-row ( num row -- string )
17     [ swap lcd-digit ] curry { } map-as concat ;
18
19 : lcd ( digit-str -- string )
20     4 [ lcd-row ] with map "\n" join ;
21
22 : hh:mm:ss ( timestamp -- string )
23     [ hour>> ] [ minute>> ] [ second>> >fixnum ] tri
24     3array [ pad-00 ] map ":" join ;
25
26 : <time-display> ( timestamp -- gadget )
27     [ hh:mm:ss lcd ] <arrow> <label-control>
28     "99:99:99" lcd >>string
29     monospace-font >>font ;
30
31 : time-window ( -- )
32     [ time get <time-display> "Time" open-window ] with-ui ;
33
34 MAIN: time-window