Skip to content

Commit

Permalink
Merge pull request #58 from vortigont/mp3rew
Browse files Browse the repository at this point in the history
DFPlayer refactoring
  • Loading branch information
vortigont authored Feb 2, 2024
2 parents 042b8e1 + e9e1000 commit 36607c8
Show file tree
Hide file tree
Showing 29 changed files with 802 additions and 452 deletions.
Binary file modified data/index.html.gz
Binary file not shown.
Binary file modified data/js/ui_lamp.json.gz
Binary file not shown.
13 changes: 7 additions & 6 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ JeeUI2 lib used under MIT License Copyright (c) 2019 Marsel Akhkamov
#define MIN_PEAK_LEVEL (50U) // Минимальный амплитудный уровень, для эффектов зависящих от микрофона
#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
// DFPlayer
//#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


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

//#define LAMP_DEBUG // режим отладки, включает вывод отладочных сообщений в Serial порт



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

Expand Down
12 changes: 7 additions & 5 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ build_flags =

[libs]
common =
https://github.com/DmytroKorniienko/DFRobotDFPlayerMini
;GyverLibs/GyverButton@3.8
mrfaptastic/ESP32 HUB75 LED MATRIX PANEL DMA Display@3.0
https://github.com/toblum/TetrisAnimation
;GyverLibs/microDS18B20@3.10

vortigont =
https://github.com/vortigont/EmbUI#v3.1
https://github.com/vortigont/LedFB
https://github.com/vortigont/TM1637
https://github.com/vortigont/ESPAsyncButton
https://github.com/vortigont/DFMiniMp3#notpls


[env]
Expand Down Expand Up @@ -79,14 +77,18 @@ extends = esp32_base
board = wemos_d1_mini32
board_build.partitions = esp32_4MiB.csv


; ESP32 with debug
[env:esp32debug]
extends = env:esp32
build_flags =
${flags.build_flags}
-DLAMP_DEBUG=1
-DEMBUI_DEBUG
; Logging level: 1 = error, 2 = warning, 3 = info, 4 = debug, 5 = verbose
; LAMP_DEBUG_LEVEL severity level: 1 = error, 2 = warning, 3 = info, 4 = debug, 5 = verbose
-DLAMP_DEBUG_LEVEL=3
;-DDfMiniMp3Debug=Serial
;-DLAMP_DEBUG_PORT=Serial3
; Arduino Core Logging level: 1 = error, 2 = warning, 3 = info, 4 = debug, 5 = verbose
;-D CORE_DEBUG_LEVEL=4
;-D CONFIG_ARDUHAL_LOG_COLORS=1

