mirror of
https://github.com/clockworkpi/PicoCalc.git
synced 2026-03-27 06:22:38 +01:00
try to sync mp3 player with latest YAHAL
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdlib>
|
||||||
#include "main_task.h"
|
#include "main_task.h"
|
||||||
#include "logo50.h"
|
#include "logo50.h"
|
||||||
#include "icon_enter.h"
|
#include "icon_enter.h"
|
||||||
@@ -293,7 +294,7 @@ void main_task::menu_start(sd_reader_task&sd_reader,mp3_decoder_task &decoder,pc
|
|||||||
assert(res == FatFs::FR_OK);
|
assert(res == FatFs::FR_OK);
|
||||||
sd_reader.start(&_fs, &_file);
|
sd_reader.start(&_fs, &_file);
|
||||||
decoder.reset();
|
decoder.reset();
|
||||||
decoder.start();
|
decoder.sign_up();
|
||||||
update_required = 1;
|
update_required = 1;
|
||||||
playing =1;
|
playing =1;
|
||||||
last_play_pos = 0;
|
last_play_pos = 0;
|
||||||
@@ -310,7 +311,7 @@ void main_task::menu_start_all(sd_reader_task &sd_reader, mp3_decoder_task &deco
|
|||||||
assert(res == FatFs::FR_OK);
|
assert(res == FatFs::FR_OK);
|
||||||
sd_reader.start(&_fs, &_file);
|
sd_reader.start(&_fs, &_file);
|
||||||
decoder.reset();
|
decoder.reset();
|
||||||
decoder.start();
|
decoder.sign_up();
|
||||||
update_required = 1;
|
update_required = 1;
|
||||||
playing =1;
|
playing =1;
|
||||||
last_play_pos = 0;
|
last_play_pos = 0;
|
||||||
@@ -515,7 +516,7 @@ void main_task::run() {
|
|||||||
draw_header("Playlist");
|
draw_header("Playlist");
|
||||||
while (true){
|
while (true){
|
||||||
if(playing){
|
if(playing){
|
||||||
if (sd_reader.isAlive() && decoder.isAlive()) {
|
if (sd_reader.isLinkedIn() && decoder.isLinkedIn()) {
|
||||||
//printf("playing now\n");
|
//printf("playing now\n");
|
||||||
|
|
||||||
if(update_required) {
|
if(update_required) {
|
||||||
|
|||||||
@@ -81,22 +81,22 @@ public:
|
|||||||
void draw_playing();
|
void draw_playing();
|
||||||
void draw_wrap_text(const char *);
|
void draw_wrap_text(const char *);
|
||||||
private:
|
private:
|
||||||
gpio_rp2040_pin _cs; // CS Line of SD card SPI interface
|
gpio_rp2040 _cs; // CS Line of SD card SPI interface
|
||||||
spi_rp2040 _spi; // SPI interface used for the SD card reader
|
spi_rp2040 _spi; // SPI interface used for the SD card reader
|
||||||
sd_spi_drv _sd; // SD card low level driver
|
sd_spi_drv _sd; // SD card low level driver
|
||||||
|
|
||||||
gpio_rp2040_pin _next; // Next button
|
gpio_rp2040 _next; // Next button
|
||||||
gpio_rp2040_pin _part; // Partition button
|
gpio_rp2040 _part; // Partition button
|
||||||
gpio_rp2040_pin _ps; // Pico Power save pin
|
gpio_rp2040 _ps; // Pico Power save pin
|
||||||
|
|
||||||
FatFs _fs;
|
FatFs _fs;
|
||||||
FatFs::DIR _dir{};
|
FatFs::DIR _dir{};
|
||||||
FatFs::FILEINFO _finfo{};
|
FatFs::FILEINFO _finfo{};
|
||||||
FatFs::FILE _file{}; // MP3 file on SD
|
FatFs::FILE _file{}; // MP3 file on SD
|
||||||
|
|
||||||
gpio_rp2040_pin _lcd_rst;
|
gpio_rp2040 _lcd_rst;
|
||||||
gpio_rp2040_pin _lcd_dc;
|
gpio_rp2040 _lcd_dc;
|
||||||
gpio_rp2040_pin _lcd_cs;
|
gpio_rp2040 _lcd_cs;
|
||||||
spi_rp2040 _lcd_spi;
|
spi_rp2040 _lcd_spi;
|
||||||
ili9488_drv _lcd;
|
ili9488_drv _lcd;
|
||||||
uGUI _gui;
|
uGUI _gui;
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ int16_t mp3_decoder_task::scale(mad_fixed_t sample)
|
|||||||
// Therefore rounding and clipping is normally not
|
// Therefore rounding and clipping is normally not
|
||||||
// necessary!
|
// necessary!
|
||||||
// round
|
// round
|
||||||
|
#if 0
|
||||||
sample += (1L << (MAD_F_FRACBITS - 16));
|
sample += (1L << (MAD_F_FRACBITS - 16));
|
||||||
// clip
|
// clip
|
||||||
if (sample >= MAD_F_ONE)
|
if (sample >= MAD_F_ONE)
|
||||||
@@ -178,8 +179,9 @@ int16_t mp3_decoder_task::scale(mad_fixed_t sample)
|
|||||||
sample = -MAD_F_ONE;
|
sample = -MAD_F_ONE;
|
||||||
// Convert to a standard 16 bit PCM value
|
// Convert to a standard 16 bit PCM value
|
||||||
// (signed) in the range of -32768...32767
|
// (signed) in the range of -32768...32767
|
||||||
|
#endif
|
||||||
sample >>= (MAD_F_FRACBITS + 1 - 16);
|
sample >>= (MAD_F_FRACBITS + 1 - 16);
|
||||||
return (int16_t)sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t mp3_decoder_task::get_position(unsigned long fsize, int max_pos) {
|
uint16_t mp3_decoder_task::get_position(unsigned long fsize, int max_pos) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ private:
|
|||||||
pcm_audio_interface & _pcm_if;
|
pcm_audio_interface & _pcm_if;
|
||||||
sd_reader_task & _sd_reader;
|
sd_reader_task & _sd_reader;
|
||||||
mad_decoder _decoder{};
|
mad_decoder _decoder{};
|
||||||
gpio_rp2040_pin _led;
|
gpio_rp2040 _led;
|
||||||
uint8_t _mp3_buf[MP3_BUF_SIZE]{};
|
uint8_t _mp3_buf[MP3_BUF_SIZE]{};
|
||||||
uint32_t _pcm_rate;
|
uint32_t _pcm_rate;
|
||||||
mad_timer_t _timer;
|
mad_timer_t _timer;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ int main()
|
|||||||
task::sleep_ms(2000);//really neccessary form uart debug
|
task::sleep_ms(2000);//really neccessary form uart debug
|
||||||
// Start Main task as privileged task
|
// Start Main task as privileged task
|
||||||
main_task Main;
|
main_task Main;
|
||||||
Main.start(MAIN_PRIORITY, true);
|
Main.sign_up(core_t::CURRENT_CORE, 50, true);
|
||||||
// Start the multitasking
|
// Start the multitasking
|
||||||
task::start_scheduler();
|
task::start_scheduler();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void sd_reader_task::start(FatFs * fs, FatFs::FILE * file) {
|
|||||||
_eof = false;
|
_eof = false;
|
||||||
_force_eof = false;
|
_force_eof = false;
|
||||||
_execute = false;
|
_execute = false;
|
||||||
task::start();
|
task::sign_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
FatFs::FRESULT sd_reader_task::read_data(uint8_t* buff, uint16_t btr, uint16_t* br) {
|
FatFs::FRESULT sd_reader_task::read_data(uint8_t* buff, uint16_t btr, uint16_t* br) {
|
||||||
|
|||||||
Reference in New Issue
Block a user