btn_mode
This commit is contained in:
@@ -32,7 +32,7 @@ void Config::init() {
|
|||||||
|
|
||||||
loadTheme();
|
loadTheme();
|
||||||
ssidsCount = 0;
|
ssidsCount = 0;
|
||||||
if(SDC_CS!=255 && store.play_mode==/*PM_SDCARD*/PM_WEB){
|
if(SDC_CS!=255 && store.play_mode==PM_WEB){
|
||||||
pinMode(SDC_CS, OUTPUT); digitalWrite(SDC_CS, HIGH);
|
pinMode(SDC_CS, OUTPUT); digitalWrite(SDC_CS, HIGH);
|
||||||
SDSPI.begin(SDC_SPI);
|
SDSPI.begin(SDC_SPI);
|
||||||
SDSPI.setFrequency(1000000);
|
SDSPI.setFrequency(1000000);
|
||||||
@@ -311,16 +311,10 @@ void Config::listSD(File &plSDfile, File &plSDindex, const char * dirname, uint8
|
|||||||
while(file){
|
while(file){
|
||||||
|
|
||||||
if(file.isDirectory()){
|
if(file.isDirectory()){
|
||||||
// Serial.print(" DIR : ");
|
|
||||||
// Serial.println(file.name());
|
|
||||||
if(levels){
|
if(levels){
|
||||||
listSD(plSDfile, plSDindex, file.path(), levels -1);
|
listSD(plSDfile, plSDindex, file.path(), levels -1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Serial.print(" FILE: ");
|
|
||||||
// Serial.print(file.name());
|
|
||||||
// Serial.print(" SIZE: ");
|
|
||||||
// Serial.println(file.size());
|
|
||||||
if(endsWith(file.name(), ".mp3") || endsWith(file.name(), ".m4a") || endsWith(file.name(), ".aac") || endsWith(file.name(), ".wav") || endsWith(file.name(), ".flac")){
|
if(endsWith(file.name(), ".mp3") || endsWith(file.name(), ".m4a") || endsWith(file.name(), ".aac") || endsWith(file.name(), ".wav") || endsWith(file.name(), ".flac")){
|
||||||
pos = plSDfile.position();
|
pos = plSDfile.position();
|
||||||
plSDfile.print(file.name()); plSDfile.print("\t"); plSDfile.print(file.path()); plSDfile.print("\t"); plSDfile.println(0);
|
plSDfile.print(file.name()); plSDfile.print("\t"); plSDfile.print(file.path()); plSDfile.print("\t"); plSDfile.println(0);
|
||||||
@@ -338,18 +332,8 @@ void Config::indexSDPlaylist() {
|
|||||||
if (!playlist) {
|
if (!playlist) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// char sName[BUFLEN], sUrl[BUFLEN];
|
|
||||||
// int sOvol;
|
|
||||||
File index = SPIFFS.open(INDEX_SD_PATH, "w");
|
File index = SPIFFS.open(INDEX_SD_PATH, "w");
|
||||||
listSD(playlist, index, "/", 2);
|
listSD(playlist, index, "/", 2);
|
||||||
/* while (playlist.available()) {
|
|
||||||
uint32_t pos = playlist.position();
|
|
||||||
if (parseCSV(playlist.readStringUntil('\n').c_str(), sName, sUrl, sOvol)) {
|
|
||||||
index.write((byte *) &pos, 4);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
index.close();
|
index.close();
|
||||||
playlist.close();
|
playlist.close();
|
||||||
}
|
}
|
||||||
@@ -357,7 +341,6 @@ void Config::indexSDPlaylist() {
|
|||||||
void Config::initSDPlaylist() {
|
void Config::initSDPlaylist() {
|
||||||
store.countStation = 0;
|
store.countStation = 0;
|
||||||
indexSDPlaylist();
|
indexSDPlaylist();
|
||||||
|
|
||||||
if (SPIFFS.exists(INDEX_SD_PATH)) {
|
if (SPIFFS.exists(INDEX_SD_PATH)) {
|
||||||
File index = SD.open(INDEX_SD_PATH, "r");
|
File index = SD.open(INDEX_SD_PATH, "r");
|
||||||
store.countStation = index.size() / 4;
|
store.countStation = index.size() / 4;
|
||||||
@@ -633,6 +616,16 @@ void Config::doSleep(){
|
|||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Config::doSleepW(){
|
||||||
|
if(BRIGHTNESS_PIN!=255) analogWrite(BRIGHTNESS_PIN, 0);
|
||||||
|
display.deepsleep();
|
||||||
|
#ifdef USE_NEXTION
|
||||||
|
nextion.sleep();
|
||||||
|
#endif
|
||||||
|
if(WAKE_PIN!=255) esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKE_PIN, LOW);
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
}
|
||||||
|
|
||||||
void Config::sleepForAfter(uint16_t sf, uint16_t sa){
|
void Config::sleepForAfter(uint16_t sf, uint16_t sa){
|
||||||
sleepfor = sf;
|
sleepfor = sf;
|
||||||
if(sa > 0) _sleepTimer.attach(sa * 60, doSleep);
|
if(sa > 0) _sleepTimer.attach(sa * 60, doSleep);
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("##[BOOT]#\t"); Serial.println(buf); }
|
#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("##[BOOT]#\t"); Serial.println(buf); }
|
||||||
#define EVERY_MS(x) static uint32_t tmr; bool flag = millis() - tmr >= (x); if (flag) tmr += (x); if (flag)
|
#define EVERY_MS(x) static uint32_t tmr; bool flag = millis() - tmr >= (x); if (flag) tmr += (x); if (flag)
|
||||||
|
|
||||||
|
#define MAX_PLAY_MODE 1
|
||||||
|
|
||||||
void u8fix(char *src);
|
void u8fix(char *src);
|
||||||
|
|
||||||
struct theme_t {
|
struct theme_t {
|
||||||
@@ -185,6 +188,7 @@ class Config {
|
|||||||
void setDspOn(bool dspon);
|
void setDspOn(bool dspon);
|
||||||
void sleepForAfter(uint16_t sleepfor, uint16_t sleepafter=0);
|
void sleepForAfter(uint16_t sleepfor, uint16_t sleepafter=0);
|
||||||
void bootInfo();
|
void bootInfo();
|
||||||
|
void doSleepW();
|
||||||
private:
|
private:
|
||||||
template <class T> int eepromWrite(int ee, const T& value);
|
template <class T> int eepromWrite(int ee, const T& value);
|
||||||
template <class T> int eepromRead(int ee, T& value);
|
template <class T> int eepromRead(int ee, T& value);
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ long encOldPosition = 0;
|
|||||||
long enc2OldPosition = 0;
|
long enc2OldPosition = 0;
|
||||||
int lpId = -1;
|
int lpId = -1;
|
||||||
|
|
||||||
#define ISPUSHBUTTONS BTN_LEFT!=255 || BTN_CENTER!=255 || BTN_RIGHT!=255 || ENC_BTNB!=255 || BTN_UP!=255 || BTN_DOWN!=255 || ENC2_BTNB!=255
|
#define ISPUSHBUTTONS BTN_LEFT!=255 || BTN_CENTER!=255 || BTN_RIGHT!=255 || ENC_BTNB!=255 || BTN_UP!=255 || BTN_DOWN!=255 || ENC2_BTNB!=255 || BTN_MODE!=255
|
||||||
#if ISPUSHBUTTONS
|
#if ISPUSHBUTTONS
|
||||||
#include "OneButton.h"
|
#include "OneButton.h"
|
||||||
OneButton button[] {{BTN_LEFT, true, BTN_INTERNALPULLUP}, {BTN_CENTER, true, BTN_INTERNALPULLUP}, {BTN_RIGHT, true, BTN_INTERNALPULLUP}, {ENC_BTNB, true, ENC_INTERNALPULLUP}, {BTN_UP, true, BTN_INTERNALPULLUP}, {BTN_DOWN, true, BTN_INTERNALPULLUP}, {ENC2_BTNB, true, ENC2_INTERNALPULLUP}};
|
OneButton button[] {{BTN_LEFT, true, BTN_INTERNALPULLUP}, {BTN_CENTER, true, BTN_INTERNALPULLUP}, {BTN_RIGHT, true, BTN_INTERNALPULLUP}, {ENC_BTNB, true, ENC_INTERNALPULLUP}, {BTN_UP, true, BTN_INTERNALPULLUP}, {BTN_DOWN, true, BTN_INTERNALPULLUP}, {ENC2_BTNB, true, ENC2_INTERNALPULLUP}, {BTN_MODE, true, BTN_INTERNALPULLUP}};
|
||||||
constexpr uint8_t nrOfButtons = sizeof(button) / sizeof(button[0]);
|
constexpr uint8_t nrOfButtons = sizeof(button) / sizeof(button[0]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ void initControls() {
|
|||||||
#if ISPUSHBUTTONS
|
#if ISPUSHBUTTONS
|
||||||
for (int i = 0; i < nrOfButtons; i++)
|
for (int i = 0; i < nrOfButtons; i++)
|
||||||
{
|
{
|
||||||
if ((i == 0 && BTN_LEFT == 255) || (i == 1 && BTN_CENTER == 255) || (i == 2 && BTN_RIGHT == 255) || (i == 3 && ENC_BTNB == 255) || (i == 4 && BTN_UP == 255) || (i == 5 && BTN_DOWN == 255) || (i == 6 && ENC2_BTNB == 255)) continue;
|
if ((i == 0 && BTN_LEFT == 255) || (i == 1 && BTN_CENTER == 255) || (i == 2 && BTN_RIGHT == 255) || (i == 3 && ENC_BTNB == 255) || (i == 4 && BTN_UP == 255) || (i == 5 && BTN_DOWN == 255) || (i == 6 && ENC2_BTNB == 255) || (i == 7 && BTN_MODE == 255)) continue;
|
||||||
button[i].attachClick([](void* p) {
|
button[i].attachClick([](void* p) {
|
||||||
onBtnClick((int)p);
|
onBtnClick((int)p);
|
||||||
}, (void*)i);
|
}, (void*)i);
|
||||||
@@ -324,7 +324,8 @@ void irLoop() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IR_AST: {
|
case IR_AST: {
|
||||||
ESP.restart();
|
//ESP.restart();
|
||||||
|
onBtnClick(EVT_BTNMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* switch (target) */
|
} /* switch (target) */
|
||||||
@@ -361,8 +362,12 @@ void onBtnLongPressStart(int id) {
|
|||||||
display.putRequest(NEWMODE, display.mode() == PLAYER ? VOL : PLAYER);
|
display.putRequest(NEWMODE, display.mode() == PLAYER ? VOL : PLAYER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
case EVT_BTNMODE: {
|
||||||
|
//onBtnClick(EVT_BTNMODE);
|
||||||
|
config.doSleepW();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,6 +494,16 @@ void onBtnClick(int id) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EVT_BTNMODE: {
|
||||||
|
config.store.play_mode++;
|
||||||
|
if(config.store.play_mode > MAX_PLAY_MODE){
|
||||||
|
config.store.play_mode=0;
|
||||||
|
config.save();
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +517,8 @@ void onBtnDoubleClick(int id) {
|
|||||||
case EVT_BTNCENTER:
|
case EVT_BTNCENTER:
|
||||||
case EVT_ENCBTNB:
|
case EVT_ENCBTNB:
|
||||||
case EVT_ENC2BTNB: {
|
case EVT_ENC2BTNB: {
|
||||||
display.putRequest(NEWMODE, display.mode() == PLAYER ? VOL : PLAYER);
|
//display.putRequest(NEWMODE, display.mode() == PLAYER ? VOL : PLAYER);
|
||||||
|
onBtnClick(EVT_BTNMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EVT_BTNRIGHT: {
|
case EVT_BTNRIGHT: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "../yoEncoder/yoEncoder.h"
|
#include "../yoEncoder/yoEncoder.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum controlEvt_e { EVT_BTNLEFT, EVT_BTNCENTER, EVT_BTNRIGHT, EVT_ENCBTNB, EVT_BTNUP, EVT_BTNDOWN, EVT_ENC2BTNB };
|
enum controlEvt_e { EVT_BTNLEFT, EVT_BTNCENTER, EVT_BTNRIGHT, EVT_ENCBTNB, EVT_BTNUP, EVT_BTNDOWN, EVT_ENC2BTNB, EVT_BTNMODE };
|
||||||
|
|
||||||
//enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST };
|
//enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST };
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
|
|||||||
#ifndef BTN_DOWN
|
#ifndef BTN_DOWN
|
||||||
#define BTN_DOWN 255
|
#define BTN_DOWN 255
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef BTN_MODE
|
||||||
|
#define BTN_MODE 255
|
||||||
|
#endif
|
||||||
#ifndef BTN_INTERNALPULLUP
|
#ifndef BTN_INTERNALPULLUP
|
||||||
#define BTN_INTERNALPULLUP true
|
#define BTN_INTERNALPULLUP true
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user