XWidgetSoft Forum https://bbs.xwidget.com/ |
|
Show txt on a time ? https://bbs.xwidget.com/viewtopic.php?f=8&t=3658 |
Page 1 of 1 |
Author: | digigamer [ October 18th, 2013, 11:01 pm ] |
Post subject: | Re: Show txt on a time ? |
Component names cannot be started with a number. That's true for every programming language Name texts with a preceeding character like "num1" etc.. then eval("num"+core1.get(null,"%Hour")).Effect.Glow.Enabled = true; ![]() |
Author: | Jimking [ October 19th, 2013, 1:01 am ] |
Post subject: | Re: Show txt on a time ? |
Thanks man!!! And what about the colour of the txt? I will set it from the designer? Edit: Never mind.. I just read your note in DA! ![]() |
Author: | Jimking [ October 19th, 2013, 6:37 am ] |
Post subject: | Re: Show txt on a time ? |
DG I almost finished the widget (I have to add the txts for the seconds), the appearing of the corresponding text/colours is working but the problem is doesn't update...(the next colour digit doesn't show up next..) ![]() I sent you the file through a Note on DA to check what I mean.. Edit: Using the same code for the datetimecore1OnUpdate: Quote: function datetimecore1OnUpdate(Sender) { eval(datetimecore1.get("%WeekEn")).Font.Color = rgba(41,1,214,255); eval(datetimecore1.get("%AMPM")).Font.Color = rgba(197,16,16,255); eval("num"+datetimecore1.get("%Hour0")).Font.Color = rgba(0,93,171,255); //hour0 eval("min"+datetimecore1.get("%Minute0")).Font.Color = rgba(0,20,171,255); //minute0 } I notice that the numbers are now updated BUT the previous number remains visible..... |
Author: | meme [ October 19th, 2013, 4:01 pm ] |
Post subject: | Re: Show txt on a time ? |
Without changing the naming system you have used function datetimecore1OnUpdate(Sender) { ResetAllColors(); ---------------------------------------------------------------------- ADD this line eval(datetimecore1.get("%WeekEn")).Font.Color = rgba(41,1,214,255); eval(datetimecore1.get("%AMPM")).Font.Color = rgba(197,16,16,255); eval("num"+datetimecore1.get("%Hour0")).Font.Color = rgba(0,93,171,255); //hour0 eval("min"+datetimecore1.get("%Minute0")).Font.Color = rgba(0,20,171,255); //minute0 } function ResetAllColors() // reset colors -------------------------------------------------- ADD this function { for (var m=0; m<60; m++) // count up the minutes 0-59 { eval("min" + ("0" + m).slice(-2)).Font.Color = rgba(0,0,0,0); // reset all mins to transparent } for (var h=1; h<12; h++) // count up the hours 1-12 { eval("num" + ("0" + h).slice(-2)).Font.Color = rgba(0,0,0,0); // reset all nums to transparent } eval(AM).Font.Color = rgba(0,0,0,0); eval(PM).Font.Color = rgba(0,0,0,0); eval(Monday).Font.Color = rgba(0,0,0,0); eval(Tuesday).Font.Color = rgba(0,0,0,0); eval(Wednesday).Font.Color = rgba(0,0,0,0); eval(Thursday).Font.Color = rgba(0,0,0,0); eval(Friday).Font.Color = rgba(0,0,0,0); eval(Saturday).Font.Color = rgba(0,0,0,0); eval(Sunday).Font.Color = rgba(0,0,0,0); } //To reduce system resources this code only need to run if the time/seconds = 0 //this could be add with an IF statement at the start of the function datetimecore1OnUpdate(Sender) |
Author: | Jimking [ October 19th, 2013, 6:08 pm ] |
Post subject: | Re: Show txt on a time ? |
Thanks meme!!! Excellent work! ![]() Now works as it should, BUT damm, the cpu consumption makes the widget unusable... ![]() No way to reduce it..? This happens because of the number of the txts??? If yes, I have an idea! Is a full screen widget. So I can take a screenshot with all the numbers in black, so I can delete all the bottom txts and leave all the other that use the script code! ![]() Edit: I did it, I notice some improvement with the cpu but is still high.. So the code causes it..? ![]() |
Author: | meme [ October 19th, 2013, 6:58 pm ] |
Post subject: | Re: Show txt on a time ? |
Quote: //To reduce system resources this code only need to run if the time/seconds = 0 //this could be add with an IF statement at the start of the function datetimecore1OnUpdate(Sender) if the above is done the code will run only once every minute when the seconds = 0, which is the only time you want it to update anyway. function datetimecore1OnUpdate(Sender) { if (eval(datetimecore1.get("%Second")) == 0) ------------------------------------------- ADD this if statement { ------------------------------------------- ADD this ResetAllColors(); eval(datetimecore1.get("%WeekEn")).Font.Color = rgba(41,1,214,255); eval(datetimecore1.get("%AMPM")).Font.Color = rgba(197,16,16,255); eval("num"+datetimecore1.get("%Hour0")).Font.Color = rgba(0,93,171,255); //hour0 eval("min"+datetimecore1.get("%Minute0")).Font.Color = rgba(0,20,171,255); //minute0 } -------------------------------------------- ADD this } To make it work properly on start up you need the function widgetOnLoad() to be added to WIDGET - FUNCTIONS - ONLOAD - ( currently it is not running at startup. ) Also fix a mistake I made please edit the line for (var h=1; h<12; h++) // count up the hours 1-12 -------------------------------------------- EDIT this it should be for (var h=1; h<13; h++) // count up the hours 1-12 |
Author: | Jimking [ October 19th, 2013, 7:20 pm ] |
Post subject: | Re: Show txt on a time ? |
Added the new script and cpu now is 0..! ![]() Quote: Also the make it work properly on start up you need the function widgetOnLoad() to be added to WIDGET - FUNCTIONS - ONLOAD - ( currently it is not running at startup. ) Without it the widget will start work on the next minute right...? What I have to add it in the space..? (I have to copy the entire code?) Quote: function widgetOnLoad()
{ } |
Author: | meme [ October 19th, 2013, 7:40 pm ] |
Post subject: | Re: Show txt on a time ? |
Please read my last edited post to correct a mistake I made. Quote: Without it the widget will start work on the next minute right...? YesQuote: What I have to add it in the space..? (I have to copy the entire code?) No the code is OK as you have it, it is not being called to run at startupto get it to run the function widgetOnLoad() at startup Click DESIGN button in the toolbar to go to design mode Click on WIDGET in the top left side column Click FUNCTIONS under widget attributes, the blue box on top of the right side column In the OnLoad edit box SELECT scripting code it should take you to the function widgetOnLoad() you have already created. now it will run at startup. |
Author: | Jimking [ October 19th, 2013, 7:58 pm ] |
Post subject: | Re: Show txt on a time ? |
Quote: Please read my last edited post to correct a mistake I made. Yes, I fixed it! Quote: No the code is OK as you have it, it is not being called to run at startup to get it to run the function widgetOnLoad() at startup Click DESIGN button in the toolbar to go to design mode Click on WIDGET in the top left side column Click FUNCTIONS under widget attributes, the blue box on top of the right side column In the OnLoad edit box SELECT scripting code it should take you to the function widgetOnLoad() you have already created. now it will run at startup. Yes, I know the path but I'm stupid because I had deleted this part in my script here and that's why I was a little confused.. But all ok now! Tomorrow I will put the seconds adding the corrisponding lines in the script.. 1000 THANKS FOR YOUR HELP, TIME AND AVAILABILITY meme! ![]() You did an amazing work! And sorry if I was a "pain in the ass"! ![]() As I said to digigamer, both you guys should be part of the official programming team of the XWidget! |
Author: | meme [ October 19th, 2013, 8:47 pm ] |
Post subject: | Re: Show txt on a time ? |
Thank you jimking for you kind words.... happy to help. ![]() Quote: Tomorrow I will put the seconds adding the corrisponding lines in the script.. Not sure what you mean, but remember the update code only runs every minute at 0 seconds. |
Author: | Jimking [ October 20th, 2013, 2:45 am ] |
Post subject: | Re: Show txt on a time ? |
meme wrote: Not sure what you mean, but remember the update code only runs every minute at 0 seconds. I made txts with name "sec", sec00, sec01.....sec59, so I have light up for the secs too and here is the full script: Quote: function datetimecore1OnUpdate(Sender) { if (eval(datetimecore1.get("%Second")) == 0) { ResetAllColors(); eval(datetimecore1.get("%WeekEn")).Font.Color = rgba(138,0,178,255); eval(datetimecore1.get("%AMPM")).Font.Color = rgba(197,16,16,255); eval("num"+datetimecore1.get("%Hour0")).Font.Color = rgba(0,93,171,255); //hour0 eval("min"+datetimecore1.get("%Minute0")).Font.Color = rgba(0,20,171,255); //minute0 eval("sec"+datetimecore1.get("%Second0")).Font.Color = rgba(84,230,0,255); //second0 } } function ResetAllColors() // reset colors { for (var m=0; m<60; m++) // count up the minutes 0-59 { eval("min" + ("0" + m).slice(-2)).Font.Color = rgba(0,0,0,0); // reset all mins to transparent } for (var h=1; h<13; h++) // count up the hours 1-12 { eval("num" + ("0" + h).slice(-2)).Font.Color = rgba(0,0,0,0); // reset all nums to transparent } for (var s=0; s<60; s++) // count up the seconds 0-59 { eval("sec" + ("0" + s).slice(-2)).Font.Color = rgba(0,0,0,0); // reset all secs to transparent } eval(AM).Font.Color = rgba(0,0,0,0); eval(PM).Font.Color = rgba(0,0,0,0); eval(Monday).Font.Color = rgba(0,0,0,0); eval(Tuesday).Font.Color = rgba(0,0,0,0); eval(Wednesday).Font.Color = rgba(0,0,0,0); eval(Thursday).Font.Color = rgba(0,0,0,0); eval(Friday).Font.Color = rgba(0,0,0,0); eval(Saturday).Font.Color = rgba(0,0,0,0); eval(Sunday).Font.Color = rgba(0,0,0,0); } //To reduce system resources this code only need to run if the time/seconds = 0 //this could be add with an IF statement at the start of the function datetimecore1OnUpdate(Sender) function widgetOnLoad() { eval(datetimecore1.get("%WeekEn")).Font.Color = rgba(138,0,178,255); eval(datetimecore1.get("%AMPM")).Font.Color = rgba(197,16,16,255); eval("num"+datetimecore1.get("%Hour0")).Font.Color = rgba(0,93,171,255); //hour0 eval("min"+datetimecore1.get("%Minute0")).Font.Color = rgba(0,20,171,255); //minute0 eval("sec"+datetimecore1.get("%Second0")).Font.Color = rgba(84,230,0,255); //second0 } WITH RED COLOUR FOR THE EXTRA/NEW CODE Deleted the Quote: if (eval(datetimecore1.get("%Second")) == 0) do the job BUT the cpu once again is "Rising To The Sky"... I'm afraid that we can't combine both right...? |
Author: | qiancang [ October 20th, 2013, 3:05 am ] |
Post subject: | Re: Show txt on a time ? |
this widget looks great! if you can upload the widget,i think i can reduce the code and components. |
Author: | Jimking [ October 20th, 2013, 4:02 am ] | ||
Post subject: | Re: Show txt on a time ? | ||
qiancang wrote: this widget looks great! if you can upload the widget,i think i can reduce the code and components. Here qiancang: ![]() I left the "if (eval(datetimecore1.get("%Second")) == 0)" code so the seconds function doesn't work..
|
Author: | qiancang [ October 20th, 2013, 4:45 am ] |
Post subject: | Re: Show txt on a time ? |
how to handle the time 15:12:12? minute and second are the same, second text will cover the minute text. |
Author: | Jimking [ October 20th, 2013, 5:58 am ] |
Post subject: | Re: Show txt on a time ? |
Yes, as the original design (this is actually an Android lwp) the seconds will cover the minute txt but only for one sec when the values will be the same. That's why there are different colours for each part. At the beginning it seemed strange to me too but there is no other option I think.. The difficult part is to fix the cpu consumption with the secs active.. |
Author: | qiancang [ October 20th, 2013, 7:45 am ] | ||
Post subject: | Re: Show txt on a time ? | ||
high cpu usage only at starting. 2% ~ 3% after loading. you can lower the cpu usage by decreasing the glow effect softness
|
Author: | Jimking [ October 20th, 2013, 7:50 am ] | ||
Post subject: | Re: Show txt on a time ? | ||
Thanks qiancang but I notice two issues: 1) One txt appears deleted (between to AM and 12). Is the number 42 that is missing. 2) One second txt remains visible.. Look:
|
Author: | qiancang [ October 20th, 2013, 7:54 am ] |
Post subject: | Re: Show txt on a time ? |
i deleted all the "min" components ![]() the second issue does not happen on my PC |
Author: | Jimking [ October 20th, 2013, 7:59 am ] |
Post subject: | Re: Show txt on a time ? |
qiancang wrote: i deleted all the "min" components ![]() the second issue does not happen on my PC I see that you used the empty background image that I made it at at the beginning! About the num 42 I found it! You just used n41 twice! ![]() The sec issue why happpens to me..? Edit: I notice that the sec number that remains "on" is the sec AT THE MOMENT WHEN THE WIDGET LOADS. |
Author: | qiancang [ October 20th, 2013, 8:10 am ] |
Post subject: | Re: Show txt on a time ? |
jimking wrote: qiancang wrote: i deleted all the "min" components ![]() the second issue does not happen on my PC I see that you used the empty background image that I made it at at the beginning! About the num 42 I found it! You just used n41 twice! ![]() The sec issue why happpens to me..? Edit: I notice that the sec number that remains "on" is the sec AT THE MOMENT WHEN THE WIDGET LOADS. no such problem on my PC, maybe someone else can help to test this widget. |
Author: | Jimking [ October 20th, 2013, 8:14 am ] |
Post subject: | Re: Show txt on a time ? |
Ok qiancang. Thank you VERY MUCH for you help! ![]() |
Author: | Jimking [ October 20th, 2013, 12:19 pm ] |
Post subject: | Re: Show txt on a time ? |
meme what do you think..? Download the qiancang's widget to check the alternative code.. |
Author: | meme [ October 20th, 2013, 4:57 pm ] |
Post subject: | Re: Show txt on a time ? |
qiancang code is much more efficent than mine and the renaming of some components allows a easier way to address the components. Quote: I notice that the sec number that remains "on" is the sec AT THE MOMENT WHEN THE WIDGET LOADS. Tested qiancang code and I can see the problem you are describing, one of the second displays stays permantly on, as you said it seem to be the first one used when the widget starts. BUT it does not do it everytime you startup ![]() It will also do it if the widget is running and you select edit to start designer. ![]() Seems to be related to timing and system load, if others can not see this problem they my have faster PC's with more resources. ![]() |
Author: | qiancang [ October 20th, 2013, 9:08 pm ] | ||
Post subject: | Re: Show txt on a time ? | ||
one mistake: please replace if(s!=mm) with if(s!=m) in about line 55
|
Author: | Jimking [ October 21st, 2013, 1:32 am ] |
Post subject: | Re: Show txt on a time ? |
Ok qiancang did it! Here is what I notice: 1) The second number that remains "on" is the sec at the moment when the widgets loads. (yes, EVERY TIME) 2) Waiting for one minute when the seconds pass from the same number, then the "permanent" number disappears, all works ok for 4-5 secs but then one more num/text remains steady again.... In the meme's script there is this part: Quote: { ResetAllColors(); eval(datetimecore1.get("%WeekEn")).Font.Color = rgba(138,0,178,255); eval(datetimecore1.get("%AMPM")).Font.Color = rgba(197,16,16,255); eval("num"+datetimecore1.get("%Hour0")).Font.Color = rgba(0,93,171,255); //hour0 eval("min"+datetimecore1.get("%Minute0")).Font.Color = rgba(0,20,171,255); //minute0 eval("sec"+datetimecore1.get("%Second0")).Font.Color = rgba(84,230,0,255); //second0 } We can combine this with your script qiancang? Maybe this can fix the problem.. The fact is that using meme's script, to make the seconds work properly we need to delete the "if (eval(datetimecore1.get("%Second")) == 0)" part. Works (!) but consums a lot of ram.. With qiancang script all work too with minimum consumption but there is this issue with the seconds.. |
Author: | Jimking [ October 21st, 2013, 2:05 am ] |
Post subject: | Re: Show txt on a time ? |
Guys here is another script that digigamer sent me on DA .The seconds function is missing but we can try to add it and see if works: Quote: //store reference to last, reset display on change
var lastmin = null; var lastweek = null; var lasthalf = null; var lasthour = null; function datetimecore1OnUpdate(Sender) { thisweek = datetimecore1.get("%WeekEn"); thismin = datetimecore1.get("%Minute0"); thishalf = datetimecore1.get("%AMPM"); thishour = datetimecore1.get("%Hour0"); //act if changed if(lastmin != thismin) { if(lastmin != null) { eval("min"+lastmin).Effect.Glow.Enabled = false; eval("min"+lastmin).Font.Color = rgba(0,0,0,255); } eval("min"+thismin).Font.Color = rgba(0,20,171,255); eval("min"+thismin).Effect.Glow.Enabled = true; //minute0 } if(lasthalf != thishalf) { if(lasthalf != null) { eval(lasthalf).Effect.Glow.Enabled = false; eval(lasthalf).Font.Color = rgba(0,0,0,255); } eval(thishalf).Effect.Glow.Enabled = true; eval(thishalf).Font.Color = rgba(197,16,16,255); } if(lasthour != thishour) { if(lasthalf != null) { eval("h"+lasthour).Effect.Glow.Enabled = false; eval("h"+lasthour).Font.Color = rgba(0,0,0,255); } eval("h"+thishour).Effect.Glow.Enabled = true; eval("h"+thishour).Font.Color = rgba(0,93,171,255); } if(lastweek != thisweek) { if(lastweek != null) { eval(lastweek).Effect.Glow.Enabled = false; eval(lastweek).Font.Color = rgba(0,0,0,255); } eval(thisweek).Effect.Glow.Enabled = true; eval(thisweek).Font.Color = rgba(41,1,214,255); } lastmin = thismin; lastweek = thisweek; lasthalf = thishalf; lasthour = thishour; } |
Author: | Jimking [ October 21st, 2013, 3:45 am ] |
Post subject: | Re: Show txt on a time ? |
I start a third test widget using the code by digigamer. I'm starting to add the seconds txts in the widget and add the extra similar fields in the script for the seconds... Let's see how the widget will work.. |
Author: | digigamer [ October 21st, 2013, 3:49 am ] |
Post subject: | Re: Show txt on a time ? |
So this is what you asked! Isn't it? With blinking seconds??? Another version: Shows seconds in green, minutes in royal blue and avoids conflicts between seconds and minutes falling at the same time ex: 04:16:16 PM Attachment: (Default Image removed to save my data... currently running mobile broadband, costly. Just generate a new one.) |
Author: | Jimking [ October 21st, 2013, 4:03 am ] |
Post subject: | Re: Show txt on a time ? |
digigamer wrote: So this is what you asked! Isn't it? With blinking seconds??? Another version: Shows seconds in green, minutes in royal blue and avoids conflicts between seconds and minutes falling at the same time ex: 04:16:16 PM Hahaha I knew it!! DG you're my hero! ![]() The default image was already in the folder so there is no problem add a new one and the defaut violet colour for the week days can be changed easily.. (I hope changing one colour will don't break the function again! ![]() An enormous THANK YOU digigamer!!! And meme and qiancang of course! Thank you all guys and sorry to be a trouble with my widget! |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |