pijuice.py 文件源码

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

项目:PiJuice 作者: PiSupply 项目源码 文件源码
def SetCustomBatteryProfile(self, profile):
        d = [0x00] * 14
        try:
            c = profile['capacity']
            d[0] = c&0xFF
            d[1] = (c >> 8)&0xFF
            d[2] = int(round((profile['chargeCurrent'] - 550) / 75))
            d[3] = int(round((profile['terminationCurrent'] - 50) / 50))
            d[4] = int(round((profile['regulationVoltage'] - 3500) / 20))
            d[5] = int(round(profile['cutoffVoltage'] / 20))
            d[6] = ctypes.c_ubyte(profile['tempCold']).value
            d[7] = ctypes.c_ubyte(profile['tempCool']).value
            d[8] = ctypes.c_ubyte(profile['tempWarm']).value
            d[9] = ctypes.c_ubyte(profile['tempHot']).value
            B = profile['ntcB']
            d[10] = B&0xFF
            d[11] = (B >> 8)&0xFF
            R = profile['ntcResistance'] / 10
            d[12] = R&0xFF
            d[13] = (R >> 8)&0xFF
        except:
            return {'error':'BAD_ARGUMENT'}
        print d
        return self.interface.WriteDataVerify(self.BATTERY_PROFILE_CMD, d, 0.2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号