mirror of
https://github.com/pschatzmann/arduino-audio-tools.git
synced 2024-09-21 02:17:31 +00:00
comple option ESP32_CMAKE
This commit is contained in:
parent
579f380289
commit
33fc7170f7
@ -26,8 +26,8 @@ add_executable (mp3_dt mp3.ino)
|
||||
|
||||
# set preprocessor defines
|
||||
target_compile_definitions(arduino_emulator PUBLIC -DDEFINE_MAIN)
|
||||
target_compile_definitions(arduino_helix PUBLIC -DARDUINO)
|
||||
target_compile_definitions(mp3_dt PUBLIC -DARDUINO -DIS_DESKTOP -DEXIT_ON_STOP)
|
||||
target_compile_definitions(arduino_helix PUBLIC -DARDUINO -DHELIX_LOGGING_ACTIVE=0)
|
||||
target_compile_definitions(mp3_dt PUBLIC -DIS_DESKTOP -DEXIT_ON_STOP)
|
||||
|
||||
# OS/X might need this setting for core audio
|
||||
target_compile_options(portaudio PRIVATE -Wno-deprecated)
|
||||
|
@ -8,12 +8,18 @@
|
||||
#if defined(IS_MIN_DESKTOP)
|
||||
# include "AudioLibs/Desktop/NoArduino.h"
|
||||
#elif defined(IS_DESKTOP_WITH_TIME_ONLY)
|
||||
# include "AudioLibs/Desktop/Millis.h"
|
||||
# include "AudioLibs/Desktop/x.h"
|
||||
# include "AudioLibs/Desktop/NoArduino.h"
|
||||
#elif defined(IS_DESKTOP)
|
||||
# include "Arduino.h"
|
||||
#elif defined(ARDUINO)
|
||||
# include "Arduino.h"
|
||||
// --- ESP32 ------------
|
||||
// E.g when using the Espressif IDF. Use cmake for the necesseary defines
|
||||
#elif defined(ESP32_CMAKE)
|
||||
# define USE_INT24_FROM_INT 1
|
||||
# include "AudioTools/AudioRuntime.h"
|
||||
# include "AudioLibs/Desktop/NoArduino.h"
|
||||
#else
|
||||
# include "AudioLibs/Desktop/NoArduino.h"
|
||||
# define IS_JUPYTER
|
||||
@ -355,26 +361,6 @@ typedef uint32_t eps32_i2s_sample_rate_type;
|
||||
|
||||
#endif
|
||||
|
||||
// --- ESP32 ------------
|
||||
// E.g when using the Espressif IDF. Use cmake for the necesseary defines
|
||||
#if defined(ESP32_CMAKE)
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#define ESP32
|
||||
#define DESKTOP_MILLIS_DEFINED
|
||||
|
||||
typedef uint32_t eps32_i2s_sample_rate_type;
|
||||
// forward declare app_amin
|
||||
extern "C" void app_main();
|
||||
// delay and millis is needed by this framework
|
||||
namespace audio_tools {
|
||||
|
||||
void delay(uint32_t ms){ vTaskDelay(1000 / portTICK_PERIOD_MS);}
|
||||
uint32_t millis() {return (xTaskGetTickCount() * portTICK_PERIOD_MS);}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
//----- ESP8266 -----------
|
||||
#ifdef ESP8266
|
||||
@ -739,7 +725,7 @@ typedef WiFiClient WiFiClientSecure;
|
||||
// Minimum desktop functionality w/o Arduino emulator
|
||||
#ifdef IS_MIN_DESKTOP
|
||||
# include "AudioLibs/Desktop/NoArduino.h"
|
||||
# include "AudioLibs/Desktop/Millis.h"
|
||||
# include "AudioLibs/Desktop/Time.h"
|
||||
# include "AudioLibs/Desktop/Main.h"
|
||||
# include "AudioLibs/Desktop/File.h"
|
||||
# define USE_STREAM_READ_OVERRIDE
|
||||
@ -795,7 +781,7 @@ using int24_t = audio_tools::int24_4bytes_t;
|
||||
# define USE_PRINT_FLUSH true
|
||||
#endif
|
||||
|
||||
#ifndef ESP32
|
||||
#ifndef ESP_IDF_VERSION_VAL
|
||||
# define ESP_IDF_VERSION_VAL(a, b , c) 0
|
||||
#endif
|
||||
|
||||
@ -810,4 +796,4 @@ using int24_t = audio_tools::int24_4bytes_t;
|
||||
#pragma GCC diagnostic ignored "-Wnarrowing"
|
||||
#endif
|
||||
|
||||
#undef rewind
|
||||
#undef rewind
|
||||
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#include "AudioLibs/Desktop/NoArduino.h"
|
||||
#include <iostream>
|
||||
|
||||
#ifndef DESKTOP_MILLIS_DEFINED
|
||||
#define DESKTOP_MILLIS_DEFINED
|
||||
|
||||
namespace audio_tools {
|
||||
|
||||
/// Waits for the indicated milliseconds
|
||||
void delay(uint32_t ms) {
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
auto end = millis()+ms;
|
||||
while(millis()<=end);
|
||||
}
|
||||
|
||||
/// Returns the milliseconds since the start
|
||||
uint32_t millis(){
|
||||
using namespace std::chrono;
|
||||
// Get current time with precision of milliseconds
|
||||
auto now = time_point_cast<milliseconds>(system_clock::now());
|
||||
// sys_milliseconds is type time_point<system_clock, milliseconds>
|
||||
using sys_milliseconds = decltype(now);
|
||||
// Convert time_point to signed integral type
|
||||
return now.time_since_epoch().count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -10,7 +10,6 @@
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <algorithm> // std::max
|
||||
#include <stdio.h>
|
||||
@ -18,6 +17,7 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <chrono>
|
||||
#include "AudioConfig.h"
|
||||
|
||||
#define IS_NOARDUINO
|
||||
|
||||
@ -162,39 +162,39 @@ inline long map(long x, long in_min, long in_max, long out_min, long out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
#ifndef DESKTOP_MILLIS_DEFINED
|
||||
// #ifndef DESKTOP_MILLIS_DEFINED
|
||||
|
||||
/// Waits for the indicated milliseconds
|
||||
extern void delay(uint32_t ms);
|
||||
// /// Waits for the indicated milliseconds
|
||||
// extern void delay(uint32_t ms);
|
||||
|
||||
/// Returns the milliseconds since the start
|
||||
extern uint32_t millis();
|
||||
// /// Returns the milliseconds since the start
|
||||
// extern uint32_t millis();
|
||||
|
||||
/// Waits for the indicated milliseconds
|
||||
extern void delayMicroseconds(uint32_t ms);
|
||||
// /// Waits for the indicated milliseconds
|
||||
// extern void delayMicroseconds(uint32_t ms);
|
||||
|
||||
/// Returns the milliseconds since the start
|
||||
extern uint32_t micros();
|
||||
// /// Returns the milliseconds since the start
|
||||
// extern uint32_t micros();
|
||||
|
||||
#else
|
||||
// #else
|
||||
|
||||
extern "C" {
|
||||
// extern "C" {
|
||||
|
||||
/// Waits for the indicated milliseconds
|
||||
extern void delay(uint32_t ms);
|
||||
// /// Waits for the indicated milliseconds
|
||||
// extern void delay(uint32_t ms);
|
||||
|
||||
/// Returns the milliseconds since the start
|
||||
extern uint32_t millis();
|
||||
// /// Returns the milliseconds since the start
|
||||
// extern uint32_t millis();
|
||||
|
||||
/// Waits for the indicated milliseconds
|
||||
extern void delayMicroseconds(uint32_t ms);
|
||||
// /// Waits for the indicated milliseconds
|
||||
// extern void delayMicroseconds(uint32_t ms);
|
||||
|
||||
/// Returns the milliseconds since the start
|
||||
extern uint32_t micros();
|
||||
// /// Returns the milliseconds since the start
|
||||
// extern uint32_t micros();
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
} // namespace
|
||||
@ -231,7 +231,7 @@ void pinMode(int pin, int mode) {
|
||||
|
||||
#endif
|
||||
|
||||
using namespace audio_tools;
|
||||
//using namespace audio_tools;
|
||||
|
||||
|
||||
|
||||
|
46
src/AudioLibs/Desktop/Time.h
Normal file
46
src/AudioLibs/Desktop/Time.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include "AudioLibs/Desktop/NoArduino.h"
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
// #ifndef DESKTOP_MILLIS_DEFINED
|
||||
// #define DESKTOP_MILLIS_DEFINED
|
||||
|
||||
namespace audio_tools {
|
||||
|
||||
/// Returns the milliseconds since the start
|
||||
inline uint32_t millis(){
|
||||
using namespace std::chrono;
|
||||
// Get current time with precision of milliseconds
|
||||
auto now = time_point_cast<milliseconds>(system_clock::now());
|
||||
// sys_milliseconds is type time_point<system_clock, milliseconds>
|
||||
using sys_milliseconds = decltype(now);
|
||||
// Convert time_point to signed integral type
|
||||
return now.time_since_epoch().count();
|
||||
}
|
||||
|
||||
// sleep ms milliseconds
|
||||
void delay(unsigned long ms){
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
}
|
||||
|
||||
// sleep us milliseconds
|
||||
void delayMicroseconds(unsigned int us){
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(us));
|
||||
}
|
||||
|
||||
// Returns the micros of milliseconds passed since epich
|
||||
inline unsigned long micros(void){
|
||||
using namespace std::chrono;
|
||||
// Get current time with precision of milliseconds
|
||||
auto now = time_point_cast<microseconds>(system_clock::now());
|
||||
// sys_milliseconds is type time_point<system_clock, milliseconds>
|
||||
using sys_milliseconds = decltype(now);
|
||||
// Convert time_point to signed integral type
|
||||
return now.time_since_epoch().count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// #endif
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include "Desktop/Millis.h"
|
||||
#include "Desktop/Time.h"
|
||||
#include "Desktop/JupyterAudio.h"
|
||||
#include "Desktop/File.h"
|
||||
|
@ -470,7 +470,7 @@ class TimedStream : public ModifyingStream {
|
||||
bool begin() override {
|
||||
calculateByteLimits();
|
||||
current_bytes = 0;
|
||||
LOGI("byte range %ld - %ld", start_bytes, end_bytes);
|
||||
LOGI("byte range %u - %u",(unsigned) start_bytes,(unsigned) end_bytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "AudioConfig.h"
|
||||
#include "../AudioConfig.h"
|
||||
|
||||
#if defined(ESP32_CMAKE)
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
// delay and millis is needed by this framework
|
||||
#define DESKTOP_MILLIS_DEFINED
|
||||
|
||||
inline void delay(uint32_t ms){ vTaskDelay(ms * 1000 / portTICK_PERIOD_MS);}
|
||||
inline uint32_t millis() {return (xTaskGetTickCount() * portTICK_PERIOD_MS);}
|
||||
inline void delayMicroseconds(uint32_t ms) {esp_rom_delay_us(ms);}
|
||||
inline uint64_t micros() { return esp_timer_get_time();}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Public generic methods
|
||||
|
Loading…
Reference in New Issue
Block a user