mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-24 05:45:59 +08:00
[state interface] set basic types by value
This commit is contained in:
@@ -166,8 +166,7 @@ void dl_parse_msg(void)
|
||||
wind.y = DL_WIND_INFO_east(dl_buffer);
|
||||
stateSetHorizontalWindspeed_f(&wind);
|
||||
#if !USE_AIRSPEED
|
||||
float wi_airspeed = DL_WIND_INFO_airspeed(dl_buffer);
|
||||
stateSetAirspeed_f(&wi_airspeed);
|
||||
stateSetAirspeed_f(DL_WIND_INFO_airspeed(dl_buffer));
|
||||
#endif
|
||||
#ifdef WIND_INFO_RET
|
||||
float airspeed = stateGetAirspeed_f();
|
||||
|
||||
@@ -129,7 +129,7 @@ static void pressure_diff_cb(uint8_t __attribute__((unused)) sender_id, float pr
|
||||
air_data.airspeed = eas_from_dynamic_pressure(air_data.differential);
|
||||
air_data.tas = tas_from_eas(air_data.airspeed);
|
||||
#if USE_AIRSPEED_AIR_DATA
|
||||
stateSetAirspeed_f(&air_data.airspeed);
|
||||
stateSetAirspeed_f(air_data.airspeed);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,6 @@ void airspeed_adc_update(void)
|
||||
#endif //SITL
|
||||
|
||||
#if USE_AIRSPEED_ADC
|
||||
stateSetAirspeed_f(&airspeed_adc.airspeed);
|
||||
stateSetAirspeed_f(airspeed_adc.airspeed);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ void airspeed_amsys_read_periodic(void)
|
||||
}
|
||||
|
||||
#if USE_AIRSPEED_AMSYS
|
||||
stateSetAirspeed_f(&airspeed_amsys);
|
||||
stateSetAirspeed_f(airspeed_amsys);
|
||||
#endif
|
||||
|
||||
#elif !defined USE_NPS
|
||||
extern float sim_air_speed;
|
||||
stateSetAirspeed_f(&sim_air_speed);
|
||||
stateSetAirspeed_f(sim_air_speed);
|
||||
#endif //SITL
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ void airspeed_amsys_read_event(void)
|
||||
|
||||
//New value available
|
||||
#if USE_AIRSPEED
|
||||
stateSetAirspeed_f(&airspeed_amsys);
|
||||
stateSetAirspeed_f(airspeed_amsys);
|
||||
#endif
|
||||
#ifdef AIRSPEED_AMSYS_SYNC_SEND
|
||||
airspeed_amsys_downlink();
|
||||
|
||||
@@ -137,7 +137,7 @@ void airspeed_ets_read_periodic(void)
|
||||
}
|
||||
#elif !defined USE_NPS
|
||||
extern float sim_air_speed;
|
||||
stateSetAirspeed_f(&sim_air_speed);
|
||||
stateSetAirspeed_f(sim_air_speed);
|
||||
#endif //SITL
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ void airspeed_ets_read_event(void)
|
||||
}
|
||||
airspeed_ets = airspeed_ets / (float)AIRSPEED_ETS_NBSAMPLES_AVRG;
|
||||
#if USE_AIRSPEED_ETS
|
||||
stateSetAirspeed_f(&airspeed_ets);
|
||||
stateSetAirspeed_f(airspeed_ets);
|
||||
#endif
|
||||
#if AIRSPEED_ETS_SYNC_SEND
|
||||
DOWNLINK_SEND_AIRSPEED_ETS(DefaultChannel, DefaultDevice, &airspeed_ets_raw, &airspeed_ets_offset, &airspeed_ets);
|
||||
|
||||
@@ -210,7 +210,7 @@ void ms45xx_i2c_event(void)
|
||||
// Compute airspeed
|
||||
ms45xx.airspeed = sqrtf(Max(ms45xx.diff_pressure * ms45xx.airspeed_scale, 0));
|
||||
#if USE_AIRSPEED_MS45XX
|
||||
stateSetAirspeed_f(&ms45xx.airspeed);
|
||||
stateSetAirspeed_f(ms45xx.airspeed);
|
||||
#endif
|
||||
if (ms45xx.sync_send) {
|
||||
ms45xx_downlink(&(DefaultChannel).trans_tx, &(DefaultDevice).device);
|
||||
|
||||
@@ -84,7 +84,7 @@ void aoa_adc_update(void)
|
||||
prev_aoa = aoa_adc.angle;
|
||||
|
||||
#ifdef USE_AOA
|
||||
stateSetAngleOfAttack_f(&aoa_adc.angle);
|
||||
stateSetAngleOfAttack_f(aoa_adc.angle);
|
||||
#endif
|
||||
|
||||
RunOnceEvery(30, DOWNLINK_SEND_AOA_ADC(DefaultChannel, DefaultDevice, &aoa_adc.raw, &aoa_adc.angle));
|
||||
|
||||
@@ -151,7 +151,7 @@ void pbn_read_event(void)
|
||||
pbn.airspeed = (pbn.airspeed_filter * pbn.airspeed + tmp_airspeed) /
|
||||
(pbn.airspeed_filter + 1.);
|
||||
#if USE_AIRSPEED_PBN
|
||||
stateSetAirspeed_f(&pbn.airspeed);
|
||||
stateSetAirspeed_f(pbn.airspeed);
|
||||
#endif
|
||||
|
||||
pbn.altitude = PBN_ALTITUDE_SCALE * (float)(pbn.altitude_adc - pbn.altitude_offset);
|
||||
|
||||
+8
-8
@@ -1233,9 +1233,9 @@ static inline void stateSetHorizontalWindspeed_i(struct Int32Vect2 *h_windspeed)
|
||||
}
|
||||
|
||||
/// Set airspeed (int).
|
||||
static inline void stateSetAirspeed_i(int32_t *airspeed)
|
||||
static inline void stateSetAirspeed_i(int32_t airspeed)
|
||||
{
|
||||
state.airspeed_i = *airspeed;
|
||||
state.airspeed_i = airspeed;
|
||||
/* clear bits for all airspeed representations and only set the new one */
|
||||
ClearBit(state.wind_air_status, AIRSPEED_F);
|
||||
SetBit(state.wind_air_status, AIRSPEED_I);
|
||||
@@ -1251,27 +1251,27 @@ static inline void stateSetHorizontalWindspeed_f(struct FloatVect2 *h_windspeed)
|
||||
}
|
||||
|
||||
/// Set airspeed (float).
|
||||
static inline void stateSetAirspeed_f(float *airspeed)
|
||||
static inline void stateSetAirspeed_f(float airspeed)
|
||||
{
|
||||
state.airspeed_f = *airspeed;
|
||||
state.airspeed_f = airspeed;
|
||||
/* clear bits for all airspeed representations and only set the new one */
|
||||
ClearBit(state.wind_air_status, AIRSPEED_I);
|
||||
SetBit(state.wind_air_status, AIRSPEED_F);
|
||||
}
|
||||
|
||||
/// Set angle of attack in radians (float).
|
||||
static inline void stateSetAngleOfAttack_f(float *aoa)
|
||||
static inline void stateSetAngleOfAttack_f(float aoa)
|
||||
{
|
||||
state.angle_of_attack_f = *aoa;
|
||||
state.angle_of_attack_f = aoa;
|
||||
/* clear bits for all AOA representations and only set the new one */
|
||||
/// @todo no integer yet
|
||||
SetBit(state.wind_air_status, AOA_F);
|
||||
}
|
||||
|
||||
/// Set sideslip angle in radians (float).
|
||||
static inline void stateSetSideslip_f(float *sideslip)
|
||||
static inline void stateSetSideslip_f(float sideslip)
|
||||
{
|
||||
state.sideslip_f = *sideslip;
|
||||
state.sideslip_f = sideslip;
|
||||
/* clear bits for all sideslip representations and only set the new one */
|
||||
/// @todo no integer yet
|
||||
SetBit(state.wind_air_status, SIDESLIP_F);
|
||||
|
||||
Reference in New Issue
Block a user