Expand Down
7 changes: 4 additions & 3 deletions resources/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<title>FireLamp</title>
<link rel="stylesheet" href="css/pure.css">
<link rel="stylesheet" href="css/lamp.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<link id="dyncss" rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
Expand Down Expand Up @@ -114,7 +115,7 @@
{{#if2 type == 1}}{{onevent "click", "on_submit", id, value}}{{/if2}}
{{#if2 type == 2}}{{onevent "click", "on_js", id, value}}{{/if2}}
{{#if2 type == 3}} onclick="location.href='{{value}}'" type="button"{{/if2}}
>{{label}}</button>
>{{#if2 fa}}<i class="{{fa}}">{{/if2}}</i>{{/if2}}{{label}}</button>
{{/if}}
{{#if type == "checkbox"}}
<div class="switch-block">
Expand All @@ -123,7 +124,7 @@
</div>
{{/if}}
{{#if html == "const"}}
<div id="{{id}}" class="pure-u-1 pure-button mr">{{label}}{{#if2 value}}<input type="hidden" name="{{id}}" value="{{value}}">{{/if2}}</div>
<div id="{{id}}" class="pure-u-1 pure-button mr">{{#if2 fa}}<i class="{{fa}}">{{/if2}}</i>{{/if2}}{{label}}{{#if2 value}}<input type="hidden" name="{{id}}" value="{{value}}">{{/if2}}</div>
{{/if}}
{{#if html == "comment"}}
<div id="{{id}}" class="comment">{{label}}</div>
Expand Down Expand Up @@ -174,7 +175,7 @@
{{/if}}

{{#if html == "img"}}
<div class = "image"><img id="{{id}}" src = {{value}}></div>
<div class = "image"><img id="{{id}}" src = {{value}}></div>
{{/if}}
{{#if html == "input" && type != "checkbox"}}
<span>{{label}}</span>
Expand Down
149 changes: 148 additions & 1 deletion resources/html/js/ui_lamp.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"type":"interface",
"version":5,
"version":6,
"descr":"FireLamp UI objects",

"settings":{
"hub75":{
"section":"display_hub75",
Expand Down Expand Up @@ -329,13 +330,15 @@
"id":"display_hub75",
"html":"button",
"type":1,
"fa": "fas fa-circle-check",
"label":"Сохранить"
},
{
"id":"ui_page_settings",
"html":"button",
"color": "green",
"type":0,
"fa": "fas fa-door-open",
"label":"Выход"
}
]
Expand Down Expand Up @@ -515,12 +518,14 @@
"html": "button",
"type": 1,
"color": "green",
"fa": "fas fa-circle-check",
"label": "Сохранить"
},
{
"id": "ui_page_settings",
"html": "button",
"type": 0,
"fa": "fas fa-door-open",
"label": "Выход"
}
]
Expand Down Expand Up @@ -603,12 +608,14 @@
"html": "button",
"type": 1,
"color": "green",
"fa": "fas fa-circle-check",
"label": "Сохранить"
},
{
"id": "ui_page_settings",
"html": "button",
"type": 0,
"fa": "fas fa-door-open",
"label": "Выход"
}
]
Expand Down Expand Up @@ -694,6 +701,7 @@
"html": "button",
"type": 1,
"color": "green",
"fa": "fas fa-circle-check",
"label": "Сохранить"
}
]
Expand All @@ -715,11 +723,150 @@
"id": "ui_page_settings",
"html": "button",
"type": 0,
"fa": "fas fa-door-open",
"label": "Выход"
}
]
},
"dfplayer":{
"section":"set_dfplayer",
"main": true,
"label":"Параметры MP3 DFPlayer",
"block":[
{
"section": "set_dfplayer_device",
"label": "DFPlayer device",
"hidden": true,
"block":[
{
"section": "dfdev01",
"line": true,
"block": [
{
"id":"enabled",
"html":"input",
"label":"Enable DFPlayer",
"type":"checkbox"
},
{
"id":"driver",
"html":"select",
"value":0,
"label":"Chip model",
"section":"options",
"block":[
{
"value":0,
"label":"Generic DFPlayer"
},
{
"value":1,
"label":"No Ack models"
},
{
"value":2,
"label":"No checksum models"
}
]
}
]
},
{
"section": "dfdev02",
"line": true,
"block": [
{
"id": "rx",
"html":"input",
"value": -1,
"type": "number",
"label": "GPIO RX",
"min": -1,
"step": 1
},
{
"id": "timeout",
"html":"input",
"value": 900,
"type": "number",
"label": "Ack timeout, ms",
"min": 100,
"max": 2000,
"step": 50
},
{
"id": "tx",
"html":"input",
"value": -1,
"type": "number",
"label": "GPIO TX",
"min": -1,
"step": 1
}
]
},
{
"id": "set_dfplayer_device",
"html": "button",
"type": 1,
"color": "green",
"fa": "fas fa-circle-check",
"label": "Сохранить"
},
{
"id": "ui_page_settings",
"html": "button",
"type": 0,
"fa": "fas fa-door-open",
"label": "Выход"
}
]
},
{
"section": "set_dfplayer_opt",
"label": "Функции DFPlayer",
"hidden": true,
"block":[
{
"section": "dffunc01",
"line": true,
"block": [
{
"id":"eff_tracks",
"html":"input",
"label":"Effects sounds",
"type":"checkbox"
},
{
"id":"eff_tracks_loop",
"html":"input",
"label":"Loop Effects",
"type":"checkbox"
}
]
},
{
"id": "set_dfplayer_opt",
"html": "button",
"type": 1,
"color": "green",
"fa": "fas fa-circle-check",
"label": "Сохранить"
},
{
"id": "ui_page_settings",
"html": "button",
"type": 0,
"fa": "fas fa-door-open",
"label": "Выход"
}

]
}
]
}
},

"sections":{
"button_event":{
"section":"button_evt_save",
Expand Down
28 changes: 28 additions & 0 deletions resources/localupd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

compressor="gz"
compress_cmd=""
compress_args=""

updlocalarchive(){
local res=$1
echo "check: $res"
[ ! -f html/${res} ] && return
[ ! -f ../data/${res}.${compressor} ] || [ html/${res} -nt ../data/${res}.${compressor} ] && ${compress_cmd} ${compress_args} -c html/${res} > ../data/${res}.${compressor} && touch -r html/${res} ../data/${res}.${compressor}
}

compress_cmd=`which gzip`
if [ "x$compress_cmd" = "x" ]; then
echo "ERROR: gzip compressor not found!"
exit 1
fi
compress_args="-9"



echo "Update local resources"
lamp_files='index.html js/ui_lamp.json favicon.ico css/wp_dark.svg css/wp_light.svg'
for f in ${lamp_files}
do
updlocalarchive $f
done
2 changes: 1 addition & 1 deletion resources/respack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ if freshtag https://github.com/ajaxorg/ace/raw/master/doc/site/images/favicon.ic
curl -sL https://github.com/ajaxorg/ace/raw/master/doc/site/images/favicon.ico | ${compress_cmd} ${compress_args} > $ace_dst/ace.ico.${compressor}
fi

updlocalarchive extras/edit.htm
#updlocalarchive extras/edit.htm


mv -f newetags.txt $tags
Expand Down
6 changes: 3 additions & 3 deletions src/actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ void run_action(ra act, const T& param) {
}
//MP3: set volume
case ra::mp3_vol : {
obj[P_action] = TCONST_mp3volume;
data[TCONST_mp3volume] = param;
obj[P_action] = T_mp3vol;
data[T_mp3vol] = param;
break;
}

Expand All @@ -195,7 +195,7 @@ void run_action(ra act, const T& param) {
//if(!myLamp.isONMP3()) return;
int offset = param;
if ( act == ra::mp3_prev) offset *= -1;
mp3->playEffect(mp3->getCurPlayingNb() + offset, "");
//mp3->playEffect(mp3->getCurPlayingNb() + offset, "");
return; // no need to execute any UI action
}

Expand Down
Loading

0 comments on commit 36607c8

Please sign in to comment.