PX4 Firmware
PX4 Autopilot Software http://px4.io
camera_interface.cpp
Go to the documentation of this file.
1 #include "camera_interface.h"
2 #include <px4_platform_common/log.h>
3 
4 /**
5  * @file camera_interface.cpp
6  *
7  */
8 
10  _p_pin(PARAM_INVALID),
11  _pins{}
12 {
13 }
14 
16 {
17 
18  // Get parameter handle
19  _p_pin = param_find("TRIG_PINS");
20 
21  if (_p_pin == PARAM_INVALID) {
22  PX4_ERR("param TRIG_PINS not found");
23  return;
24  }
25 
26  int pin_list;
27  param_get(_p_pin, &pin_list);
28 
29  // Set all pins as invalid
30  for (unsigned i = 0; i < arraySize(_pins); i++) {
31  _pins[i] = -1;
32  }
33 
34  // Convert number to individual channels
35  unsigned i = 0;
36  int single_pin;
37 
38  while ((single_pin = pin_list % 10)) {
39 
40  _pins[i] = single_pin - 1;
41 
42  if (_pins[i] < 0) {
43  _pins[i] = -1;
44  }
45 
46  pin_list /= 10;
47  i++;
48  }
49 
50 }
#define PARAM_INVALID
Handle returned when a parameter cannot be found.
Definition: param.h:103
CameraInterface()
Constructor.
__EXPORT int param_get(param_t param, void *val)
Copy the value of a parameter.
Definition: parameters.cpp:589
void get_pins()
get the hardware configuration
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
Definition: parameters.cpp:370
#define arraySize(a)