diff --git a/libraries/SITL/SIM_ToneAlarm.cpp b/libraries/SITL/SIM_ToneAlarm.cpp new file mode 100644 index 0000000000..cf3885690d --- /dev/null +++ b/libraries/SITL/SIM_ToneAlarm.cpp @@ -0,0 +1,45 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/* + simple tonealarm simulator class +*/ + +#include +#include + +#include "SIM_ToneAlarm.h" + +using namespace SITL; + +// table of user settable parameters +const AP_Param::GroupInfo ToneAlarm::var_info[] = { + + // @Param: ENABLE + // @DisplayName: ToneAlarm enable/disable + // @Description: Allows you to enable (1) or disable (0) the simulated tonealarm + // @Values: 0:Disabled,1:Enabled + // @User: Advanced + AP_GROUPINFO("ENABLE", 0, ToneAlarm, _enable, 1), + + AP_GROUPEND +}; + +/* + update tonealarm state + */ +void ToneAlarm::update(const struct sitl_input &input) +{ + // currently all of the simulated buzzer logic is within AP_HAL_SITL +} diff --git a/libraries/SITL/SIM_ToneAlarm.h b/libraries/SITL/SIM_ToneAlarm.h new file mode 100644 index 0000000000..7a80636719 --- /dev/null +++ b/libraries/SITL/SIM_ToneAlarm.h @@ -0,0 +1,48 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/* + simple tonealarm simulation class; note that the bulk of this is + actuall in AP_HAL_SITL at the moment in ToneAlarm_SF.h and + ToneAlarm_SF.cpp +*/ + +#pragma once + +#include +#include "SITL_Input.h" + +#include "stdint.h" + +namespace SITL { + +class ToneAlarm { +public: + ToneAlarm() { + AP_Param::setup_object_defaults(this, var_info); + }; + + void update(const struct sitl_input &input); + + static const struct AP_Param::GroupInfo var_info[]; + + bool is_enabled() const {return static_cast(_enable);} + + private: + + AP_Int8 _enable; // enable buzzer sim + +}; + +} diff --git a/libraries/SITL/SITL.cpp b/libraries/SITL/SITL.cpp index 7f5e204c8f..5e1520fe38 100644 --- a/libraries/SITL/SITL.cpp +++ b/libraries/SITL/SITL.cpp @@ -192,6 +192,9 @@ const AP_Param::GroupInfo SITL::var_info2[] = { // @Path: ./SIM_Buzzer.cpp AP_SUBGROUPINFO(buzzer_sim, "BZ_", 56, SITL, Buzzer), + // @Path: ./SIM_ToneAlarm.cpp + AP_SUBGROUPINFO(tonealarm_sim, "TA_", 57, SITL, ToneAlarm), + AP_GROUPINFO("MAG_SCALING", 60, SITL, mag_scaling, 1), AP_GROUPEND diff --git a/libraries/SITL/SITL.h b/libraries/SITL/SITL.h index 47a17d57bc..13e0a60144 100644 --- a/libraries/SITL/SITL.h +++ b/libraries/SITL/SITL.h @@ -5,11 +5,12 @@ #include #include "SIM_Buzzer.h" -#include "SIM_Sprayer.h" -#include "SIM_Gripper_Servo.h" #include "SIM_Gripper_EPM.h" +#include "SIM_Gripper_Servo.h" #include "SIM_Parachute.h" #include "SIM_Precland.h" +#include "SIM_Sprayer.h" +#include "SIM_ToneAlarm.h" namespace SITL { @@ -300,6 +301,7 @@ public: Parachute parachute_sim; Buzzer buzzer_sim; + ToneAlarm tonealarm_sim; SIM_Precland precland_sim; };