Named Colours

105 views
Skip to first unread message

Alan Hendry

unread,
Dec 5, 2021, 1:15:30 PM12/5/21
to DroidScript
HI,
I noted a while ago that the docs for SetBackColor and SetTextColor show red, green, ...
And asked if all HTML colours were supported
black, white, silver, grey, red, yellow, blue, green, aqua, magenta seem OK
but orange and indigo and violet don't.
So I suspect it doesn't support all the named HTML colours.
Is there a list of what works? 
(MUI seems to include violet and orange)
Regards, ah

Dave

unread,
Dec 5, 2021, 2:19:27 PM12/5/21
to DroidScript

Alan Hendry

unread,
Dec 5, 2021, 3:54:45 PM12/5/21
to DroidScript
Thanks,
In the body of that page  parseColor  seems correct
Here's a mash up of voice control for a coloured night light (black=darkest, white=lightest)
(nobeep on speech recognition doesn't work, so system volume is set to 0, not sure if it needs an OnExit to reset volume.)
To run all night the user would need to set phone not to go to sleep, and have battery charged or on charge. 
Regards, ah

const colours = "red, blue, green, black, white, gray, cyan, magenta, yellow,\n aqua, fuchsia, lime, maroon, navy, olive, purple, silver, teal"
function OnStart() {
    app.SetVolume("System",0) ;
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );
    txt = app.AddText( lay , "Night Light - say one of these colours\n"+colours, -1, -1 , "Multiline");
    txt.SetBackColor("#666666") ;
    txt.SetTextColor("#cccccc") ;
    app.AddLayout( lay );
    speech = app.CreateSpeechRec("NoBeep,Partial");
    speech.SetOnReady( speech_OnReady );
    speech.SetOnResult( speech_OnResult );
    speech.SetOnError( speech_OnError );
    speech.Recognize();
}
function speech_OnReady() {
}
function speech_OnError() {
    speech.Recognize();
}
function speech_OnResult( results ) {
    var r = results[0].toLowerCase() ;
    if (colours.indexOf(r) != -1) { lay.SetBackColor(r); }
speech.Recognize();
}

Dave

unread,
Dec 5, 2021, 4:10:22 PM12/5/21
to DroidScript
If you want to take this a step further, get yourself a TP-Link Kasa Smart wi-fi plug as a Christmas present (to yourself), then you can use the new nodejs feature of DS to control your bedside lamp too, perhaps with the commands 'lamp on" or "lamp off" :)

You just need to install this node plugin using the wifi IDE - https://www.npmjs.com/package/tplink-smarthome-api

Alan Hendry

unread,
Dec 5, 2021, 5:04:19 PM12/5/21
to DroidScript
Dave,
I have a fairly long list of additional features (some already in prototype, some assembly required)
speak the date or time, set/snooze alarm, torch on/off/front/back (camera flash), take notes, read first/days appointment(s), lullaby, ...
Regards, ah

Alan Hendry

unread,
Dec 6, 2021, 9:50:22 AM12/6/21
to DroidScript
HI,
V. interesting. 
Most other devices I've seen seem to require a hub (not cheap) but this doesn't seem to.
On the tp-link site they have Kasa and Tapo brands. 
There's Smart Plugs and Bulbs and Strip Lights.
lists compatible plugs (HSnnn ,KP303, KP400) and bulbs (LBnnn) 
and says "Most other TP-Link Plug and Bulb models may work as well."
Quite a few of the plugs on Amazon/eBay, some under a tenner.
Regards, ah

Dave

unread,
Dec 6, 2021, 10:33:05 AM12/6/21
to DroidScript
I've already tested the Kasa version of the UK power strip and it works well, so I expect the Kasa series would be the safest bet if you are planning to give it a go.  I also have the 'Kasa Smart WiFi Plug Slim', but I can't remember if I tested that one yet. 

Dave

unread,
Dec 6, 2021, 10:34:25 AM12/6/21
to DroidScript
P.S. Gareth is going to do a youtube tutorial on using NodeJS and the tp-link plugs soon.  (Gareth does all the DS Youtube tutorials)

Alan Hendry

unread,
Dec 14, 2021, 5:44:48 PM12/14/21
to DroidScript
HI,
I've just seen an ad on UK television for Mood Lights with (probably infra-red) remote control
(4 small stick-up battery powered lights, about 15 colours) about £20.
Should be easy to add more colours to my code (convert to hex), 
and/or convert to MUI (18 colours, plus 4 tones and 4 shades).
There's a lot of documentation on the Calendar, but it doesn't seem at all easy to extract events.
Regards, ah 

Alan Hendry

unread,
May 26, 2022, 10:27:31 AM5/26/22
to DroidScript
HI,
Wondering if it's possible to write an app for the Banglejs watch that would control TP-Link plugs.
(Then it'd possible to turn lights on/off etc using a watch).
Regards, ah

Alan Hendry

unread,
May 26, 2022, 3:12:08 PM5/26/22
to DroidScript
Hi,
Just noticed T-Watch (aka TTGO or LilyGo) on the web
that seems to be programmable thru Arduino, Scratch, micropython, pictoblox, etc.
Regards, ah
Reply all
Reply to author
Forward
0 new messages