aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-10 09:30:06 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-10 09:30:06 +0200
commitd0c10808d2908e2fada3bc13ab5a47260297c74b (patch)
tree925ddfdad385c7aaf9f65f30fa212bd5f66c6ef4 /src
parentb5191a8c7c1764a2a8663775d1c45d25e356e12f (diff)
downloadglutte-o-matic-d0c10808d2908e2fada3bc13ab5a47260297c74b.tar.gz
glutte-o-matic-d0c10808d2908e2fada3bc13ab5a47260297c74b.tar.bz2
glutte-o-matic-d0c10808d2908e2fada3bc13ab5a47260297c74b.zip
Implement 5s 1750 to disable FAX
Diffstat (limited to 'src')
-rw-r--r--src/common/includes/Audio/tone.h4
-rw-r--r--src/common/includes/Core/fsm.h1
-rw-r--r--src/common/src/Audio/tone.c20
-rw-r--r--src/common/src/Core/fsm.c4
-rw-r--r--src/common/src/Core/main.c1
5 files changed, 25 insertions, 5 deletions
diff --git a/src/common/includes/Audio/tone.h b/src/common/includes/Audio/tone.h
index e88cae2..ba05304 100644
--- a/src/common/includes/Audio/tone.h
+++ b/src/common/includes/Audio/tone.h
@@ -37,6 +37,10 @@ void tone_detector_enable(int enable);
/* Return 1 when 1750 detected, 0 otherwise */
int tone_1750_status(void);
+/* Return 1 if 1750 is currently detected, and has been already for at
+ * least 5s */
+int tone_1750_for_5_seconds(void);
+
/* The FAX status is 1 if the recently decoded DTMF is the 0-7-* sequence. */
int tone_fax_status(void);
diff --git a/src/common/includes/Core/fsm.h b/src/common/includes/Core/fsm.h
index ae12dae..37ca386 100644
--- a/src/common/includes/Core/fsm.h
+++ b/src/common/includes/Core/fsm.h
@@ -83,6 +83,7 @@ struct fsm_input_signals_t {
/* Signals coming from FAX and 1750 detector */
int fax_mode; // 1750Hz filter disabled for machine-generated modes
int det_1750; // 1750Hz detected
+ int long_1750; // 1750Hz detected for more than 5s
/* Signals coming from CW and PSK generator */
int cw_psk31_done; // The CW and PSK generator has finished transmitting the message
diff --git a/src/common/src/Audio/tone.c b/src/common/src/Audio/tone.c
index 9c2b15a..fdac42c 100644
--- a/src/common/src/Audio/tone.c
+++ b/src/common/src/Audio/tone.c
@@ -85,6 +85,7 @@ static QueueHandle_t m_squared_queue;
static int32_t normalised_results[NUM_DETECTORS];
static int num_tone_1750_detected = 0;
+static uint64_t tone_1750_detected_since = 0;
static int detectors_enabled = 0;
static enum dtmf_code dtmf_last_seen = 0;
@@ -190,6 +191,12 @@ int tone_1750_status()
return num_tone_1750_detected >= num_1750_required;
}
+int tone_1750_for_5_seconds()
+{
+ return (num_tone_1750_detected >= num_1750_required) &&
+ tone_1750_detected_since + 5000 < timestamp_now();
+}
+
int tone_fax_status()
{
return dtmf_sequence[0] == DTMF_0 &&
@@ -320,8 +327,13 @@ void tone_do_analysis()
if (num_tone_1750_detected < num_1750_required &&
normalised_results[DET_1750] > thresh_1750) {
num_tone_1750_detected++;
+
+ if (num_tone_1750_detected == num_1750_required) {
+ tone_1750_detected_since = timestamp_now();
+ }
}
- else if (num_tone_1750_detected > 0) {
+ else if (num_tone_1750_detected > 0 &&
+ normalised_results[DET_1750] <= thresh_1750) {
num_tone_1750_detected--;
}
@@ -330,12 +342,14 @@ void tone_do_analysis()
#if PRINT_TONES_STATS
static int printcounter = 0;
if (++printcounter == 5) {
- usart_debug("Tones: % 3d % 3d % 3d % 3d % 3d\r\n",
+ usart_debug("Tones: % 3d % 3d % 3d % 3d % 3d since %d\r\n",
normalised_results[0],
normalised_results[1],
normalised_results[2],
normalised_results[3],
- normalised_results[4]);
+ normalised_results[4],
+ (int)(timestamp_now() - tone_1750_detected_since)
+ );
printcounter = 0;
}
diff --git a/src/common/src/Core/fsm.c b/src/common/src/Core/fsm.c
index 35fd3bf..abe84b3 100644
--- a/src/common/src/Core/fsm.c
+++ b/src/common/src/Core/fsm.c
@@ -651,11 +651,11 @@ int fsm_sstv_update() {
case SSTV_FSM_ON:
if (current_state == FSM_BALISE_LONGUE ||
current_state == FSM_ANTI_BAVARD ||
- current_state == FSM_BALISE_SPECIALE
+ current_state == FSM_BALISE_SPECIALE ||
+ fsm_in.long_1750
) {
next_state = SSTV_FSM_OFF;
}
-#warning "Disable FAX mode if 1750 is active for 5 seconds"
break;
default:
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c
index 5efbb18..f1cf0e7 100644
--- a/src/common/src/Core/main.c
+++ b/src/common/src/Core/main.c
@@ -583,6 +583,7 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters)
gui_in_tone_1750 =
#endif
fsm_input.det_1750 = tone_1750_status();
+ fsm_input.long_1750 = tone_1750_for_5_seconds();
// TODO implement a DTMF controlled state machine for setting SQ2
pio_set_sq2(0);