Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ******************************************************************************************************************* //
- // *** W I K I M P 3 L I B R A R Y ********************************************************************************* //
- // ******************************************************************************************************************* //
- // WIKIMP3.cpp //
- // //
- // biblioteka obsługi odtwarzacza mp3 dla MD_YX5300.h //
- // //
- // version : 0.1 BETA - codename : Music Is Play //
- // build date : 31.01.2021 //
- // code by : Wiktoria //
- // //
- // ******************************************************************************************************************* //
- #ifndef _wikimp3_h
- #include "wikimp3.h"
- #endif
- #ifndef _arduino_h
- #include "Arduino.h"
- #endif
- #ifndef _SoftwareSerial_h
- #include <SoftwareSerial.h>
- #endif
- // 28364 - 2444
- // ------------------------------------------------------------------------------------------------------------- //
- // --- B T S ----------------------------------------------------------------------------------------------- //
- // ------------------------------------------------------------------------------------------------------------- //
- const unsigned int btsfile000 [] PROGMEM = { 0, 0, 1 };
- const unsigned int btsfile001 [] PROGMEM = { 1, 245, 1 };
- const unsigned int btsfile002 [] PROGMEM = { 2, 266, 1 };
- const unsigned int btsfile003 [] PROGMEM = { 3, 257, 1 };
- const unsigned int btsfile004 [] PROGMEM = { 4, 255, 1 };
- const unsigned int btsfile005 [] PROGMEM = { 5, 265, 1 };
- const unsigned int btsfile006 [] PROGMEM = { 6, 268, 1 };
- const unsigned int btsfile007 [] PROGMEM = { 7, 42, 1 };
- const unsigned int btsfile008 [] PROGMEM = { 8, 236, 1 };
- const unsigned int btsfile009 [] PROGMEM = { 9, 242, 1 };
- const unsigned int btsfile010 [] PROGMEM = { 10, 226, 1 };
- const unsigned int btsfile011 [] PROGMEM = { 11, 221, 1 };
- const unsigned int btsfile012 [] PROGMEM = { 12, 235, 1 };
- const unsigned int btsfile013 [] PROGMEM = { 13, 228, 1 };
- const unsigned int btsfile014 [] PROGMEM = { 14, 217, 1 };
- const unsigned int btsfile015 [] PROGMEM = { 15, 224, 1 };
- const unsigned int btsfile016 [] PROGMEM = { 16, 234, 1 };
- const unsigned int btsfile017 [] PROGMEM = { 17, 227, 1 };
- const unsigned int btsfile018 [] PROGMEM = { 18, 237, 1 };
- const unsigned int btsfile019 [] PROGMEM = { 19, 323, 1 };
- const unsigned int btsfile020 [] PROGMEM = { 20, 277, 1 };
- const unsigned int btsfile021 [] PROGMEM = { 21, 300, 1 };
- const unsigned int btsfile022 [] PROGMEM = { 22, 197, 1 };
- const unsigned int btsfile023 [] PROGMEM = { 23, 241, 1 };
- const unsigned int btsfile024 [] PROGMEM = { 24, 241, 1 };
- const unsigned int btsfile025 [] PROGMEM = { 25, 230, 1 };
- const unsigned int btsfile026 [] PROGMEM = { 26, 211, 1 };
- const unsigned int btsfile027 [] PROGMEM = { 27, 222, 1 };
- const unsigned int btsfile028 [] PROGMEM = { 28, 276, 1 };
- const unsigned int btsfile029 [] PROGMEM = { 29, 219, 1 };
- const unsigned int btsfile030 [] PROGMEM = { 30, 233, 1 };
- const unsigned int btsfile031 [] PROGMEM = { 31, 282, 1 };
- const unsigned int btsfile032 [] PROGMEM = { 32, 285, 1 };
- const unsigned int btsfile033 [] PROGMEM = { 33, 85, 1 };
- const unsigned int btsfile034 [] PROGMEM = { 34, 243, 1 };
- const unsigned int btsfile035 [] PROGMEM = { 35, 230, 1 };
- const unsigned int btsfile036 [] PROGMEM = { 36, 226, 1 };
- const unsigned int btsfile037 [] PROGMEM = { 37, 249, 1 };
- const unsigned int btsfile038 [] PROGMEM = { 38, 223, 1 };
- const unsigned int btsfile039 [] PROGMEM = { 39, 220, 1 };
- const unsigned int btsfile040 [] PROGMEM = { 40, 244, 1 };
- const unsigned int btsfile041 [] PROGMEM = { 41, 199, 1 };
- const unsigned int btsfile042 [] PROGMEM = { 42, 248, 1 };
- const unsigned int btsfile043 [] PROGMEM = { 43, 293, 1 };
- const unsigned int btsfile044 [] PROGMEM = { 44, 245, 1 };
- const unsigned int btsfile045 [] PROGMEM = { 45, 77, 1 };
- const unsigned int btsfile046 [] PROGMEM = { 46, 75, 1 };
- const unsigned int btsfile047 [] PROGMEM = { 47, 255, 1 };
- const unsigned int btsfile048 [] PROGMEM = { 48, 237, 1 };
- const unsigned int btsfile049 [] PROGMEM = { 49, 233, 1 };
- const unsigned int btsfile050 [] PROGMEM = { 50, 334, 1 };
- const unsigned int btsfile051 [] PROGMEM = { 51, 232, 1 };
- const unsigned int btsfile052 [] PROGMEM = { 52, 235, 1 };
- const unsigned int btsfile053 [] PROGMEM = { 53, 222, 1 };
- const unsigned int btsfile054 [] PROGMEM = { 54, 248, 1 };
- const unsigned int btsfile055 [] PROGMEM = { 55, 212, 1 };
- const unsigned int btsfile056 [] PROGMEM = { 56, 353, 1 };
- const unsigned int btsfile057 [] PROGMEM = { 57, 96, 1 };
- const unsigned int btsfile058 [] PROGMEM = { 58, 122, 1 };
- const unsigned int btsfile059 [] PROGMEM = { 59, 217, 1 };
- const unsigned int btsfile060 [] PROGMEM = { 60, 230, 1 };
- const unsigned int btsfile061 [] PROGMEM = { 61, 216, 1 };
- const unsigned int btsfile062 [] PROGMEM = { 62, 216, 1 };
- const unsigned int btsfile063 [] PROGMEM = { 63, 190, 1 };
- const unsigned int btsfile064 [] PROGMEM = { 64, 234, 1 };
- const unsigned int btsfile065 [] PROGMEM = { 65, 212, 1 };
- const unsigned int btsfile066 [] PROGMEM = { 66, 226, 1 };
- const unsigned int btsfile067 [] PROGMEM = { 67, 242, 1 };
- const unsigned int btsfile068 [] PROGMEM = { 68, 294, 1 };
- const unsigned int btsfile069 [] PROGMEM = { 69, 213, 1 };
- const unsigned int btsfile070 [] PROGMEM = { 70, 193, 1 };
- const unsigned int btsfile071 [] PROGMEM = { 71, 273, 1 };
- const unsigned int btsfile072 [] PROGMEM = { 72, 144, 1 };
- const unsigned int btsfile073 [] PROGMEM = { 73, 139, 1 };
- const unsigned int btsfile074 [] PROGMEM = { 74, 238, 1 };
- const unsigned int btsfile075 [] PROGMEM = { 75, 205, 1 };
- const unsigned int btsfile076 [] PROGMEM = { 76, 232, 1 };
- const unsigned int btsfile077 [] PROGMEM = { 77, 268, 1 };
- const unsigned int btsfile078 [] PROGMEM = { 78, 200, 1 };
- const unsigned int btsfile079 [] PROGMEM = { 79, 246, 1 };
- const unsigned int btsfile080 [] PROGMEM = { 80, 236, 1 };
- const unsigned int btsfile081 [] PROGMEM = { 81, 272, 1 };
- const unsigned int btsfile082 [] PROGMEM = { 82, 241, 1 };
- const unsigned int btsfile083 [] PROGMEM = { 83, 285, 1 };
- const unsigned int btsfile084 [] PROGMEM = { 84, 212, 1 };
- const unsigned int btsfile085 [] PROGMEM = { 85, 173, 1 };
- const unsigned int btsfile086 [] PROGMEM = { 86, 207, 1 };
- const unsigned int btsfile087 [] PROGMEM = { 87, 222, 1 };
- const unsigned int btsfile088 [] PROGMEM = { 88, 255, 1 };
- const unsigned int btsfile089 [] PROGMEM = { 89, 180, 1 };
- const unsigned int btsfile090 [] PROGMEM = { 90, 202, 1 };
- const unsigned int btsfile091 [] PROGMEM = { 91, 240, 1 };
- const unsigned int btsfile092 [] PROGMEM = { 92, 205, 1 };
- const unsigned int btsfile093 [] PROGMEM = { 93, 199, 1 };
- const unsigned int btsfile094 [] PROGMEM = { 94, 171, 1 };
- const unsigned int btsfile095 [] PROGMEM = { 95, 230, 1 };
- const unsigned int btsfile096 [] PROGMEM = { 96, 226, 1 };
- const unsigned int btsfile097 [] PROGMEM = { 97, 227, 1 };
- const unsigned int btsfile098 [] PROGMEM = { 98, 250, 1 };
- const unsigned int btsfile099 [] PROGMEM = { 99, 261, 1 };
- const unsigned int btsfile100 [] PROGMEM = { 100, 198, 1 };
- const unsigned int btsfile101 [] PROGMEM = { 101, 181, 1 };
- const unsigned int btsfile102 [] PROGMEM = { 102, 236, 1 };
- const unsigned int btsfile103 [] PROGMEM = { 103, 217, 1 };
- const unsigned int btsfile104 [] PROGMEM = { 104, 247, 1 };
- const unsigned int btsfile105 [] PROGMEM = { 105, 227, 1 };
- const unsigned int btsfile106 [] PROGMEM = { 106, 251, 1 };
- const unsigned int btsfile107 [] PROGMEM = { 107, 233, 1 };
- const unsigned int btsfile108 [] PROGMEM = { 108, 200, 1 };
- const unsigned int btsfile109 [] PROGMEM = { 109, 209, 1 };
- const unsigned int btsfile110 [] PROGMEM = { 110, 239, 1 };
- const unsigned int btsfile111 [] PROGMEM = { 111, 263, 1 };
- const unsigned int btsfile112 [] PROGMEM = { 112, 192, 1 };
- // --------------------------------------------------------------------------------------------------
- const unsigned int * const btsfile[] PROGMEM = {
- btsfile000, btsfile001, btsfile002, btsfile003, btsfile004,
- btsfile005, btsfile006, btsfile007, btsfile008, btsfile009,
- btsfile010, btsfile011, btsfile012, btsfile013, btsfile014,
- btsfile015, btsfile016, btsfile017, btsfile018, btsfile019,
- btsfile020, btsfile021, btsfile022, btsfile023, btsfile024,
- btsfile025, btsfile026, btsfile027, btsfile028, btsfile029,
- btsfile030, btsfile031, btsfile032, btsfile033, btsfile034,
- btsfile035, btsfile036, btsfile037, btsfile038, btsfile039,
- btsfile040, btsfile041, btsfile042, btsfile043, btsfile044,
- btsfile045, btsfile046, btsfile047, btsfile048, btsfile049,
- btsfile050, btsfile051, btsfile052, btsfile053, btsfile054,
- btsfile055, btsfile056, btsfile057, btsfile058, btsfile059,
- btsfile060, btsfile061, btsfile062, btsfile063, btsfile064,
- btsfile065, btsfile066, btsfile067, btsfile068, btsfile069,
- btsfile070, btsfile071, btsfile072, btsfile073, btsfile074,
- btsfile075, btsfile076, btsfile077, btsfile078, btsfile079,
- btsfile080, btsfile081, btsfile082, btsfile083, btsfile084,
- btsfile085, btsfile086, btsfile087, btsfile088, btsfile089,
- btsfile090, btsfile091, btsfile092, btsfile093, btsfile094,
- btsfile095, btsfile096, btsfile097, btsfile098, btsfile099,
- btsfile100, btsfile101, btsfile102, btsfile103, btsfile104,
- btsfile105, btsfile106, btsfile107, btsfile108, btsfile109,
- btsfile110, btsfile111, btsfile112
- };
- // --- Z M I E N N E E X T E R N ----------------------------------------------------------------------------------- //
- extern volatile uint_fast8_t godzina; // --- aktualna godzina dla MP3 - która godzina minęła -------- //
- //
- extern volatile uint_fast8_t progressBar[16]; // --- progress bar ------------------------------------------- //
- extern bool F_music_play; // --- flaga globalna --- czy muzyka jest odtwarzana ---------- //
- extern bool F_music_start; // --- flaga globalna --- muzyka zaczęła grać ----------------- //
- extern bool F_music_stop; // --- flaga globalna --- muzyka się skonczyla ---------------- //
- extern bool F_music_auto; // --- flaga globalna --- dla wątku jeślu TRUE to wywołuj ----- //
- // --- funkcję MP3Play(); jeśli trwa odtwarzanie lub jeśli ---- //
- // --- F_mp3_is_play przestawione na FALSE wywołaj MP3Start --- //
- extern bool F_timer_auto; // --- flaga globalna --- powiedz ktora godzina --------------- //
- extern bool F_NeoFire_stop; // --- ustaw na TRUE jeśli mp3_STOP --------------------------- //
- extern bool F_NeoFire_play; // --- ustaw na TRUE jeśli mp3 PLAY --------------------------- //
- extern volatile uint_fast16_t data[4]; // --- bieżąca data [0] -> to dzień tygodnia, od 1 do 7 //
- // --- I N I T ------------------------------------------------------------------------------------------------------- //
- void WIKIMP3::init() //
- { //
- mp3.volume(mp3_volume); // --- volume na 60 (max 67, HEX: 0x43) //
- sizeBTS = sizeof(btsfile)/2; // --- ile plików mp3 --- policz ------------------------------ //
- } //
- // --- M P 3 P L A Y ----------------------------------------------------------------------------------------------- //
- void WIKIMP3::MP3Play() //
- { //
- unsigned int progress = 0; // --- przechowuj tu zmapowany stan progress BAR -------------- //
- //
- // --- jesli trwa odtwarzanie ------------------------------------------------------------------------------------ //
- if(F_mp3_is_play) //
- { //
- mp3_current_time++; // czas utworu +1 ---------------- //
- progress = map(mp3_current_time, 0, mp3_playing_time, 1, 17); // mapuj czas do progress BAR ---- //
- for(byte index = 0; index < progress; index ++) progressBar[index] = 1; // zapisz tablicę progress BAR --- //
- // --- komunikacja SERIAL ------------------------------------------------------------------------------------ //
- #if DEBUG_WIKIMP3
- static byte slow_debug = 0; //
- slow_debug ++; //
- if(slow_debug > 9) //
- { //
- Serial.print(F("Inside: MP3Play(); Music is now Play !!! Nr.Pliku : ")); //
- Serial.print(mp3_current_file); //
- Serial.print(F(" Real Time: ")); //
- Serial.print(mp3_current_time); //
- Serial.print(F(" of ")); //
- Serial.println(mp3_playing_time); //
- slow_debug = 0; //
- } //
- //
- #endif //
- } //
- // --- jeśli skończył się utwót ---------------------------------------------------------------------------------- //
- if(mp3_current_time>=mp3_playing_time) //
- { //
- F_mp3_is_play = false; // odtwarzacz WOLNY -------------- //
- F_music_stop = true; // dla LCD -> usuń progress BAR -- //
- //
- if(mp3_current_file<sizeBTS) mp3_current_file++; // ustaw znacznik na kolejny plik //
- else mp3_current_file=1; // koniec playlisty, RESET LOOP -- //
- // --- komunikacja SERIAL ------------------------------------------------------------------------------------ //
- #if DEBUG_WIKIMP3
- static byte slow_debug = 0; //
- slow_debug ++; //
- if(slow_debug > 10) //
- { //
- Serial.print(F("Inside: MP3Play(); Music is end Play !!! Nr.Pliku nastepnego: ")); //
- Serial.println(mp3_current_file); //
- slow_debug = 0; //
- } //
- #endif //
- //
- } //
- } //
- // --- M P 3 S T A R T --------------------------------------------------------------------------------------------- //
- void WIKIMP3::MP3Start() //
- { //
- // jesli muzyka nie jest odtwarzana uruchom od bieżącego pliku --------------------------------------------------- //
- if(!F_mp3_is_play) //
- {
- unsigned int * ptr = (unsigned int*) pgm_read_word(&btsfile[mp3_current_file]); // wskaźnik do PROGMEM --- //
- mp3_current_file = pgm_read_word ( & ptr[0] ); // wyłuskaj nr. pliku ---- //
- mp3_playing_time = pgm_read_word ( & ptr[1] ); // wyłuskaj czas trwania - //
- //mp3_current_dir = pgm_read_word ( & ptr[2] ); // wyluskaj folder plikow //
- mp3_current_time = 0; // zeruj czas ------------ //
- //
- mp3.playSpecific(1, mp3_current_file); // uruchom odtwarzanie ----------------------------- //
- //
- F_mp3_is_play = true; // flaga TRUE jeśli trwa odtwarzanie //
- F_music_play = true; // flaga dla LCD, jesli TRUE to progress BAR //
- F_music_stop = false; // ??? --------------------------------------------- //
- F_music_start = true; // flaga dla LCD, jeśli start to rysuj progress //
- //
- // potem jest przestawiania na FALSE by nie drukować //
- // poraz kolejny, tylko uzupełniany postęp pliku //
- F_music_auto = true; // flaga wątku (jeśli TRUE sprawdzaj co 1 sekundę) //
- F_timer_auto = false; // flaga TimeSpeaker --- FALSE jesli blokada ------- //
- F_NeoFire_play = true; // uruchom wątek dla FireLed ----------------------- //
- // --- komunikacja SERIAL ------------------------------------------------------------------------------------ //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: MP3Start(); Start Music Play !!! Uruchomiono plik, nr: "));
- Serial.println(mp3_current_file);
- #endif //
- } //
- // jeśli muzyka jest odtwarzana to : STOP i reset flag ----------------------------------------------------------- //
- else //
- { //
- mp3.playStop(); // zatrzymaj muzykę //
- F_music_play = false; // dla wyświetlacza LCD, nie wyświetlaj progress BAR //
- F_music_auto = false; // dla wątku, nie uruchamiaj funkcji PlayerUpdate //
- F_mp3_is_play = false; // flaga FALSE jeśli nie trwa odtwarzanie //
- F_music_stop = true; // flaga dla LCD -> jest STOP wyczyść progress BAR //
- F_timer_auto = true; // pozwolenie na TimeSpeaker ----------------------- //
- F_NeoFire_stop = true; // zatrzymaj wątek dla FireLed --------------------- //
- // --- komunikacja SERIAL ------------------------------------------------------------------------------------ //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: MP3Start(); Stop Music Play !!! Zatrzymano na pliku, nr: "));
- Serial.println(mp3_current_file - 1);
- #endif //
- } //
- } //
- // ------------------------------------------------------------------------------------------------------------------- //
- // ---- M P 3 N E X T F I L E ------------------------------------------------------------------------------------ //
- // ------------------------------------------------------------------------------------------------------------------- //
- // void WIKIMP3::MP3Next() uruchamiana jest tylko wtedy kiedy trwa odtwarzanie pliku mp3. Funkcja jest uruchamiana //
- // z funkcji PlayerUpdate, która otrzymuje kod pilota - jeśli jest to 3 i flaga TRUE //
- // Wykorzystano do obsługi kolejnego pliku funkcje MP3Start (stop/przestawienie/start) //
- // ------------------------------------------------------------------------------------------------------------------- //
- void WIKIMP3::MP3Next() //
- { //
- // zatrzymanie odtwarzacza ------------------------- //
- if(mp3_current_file<sizeBTS) mp3_current_file++; // ustaw znacznik na kolejny plik jeśli nie koniec - //
- else mp3_current_file=1; // ustaw znacznik na pierwszy plik jeśli koniec ---- //
- MP3Start(); // zatrzymaj odtwarzacz ---------------------------- //
- for(byte index = 0; index <= 16; index ++) progressBar[index] = 0; // posprzątaj progress BAR ------ //
- // --- komunikacja SERIAL ---------------------------------------------------------------------------------------- //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: MP3Next(); Check -> mp3_current_file = "));
- Serial.println(mp3_current_file);
- #endif
- } //
- // ---- M P 3 P R E V F I L E ------------------------------------------------------------------------------------ //
- void WIKIMP3::MP3Prev() //
- { //
- if(mp3_current_file==1) mp3_current_file = sizeBTS - 1; //
- else mp3_current_file --; //
- MP3Start(); // zatrzymaj odtwarzacz ---------------------------- //
- for(byte index = 0; index <= 16; index ++) progressBar[index] = 0; // posprzątaj progress BAR ------ //
- // --- komunikacja SERIAL ---------------------------------------------------------------------------------------- //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: MP3Prev(); Check -> mp3_current_file = "));
- Serial.println(mp3_current_file);
- #endif //
- } //
- // ------------------------------------------------------------------------------------------------------------------- //
- // ---- M P 3 V O L U M E U P ---------------------------------------------------------------------------------- //
- // ------------------------------------------------------------------------------------------------------------------- //
- // Funkcja zwiększająca dźwięk. Wykona się jeśli na pilocie zostanie wciśnięty przycisk "+" oraz flaga //
- // F_mp3_is_play ma wartość TRUE - czyli aktualnie odtwarzany jest plik. mp3, w innym przypadku nic nie jest robione //
- // maksymalna wartość to 60, każde wciśnięcie powiększa bieżącą wartość o 5 jednostek pod warunkiem, że nie osiągnięto //
- // wartości maksymalnej. Jeśli DEBUG_WIKIMP3 ma wartość TRUE pokazuj na SERIAL MONITOR komunikaty //
- // ------------------------------------------------------------------------------------------------------------------- //
- void WIKIMP3::MP3VolUp() //
- { //
- if(mp3_volume < 56) // jeśli nie osiągnięto maksimum --- //
- { //
- mp3_volume += 5; // zwiększ dźwięk o 5 jeśli < 56 --- //
- mp3.volume(mp3_volume); // ustaw nową wartość dźwięku ------ //
- } //
- // --- komunikacja SERIAL ---------------------------------------------------------------------------------------- //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: MP3VolUp(); Check -> uint8_t mp3_volume = "));
- Serial.println(mp3_volume);
- #endif //
- //
- } //
- // ------------------------------------------------------------------------------------------------------------------- //
- // ---- M P 3 V O L U M E D O W N ------------------------------------------------------------------------------ //
- // ------------------------------------------------------------------------------------------------------------------- //
- // Funkcja zmniejszająca dźwięk. Wykona się jeśli na pilocie zostanie wciśnięty przycisk "-" oraz flaga //
- // F_mp3_is_play ma wartość TRUE - czyli aktualnie odtwarzany jest plik. mp3, w innym przypadku nic nie jest robione //
- // minimalna wartość to 0, każde wciśnięcie pomniejsza bieżącą wartość o 5 jednostek, pod warunkiem, że nie osiągnięto //
- // wartości minimalnej. Jeśli DEBUG_WIKIMP3 ma wartość TRUE pokazuj na SERIAL MONITOR komunikaty //
- // ------------------------------------------------------------------------------------------------------------------- //
- void WIKIMP3::MP3VolDown() //
- { //
- if(mp3_volume > 4) // jeśli nie osiągnieto minimum ---- //
- { //
- mp3_volume -=5; // zmniejsz dźwięk 0 5 jeśli > 4 --- //
- mp3.volume(mp3_volume); // ustaw nową wartość dźwięku ------ //
- } //
- // --- komunikacja SERIAL ---------------------------------------------------------------------------------------- //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: MP3VolDown(); Check -> uint8_t mp3_volume = "));
- Serial.println(mp3_volume);
- #endif //
- } //
- // ------------------------------------------------------------------------------------------------------------------- //
- // ---- T I M E S P E A K E R b y C Z U B Ó W N A -------------------------------------------------------------- //
- // ------------------------------------------------------------------------------------------------------------------- //
- // Funkcja co godzinę mówi głosem Czubówny która godzina upłynęła. Uruchamiana jest tylko wtedy kiedy odtwarzacz //
- // nie odtwarza w danej chwili pliku mp3. Za pozwolenie na wykonanie odpowiada flaga : F_timer_auto, jest jest FALSE //
- // nigdy się nie wykona, możliwe tylko wtedy gdy program sterujący mp3 przestawi flagę na TRUE czyli zwolni mp3 //
- // ------------------------------------------------------------------------------------------------------------------- //
- void WIKIMP3::SpeakTime() //
- { //
- mp3.playSpecific(2, godzina); // powiedz która godzina ----------- //
- // --- komunikacja SERIAL ---------------------------------------------------------------------------------------- //
- #if DEBUG_WIKIMP3
- Serial.print(F("Inside: SpeakTime(); Say: Time "));
- Serial.println(godzina);
- #endif
- } //
- // ------------------------------------------------------------------------------------------------------------------- //
- // --- A U T O P L A Y E R I O B S Ł U G A P I L O T A ------------------------------------------------------ //
- // //
- // code = 0 -> jeśli flaga F_music_auto jest TRUE kod wchodzi z obsługi wątku co 1 sekundę w celu wyświetlenia //
- // progressBAR na wyświetlaczu LCD, zwiększenia programowo czasu odwarzanego pliku : mp3_current_time ++ //
- // jeśli odtwarzanie dobiegło końcowi zaczynają się operację wyboru następnego utworu i sprzątanie //
- // progress BAR, przestawianie FLAG. Jeśli F_music_auto to FALSE funkcja klasy nie jest wywoływana //
- // //
- // case = 1 -> jeśli flaga F_mp3_is_play to TRUE wywołana funkcja MP3Start powoduje zatrzymanie odtwarzania //
- // jeśli flaga F_mp3_is_play to FALSE wywołana funkcja MP3Start powoduje rozpoczęcie odtwarzania //
- // kod 1 - pochodzi z przycisku PLAY pilota, możliwe że w późniejszym czasie będzie też wysyłany przez //
- // funkcje zarządzające czasem (autoplay / autostop) o danych godzinach w określonych dniach //
- // //
- // case = 2 -> jeśli flaga F_music_is_play jest TRUE czyli trwa odtwarzanie, wywołaj funkcję MP3Prev(); //
- // przestaw bieżący plik na poprzedni, ale jeśli obecnie odtwarzany plik jest pierwszym z playlisty //
- // to ustaw na ostatni. Zatrzymaj odtwarzanie funkcją MP3Start(); i ponowie ją wywołaj w celu PLAY //
- // //
- // case = 3 -> jeśli flaga F_music_is_play jest TRUE czyli trwa odtwarzanie, wywołaj funkcję MP3Next(); //
- // przestaw bieżący plik na następny, ale jeśli obecnie odtwarzany plik jest ostatnim z playlisty //
- // to ustaw na pierwszy. Zatrzymaj odtwarzanie funkcją MP3Start(); i ponowie ją wywołaj w celu PLAY //
- // //
- // case = 4 -> jeśli flaga F_music_is_play jest TRUE czyli trwa odtwarzanie, wywołaj funkcję MP3VolUp(); //
- // zwiększ głośność o 5 jednostek pod warunkiem że nie osiągnięto wartości maksymalnej 60 //
- // //
- // case = 5 -> jesli flaga F_music_is_play jest TRUE czyli trwa odtwarzanie, wywołaj funkcję MP3VolDown(); //
- // zmniejsz głośność o 5 jednostek pod warunkiem że nie osiągnieto wartości minimalnej 0 //
- // ------------------------------------------------------------------------------------------------------------------- //
- void WIKIMP3::PlayerUpdate(byte code) //
- { //
- switch (code) //
- { //
- case 0 : if ( F_mp3_is_play ) MP3Play(); // jesli trwa odtwarzanie wykonaj operacje obsługi --- //
- else //
- if (!F_mp3_is_play ) MP3Start(); // auto play -> obsługiwane flagą f_musi_auto -------- //
- break;
- case 1 : MP3Start(); // uruchom funkcję PLAY jest (F_mp3_is_play = FALSE) //
- break;
- case 2 : MP3Prev();
- MP3Start();
- break;
- case 3 : MP3Next();
- MP3Start(); // next mp3 file -> jeśli F_mp3_is_play jest TRUE ---- //
- break;
- case 4 : MP3VolUp();
- break;
- case 5 : MP3VolDown();
- break;
- default : break; //
- } //
- } //
- // ------------------------------------------------------------------------------------------------------------------- //
- /*
- void Test(int nr)
- {
- unsigned int * ptr = (unsigned int*) pgm_read_word(&btsfile[nr]);
- cFile = pgm_read_word ( & ptr[0] );
- cTime = pgm_read_word ( & ptr[1] );
- Serial.print("FILE : ");
- Serial.println(cFile);
- Serial.print("TIME : ");
- Serial.println(cTime);
- }
- */
Add Comment
Please, Sign In to add comment