'variation on alarm clock 2019-06-22
'designed for xmax = ymax = 320 but anything bigger should be OK
'2019-12-05 changed face again, changed arms by adding a trangle opposite point end
'improved Alarm input screen and installed Ken's chimes to indicate the hour
CONST xmax
= 500, ymax
= 500, xCenter
= xmax
/ 2, yCenter
= ymax
/ 2, p
= 3.14159265, p2
= p
* 2, pd2
= p
/ 2 iso
AS SINGLE 'iso tri base, now for radius arm width perpedicular to point direction
DIM t$
, h
, m
, s
, chimes
, sample
, ttt
drawClockFace
outputClock
'Chimes
ttt = 0
'queue some sound
sample
= SIN(ttt
* 340 * ATN(1) * 8) '340Hz sine wave (ttt * 440 * 2p) sample
= sample
* EXP(-ttt
* 3) 'fade out eliminates clicks after sound ttt
= ttt
+ 1 / _SNDRATE 'sound card sample frequency determines time 'do other stuff, but it may interrupt sound
drawArms
_TITLE "Press any to stop beeping..."
rr = 10: gg = 5: bb = 2
angle = p2 / 60: r = yCenter * .95
x1
= xCenter
+ COS(0 - pd2
) * r: y1
= yCenter
+ SIN(0 - pd2
) * r
x2
= xCenter
+ COS(n
* angle
- pd2
) * r: y2
= yCenter
+ SIN(n
* angle
- pd2
) * r
IF level
= 1 THEN shade
= 30 - shade
c
= _RGB32(((level
* 1.5) + rr
+ shade
* 10), ((level
* .75) + gg
+ shade
* 5), ((level
* .4) + bb
+ shade
* 2.5)) fillTriangle xCenter, yCenter, x1, y1, x2, y2, c
x1 = x2: y1 = y2
IF level
= 0 THEN r
= r
- .1 * yCenter
ELSE r
= r
- .02 * yCenter
DIM xPlus90
, yPlus90
, xMinus90
, yMinus90
, xop
, yop
, xPoint
, yPoint
, t
AS DOUBLE, i
AS INTEGER, rr
, c
AS _UNSIGNED LONG arms(1).c = &HFF222211: arms(2).c = &HFF331111: arms(3).c = &HFF663322
arms(1).l = yCenter * .6: arms(2).l = yCenter * .8: arms(3).l = yCenter * .84
arms(1).iso = yCenter * .065: arms(2).iso = yCenter * .05: arms(3).iso = yCenter * .04 ' don't use in arm 3
'the follwing angles are in radians with pd2 = Pi/2 subtracted
arms(1).a = (t / 3600) / 12 * p2 - pd2
arms
(2).a
= (t
/ 60 - 60 * INT(arms
(1).a
)) / 60 * p2
- pd2
arms
(3).a
= (t
- INT(arms
(1).a
) * 3600 - INT(arms
(2).a
) * 60) / 60 * p2
- pd2
xPlus90
= xCenter
+ arms
(i
).iso
* COS(arms
(i
).a
+ pd2
) yPlus90
= yCenter
+ arms
(i
).iso
* SIN(arms
(i
).a
+ pd2
)
xMinus90
= xCenter
+ arms
(i
).iso
* COS(arms
(i
).a
- pd2
) yMinus90
= yCenter
+ arms
(i
).iso
* SIN(arms
(i
).a
- pd2
)
xPoint
= xCenter
+ arms
(i
).l
* COS(arms
(i
).a
) yPoint
= yCenter
+ arms
(i
).l
* SIN(arms
(i
).a
)
xop
= xCenter
+ 3 * arms
(i
).iso
* COS(arms
(i
).a
- p
) yop
= yCenter
+ 3 * arms
(i
).iso
* SIN(arms
(i
).a
- p
)
fillTriangle xPlus90, yPlus90, xMinus90, yMinus90, xPoint, yPoint, arms(i).c
fillTriangle xPlus90, yPlus90, xMinus90, yMinus90, xop, yop, arms(i).c
LINE (xop
, yop
)-(xPoint
, yPoint
), arms
(i
).c
CIRCLE (xCenter
, yCenter
), rr
, c
s$ = "For time: hh = 00-23 : mm = 00-59"
s$ = "Enter hh:mm "
'INPUT for Graphics screen
SUB inputG
(x
, y
, prmpt$
, var$
, expectedLenVar%
) 'input for a graphics screen x, y is where the prompt will start , returns through var$ _PRINTSTRING (x
, y
), prmpt$
+ " {" + tmp$
+ "}" + SPACE$(expectedLenVar%
- LEN(tmp$
)) 'spaces needed at end to clear backspace chars