CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_EFI/AP_EFI_MAV.cpp
Views: 1798
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
This program is distributed in the hope that it will be useful,
7
but WITHOUT ANY WARRANTY; without even the implied warranty of
8
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
GNU General Public License for more details.
10
You should have received a copy of the GNU General Public License
11
along with this program. If not, see <http://www.gnu.org/licenses/>.
12
*/
13
14
#include "AP_EFI_config.h"
15
16
#if AP_EFI_MAV_ENABLED
17
18
#include "AP_EFI_MAV.h"
19
#include <AP_Math/AP_Math.h>
20
21
//Called from frontend to update with the readings received by handler
22
void AP_EFI_MAV::update()
23
{
24
if (receivedNewData) {
25
copy_to_frontend();
26
receivedNewData = false;
27
}
28
}
29
30
//Decode MavLink message
31
void AP_EFI_MAV::handle_EFI_message(const mavlink_message_t &msg)
32
{
33
mavlink_efi_status_t state;
34
mavlink_msg_efi_status_decode(&msg, &state);
35
36
internal_state.ecu_index = state.ecu_index;
37
internal_state.engine_speed_rpm = state.rpm;
38
internal_state.estimated_consumed_fuel_volume_cm3 = state.fuel_consumed;
39
internal_state.fuel_consumption_rate_cm3pm = state.fuel_flow;
40
internal_state.engine_load_percent = state.engine_load;
41
internal_state.throttle_position_percent = state.throttle_position;
42
internal_state.spark_dwell_time_ms = state.spark_dwell_time;
43
internal_state.atmospheric_pressure_kpa = state.barometric_pressure;
44
internal_state.intake_manifold_pressure_kpa = state.intake_manifold_pressure;
45
internal_state.intake_manifold_temperature = C_TO_KELVIN(state.intake_manifold_temperature);
46
internal_state.cylinder_status.cylinder_head_temperature = C_TO_KELVIN(state.cylinder_head_temperature);
47
internal_state.cylinder_status.ignition_timing_deg = state.ignition_timing;
48
internal_state.cylinder_status.injection_time_ms = state.injection_time;
49
internal_state.cylinder_status.exhaust_gas_temperature = C_TO_KELVIN(state.exhaust_gas_temperature);
50
internal_state.throttle_out = state.throttle_out;
51
internal_state.pt_compensation = state.pt_compensation;
52
//internal_state.??? = state.health;
53
internal_state.ignition_voltage = state.ignition_voltage;
54
55
receivedNewData = true;
56
}
57
58
#endif // AP_EFI_MAV_ENABLED
59
60