Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : 16 : #include "AP_TemperatureSensor_Params.h" 17 : #include "AP_TemperatureSensor.h" 18 : 19 : #if AP_TEMPERATURE_SENSOR_ENABLED 20 : 21 : #ifndef AP_TEMPERATURE_SENSOR_I2C_ADDR_DEFAULT 22 : #define AP_TEMPERATURE_SENSOR_I2C_ADDR_DEFAULT 0 23 : #endif 24 : 25 : #ifndef AP_TEMPERATURE_SENSOR_I2C_BUS_DEFAULT 26 : #define AP_TEMPERATURE_SENSOR_I2C_BUS_DEFAULT 0 27 : #endif 28 : 29 : #ifndef AP_TEMPERATURE_SENSOR_SOURCE_ID_DEFAULT 30 : #define AP_TEMPERATURE_SENSOR_SOURCE_ID_DEFAULT -1 31 : #endif 32 : 33 : const AP_Param::GroupInfo AP_TemperatureSensor_Params::var_info[] = { 34 : // @Param: TYPE 35 : // @DisplayName: Temperature Sensor Type 36 : // @Description: Enables temperature sensors 37 : // @Values: 0:Disabled, 1:TSYS01, 2:MCP9600, 3:MAX31865 2 or 4 wire, 4:TSYS03, 5:Analog, 6:DroneCAN, 7:MLX90614, 8:SHT3x, 9:MAX31865 3 wire, 10:TMP119 38 : // @User: Standard 39 : // @RebootRequired: True 40 : AP_GROUPINFO_FLAGS("TYPE", 1, AP_TemperatureSensor_Params, type, (float)Type::NONE, AP_PARAM_FLAG_ENABLE), 41 : 42 : // @Param: BUS 43 : // @DisplayName: Temperature sensor bus 44 : // @Description: Temperature sensor bus number, typically used to select from multiple I2C buses 45 : // @Range: 0 3 46 : // @User: Advanced 47 : // @RebootRequired: True 48 : AP_GROUPINFO("BUS", 2, AP_TemperatureSensor_Params, bus, AP_TEMPERATURE_SENSOR_I2C_BUS_DEFAULT), 49 : 50 : // @Param: ADDR 51 : // @DisplayName: Temperature sensor address 52 : // @Description: Temperature sensor address, typically used for I2C address 53 : // @Range: 0 127 54 : // @User: Advanced 55 : // @RebootRequired: True 56 : AP_GROUPINFO("ADDR", 3, AP_TemperatureSensor_Params, bus_address, AP_TEMPERATURE_SENSOR_I2C_ADDR_DEFAULT), 57 : 58 : // @Param: SRC 59 : // @DisplayName: Sensor Source 60 : // @Description: Sensor Source is used to designate which device's temperature report will be replaced by this temperature sensor's data. If 0 (None) then the data is only available via log. In the future a new Motor temperature report will be created for returning data directly. 61 : // @Values: 0: None, 1:ESC, 2:Motor, 3:Battery Index, 4:Battery ID/SerialNumber, 5:CAN based Pitot tube, 6:DroneCAN-out on AP_Periph, 7:Servo motor, 8:Servo PCB, 9:Rangefinder 62 : // @User: Standard 63 : AP_GROUPINFO("SRC", 4, AP_TemperatureSensor_Params, source, (float)Source::None), 64 : 65 : // @Param: SRC_ID 66 : // @DisplayName: Sensor Source Identification 67 : // @Description: Sensor Source Identification is used to replace a specific instance of a system component's temperature report with the temp sensor's. Examples: TEMP_SRC = 1 (ESC), TEMP_SRC_ID = 1 will set the temp of ESC1. TEMP_SRC = 3 (BatteryIndex),TEMP_SRC_ID = 2 will set the temp of BATT2. TEMP_SRC = 4 (BatteryId/SerialNum),TEMP_SRC_ID=42 will set the temp of all batteries that have param BATTn_SERIAL = 42. 68 : AP_GROUPINFO("SRC_ID", 5, AP_TemperatureSensor_Params, source_id, AP_TEMPERATURE_SENSOR_SOURCE_ID_DEFAULT), 69 : 70 : AP_GROUPEND 71 : }; 72 : 73 6294 : AP_TemperatureSensor_Params::AP_TemperatureSensor_Params(void) { 74 6294 : AP_Param::setup_object_defaults(this, var_info); 75 6294 : } 76 : 77 : #endif // AP_TEMPERATURE_SENSOR_ENABLED