Maurício Vilarinho Maurício Vilarinho - 1 year ago 67
C Question

You just need to think a little bit to help me find the solution

I have rpm, max_rpm and a variable x.

When rpm aproaches max_rpm -> x tends to 0

When rpm aproaches 0 -> x tends to 255

x = (rpm/rpm_max)*255;

I have the exact opposite. What can I do? I'm really dumb to figure it out.

obe obe
Answer Source

If I understood your question correctly then maybe this?

x = (1 - rpm/rpm_max)*255

UPDATE: as mentioned by CandiedOrange - rpm and rpm_max need to be float or double for it to work. Otherwise the value of x would simply switch back and forth between 0 and 255.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download