factor/extra/lcd/lcd.factor

29 lines
958 B
Factor
Raw Normal View History

2008-07-05 22:29:02 -04:00
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2009-11-28 19:36:47 -05:00
USING: accessors calendar.format calendar.model fonts fry
grouping kernel math models.arrow namespaces sequences ui
ui.gadgets.labels ;
2007-09-20 18:09:08 -04:00
IN: lcd
2009-11-28 19:36:47 -05:00
: lcd-digit ( digit row -- str )
[ dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if ] dip {
2008-01-28 19:13:35 -05:00
" _ _ _ _ _ _ _ _ "
" | | | _| _| |_| |_ |_ | |_| |_| * "
" |_| | |_ _| | _| |_| | |_| | * "
2008-02-26 15:57:37 -05:00
" "
2008-08-27 17:24:04 -04:00
} nth 4 <groups> nth ;
2007-09-20 18:09:08 -04:00
2009-11-28 19:36:47 -05:00
: lcd-row ( row digit -- string )
'[ _ lcd-digit ] { } map-as concat ;
2007-09-20 18:09:08 -04:00
2008-01-28 19:13:35 -05:00
: lcd ( digit-str -- string )
4 <iota> [ lcd-row ] with map "\n" join ;
2007-09-20 18:09:08 -04:00
2009-11-28 19:36:47 -05:00
: <time-display> ( model -- gadget )
[ timestamp>hms lcd ] <arrow> <label-control>
"99:99:99" lcd >>string
2008-09-02 14:02:58 -04:00
monospace-font >>font ;
2008-02-26 15:57:37 -05:00
MAIN-WINDOW: time-window { { title "Time" } }
time get <time-display> >>gadgets ;