pijuice.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:PiJuice 作者: PiSupply 项目源码 文件源码
def GetBatteryProfile(self):
        ret = self.interface.ReadData(self.BATTERY_PROFILE_CMD, 14)
        if ret['error'] != 'NO_ERROR':
            return ret
        else:
            d = ret['data']
            if all(v == 0 for v in d):
                return {'data':'INVALID', 'error':'NO_ERROR'} 
            profile = {}
            profile['capacity'] = (d[1] << 8) | d[0]
            profile['chargeCurrent'] = d[2] * 75 + 550
            profile['terminationCurrent'] = d[3] * 50 + 50
            profile['regulationVoltage'] = d[4] * 20 + 3500
            profile['cutoffVoltage'] = d[5] * 20
            profile['tempCold'] = ctypes.c_byte(d[6]).value
            profile['tempCool'] = ctypes.c_byte(d[7]).value
            profile['tempWarm'] = ctypes.c_byte(d[8]).value
            profile['tempHot'] = ctypes.c_byte(d[9]).value
            profile['ntcB'] = (d[11] << 8) | d[10]
            profile['ntcResistance'] = ((d[13] << 8) | d[12]) * 10
            return {'data':profile, 'error':'NO_ERROR'}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号