Skip to content

Commit

Permalink
remove MP3PLAYER define
Browse files Browse the repository at this point in the history
  • Loading branch information
vortigont committed Jan 17, 2024
1 parent 6d95c92 commit 42d14b4
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 66 deletions.
28 changes: 0 additions & 28 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ JeeUI2 lib used under MIT License Copyright (c) 2019 Marsel Akhkamov

//-----------------------------------
//#define LAMP_DEBUG // режим отладки, можно также включать в platformio.ini
//#define MP3PLAYER // Включить использование MP3 плеера (DF Player)
//-----------------------------------
#ifndef LANG_FILE
#define LANG_FILE "text_res-RUS.h" // Языковой файл по дефолту
Expand Down Expand Up @@ -134,39 +133,12 @@ JeeUI2 lib used under MIT License Copyright (c) 2019 Marsel Akhkamov
#define MIN_PEAK_LEVEL (50U) // Минимальный амплитудный уровень, для эффектов зависящих от микрофона
#endif

#ifdef MP3PLAYER
#ifndef MP3_TX_PIN
#ifdef ESP8266
#define MP3_TX_PIN (12) // TX mp3 player RX (D5)
#else
#define MP3_TX_PIN 17 // Serial2 tx
#endif
#endif
#ifndef MP3_RX_PIN
#ifdef ESP8266
#define MP3_RX_PIN (14) // RX mp3 player TX (D6)
#else
#define MP3_RX_PIN 16 // Serial2 rx
#endif

#endif
#ifndef MP3_SERIAL_TIMEOUT
#define MP3_SERIAL_TIMEOUT (300U) // 300мс по умолчанию, диапазон 200...1000, подбирается экспериментально, не желательно сильно повышать
#endif
#ifndef DFPLAYER_START_DELAY
#define DFPLAYER_START_DELAY (500U) // 500мс по умолчанию, диапазон 10...1000, подбирается экспериментально, не желательно сильно повышать, безусловная задержка до инициализации
#endif
#endif

#ifndef BTN_PIN
#define BTN_PIN (5U) // пин кнопки (D1)
#if BTN_PIN == 0
#define PULL_MODE (HIGH_PULL) // пин кнопки "FLASH" NodeMCU, подтяжка должна быть PULL_MODE=HIGH_PULL
#endif
#endif
#ifndef NUMHOLD_TIME
#define NUMHOLD_TIME (3000U) // время запоминания последней комбинации яркости/скорости/масштаба в мс
#endif


#ifndef DS18B20_PIN
Expand Down
1 change: 0 additions & 1 deletion include/user_config.h.default
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ https://github.com/vortigont/FireLamp_JeeUI/wiki/%D0%9D%D0%B0%D0%B7%D0%BD%D0%B0%


//------------------------------ Подключаемое дополнительное оборудование
//#define MP3PLAYER // Включить использование MP3 плеера (DF Player)
//#define ENCODER // Использовать Энкодер

//------------------------------
Expand Down
2 changes: 0 additions & 2 deletions src/actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ void run_action(ra act, const T& param) {
break;
}

