Here is the source:
REBOL [
title: "Led Clock"
Date: 11-Oct-2010
Version: 2.2
Author: ["FrançÂois Jouen" "Massimiliano Vessi"]
File: %ledclock.r
Purpose: { A simple demo with leds}
license: 'pd
]
;digits made of pixels
pixels: [
; digit 1, can you see it?
[
[0 0 0 0 0 0 0 0 0 0 ]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 0 0]
]
[
[0 0 0 0 0 0 0 0 0 0]
[0 1 1 1 1 1 1 1 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 1 0]
[0 1 1 1 1 1 1 1 1 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0]
[0 1 1 1 1 1 1 1 1 0]
[0 0 0 0 0 0 0 0 0 0]
]
[
[0 0 0 0 0 0 0 0 0 0]
[0 1 1 1 1 1 1 1 1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 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 0 0 0 0 0 0 1 0]
[0 1 1 1 1 1 1 1 1 0]
[0 0 0 0 0 0 0 0 0 0]
]
]
color2: 200.200.200 ;standard background
color3: 0.255.0
color4: 255.0.0
;p=digit
update_led: func [p [integer!] /local plot color] [
if p = 0 [p: 10] ;zero is the tenth digit in pixels series
plot: copy [pen none]
repeat y 19 [
repeat x 10 [
either pixels/:p/:y/:x = 0 [color: color3] [color: color4]
append plot compose [fill-pen (color) circle (10 * as-pair x y ) (4) ]
]
]
return plot
]
get-time: func [pos [integer!] ] [
;this function take the time (11:33:44) and transform it in a string "113344"
tmp: rejoin (parse to-string now/time/precise ":")
to-integer to-string tmp/:pos
]
; simple window
view center-face layout [
style bbox box 115x205 user-data 1 rate 1 feel [
engage: func [face action event][
face/effect: reduce [
'draw update_led get-time face/user-data
]
show face
]
]
style pbox panel [
box 10x10 color4 effect reduce ['oval color2] rate 1 feel [engage: func [f a e][f/color: color4 f/effect: reduce ['oval color2] show f]]
box 10x10 color4 effect reduce ['oval color2] rate 1 feel [engage: func [f a e][f/color: color4 f/effect: reduce ['oval color2] show f]]
]
across
bbox user-data 1
bbox user-data 2
pad 5x100
pbox
pad 5x-100
b3: bbox user-data 3
b4: bbox user-data 4
pad 5x100
pbox
pad 5x-100
b5: bbox user-data 5
b6: bbox user-data 6
return
button "Background" [color2: face/parent-face/color: request-color show face/parent-face ]
button "Dark leds" [color3: request-color]
button "Light leds" [color4: request-color]
]
No comments:
Post a Comment