For sure it is possible with a lua script as well, however for first, I'd try with simple Rainmeter code. As you figured out by yourself, the lua approach has the advantage of needing a single function, however let's see now the Rainmeter approach. Later we can switch to lua.Each of the 8 sectors is one of my CPU core and shows some data about it.
I would like to make them to change color from blue to red to show the core temp, and change the size (the external diameter) to show the core load.
Given that each sector has to make the same math, i THINK that some common functions could be a better solution than rewriting everything 8 times. And, for what i've understand, functions are a LUA scripts thing.
So, theoretically the disadvantage of the following approach is that you should have to calculate the eight color codes on eight different measures. But this is not needed, all calculation can be done on the apropriate meters, no need to add extra measures. Since you didn't share your code, I post a sample, using Image meters. Your meters most probably are some Shape meters, however not knowing them I used the most simple meter type, the Image meters. If we get this working as expected, using Shape meters is a much simpler task.
Let's assume you have some CPU measures, to get the CPU usage of each of the cores. Something like this:
Code:
[MeasureCPU1]Measure=CPUProcessor=1
Using the above measure, the Image meter associated with the first code might look this way:
Code:
[MeterCPU1]...SolidColor=(255*((Clamp([MeasureCPU1],(#Min#+2*(#Max#-#Min#)/3),#Max#))-(#Min#+2*(#Max#-#Min#)/3))/(#Max#-(#Min#+2*(#Max#-#Min#)/3))),(([MeasureCPU1]<=(#Min#+(#Max#-#Min#)/3))?(255*(((Clamp([MeasureCPU1],#Min#,(#Min#+(#Max#-#Min#)/3)))-#Min#)/((#Max#-#Min#)/3))):(255*((100-Clamp([MeasureCPU1],(#Min#+2*(#Max#-#Min#)/3),#Max#)-#Min#)/#Min#))),(255*((Clamp((100-[MeasureCPU1]),(#Min#+(#Max#-#Min#)/3),(#Min#+2*(#Max#-#Min#)/3))-(#Max#-#Min#)/3)-#Min#)/((#Max#-#Min#)/3))DynamicVariables=1
In order this formula to work, you have to define in the [Variables] section the Min and Max variables, which you were talking about. For instance:
Code:
[Variables]Min=20Max=80
Try out this code and let me know if you could get it working. If you couldn't, post the code of your skin please, with both, the measures returning the CPU usage and the meters showing the usage, to can better advice.
Note that this solution doesn't change the size of the meters so far, but this will be the next step. For now test only the colors, please.
Statistics: Posted by balala — December 8th, 2024, 9:07 pm