2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
25 #include "drivers/pwm_output.h"
27 #define CAMERA_CONTROL_PWM_RESOLUTION 128
28 #define CAMERA_CONTROL_SOFT_PWM_RESOLUTION 448
31 CAMERA_CONTROL_KEY_ENTER
,
32 CAMERA_CONTROL_KEY_LEFT
,
33 CAMERA_CONTROL_KEY_UP
,
34 CAMERA_CONTROL_KEY_RIGHT
,
35 CAMERA_CONTROL_KEY_DOWN
,
36 CAMERA_CONTROL_KEYS_COUNT
40 CAMERA_CONTROL_MODE_HARDWARE_PWM
,
41 CAMERA_CONTROL_MODE_SOFTWARE_PWM
,
42 CAMERA_CONTROL_MODE_DAC
,
43 CAMERA_CONTROL_MODES_COUNT
44 } cameraControlMode_e
;
46 typedef struct cameraControlConfig_s
{
47 cameraControlMode_e mode
;
48 // measured in 10 mV steps
51 // measured 100 Ohm steps
52 uint16_t internalResistance
;
56 uint16_t buttonResistanceValues
[CAMERA_CONTROL_KEYS_COUNT
]; // resistance in 100ohm steps
57 } cameraControlConfig_t
;
59 PG_DECLARE(cameraControlConfig_t
, cameraControlConfig
);
61 void cameraControlInit(void);
63 void cameraControlProcess(uint32_t currentTimeUs
);
64 void cameraControlKeyPress(cameraControlKey_e key
, uint32_t holdDurationMs
);
66 void cameraControlHi(void);
67 void cameraControlLo(void);
69 void cameraControlSoftwarePwmInit(void);
70 void cameraControlSoftwarePwmEnable(uint32_t hiTime
, uint32_t period
);
71 void cameraControlSoftwarePwmDisable(void);
72 void cameraControlHardwarePwmInit(timerChannel_t
*channel
, const timerHardware_t
*timerHardware
, uint8_t inverted
);