Post Reply 
I have a way to measure battery power
06-27-2017, 10:43 AM
Post: #3
RE: I have a way to measure battery power
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
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 - webmasterpdx - 06-27-2017 10:43 AM



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