Fixed code style

This commit is contained in:
Lorenz Meier
2014-02-05 09:36:22 +01:00
parent 94b162d0e0
commit 399d59483e
+13 -6
View File
@@ -556,7 +556,7 @@ MK::task_main()
} }
} }
if(!_overrideSecurityChecks) { if (!_overrideSecurityChecks) {
/* don't go under BLCTRL_MIN_VALUE */ /* don't go under BLCTRL_MIN_VALUE */
if (outputs.output[i] < BLCTRL_MIN_VALUE) { if (outputs.output[i] < BLCTRL_MIN_VALUE) {
@@ -612,13 +612,16 @@ MK::task_main()
esc.esc[i].esc_current = (uint16_t) Motor[i].Current; esc.esc[i].esc_current = (uint16_t) Motor[i].Current;
esc.esc[i].esc_rpm = (uint16_t) 0; esc.esc[i].esc_rpm = (uint16_t) 0;
esc.esc[i].esc_setpoint = (float) Motor[i].SetPoint_PX4; esc.esc[i].esc_setpoint = (float) Motor[i].SetPoint_PX4;
if (Motor[i].Version == 1) { if (Motor[i].Version == 1) {
// BLCtrl 2.0 (11Bit) // BLCtrl 2.0 (11Bit)
esc.esc[i].esc_setpoint_raw = (uint16_t) (Motor[i].SetPoint<<3) | Motor[i].SetPointLowerBits; esc.esc[i].esc_setpoint_raw = (uint16_t)(Motor[i].SetPoint << 3) | Motor[i].SetPointLowerBits;
} else { } else {
// BLCtrl < 2.0 (8Bit) // BLCtrl < 2.0 (8Bit)
esc.esc[i].esc_setpoint_raw = (uint16_t) Motor[i].SetPoint; esc.esc[i].esc_setpoint_raw = (uint16_t) Motor[i].SetPoint;
} }
esc.esc[i].esc_temperature = (uint16_t) Motor[i].Temperature; esc.esc[i].esc_temperature = (uint16_t) Motor[i].Temperature;
esc.esc[i].esc_state = (uint16_t) Motor[i].State; esc.esc[i].esc_state = (uint16_t) Motor[i].State;
esc.esc[i].esc_errorcount = (uint16_t) 0; esc.esc[i].esc_errorcount = (uint16_t) 0;
@@ -665,7 +668,7 @@ MK::mk_servo_arm(bool status)
unsigned int unsigned int
MK::mk_check_for_blctrl(unsigned int count, bool showOutput, bool initI2C) MK::mk_check_for_blctrl(unsigned int count, bool showOutput, bool initI2C)
{ {
if(initI2C) { if (initI2C) {
I2C::init(); I2C::init();
} }
@@ -719,7 +722,7 @@ MK::mk_check_for_blctrl(unsigned int count, bool showOutput, bool initI2C)
} }
if(!_overrideSecurityChecks) { if (!_overrideSecurityChecks) {
if (foundMotorCount != 4 && foundMotorCount != 6 && foundMotorCount != 8) { if (foundMotorCount != 4 && foundMotorCount != 6 && foundMotorCount != 8) {
_task_should_exit = true; _task_should_exit = true;
} }
@@ -748,8 +751,8 @@ MK::mk_servo_set(unsigned int chan, short val)
tmpVal = 0; tmpVal = 0;
} }
Motor[chan].SetPoint = (uint8_t)(tmpVal>>3)&0xff; Motor[chan].SetPoint = (uint8_t)(tmpVal >> 3) & 0xff;
Motor[chan].SetPointLowerBits = ((uint8_t)tmpVal%8)&0x07; Motor[chan].SetPointLowerBits = ((uint8_t)tmpVal % 8) & 0x07;
if (_armed == false) { if (_armed == false) {
Motor[chan].SetPoint = 0; Motor[chan].SetPoint = 0;
@@ -1003,6 +1006,7 @@ MK::pwm_ioctl(file *filp, int cmd, unsigned long arg)
if (arg < 2150) { if (arg < 2150) {
Motor[cmd - PWM_SERVO_SET(0)].RawPwmValue = (unsigned short)arg; Motor[cmd - PWM_SERVO_SET(0)].RawPwmValue = (unsigned short)arg;
mk_servo_set(cmd - PWM_SERVO_SET(0), scaling(arg, 1010, 2100, 0, 2047)); mk_servo_set(cmd - PWM_SERVO_SET(0), scaling(arg, 1010, 2100, 0, 2047));
} else { } else {
ret = -EINVAL; ret = -EINVAL;
} }
@@ -1182,6 +1186,7 @@ mk_start(unsigned motors, char *device_path)
if (OK == g_mk->init(motors)) { if (OK == g_mk->init(motors)) {
warnx("[mkblctrl] scanning i2c3...\n"); warnx("[mkblctrl] scanning i2c3...\n");
ret = g_mk->mk_check_for_blctrl(8, false, true); ret = g_mk->mk_check_for_blctrl(8, false, true);
if (ret > 0) { if (ret > 0) {
return OK; return OK;
} }
@@ -1199,6 +1204,7 @@ mk_start(unsigned motors, char *device_path)
if (OK == g_mk->init(motors)) { if (OK == g_mk->init(motors)) {
warnx("[mkblctrl] scanning i2c1...\n"); warnx("[mkblctrl] scanning i2c1...\n");
ret = g_mk->mk_check_for_blctrl(8, false, true); ret = g_mk->mk_check_for_blctrl(8, false, true);
if (ret > 0) { if (ret > 0) {
return OK; return OK;
} }
@@ -1316,6 +1322,7 @@ mkblctrl_main(int argc, char *argv[])
} }
exit(0); exit(0);
} else { } else {
errx(1, "MK-BLCtrl driver already running"); errx(1, "MK-BLCtrl driver already running");
} }