I have a way to measure battery power
06-28-2017, 12:05 PM
Post: #10
 toml_12953 Senior Member Posts: 2,146 Joined: Dec 2013
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
Cui bono?
 « Next Oldest | Next Newest »

 Messages In This Thread I have a way to measure battery power - webmasterpdx - 06-25-2017, 05:03 AM RE: I have a way to measure battery power - cyrille de brĂ©bisson - 06-26-2017, 05:30 AM RE: I have a way to measure battery power - webmasterpdx - 06-27-2017, 10:43 AM RE: I have a way to measure battery power - toml_12953 - 06-28-2017 12:05 PM RE: I have a way to measure battery power - Tim Wessman - 06-28-2017, 02:59 PM RE: I have a way to measure battery power - toml_12953 - 06-28-2017, 05:38 PM RE: I have a way to measure battery power - DrD - 06-27-2017, 11:21 AM RE: I have a way to measure battery power - TravisE - 06-27-2017, 09:13 PM RE: I have a way to measure battery power - webmasterpdx - 06-28-2017, 01:14 AM RE: I have a way to measure battery power - DrD - 06-28-2017, 10:50 AM RE: I have a way to measure battery power - webmasterpdx - 06-28-2017, 11:02 AM RE: I have a way to measure battery power - DrD - 06-28-2017, 11:20 AM RE: I have a way to measure battery power - webmasterpdx - 06-28-2017, 01:28 PM RE: I have a way to measure battery power - webmasterpdx - 06-28-2017, 01:25 PM RE: I have a way to measure battery power - StephenG1CMZ - 06-28-2017, 04:45 PM RE: I have a way to measure battery power - StephenG1CMZ - 10-28-2017, 02:57 PM RE: I have a way to measure battery power - webmasterpdx - 06-29-2017, 01:54 AM RE: I have a way to measure battery power - toml_12953 - 06-29-2017, 02:46 AM RE: I have a way to measure battery power - StephenG1CMZ - 06-29-2017, 05:35 AM RE: I have a way to measure battery power - webmasterpdx - 06-29-2017, 06:34 AM RE: I have a way to measure battery power - webmasterpdx - 07-01-2017, 09:03 AM RE: I have a way to measure battery power - Dieter - 07-01-2017, 09:57 AM RE: I have a way to measure battery power - webmasterpdx - 07-01-2017, 10:37 AM RE: I have a way to measure battery power - webmasterpdx - 07-01-2017, 06:37 PM RE: I have a way to measure battery power - webmasterpdx - 07-01-2017, 07:13 PM

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