Post Reply 
I have a way to measure battery power
06-28-2017, 12:05 PM
Post: #10
RE: I have a way to measure battery power
(06-27-2017 10:43 AM)webmasterpdx Wrote:  I wrote a utility to give me the value and so far, it's given me 100% and 80%, so it's not following the internal hardware values....but who cares as long as it's close. Here is my utility...
Note that my not equal symbol isn't on my laptop keyboard, so I'm showing it below as <>, but I used the not equal symbol from shift-6.
Enjoy....

EXPORT BATVAL()
BEGIN
LOCAL x,y,c,d;
x:=315;
y:=14;
d:=GETPIX_P(x,y);
IF d<>#8400h THEN // Green value that's used to indicate power
RETURN 0; // if first pixel is not green, no power
END;

FOR y FROM 13 DOWNTO 3 STEP 1 DO // check the rest of the pixels
c:=GETPIX_P(x,y);
IF c<>d THEN // change in pixel color...break out of loop

IF y==3 THEN // If reached 3, means it's full of green = 100%
RETURN 100;
ELSE // otherwise, base on percentage filled
y:=14-y;
y:=y*10;
RETURN y;
END;

END; // if y==3....
d:=c;
END; // FOR y loop
// Never gets here because y==3 is border of battery icon so color change
END; // BEGIN-END

Do you really need a loop? There are only 4 possible levels so test the top row. If it's green, you're at 100%, test the next level, if green, you're at 75%, the next level is 50% and the last level is 25% Of course those levels will have to be determined but it shouldn't be too hard to do. You can even test certain pixels in the lightning bolt for yellow to know if the calculator is charging or not.

Tom L
...other than that, Mrs. Lincoln, what did you think of the play?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: I have a way to measure battery power - toml_12953 - 06-28-2017 12:05 PM



User(s) browsing this thread: 1 Guest(s)