]> gitweb.factorcode.org Git - factor.git/commitdiff
clean up lcd
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 29 Nov 2009 00:36:47 +0000 (18:36 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 29 Nov 2009 00:36:47 +0000 (18:36 -0600)
extra/lcd/lcd.factor

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