diff options
author | Maximilien Cuony <maximilien@theglu.org> | 2018-05-10 23:38:09 +0200 |
---|---|---|
committer | Maximilien Cuony <maximilien@theglu.org> | 2018-05-10 23:38:09 +0200 |
commit | 7b25d27d064b561cd8f3b72e25f61102241991f8 (patch) | |
tree | 62d883a8c10f03b2973504c3d98c20ee949a913a /src/simulator | |
parent | 7cbb03e3e7fbe584b3764dfc8b5486811ee4d929 (diff) | |
download | glutte-o-matic-7b25d27d064b561cd8f3b72e25f61102241991f8.tar.gz glutte-o-matic-7b25d27d064b561cd8f3b72e25f61102241991f8.tar.bz2 glutte-o-matic-7b25d27d064b561cd8f3b72e25f61102241991f8.zip |
Base with a working implementation on the simulator for software 1750 detection
Diffstat (limited to 'src/simulator')
-rw-r--r-- | src/simulator/src/Audio/audio.c | 5 | ||||
-rw-r--r-- | src/simulator/src/Audio/audio_in.c | 75 | ||||
-rw-r--r-- | src/simulator/src/Audio/tone.c | 0 | ||||
-rw-r--r-- | src/simulator/src/Gui/gui.c | 15 |
4 files changed, 89 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..df3e690 --- /dev/null +++ b/src/simulator/src/Audio/audio_in.c @@ -0,0 +1,75 @@ +/* + * 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 <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); + + if (!s_in) { + printf("Pulseaudio record init error\n"); + while(1); + } + + 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); |