#ifdef MP3PLAYER
//MP3: enable/disable
case ra::mp3_enable : {
obj[P_action] = TCONST_Mic;
Expand All @@ -199,7 +198,6 @@ void run_action(ra act, const T& param) {
mp3->playEffect(mp3->getCurPlayingNb() + offset, "");
return; // no need to execute any UI action
}
#endif //#ifdef MP3PLAYER


// all the rest we just assign "action": 'value' pair
Expand Down
24 changes: 5 additions & 19 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ void ui_section_effects_list_configuration(Interface *interf, const JsonObject *
interf->json_section_begin(TCONST_set_effect);

interf->text(TCONST_effname, "", TINTF_effrename); // поле под новое имя оставляем пустым
#ifdef MP3PLAYER
//interf->text(TCONST_soundfile, tmpSoundfile, TINTF_0B2);
#endif

interf->json_section_line();
interf->checkbox(TCONST_eff_sel, confEff->canBeSelected(), TINTF_in_sel_lst); // доступен для выбора в выпадающем списке на главной странице
interf->checkbox(TCONST_eff_fav, confEff->isFavorite(), TINTF_in_demo); // доступен в демо-режиме
Expand Down Expand Up @@ -614,11 +612,10 @@ void set_effects_config_list(Interface *interf, const JsonObject *data, const ch
// обновляем поля
interf->json_frame_value();

#ifdef MP3PLAYER
String tmpSoundfile;
myLamp.effwrkr.loadsoundfile(tmpSoundfile,confEff->eff_nb);
interf->value(TCONST_soundfile, tmpSoundfile, false);
#endif

interf->value(TCONST_eff_sel, confEff->canBeSelected(), false); // доступен для выбора в выпадающем списке на главной странице
interf->value(TCONST_eff_fav, confEff->isFavorite(), false); // доступен в демо-режиме

Expand Down Expand Up @@ -780,9 +777,8 @@ void ui_block_mainpage_switches(Interface *interf, const JsonObject *data, const
interf->checkbox(TCONST_drawbuff, myLamp.isDrawOn(), TINTF_0CE, true);
interf->checkbox(TCONST_Mic, myLamp.isMicOnOff(), TINTF_012, true);
interf->checkbox(TCONST_AUX, embui.paramVariant(TCONST_AUX), TCONST_AUX, true);
#ifdef MP3PLAYER
interf->checkbox(TCONST_isOnMP3, myLamp.isONMP3(), TINTF_099, true);
#endif

#ifdef LAMP_DEBUG
interf->checkbox(TCONST_debug, myLamp.isDebugOn(), TINTF_08E, true);
#endif
Expand All @@ -797,7 +793,7 @@ void ui_block_mainpage_switches(Interface *interf, const JsonObject *data, const
interf->json_section_end(); // select

interf->json_section_end(); // json_section_line()
#ifdef MP3PLAYER

if(mp3->isMP3Mode()){
interf->json_section_line("line124"); // спец. имя - разбирается внутри html
interf->button(button_t::generic, CMD_MP3_PREV, TINTF_0BD, P_GRAY);
Expand All @@ -808,7 +804,6 @@ void ui_block_mainpage_switches(Interface *interf, const JsonObject *data, const
}
// регулятор громкости mp3 плеера
interf->range(TCONST_mp3volume, embui.paramVariant(TCONST_mp3volume).as<int>(), 1, 30, 1, TINTF_09B, true);
#endif

interf->button(button_t::generic, A_ui_page_effects, TINTF_exit);
interf->json_frame_flush();
Expand Down Expand Up @@ -1070,7 +1065,6 @@ void set_overlay_drawing(Interface *interf, const JsonObject *data, const char*
myLamp.enableDrawing((*data)[TCONST_drawbuff]);
}

#ifdef MP3PLAYER
// show page with MP3 Player setup
void show_settings_mp3(Interface *interf, const JsonObject *data, const char* action){
if (!interf) return;
Expand Down Expand Up @@ -1201,7 +1195,6 @@ void set_mp3_player(Interface *interf, const JsonObject *data, const char* actio
mp3->playEffect(cur_palyingnb+5,"");
}
}
#endif

/*
сохраняет настройки GPIO и перегружает контроллер
Expand All @@ -1215,7 +1208,6 @@ void set_gpios(Interface *interf, const JsonObject *data, const char* action){

gpio_device dev = static_cast<gpio_device>((*data)[TCONST_set_gpio].as<int>());
switch(dev){
#ifdef MP3PLAYER
// DFPlayer gpios
case gpio_device::dfplayer : {
// save pin numbers into config file if present/valid
Expand All @@ -1226,7 +1218,6 @@ void set_gpios(Interface *interf, const JsonObject *data, const char* action){
else doc[TCONST_mp3tx] = (*data)[TCONST_mp3tx];
break;
}
#endif
// MOSFET gpios
case gpio_device::mosfet : {
if ( (*data)[TCONST_mosfet_gpio] == static_cast<int>(GPIO_NUM_NC) ) doc.remove(TCONST_mosfet_gpio);
Expand Down Expand Up @@ -1422,7 +1413,7 @@ void page_gpiocfg(Interface *interf, const JsonObject *data, const char* action)
embuifs::deserializeFile(doc, TCONST_fcfg_gpio);

interf->json_section_begin(TCONST_set_gpio, "");
#ifdef MP3PLAYER

// gpio для подключения DP-плеера
interf->json_section_hidden(TCONST_playMP3, "DFPlayer");
interf->json_section_line(); // расположить в одной линии
Expand All @@ -1431,7 +1422,6 @@ void page_gpiocfg(Interface *interf, const JsonObject *data, const char* action)
interf->json_section_end();
interf->button_value(button_t::submit, TCONST_set_gpio, static_cast<int>(gpio_device::dfplayer), TINTF_Save);
interf->json_section_end();
#endif

#if DISABLED_CODE
// gpio для подключения 7 сегментного индикатора
Expand Down Expand Up @@ -1685,10 +1675,8 @@ void embui_actions_register(){
//embui.var_create(TCONST_EncVGCol, "#FF2A00"); // Дефолтный цвет шкалы
#endif

#ifdef MP3PLAYER
embui.var_create(TCONST_mp3volume, 25); // громкость
//embui.var_create(TCONST_mp3count, 255); // кол-во файлов в папке mp3 (установка убрана, используется значение по-умолчанию равное максимальному числу эффектов)
#endif

embui.var_create(TCONST_tmBright, 82); // 5<<4+5, старшие и младшие 4 байта содержат 5

Expand Down Expand Up @@ -1758,7 +1746,6 @@ void embui_actions_register(){
embui.action.add(TCONST_debug, set_debugflag);
#endif

#ifdef MP3PLAYER
embui.action.add(TCONST_isOnMP3, set_mp3flag);
embui.action.add(TCONST_mp3volume, set_mp3volume);
embui.action.add(TCONST_show_mp3, show_settings_mp3);
Expand All @@ -1768,7 +1755,6 @@ void embui_actions_register(){
embui.action.add(CMD_MP3_NEXT, set_mp3_player);
embui.action.add(TCONST_mp3_p5, set_mp3_player);
embui.action.add(TCONST_mp3_n5, set_mp3_player);
#endif
/* #ifdef ENCODER
embui.action.add(TCONST_set_enc, set_settings_enc);
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/interface_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ void set_pwrswitch(Interface *interf, const JsonObject *data, const char* action
myLamp.power((*data)[action]);
//EVT_POST(LAMP_SET_EVENTS, (*data)[A_dev_pwrswitch] ? e2int(evt::lamp_t::pwron) : e2int(evt::lamp_t::pwroff));

#ifdef MP3PLAYER
if(myLamp.getLampFlagsStuct().isOnMP3)
mp3->setIsOn((*data)[A_dev_pwrswitch]);
#endif
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/lamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void Lamp::power(bool flag) // флаг включения/выключения
save_flags();
}

#ifdef MP3PLAYER
/*
temporary disable
void Lamp::playEffect(bool isPlayName, EFFSWITCH action){
Expand All @@ -205,7 +204,6 @@ void Lamp::playEffect(bool isPlayName, EFFSWITCH action){
}
}
*/
#endif // MP3PLAYER

void Lamp::startRGB(CRGB &val){
rgbColor = val;
Expand Down Expand Up @@ -479,21 +477,15 @@ void Lamp::_switcheffect(effswitch_t action, bool fade, uint16_t effnb, bool ski
effwrkr.switchEffect(effnb, true);

bool isShowName = (mode==LAMPMODE::MODE_DEMO && flags.showName);
#ifdef MP3PLAYER
bool isPlayName = (isShowName && flags.playName && !flags.playMP3 && effwrkr.getCurrent()>0);
#endif

// show effects's name on screen and play name over speaker (if set)
if(isShowName){
#ifdef MP3PLAYER
if(isPlayName && mp3!=nullptr && mp3->isOn()) // воспроизведение
mp3->playName(effwrkr.getCurrent());
#endif
}

#ifdef MP3PLAYER
playEffect(isPlayName, action); // воспроизведение звука, с проверкой текущего состояния
#endif

setBrightness(globalBrightness); // need to reapply brightness as effect's curve might have changed

Expand Down
4 changes: 0 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ JeeUI2 lib used under MIT License Copyright (c) 2019 Marsel Akhkamov
#endif


#ifdef MP3PLAYER
MP3PlayerDevice *mp3 = nullptr;
#endif


// Forward declarations
Expand Down Expand Up @@ -315,13 +313,11 @@ void gpio_setup(){
embuifs::deserializeFile(doc, TCONST_fcfg_gpio);
int rxpin, txpin;

#ifdef MP3PLAYER
// spawn an instance of mp3player
rxpin = doc[TCONST_mp3rx] | -1;
txpin = doc[TCONST_mp3tx] | -1;
LOG(printf_P, PSTR("DFPlayer: rx:%d tx:%d\n"), rxpin, txpin);
mp3 = new MP3PlayerDevice(rxpin, txpin, embui.paramVariant(TCONST_mp3volume) | DFPLAYER_DEFAULT_VOL );
#endif

}

Expand Down
2 changes: 0 additions & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,5 @@ JeeUI2 lib used under MIT License Copyright (c) 2019 Marsel Akhkamov


// глобальные переменные для работы с ними в программе
#ifdef MP3PLAYER
#include "mp3player.h"
extern MP3PlayerDevice *mp3;
#endif

0 comments on commit 42d14b4

Please sign in to comment.