aboutsummaryrefslogtreecommitdiffstats
path: root/src/simulator
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-03-02 17:49:33 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-03-02 17:49:33 +0100
commit2e7c6404ad67bdd0659efdf1d9f2d9a52b2005df (patch)
tree4e6bd2c96c618e90eeeca717fffba872ab942d19 /src/simulator
parenta8107b3b360449d2edb6f9dc122ed47de88ed3bc (diff)
parent021632411d14c4f87e16560ed56a5681da55170b (diff)
downloadglutte-o-matic-2e7c6404ad67bdd0659efdf1d9f2d9a52b2005df.tar.gz
glutte-o-matic-2e7c6404ad67bdd0659efdf1d9f2d9a52b2005df.tar.bz2
glutte-o-matic-2e7c6404ad67bdd0659efdf1d9f2d9a52b2005df.zip
Merge branch '1750_soft'
Diffstat (limited to 'src/simulator')
-rw-r--r--src/simulator/src/Audio/audio.c5
-rw-r--r--src/simulator/src/Audio/audio_in.c71
-rw-r--r--src/simulator/src/Audio/tone.c0
-rw-r--r--src/simulator/src/Gui/gui.c15
4 files changed, 85 insertions, 6 deletions
diff --git a/src/simulator/src/Audio/audio.c b/src/simulator/src/Audio/audio.c
index 88f0db2..31f4c98 100644
--- a/src/simulator/src/Audio/audio.c
+++ b/src/simulator/src/Audio/audio.c
@@ -50,9 +50,7 @@ void audio_initialize_platform(int __attribute__ ((unused))plln, int __attribute
s = pa_simple_new(NULL, "Glutte", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error);
- if (s) {
-
- } else {
+ if (!s) {
printf("Pulseaudio playback init error\n");
while(1);
}
@@ -140,4 +138,3 @@ void audio_start_dma_and_request_buffers() {
void audio_stop_dma() {
dma_running = false;
}
-
diff --git a/src/simulator/src/Audio/audio_in.c b/src/simulator/src/Audio/audio_in.c
new file mode 100644
index 0000000..936fe1c
--- /dev/null
+++ b/src/simulator/src/Audio/audio_in.c
@@ -0,0 +1,71 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#include <stdio.h>
+#include <assert.h>
+#include <pulse/simple.h>
+#include "Audio/audio_in.h"
+#include "FreeRTOS.h"
+#include "task.h"
+
+pa_simple *s_in = NULL;
+
+
+static void audio_buffer_reader(void *args);
+
+void audio_in_initialize_plateform(int rate) {
+ int error;
+
+ static pa_sample_spec ss = {
+ .format = PA_SAMPLE_S16LE,
+ .rate = 0,
+ .channels = 1
+ };
+
+ ss.rate = rate;
+
+ s_in = pa_simple_new(NULL, "GlutteR", PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error);
+
+ assert(s_in);
+
+ TaskHandle_t task_handle;
+ xTaskCreate(
+ audio_buffer_reader,
+ "Audio buffer reader",
+ configMINIMAL_STACK_SIZE,
+ (void*) NULL,
+ tskIDLE_PRIORITY + 2UL,
+ &task_handle);
+}
+
+static void audio_buffer_reader(void __attribute__ ((unused)) *args) {
+
+ while(1) {
+ pa_simple_read(s_in, audio_in_buffer, AUDIO_IN_BUF_LEN * 2, NULL);
+ audio_in_buffer_ready();
+
+ taskYIELD();
+ }
+
+}
diff --git a/src/simulator/src/Audio/tone.c b/src/simulator/src/Audio/tone.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/simulator/src/Audio/tone.c
diff --git a/src/simulator/src/Gui/gui.c b/src/simulator/src/Gui/gui.c
index adf281a..be90afc 100644
--- a/src/simulator/src/Gui/gui.c
+++ b/src/simulator/src/Gui/gui.c
@@ -163,6 +163,8 @@ int in_u = 0;
int in_d = 0;
int in_fax_n = 1;
+extern int TONE_1750_DETECTED;
+
/**
* FSM
@@ -649,7 +651,7 @@ void main_gui() {
nk_end(ctx);
- if (nk_begin(ctx, &layout, "Output", nk_rect(720, 380, 200, 170), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
+ if (nk_begin(ctx, &layout, "Output", nk_rect(720, 410, 200, 170), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
nk_layout_row_dynamic(ctx, 25, 2);
@@ -691,7 +693,7 @@ void main_gui() {
}
nk_end(ctx);
- if (nk_begin(ctx, &layout, "Input", nk_rect(720, 50, 200, 330), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
+ if (nk_begin(ctx, &layout, "Input", nk_rect(720, 50, 200, 360), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
nk_layout_row_dynamic(ctx, 25, 3);
@@ -819,6 +821,15 @@ void main_gui() {
nk_property_float(ctx, "V", 0.0f, &gui_measured_voltage, 24.0f, 0.5f, 0.5f);
+ if (TONE_1750_DETECTED) {
+ c = color_on;
+ } else {
+ c = color_off;
+ }
+
+ nk_label_colored(ctx, "TONE_1750", NK_TEXT_LEFT, c);
+
+
}
nk_end(ctx);