Camera trigger: fix formatting

This commit is contained in:
Lorenz Meier
2015-07-05 12:05:59 +02:00
parent a02319e901
commit 65d035a892
+27 -36
View File
@@ -194,11 +194,11 @@ CameraTrigger::start()
if (_polarity == 0) { if (_polarity == 0) {
stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 1); // GPIO pin pull high stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 1); // GPIO pin pull high
}
else if(_polarity == 1) { } else if (_polarity == 1) {
stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 0); // GPIO pin pull low stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 0); // GPIO pin pull low
}
else { } else {
warnx(" invalid trigger polarity setting. stopping."); warnx(" invalid trigger polarity setting. stopping.");
stop(); stop();
} }
@@ -231,26 +231,20 @@ CameraTrigger::poll(void *arg)
orb_copy(ORB_ID(vehicle_command), trig->_vcommand_sub, &trig->_command); orb_copy(ORB_ID(vehicle_command), trig->_vcommand_sub, &trig->_command);
if(trig->_command.command == vehicle_command_s::VEHICLE_CMD_DO_TRIGGER_CONTROL) if (trig->_command.command == vehicle_command_s::VEHICLE_CMD_DO_TRIGGER_CONTROL) {
{ if (trig->_command.param1 < 1) {
if(trig->_command.param1 < 1) if (trig->_trigger_enabled) {
{
if(trig->_trigger_enabled)
{
trig->_trigger_enabled = false ; trig->_trigger_enabled = false ;
} }
}
else if(trig->_command.param1 >= 1) } else if (trig->_command.param1 >= 1) {
{ if (!trig->_trigger_enabled) {
if(!trig->_trigger_enabled)
{
trig->_trigger_enabled = true ; trig->_trigger_enabled = true ;
} }
} }
// Set trigger rate from command // Set trigger rate from command
if(trig->_command.param2 > 0) if (trig->_command.param2 > 0) {
{
trig->_integration_time = trig->_command.param2; trig->_integration_time = trig->_command.param2;
param_set(trig->integration_time, &(trig->_integration_time)); param_set(trig->integration_time, &(trig->_integration_time));
} }
@@ -260,9 +254,8 @@ CameraTrigger::poll(void *arg)
if (!trig->_trigger_enabled) { if (!trig->_trigger_enabled) {
hrt_call_after(&trig->_pollcall, 1e6, (hrt_callout)&CameraTrigger::poll, trig); hrt_call_after(&trig->_pollcall, 1e6, (hrt_callout)&CameraTrigger::poll, trig);
return; return;
}
else } else {
{
engage(trig); engage(trig);
hrt_call_after(&trig->_firecall, trig->_activation_time * 1000, (hrt_callout)&CameraTrigger::disengage, trig); hrt_call_after(&trig->_firecall, trig->_activation_time * 1000, (hrt_callout)&CameraTrigger::disengage, trig);
@@ -273,11 +266,13 @@ CameraTrigger::poll(void *arg)
if (trig->_trigger_pub != nullptr) { if (trig->_trigger_pub != nullptr) {
orb_publish(ORB_ID(camera_trigger), trig->_trigger_pub, &trig->_trigger); orb_publish(ORB_ID(camera_trigger), trig->_trigger_pub, &trig->_trigger);
} else { } else {
trig->_trigger_pub = orb_advertise(ORB_ID(camera_trigger), &trig->_trigger); trig->_trigger_pub = orb_advertise(ORB_ID(camera_trigger), &trig->_trigger);
} }
hrt_call_after(&trig->_pollcall, (trig->_transfer_time + trig->_integration_time)*1000, (hrt_callout)&CameraTrigger::poll, trig); hrt_call_after(&trig->_pollcall, (trig->_transfer_time + trig->_integration_time) * 1000,
(hrt_callout)&CameraTrigger::poll, trig);
} }
} }
@@ -290,12 +285,10 @@ CameraTrigger::engage(void *arg)
stm32_configgpio(GPIO_GPIO0_OUTPUT); stm32_configgpio(GPIO_GPIO0_OUTPUT);
if(trig->_polarity == 0) // ACTIVE_LOW if (trig->_polarity == 0) { // ACTIVE_LOW
{
stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 0); stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 0);
}
else if(trig->_polarity == 1) // ACTIVE_HIGH } else if (trig->_polarity == 1) { // ACTIVE_HIGH
{
stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 1); stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 1);
} }
@@ -310,12 +303,10 @@ CameraTrigger::disengage(void *arg)
stm32_configgpio(GPIO_GPIO0_OUTPUT); stm32_configgpio(GPIO_GPIO0_OUTPUT);
if(trig->_polarity == 0) // ACTIVE_LOW if (trig->_polarity == 0) { // ACTIVE_LOW
{
stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 1); stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 1);
}
else if(trig->_polarity == 1) // ACTIVE_HIGH } else if (trig->_polarity == 1) { // ACTIVE_HIGH
{
stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 0); stm32_gpiowrite(GPIO_GPIO0_OUTPUT, 0);
} }
@@ -358,15 +349,16 @@ int camera_trigger_main(int argc, char *argv[])
if (argc > 3) { if (argc > 3) {
camera_trigger::g_camera_trigger->pin = (int)argv[3]; camera_trigger::g_camera_trigger->pin = (int)argv[3];
if (atoi(argv[3]) > 0 && atoi(argv[3]) < 6) { if (atoi(argv[3]) > 0 && atoi(argv[3]) < 6) {
warnx("starting trigger on pin : %li ", atoi(argv[3])); warnx("starting trigger on pin : %li ", atoi(argv[3]));
camera_trigger::g_camera_trigger->pin = atoi(argv[3]); camera_trigger::g_camera_trigger->pin = atoi(argv[3]);
}
else } else {
{
usage(); usage();
} }
} }
camera_trigger::g_camera_trigger->start(); camera_trigger::g_camera_trigger->start();
return 0; return 0;
@@ -379,8 +371,7 @@ int camera_trigger_main(int argc, char *argv[])
else if (!strcmp(argv[1], "stop")) { else if (!strcmp(argv[1], "stop")) {
camera_trigger::g_camera_trigger->stop(); camera_trigger::g_camera_trigger->stop();
} } else if (!strcmp(argv[1], "info")) {
else if (!strcmp(argv[1], "info")) {
camera_trigger::g_camera_trigger->info(); camera_trigger::g_camera_trigger->info();
} else { } else {