ajsraceway <
ajsra...@gmail.com> probably said:
>If you run this as a shell command: dumpsys battery
>(*you need root*, by the way)
Interesting, good to know.
>What I do, though, is change the shell command to just get the number:
> dumpsys battery | grep "temperature" | awk '{ print $2 }'
To remove one stage of that pipeline and stop processing input once
the line has been found:
dumpsys battery | awk '/temperature:/ { print $2; exit }'
or in C rather than 10*C:
dumpsys battery | awk '/temperature:/ { print $2 / 10; exit }'
>I store the output in something like %BATTERYTEMP, then, to get the
>temperature in Fahrenheit, I convert like this: round(%BATTERYTEMP * 0.18
>+ 32.0)
or in F:
dumpsys battery | awk '/temperature:/ { print $2 * 0.18 + 32; exit }'
Just reduces the number of operations and processes, which can help if
you're doing something frequently enough.
P.
--
pir