batterie.py

Created by antarctus

Created on February 27, 2022

788 Bytes

Affichage graphique du niveau de la batterie.
Ne marche qu’avec Upsilon, une autre version de l’OS de la calculatrice.
Montre également une estimation précise tu temps d’utilisation encore disponible et du temps de chargement restant.


from kandinsky import *
from ion import *

niv=0
for i in range(20):
  niv+=battery()/20

niv=(niv-3.6)*1.66+(0.085*battery_ischarging())
c=[(255,0,0),(255,200,0),(0,255,0)][(niv>0.2)+(niv>0.5)]
txt=str(int(niv*100+0.5))+"%"
t1=21.5*niv
t2=5-(5*niv)
t1=(int(t1),int((t1-int(t1))*60))
t2=(int(t2),int((t2-int(t2))*60))


fill_rect(10,20,300,140,(0,)*3)
fill_rect(15,25,290,130,(255,)*3)
fill_rect(305,75,10,30,(0,)*3)

fill_rect(15,25,int(290*niv),130,c)
if niv>0.2:
  draw_string(txt,int(290*niv)-20,78,(255,)*3,c)
else:
  draw_string(txt,int(290*niv)+20,78)

draw_string("Temps estime :",10,162)
fill_rect(10,177,140,1,(0,)*3)

draw_string("- d'utilisation: "+str(t1[0])+"h "+str(t1[1])+"m",10,182)
draw_string("- de chargement: "+str(t2[0])+"h "+str(t2[1])+"m",10,202)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.