The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Z LIGHTS: Prime's answer to mobile phone torches
10-29-2015, 10:40 PM
Post: #1
Z LIGHTS: Prime's answer to mobile phone torches
As the clocks change and the nights get darker, it seems the right time for this little program...It can also be called from ZIPP, another of my programs.

Given that the HP Prime has no external accessible lights, this program may be of little practical use...unless the lights go out whilst you are using your calculator.

The design aim is a compromise between maximising the limited illumination available, and including some information that a torch would not (the time the light was activated).

Version 0.1:
Code:


 LOCAL CRID:="Z LIGHTS V0.1 © 2015 StephenG1CMZ";
 LOCAL NL:=CHAR(10);

 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 CHOICES:={WABTHLP(1),"INFO",WSTDYLIGHT(1),WCOLR(1),WBLNKLIGHT(1),WBCN(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:=""; 
  //LOCAL LGL:="No liability is accepted.";
  PRINT(); PRINT(CRID);
  PRINT(ST+NL+SZ);
  PRINT(THANX);
  PRINT(LGL);
  WAIT;

  LIGHTELF();
 END;

 EXPORT INFO()
 BEGIN
  LIGHTELF();
 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;
  //RECT_P(0,0,320-45,240,0,COLR);
  CLS();
  TS:=Time;
  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;
  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;

 HELP()
 BEGIN
  LOCAL CHS;
  
  LOCAL HLPCOLR:="Red light may help preserve night vision";

  PRINT(); 
  CHOOSE(CHS,WABTHLP(1),CHOICES);
  PRINT(CHOICES(CHS));
  CASE
   IF CHS==1 THEN ABOUT() END;
   IF CHS==2 THEN INFO() END;
   IF CHS==4 THEN PRINT(HLPCOLR) END;
 
   DEFAULT
    LIGHTELF();
    //BACKSTORY();
  END;
  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;
 
    DEFAULT
   END;
  UNTIL CHS==0;
//I HAD CONSIDERED A WAKEUP ALARM. BUT AUTO DIMMING OFSCREEN


 END;
Is there a way to un-dim the screen after a programmed delay? Then I could add a wake-up function.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Z LIGHTS: Prime's answer to mobile phone torches - StephenG1CMZ - 10-29-2015 10:40 PM



User(s) browsing this thread: 1 Guest(s)