Improve LCD demo
parent
bca3dfcf2c
commit
aeef08cd51
|
@ -1,4 +1,6 @@
|
||||||
USING: sequences kernel math io ;
|
USING: sequences kernel math io calendar calendar.model
|
||||||
|
arrays models namespaces ui.gadgets ui.gadgets.labels
|
||||||
|
ui.gadgets.theme ui ;
|
||||||
IN: lcd
|
IN: lcd
|
||||||
|
|
||||||
: lcd-digit ( row digit -- str )
|
: lcd-digit ( row digit -- str )
|
||||||
|
@ -6,14 +8,26 @@ IN: lcd
|
||||||
" _ _ _ _ _ _ _ _ "
|
" _ _ _ _ _ _ _ _ "
|
||||||
" | | | _| _| |_| |_ |_ | |_| |_| * "
|
" | | | _| _| |_| |_ |_ | |_| |_| * "
|
||||||
" |_| | |_ _| | _| |_| | |_| | * "
|
" |_| | |_ _| | _| |_| | |_| | * "
|
||||||
|
" "
|
||||||
} nth >r 4 * dup 4 + r> subseq ;
|
} nth >r 4 * dup 4 + r> subseq ;
|
||||||
|
|
||||||
: lcd-row ( num row -- string )
|
: lcd-row ( num row -- string )
|
||||||
[ swap lcd-digit ] curry { } map-as concat ;
|
[ swap lcd-digit ] curry { } map-as concat ;
|
||||||
|
|
||||||
: lcd ( digit-str -- string )
|
: lcd ( digit-str -- string )
|
||||||
3 [ lcd-row ] with map "\n" join ;
|
4 [ lcd-row ] with map "\n" join ;
|
||||||
|
|
||||||
: lcd-demo ( -- ) "31337" lcd print ;
|
: hh:mm:ss ( timestamp -- string )
|
||||||
|
{
|
||||||
|
timestamp-hour timestamp-minute timestamp-second
|
||||||
|
} get-slots >fixnum 3array [ pad-00 ] map ":" join ;
|
||||||
|
|
||||||
MAIN: lcd-demo
|
: <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
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
7-segment numeric display demo
|
7-segment LCD clock demo
|
||||||
|
|
Loading…
Reference in New Issue