arduino-audio-tools
Loading...
Searching...
No Matches
AudioRuntime.h
Go to the documentation of this file.
1#pragma once
2
3#include <string.h>
4#include <stdint.h>
5#include <assert.h>
6#include "AudioToolsConfig.h"
7
8
9
10#if defined(ARDUINO)
11#include <Arduino.h>
12// Non Arduino
13#elif defined(IS_ZEPHYR) || defined(ESP32_CMAKE)
15#else
16#include <algorithm>
17using std::min;
18using std::max;
19#endif
20
21namespace audio_tools {
22
23
25inline static void checkMemory(bool printMemory=false) {
26 #if defined(ESP32) && defined(ARDUINO)
28 if (printMemory) Serial.printf("==> Available stack: %d - heap: %u - psram: %u\n",(int) uxTaskGetStackHighWaterMark(NULL), (unsigned)ESP.getFreeHeap(),(unsigned)ESP.getFreePsram());
29 #endif
30}
31
32// Arduino
33#ifdef ARDUINO
35inline void printNChar(char ch, int n){
36 for (int j=0;j<n;j++) Serial.print(ch);
37 Serial.println();
38}
39
40#ifndef ESP_ARDUINO_VERSION_STR
41# define df2xstr(s) #s
42# define df2str(s) df2xstr(s)
43# define ESP_ARDUINO_VERSION_STR df2str(ESP_ARDUINO_VERSION_MAJOR) "." df2str(ESP_ARDUINO_VERSION_MINOR) "." df2str(ESP_ARDUINO_VERSION_PATCH)
44#endif
45
47inline void printVersionInfo() {
48 printNChar('*',50);
49 Serial.print("AudioTools: ");
51 Serial.print("Arduino: ");
52 Serial.println(ARDUINO);
53#ifdef ESP32
54 Serial.print("Arduino ESP Core Version: ");
56 Serial.print("IDF Version: ");
57 Serial.println(IDF_VER);
58#endif
59 printNChar('*',50);
60}
61
62#define GPIO_NONE -1
63#define IS_GPIO(pin) (pin >= 0)
64#define GPIO_TO_INT(pin) pin
65#define GPIO_TO_STR(pin) std::to_string(pin).c_str()
66using digital_pin_t = int;
67
68#endif
69
71inline void stop() {
72 #ifdef EXIT_ON_STOP
73 exit(0);
74 #else
75 while(true){
76 delay(1000);
77 }
78 #endif
79}
80
81}
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...
static HardwareSerial Serial
Definition Arduino.h:179
#define AUDIOTOOLS_VERSION
AutioTools Configuration.
Definition AudioToolsConfig.h:17
#define ARDUINO
Definition desktop.h:29
#define assert(T)
Definition avr.h:10
void stop()
stops any further processing by spinning in an endless loop
Definition AudioRuntime.h:71
static void checkMemory(bool printMemory=false)
Executes heap_caps_check_integrity_all()
Definition AudioRuntime.h:25
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
gpio_dt_spec digital_pin_t
Zephyr GPIO spec as digital_pin_t.
Definition Arduino.h:266
void delay(uint32_t ms)
Definition Arduino.h:255
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:508