Skip to content

Commit

Permalink
AP_Camera: create and use an option_is_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed Aug 20, 2024
1 parent d859e9a commit b86380b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libraries/AP_Camera/AP_Camera_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ AP_Camera_Backend::AP_Camera_Backend(AP_Camera &frontend, AP_Camera_Params &para
void AP_Camera_Backend::update()
{
// Check camera options and start/stop recording based on arm/disarm
if ((_params.options.get() & (uint8_t)Options::RecordWhileArmed) != 0) {
if (option_is_enabled(Option::RecordWhileArmed)) {
if (hal.util->get_soft_armed() != last_is_armed) {
last_is_armed = hal.util->get_soft_armed();
if (!record_video(last_is_armed)) {
Expand Down
5 changes: 4 additions & 1 deletion libraries/AP_Camera/AP_Camera_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ class AP_Camera_Backend
CLASS_NO_COPY(AP_Camera_Backend);

// camera options parameter values
enum class Options : int8_t {
enum class Option : uint8_t {
RecordWhileArmed = (1 << 0U)
};
bool option_is_enabled(Option option) const {
return ((uint8_t)_params.options.get() & (uint8_t)option) != 0;
}

// init - performs any required initialisation
virtual void init() {};
Expand Down

0 comments on commit b86380b

Please sign in to comment.