factor/extra/lcd/lcd.factor

35 lines
1.1 KiB
Factor
Raw Normal View History

2008-02-26 20:18:21 -05:00
USING: sequences kernel math io calendar calendar.format
calendar.model arrays models namespaces ui.gadgets
ui.gadgets.labels
2008-02-26 15:57:37 -05:00
ui.gadgets.theme ui ;
2007-09-20 18:09:08 -04:00
IN: lcd
2008-01-28 19:13:35 -05:00
: lcd-digit ( row digit -- str )
dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if swap {
" _ _ _ _ _ _ _ _ "
" | | | _| _| |_| |_ |_ | |_| |_| * "
" |_| | |_ _| | _| |_| | |_| | * "
2008-02-26 15:57:37 -05:00
" "
2007-09-20 18:09:08 -04:00
} nth >r 4 * dup 4 + r> subseq ;
2008-01-28 19:13:35 -05:00
: lcd-row ( num row -- string )
[ swap lcd-digit ] curry { } map-as concat ;
2007-09-20 18:09:08 -04:00
2008-01-28 19:13:35 -05:00
: lcd ( digit-str -- string )
2008-02-26 15:57:37 -05:00
4 [ lcd-row ] with map "\n" join ;
2007-09-20 18:09:08 -04:00
2008-02-26 15:57:37 -05:00
: hh:mm:ss ( timestamp -- string )
{
timestamp-hour timestamp-minute timestamp-second
} get-slots >fixnum 3array [ pad-00 ] map ":" join ;
2007-09-20 18:09:08 -04:00
2008-02-26 15:57:37 -05:00
: <time-display> ( timestamp -- gadget )
[ hh:mm:ss lcd ] <filter> <label-control>
"99:99:99" lcd over set-label-string
monospace-font over set-label-font ;
: time-window ( -- )
[ time get <time-display> "Time" open-window ] with-ui ;
MAIN: time-window