clean up lcd
parent
5cec6f15ca
commit
2d21f3bdd3
|
@ -1,30 +1,26 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors sequences kernel math io calendar grouping
|
USING: accessors calendar.format calendar.model fonts fry
|
||||||
calendar.format calendar.model fonts arrays models models.arrow
|
grouping kernel math models.arrow namespaces sequences ui
|
||||||
namespaces ui.gadgets ui.gadgets.labels ui ;
|
ui.gadgets.labels ;
|
||||||
IN: lcd
|
IN: lcd
|
||||||
|
|
||||||
: lcd-digit ( row digit -- str )
|
: lcd-digit ( digit row -- str )
|
||||||
dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if swap {
|
[ dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if ] dip {
|
||||||
" _ _ _ _ _ _ _ _ "
|
" _ _ _ _ _ _ _ _ "
|
||||||
" | | | _| _| |_| |_ |_ | |_| |_| * "
|
" | | | _| _| |_| |_ |_ | |_| |_| * "
|
||||||
" |_| | |_ _| | _| |_| | |_| | * "
|
" |_| | |_ _| | _| |_| | |_| | * "
|
||||||
" "
|
" "
|
||||||
} nth 4 <groups> nth ;
|
} nth 4 <groups> nth ;
|
||||||
|
|
||||||
: lcd-row ( num row -- string )
|
: lcd-row ( row digit -- string )
|
||||||
[ swap lcd-digit ] curry { } map-as concat ;
|
'[ _ lcd-digit ] { } map-as concat ;
|
||||||
|
|
||||||
: lcd ( digit-str -- string )
|
: lcd ( digit-str -- string )
|
||||||
4 [ lcd-row ] with map "\n" join ;
|
4 iota [ lcd-row ] with map "\n" join ;
|
||||||
|
|
||||||
: hh:mm:ss ( timestamp -- string )
|
: <time-display> ( model -- gadget )
|
||||||
[ hour>> ] [ minute>> ] [ second>> >fixnum ] tri
|
[ timestamp>hms lcd ] <arrow> <label-control>
|
||||||
3array [ pad-00 ] map ":" join ;
|
|
||||||
|
|
||||||
: <time-display> ( timestamp -- gadget )
|
|
||||||
[ hh:mm:ss lcd ] <arrow> <label-control>
|
|
||||||
"99:99:99" lcd >>string
|
"99:99:99" lcd >>string
|
||||||
monospace-font >>font ;
|
monospace-font >>font ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue