Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Espbutton #55

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ user_*.ini
.vscode/c_cpp_properties.json
include/user_config.h
include/user_cfg*
!/data/benc.json
/data/*.json
/data.*
resources/embui.zip
Expand Down
Binary file modified data/css/style.css.gz
Binary file not shown.
Binary file modified data/index.html.gz
Binary file not shown.
Binary file modified data/js/embui.js.gz
Binary file not shown.
Binary file modified data/js/ui_lamp.json.gz
Binary file not shown.
29 changes: 0 additions & 29 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ JeeUI2 lib used under MIT License Copyright (c) 2019 Marsel Akhkamov
#include "Arduino.h"

//-----------------------------------
//#define ESP_USE_BUTTON // если строка не закомментирована, должна быть подключена кнопка (иначе ESP может регистрировать "фантомные" нажатия и некорректно устанавливать яркость)
//#define LAMP_DEBUG // режим отладки, можно также включать в platformio.ini
//#define MP3PLAYER // Включить использование MP3 плеера (DF Player)
//-----------------------------------
#ifndef LANG_FILE
#define LANG_FILE "text_res-RUS.h" // Языковой файл по дефолту
Expand Down Expand Up @@ -135,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
14 changes: 0 additions & 14 deletions include/user_config.h.default
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ https://github.com/vortigont/FireLamp_JeeUI/wiki/%D0%9D%D0%B0%D0%B7%D0%BD%D0%B0%


//------------------------------ Подключаемое дополнительное оборудование
#define ESP_USE_BUTTON // если строка не закомментирована, должна быть подключена кнопка (иначе ESP может регистрировать "фантомные" нажатия и некорректно устанавливать яркость)
//#define MP3PLAYER // Включить использование MP3 плеера (DF Player)
//#define ENCODER // Использовать Энкодер

//------------------------------
Expand All @@ -77,7 +75,6 @@ https://github.com/vortigont/FireLamp_JeeUI/wiki/%D0%9D%D0%B0%D0%B7%D0%BD%D0%B0%
//------------------------------ Описание Оборудования (пины подключения, параметры и т.)
// настройки энкодера и поведения, если разрешен
#ifdef ENCODER
#undef ESP_USE_BUTTON
#define ENC_SW (5) // Пин кнопки стандартного энкодера
#define ENC_DT (14) // Пин DT энкодера
#define ENC_CLK (15) // Пин CLK энкодера
Expand Down Expand Up @@ -105,17 +102,6 @@ https://github.com/vortigont/FireLamp_JeeUI/wiki/%D0%9D%D0%B0%D0%B7%D0%BD%D0%B0%
//#define ENC_STRING_EFFNUM_DELAY (17U) // Скорость вывода номера эффекта при вращении энкодера, меньше = быстрее
#endif

// настройка кнопки, если разрешена
#ifdef ESP_USE_BUTTON
//#define BTN_PIN (5) // пин кнопки (5)
//#define PULL_MODE (LOW_PULL) // подтяжка кнопки к нулю (для сенсорных кнопок на TP223) - LOW_PULL, подтяжка кнопки к питанию (для механических кнопок НО, к нулю) - HIGH_PULL

// #define BUTTON_STEP_TIMEOUT (75U) // каждые BUTTON_STEP_TIMEOUT мс будет генерироваться событие удержания кнопки (для регулировки яркости)
// #define BUTTON_CLICK_TIMEOUT (500U) // максимальное время между нажатиями кнопки в мс, до достижения которого считается серия последовательных нажатий
// #define BUTTON_TIMEOUT (500U) // с какого момента начинает считаться, что кнопка удерживается в мс
// #define NUMHOLD_TIME (3000U) // время запоминания последней комбинации яркости/скорости/масштаба в мс (для кнопки)
#endif

//#define MIC_PIN (-1) // пин для микрофона
//#define MIC_POLLRATE (100U) // как часто опрашиваем микрофон, мс
//#define FAST_ADC_READ // микрофон, использовать полный диапазон звуковых частот, если закомментировано, то будет до 5кГц, но сэкономит память и проще обсчитать...
Expand Down
4 changes: 3 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ build_flags =
[libs]
common =
https://github.com/DmytroKorniienko/DFRobotDFPlayerMini
GyverLibs/GyverButton@3.8
;GyverLibs/GyverButton@3.8
mrfaptastic/ESP32 HUB75 LED MATRIX PANEL DMA Display@3.0
https://github.com/toblum/TetrisAnimation
;GyverLibs/microDS18B20@3.10
Expand All @@ -45,6 +45,8 @@ vortigont =
https://github.com/vortigont/EmbUI#v3.1
https://github.com/vortigont/LedFB
https://github.com/vortigont/TM1637
https://github.com/vortigont/ESPAsyncButton


[env]
framework = arduino
Expand Down
1 change: 0 additions & 1 deletion resources/html/buttons_config.json

This file was deleted.

1 change: 0 additions & 1 deletion resources/html/events_config.json

This file was deleted.

4 changes: 2 additions & 2 deletions resources/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
</script>

<script type="text/html" id="tmpl_content">
{{#if _this.line && _this.section!="line124"}}<div class="pure-u-sm-1-2 {{#if2 _this.block.length > 2}}pure-u-md-1-3{{/if2}} {{#if2 _this.block.length > 3}}pure-u-lg-1-4{{/if2}} {{#if2 _this.block.length > 4}}pure-u-xl-1-5{{/if2}}">{{/if}}
{{#if _this.line && _this.section!="line124"}}<div class="pure-u-sm-1-2 {{#if2 _this.block.length > 2}}pure-u-sm-1-3{{/if2}} {{#if2 _this.block.length > 3}}pure-u-md-1-4{{/if2}} {{#if2 _this.block.length > 4}}pure-u-lg-1-5{{/if2}}">{{/if}}
{{#if _this.line && _this.section=="line124"}}<div class="pure-u-sm-1-2 {{#if2 _this.block.length > 2}}pure-u-lg-1-4{{/if2}}">{{/if}}
{{#if !_this.line}}<div class="pure-u-1" {{#if2 html == "hidden"}}style="display:hidden;"{{/if2}}>{{/if}}

Expand Down Expand Up @@ -180,7 +180,7 @@
<span>{{label}}</span>
{{#if2 type == "range" || type == "color"}}<span id="{{id}}-val">: {{value}}</span>{{/if2}}
{{#if2 type == "text" || type == "password"}}<span id="{{id}}-val"> ({{calc value.length || 0}})</span>{{/if2}}
<input type="{{type}}" id="{{id}}" name="{{id}}" class="pure-u-1 mr" value="{{value}}"
<input type="{{type}}" id="{{id}}" name="{{id}}" class="pure-u-1" value="{{value}}"
{{#if2 (min || min === 0)}}min="{{min}}"{{/if2}}
{{#if2 (max || max === 0)}}max="{{max}}"{{/if2}}
{{#if2 (step || step === 0)}}step="{{step}}"{{/if2}}
Expand Down
203 changes: 202 additions & 1 deletion resources/html/js/ui_lamp.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"interface",
"version":3,
"version":4,
"descr":"FireLamp UI objects",
"settings":{
"hub75":{
Expand Down Expand Up @@ -612,6 +612,207 @@
"label": "Выход"
}
]
},
"button":{
"section":"set_button",
"main": true,
"label":"Параметры кнопки",
"block":[
{
"section": "set_button_block",
"label": "Button GPIO",
"hidden": true,
"block":[
{
"section": "set_button_gpio",
"block": [
{
"section": "enagpio",
"line": true,
"block": [
{
"id":"enabled",
"html":"input",
"label":"Enable button",
"type":"checkbox"
},
{
"id": "gpio",
"html": "input",
"value": -1,
"type": "number",
"label": "GPIO pin",
"min": -1,
"step": 1
}
]
},
{
"section": "enagpio",
"line": true,
"block": [
{
"id":"logicL",
"html":"input",
"label":"HIGH logic level",
"type":"checkbox"
},
{
"id":"debounce",
"html":"input",
"label":"Debounce",
"type":"checkbox"
}
]
},
{
"id": "set_button_gpio",
"html": "button",
"type": 1,
"color": "green",
"label": "Сохранить"
}
]
}
]
},
{
"section": "set_button_block2",
"label": "Button Events",
"hidden": true,
"block":[
{
"section":"button_events_list",
"block":[]
}
]
},
{
"id": "ui_page_settings",
"html": "button",
"type": 0,
"label": "Выход"
}
]
}
},
"sections":{
"button_event":{
"section":"button_evt_save",
"block":[
{
"id":"idx",
"html":"hidden",
"value":-1
},
{
"id":"enabled",
"html":"input",
"label":"Active",
"type":"checkbox"
},
{
"id":"lamppwr",
"html":"input",
"label":"Device On/Off",
"type":"checkbox"
},
{
"id":"btn_event",
"html":"select",
"value":0,
"label":"Button action",
"section":"options",
"block":[
{
"value":2,
"label":"Click"
},
{
"value":3,
"label":"Long press"
},
{
"value":5,
"label":"Hold repeat"
},
{
"value":6,
"label":"Multi Click"
}
]
},
{
"id":"clicks",
"html":"input",
"type":"number",
"label":"MultiClicks",
"min":2,
"step":1
},
{
"id":"lamp_event",
"html":"select",
"value":0,
"label":"Lamp action",
"section":"options",
"block":[
{
"value":11,
"label":"Power On"
},
{
"value":12,
"label":"Power Off"
},
{
"value":13,
"label":"Power Toggle"
},
{
"value":24,
"label":"Brightness step:"
},
{
"value":30,
"label":"Sw Effect to:"
},
{
"value":31,
"label":"Sw Next Effect"
},
{
"value":32,
"label":"Sw Prev Effect"
},
{
"value":33,
"label":"Sw Random Effect"
}
]
},
{
"id":"arg",
"html":"input",
"type":"number",
"label":"Argument",
"step":1
},
{
"id": "button_evt_save",
"html": "button",
"type": 1,
"color": "green",
"label": "Save"
},
{
"id": "ui_page",
"html": "button",
"type": 0,
"value": 55,
"label": "Exit"
}
]
}
}
}
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
Loading