- if pitch > self.pitch_handicap_limit*pi/180:
- val = (100.0/self.pitch_handicap_strength)*abs(pitch)*180/pi
- self.set_motor_handicap(int(val), 0)
- elif pitch < -self.pitch_handicap_limit*pi/180:
- val = (100.0/self.pitch_handicap_strength)*abs(pitch)*180/pi
- self.set_motor_handicap(0, int(val))
- else:
- self.set_motor_handicap(0, 0)
+ if pitch > self.rollover_protect_limit*pi/180:
+ self.bMotorManual = True
+ i2c_write_reg(0x50, 0x3, struct.pack(">h", self.rollover_protect_pwm))
+ i2c_write_reg(0x50, 0x7, struct.pack(">h", self.rollover_protect_pwm))
+ elif pitch < -self.rollover_protect_limit*pi/180:
+ self.bMotorManual = True
+ i2c_write_reg(0x50, 0x1, struct.pack(">h", -self.rollover_protect_pwm))
+ i2c_write_reg(0x50, 0x5, struct.pack(">h", -self.rollover_protect_pwm))
+ elif self.bMotorManual:
+ i2c_write_reg(0x50, 0x1, struct.pack(">hhhh", 0, 0, 0, 0))
+ self.bMotorManual = False