Version 0.2 has some new functionality that you will hopefully never need.
It would be nice if someone that reads Morse code could check it out, as I haven't checked out its readability.
Code:
LOCAL CRID:="Z LIGHTS V0.2 © 2015 StephenG1CMZ";
LOCAL NL:=CHAR(10);
EXPORT ACT_TIME;//:={};
EXPORT ACT_TIME_SOS;//:={};
EXPORT WPM:=3;
LOCAL DOTT;
LOCAL COLRNAME:={"RED","GREEN","BLUE","WHITE"};
LOCAL COLRGB:={#FF0000h,#00FF00h,#0000FFh,#FFFFFFh};
LOCAL LIGHTON:=" ON: Tap Esc to exit";
LOCAL LIGHTT:="Tap a key to see elapsed time s";
LOCAL WABTHLP:={"ABOUT/Help"};
LOCAL WBCN:={"Beacon"};
LOCAL WBLNKLIGHT:={"Blink Light"};
LOCAL WCOLR:={"Colour"};
LOCAL WSTDYLIGHT:={"Steady Light"};
LOCAL WWPM:={"Words per minute (WPM)"};
LOCAL CHOICES:={WABTHLP(1),"INFO",WSTDYLIGHT(1),WCOLR(1),WBLNKLIGHT(1),"SOS",WWPM(1)};
LOCAL LGL:="No liability is accepted.";
LOCAL COLR:=#FFFFFFh;
LOCAL TS;
CLS()
BEGIN
RECT_P(0,0,320-45,240,COLR);
RECT_P(0,20,320,240,COLR);
END;
SCRID()
BEGIN
IF 1 THEN
TEXTOUT_P(CRID,0,0,0,0,320,COLR);
END;
END;
LIGHTELF()
BEGIN
LOCAL ELFST:={"Use of lights may have health and legal consequences.
The user is responsible.
"+LGL};
RETURN MSGBOX(ELFST(1),1);
END;
EXPORT ABOUT()
BEGIN
LOCAL ST:="StephenG1CMZ is a programmer and can work to your requirements."+NL;
LOCAL SZ:="LIGHTS provides useful practical results.
Ask, if you have specific requirements."+NL;
LOCAL THANX:="";
PRINT(); PRINT(CRID);
PRINT(ST+NL+SZ);
PRINT(THANX);
PRINT(LGL);
WAIT;
LIGHTELF();
END;
EXPORT INFO()
BEGIN
LIGHTELF();
END;
AT(TS)
BEGIN
//RETURN {HH,MM,SS} ;
RETURN TS;
END;
EXPORT LIGHTCOLR()
BEGIN
LOCAL CHS;
CHOOSE(CHS,"",COLRNAME);
IF CHS THEN
COLR:=COLRGB(CHS);
END;
END;
EXPORT LIGHTSTEADY()
BEGIN
LOCAL WR;
LOCAL DUN:=0;
CLS();
TS:=Time;
ACT_TIME:={WSTDYLIGHT,AT(TS)};
SCRID();
TEXTOUT_P(TS+LIGHTON,0,180);
TEXTOUT_P(LIGHTT,0,220);
TEXTOUT_P("DEMO TEXT",0,100,7);
REPEAT
TEXTOUT_P((Time-TS),0,200,0,#FFFFFFh,320,0);
WR:=WAIT(−1);
IF TYPE(WR)==0 THEN
IF WR==4 THEN
DUN:=1;
END;
END;
UNTIL DUN; //WR==4;
END;
EXPORT LIGHTBLINK()
BEGIN
TS:=Time;
ACT_TIME:={WBLNKLIGHT,AT(TS)};
REPEAT
RECT_P(0,20,320,240,0,COLR);
TEXTOUT_P(TS+LIGHTON,0,180);
TEXTOUT_P(Time-TS,0,200,0,#FFFFFFh,320,0);
TEXTOUT_P("DEMO TEXT",0,100,7);
SCRID();
WAIT(1);
RECT_P(0,20,320,240,0,0);
WAIT(1);
UNTIL GETKEY==4;//CHECK BOTH TBD
END;
SIGOFF()
BEGIN
RECT_P(0,20,320,240,0,0);
END;
SIGON()
BEGIN
RECT_P(0,20,320,240,0,COLR);
END;
DAH()
BEGIN
SIGON();
WAIT(3*DOTT);
SIGOFF();
WAIT(DOTT);
END;
DIT()
BEGIN
SIGON();
WAIT(DOTT);
SIGOFF();
WAIT(DOTT);
END;
EXPORT LIGHT_SOS()
BEGIN
LOCAL OK;
LOCAL OKC:="OK TO CONFIRM?";
LOCAL MYWPM:=MAX(MIN(WPM,50),1);
//LOCAL BAUD:=ROUND(0.83*MYWPM,0);//APPROX
DOTT:=1.2/MYWPM;
OK:=MSGBOX(MYWPM+" WPM"+NL+".="+DOTT+" s"+NL+OKC,1);
IF OK THEN
TS:=Time;
ACT_TIME_SOS:={"SOS",AT(TS)};
CLS();
TEXTOUT_P(TS,0,0);
//INTERWORD GAP
//SEPERATES , REPOSITION
SIGOFF();
OK:=WAIT(7*DOTT);
REPEAT
DIT(); DIT(); DIT(); //S
DAH(); DAH(); DAH(); //O
DIT(); DIT(); DIT(); //S
OK:=WAIT(3*DOTT); //INTERLETTER GAP
UNTIL GETKEY==4;
END;
END;
ASK_WPM()
BEGIN
LOCAL OK;
LOCAL TTL:="WORDS PER MINUTE";
LOCAL LBL:="WPM";
LOCAL HLP:="1..25 RECOMMENDED";
OK:=INPUT(WPM,TTL,LBL,HLP,5,5);
IF OK THEN
WPM:=MAX(WPM,1);
END;
END;
HELP()
BEGIN
LOCAL CHS;
LOCAL HLPCHC:=CONCAT(CHOICES,{"VARIABLES"});
LOCAL HLPCOLR:="Red light may help preserve night vision";
LOCAL CNW:="Connectivity Not Working";
LOCAL HLPVARS:="
ACT_TIME:
ACT_TIME_SOS:
Activation time
WPM: WORDS PER MINUTE
@Home:
WPM:=n n==1..25";
REPEAT
PRINT();
CHOOSE(CHS,WABTHLP(1),HLPCHC);
IF CHS THEN
PRINT(HLPCHC(CHS));
CASE
IF CHS==1 THEN ABOUT() END;
IF CHS==2 THEN INFO() END;
IF CHS==4 THEN PRINT(HLPCOLR) END;
IF CHS==6 THEN PRINT(CNW) END;
IF CHS==8 THEN PRINT(HLPVARS) END;
DEFAULT
LIGHTELF();
//BACKSTORY();
END;
WAIT;
END;
UNTIL CHS==0;
WAIT;
END;
EXPORT Z_LIGHTS()
BEGIN
LOCAL CHS;
//SCRID();
REPEAT
CHOOSE(CHS,CRID,CHOICES);
CASE
IF CHS==1 THEN HELP() END;
IF CHS==2 THEN INFO() END;
IF CHS==3 THEN LIGHTSTEADY() END;
IF CHS==4 THEN LIGHTCOLR() END;
IF CHS==5 THEN LIGHTBLINK() END;
//IF CHS==6 THEN LIGHTBLINK() END;
IF CHS==6 THEN LIGHT_SOS() END;
IF CHS==7 THEN ASK_WPM() END;
DEFAULT
END;
UNTIL CHS==0;
//I HAD CONSIDERED A WAKEUP ALARM. BUT AUTO DIMMING OFSCREEN
END;