Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
pprz_chirp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Joost Meulenbeld
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
51 #ifndef PPRZ_CHIRP_H
52 #define PPRZ_CHIRP_H
53 
54 #include "std.h"
55 
59 struct chirp_t {
60  float f0_hz;
61  float f1_hz;
62  float start_time_s;
63  float length_s; // Amount of seconds of the chirp, excluding fade-in if applicable
64  float total_length_s; // Amount of seconds of the chirp, including fade-in if applicable
65 
67  float current_value; // Value is [-1, 1]
69  float percentage_done; // t / total_length: [0, 1]
70 
72  bool fade_in;
73 };
74 
84 void chirp_init(struct chirp_t *chirp, float f0_hz, float f1_hz, float length_s, float current_time_s,
85  bool exponential_chirp, bool fade_in);
86 
92 void chirp_reset(struct chirp_t *chirp, float current_time_s);
93 
97 bool chirp_is_running(struct chirp_t *chirp, float current_time_s);
98 
103 float chirp_update(struct chirp_t *chirp, float current_time_s);
104 
105 #endif
bool chirp_is_running(struct chirp_t *chirp, float current_time_s)
Return if the current_time is within the chirp manoeuvre.
Definition: pprz_chirp.c:65
bool fade_in
Definition: pprz_chirp.h:72
void chirp_init(struct chirp_t *chirp, float f0_hz, float f1_hz, float length_s, float current_time_s, bool exponential_chirp, bool fade_in)
Allocate and initialize a new chirp struct.
Definition: pprz_chirp.c:34
float current_frequency_hz
Definition: pprz_chirp.h:66
float percentage_done
Definition: pprz_chirp.h:69
float start_time_s
Definition: pprz_chirp.h:62
float f1_hz
Definition: pprz_chirp.h:61
bool exponential_chirp
Definition: pprz_chirp.h:71
float total_length_s
Definition: pprz_chirp.h:64
float length_s
Definition: pprz_chirp.h:63
float current_time_s
Definition: pprz_chirp.h:68
float chirp_update(struct chirp_t *chirp, float current_time_s)
Calculate the value at current_time_s and update the struct with current frequency and value.
Definition: pprz_chirp.c:71
float f0_hz
Definition: pprz_chirp.h:60
void chirp_reset(struct chirp_t *chirp, float current_time_s)
Reset the time of the chirp.
Definition: pprz_chirp.c:56
float current_value
Definition: pprz_chirp.h:67
Initialize with chirp_init.
Definition: pprz_chirp.h:59
static struct chirp_t chirp
Definition: sys_id_chirp.c:64