modmypi / PiModules

GNU General Public License v3.0
54 stars 26 forks source link

Error : 'datapercentage' referenced before assignment #34

Open VigibotDev opened 6 years ago

VigibotDev commented 6 years ago

Same problem with python2 / python2.7

(root|~/PiModules/pico_status) python pico_status_hv3.0.py

***********************************
      UPS PIco HV3.0A Status
***********************************

  UPS PIco Firmware.....: ec
  UPS PIco Bootloader...: 53
  UPS PIco PCB Version..: 43
  UPS PIco BAT Version..: ERROR
  UPS PIco BAT Runtime..: 2 MIN
  UPS PIco r232 State...: OFF

  Powering Mode.........: RPi POWERED
  BAT Percentage........:
Traceback (most recent call last):
  File "pico_status_hv3.0.py", line 194, in <module>
    print " ","BAT Percentage........:",bat_percentage(),"%"
  File "pico_status_hv3.0.py", line 95, in bat_percentage
    return datapercentage
UnboundLocalError: local variable 'datapercentage' referenced before assignment

With python3 / 3.5

(root|~/PiModules/pico_status) python3 pico_status_hv3.0.py
  File "pico_status_hv3.0.py", line 181
    print " "
            ^
SyntaxError: Missing parentheses in call to 'print'
VigibotDev commented 6 years ago

There is a bug inside the python script when the chemistry type is not set.

Unlimited bat runtime (I need this but clean shutdown when bat is empty) :

(root|~/PiModules/pico_status) i2cset -y 1 0x6b 0x01 0xff

I need to set LiPo on Stack/Top/Plus version ? Documentation is bad what is the non-Stack/Top Plus version ?

(root|~/PiModules/pico_status) i2cset -y 1 0x6b 0x07 0x53

or

(root|~/PiModules/pico_status) i2cset -y 1 0x6b 0x07 0x50

?

Documentation is too random for this product. It's very hard to get clear information.

(root|~/PiModules/pico_status) python pico_status_hv3.0.py

***********************************
      UPS PIco HV3.0A Status
***********************************

  UPS PIco Firmware.....: ec
  UPS PIco Bootloader...: 53
  UPS PIco PCB Version..: 43
  UPS PIco BAT Version..: LiPO (ASCII: P)
  UPS PIco BAT Runtime..: TIMER DISABLED
  UPS PIco r232 State...: OFF

  Powering Mode.........: RPi POWERED
  BAT Percentage........: 133.333333333 %
  BAT Voltage...........: 4.4 V
  RPi Voltage...........: 5.0 V
  NTC1 Temperature......: 45 C
  TO-92 Temperature.....: 10 C
  Extended Voltage......: 0.0 V
  A/D2 Voltage..........: 0.0 V

  PIco FAN Mode.........: ERROR
  PIco FAN State........: OFF
  PIco FAN Speed........: 320.0 RPM

***********************************
         Powered by PiCo
***********************************
VigibotDev commented 6 years ago

133.333333333 % WTF ????

Never convert a voltage to a bat percent !!!! you must use current integration + auto-calibration algorithm to get the a real bat % like any smartphone or laptop !!!!