I'm using the Crestron Mobile V3.4 with a particular gui. I have a 16bit analog value coming in (volume gauge). I would like this to be displayed as a percentage 0-100% on a serial join. I already have a function triggering when the join changes that uses parseInt to return a value. Is there a easy way to simply convert that into a percentage?**Please include as much software version information as possible. This ensures that other users and CommandFusion staff can provide a helpful answer as quickly as possible.** - Please Delete this line BEFORE posting.
--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
It depends on what you want to do with the value once you get it. If you want to use the value to control a slider then you need to scale it to be 0-65535. If you want to show it as a percentage you need it to be scaled 0-100.
I do both for my lighting system. My lighting system returns 0-100 so I only need to scale it for a slider. (divide by 100, multiply by 65535 or just multiply by 655.35)
The volume return from my A/V system is more complex. It returns a value from -80 to +20. In that case two things need to be done. First the origin needs to be reset by adding 80 to the returned value producing a value in the range 0-100. The value can then be divided by 100 to produce a fractional value in the range 0-1. In Javascript all arithmetic is handles internally in floating point so the system is more accurate than needed for the display of volumes and we need not worry about rounding errors.