It is currently March 29th, 2024, 9:36 am

Need help to code a USB Meter - Please

Get help with creating, editing & fixing problems with skins
dfghrngsdkg
Posts: 43
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

Post by dfghrngsdkg »

balala wrote: October 3rd, 2019, 5:18 pm Which meters are you talking about? Because in the last package you've posted (but in fact nor in the previous one) there are no height set to H=10 nor in Drive3_USB.inc, nor in Drive4_USB.inc.
I downloaded: Drive++_Tested_0.2.rmskin which eclectic-tech provided. He rewrote some parts and added some too, incl. "[Spacer]" at the bottom of the Drive3/4/5_USB.inc files.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help to code a USB Meter - Please

Post by balala »

dfghrngsdkg wrote: October 3rd, 2019, 5:31 pm I downloaded: Drive++_Tested_0.2.rmskin which eclectic-tech provided. He rewrote some parts and added some too, incl. "[Spacer]" at the bottom of the Drive3/4/5_USB.inc files.
Ok, got it.
There is a small problem which probably eclectic-tech missed: there are three [Spacer] meters at the end of each of the Drive3_USB.inc, Drive4_USB.inc and Drive5_USB.inc files. Because all these files are included into the skin, and more sections with the same name can't be used into one skin, the skin shows only one of those meters.
The simplest solution is to rename the meters accordingly to the file where it is placed. So rename the [Spacer] as [Spacer3] into Drive3_USB.inc, as [Spacer4] into Drive4_USB.inc and as [Spacer5] into Drive5_USB.inc. This way you'll have three meters with distinct names and from now on you can set the desired height to each of them and these height will be applied if you refresh the skin.
Keep in mind that you never can use more sections with the same name into one single skin, same way as you also can't have twice the same option into one single section.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help to code a USB Meter - Please

Post by balala »

And one more problem I just discovered in the code: the [MeasureColorBar3], [MeasureColorBar4] and [MeasureColorBar5] measures within the Drive3_USB.inc, Drive4_USB.inc and Drive5_USB.inc files give a Calc: Division by 0 error message in the log when the skin is refreshed. This is caused by the fact that when you refresh the skin, the [MeasureTotalDrive3], [MeasureTotalDrive4] and [MeasureTotalDrive5] measures, used as divider in the formulas of the mentioned measures don't have yet their values, being zero all three. But as probably you remember from the math classes, you can't divide by zero, this always leads to an error message.
There is an extremely simple way to avoid these messages: you have to modify the formulas in a way to not divide by zero. Define an extremely small, but not zero variable into the [Variables] section of the skin, then add it to all three dividers of all three formulas, in all three files. So declare first the variable into the [Variables] section of the main file:

Code: Select all

[Variables]
...
Const=0.0001
Then add this variable to all three dividers in all three included files:

Code: Select all

[MeasureColorBar3]
...
Formula=( MeasureFreeDrive3 / ( MeasureTotalDrive3 + #Const# ))

Code: Select all

[MeasureColorBar4]
...
Formula=( MeasureFreeDrive4 / ( MeasureTotalDrive4 + #Const# ))

Code: Select all

[MeasureColorBar5]
...
Formula=( MeasureFreeDrive5 / ( MeasureTotalDrive5 + #Const# ))
dfghrngsdkg
Posts: 43
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

Post by dfghrngsdkg »

Hey balala,

Thank you for clarifying things!

1. Me when you pointed out: "So rename the [Spacer] as [Spacer3] into Drive3_USB.inc, as [Spacer4] into Drive4_USB.inc and as [Spacer5] into Drive5_USB.inc."
68523_23562140_0a875fa577.jpg
OF COURSE! Why else I have to use 1,2,3,etc. all the time? Eww!

2. "And one more problem I just discovered in the code: the [MeasureColorBar3], [MeasureColorBar4] and [MeasureColorBar5] measures within the Drive3_USB.inc, Drive4_USB.inc and Drive5_USB.inc files give a Calc: Division by 0 error message in the log when the skin is refreshed.". Hmm, honestly I didn't noticed any problems as everything was functioning too. Might be because I am not aware of this because I sometimes just copy whole sets of code without knowing its relations or specialties in specific situations. I'll change that. "But as probably you remember from the math classes, you can't divide by zero, [...]." Yes, that's why I probably so bad at coding. :oops:

"Define an extremely small, but not zero variable". Ahh, Yes the infamous infinitesimal calculus. Have some love-hate relationship with it. To keep my reputation I can say I was more into Matrix.

And "Sorry" for my late reply, right now I am a bit busy with other stuff so I took a break from this for two days, but not without benefiting from it!
The '[Spacer]" is WOAHH! quite a powerful tool when getting it to work! So thanks to eclectic-tech for bringing this up. Best part> In the beginning I had problems in anchoring the F: and G: Drives into position even when using the "[Spacer]" so I came up with a quite handy solution to get the way I want it to be. Needs a bit more testing, but it is promising! I'll post my result here later on. Whit later on I mean in 2 months from now because I am currently on a leave on short-notice and therefore more focused on packing my stuff. And while away without a chance to access a PC nor the time to sit and code I can't do a thing* - maybe only on paper. So If I not reply then because of this but rest assured that -when back- I'll reach out, no doubt! Until then I remain with best regards. :welcome:

* See jsmorley, a Rainmeter for unrooted Mobiles or Tablet would be a thing, no?
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help to code a USB Meter - Please

Post by balala »

dfghrngsdkg wrote: October 5th, 2019, 1:25 pm OF COURSE! Why else I have to use 1,2,3,etc. all the time? Eww!
As I said, there isn't possible to have two or more sections with the same name, but probably you already know this.
dfghrngsdkg wrote: October 5th, 2019, 1:25 pm Yes, that's why I probably so bad at coding. :oops:
No, you're not. We all miss sometimes things that others see from the first moment. There is nothing wrong with this.
You have to get used to always check the Log, where these error messages tell you what's wrong with your code and you can fix the errors.
dfghrngsdkg wrote: October 5th, 2019, 1:25 pm And "Sorry" for my late reply, right now I am a bit busy with other stuff so I took a break from this for two days, but not without benefiting from it!
No problem, we all are replying only when we have enough time. Don't worry...
dfghrngsdkg wrote: October 5th, 2019, 1:25 pm And while away without a chance to access a PC nor the time to sit and code I can't do a thing* - maybe only on paper.
Obviously it's not possible to do anything with Rainmeter on paper. Time and energy are required to properly code.
dfghrngsdkg wrote: October 5th, 2019, 1:25 pm * See jsmorley, a Rainmeter for unrooted Mobiles or Tablet would be a thing, no?
I suppose this is possible only if the mobile or the tablet is running Windows. Rainmeter doesn't run on Android or any other OS.