mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 12:06:00 +08:00
Final integration for buzzer
add [ESP900] to enable/disable buzzer add [ESP250] to play beed if no parameter, or specific sound using frequency and duration parameters add missing Serial communication state in [ESP420] fix typo in [ESP900]
This commit is contained in:
parent
4330d8eb30
commit
4961ff9902
@ -76,6 +76,10 @@ Flash pins (6~11) cannot be used
|
|||||||
* Touch Calibration
|
* Touch Calibration
|
||||||
[ESP215]<CALIBRATE>[pwd=<user password>]
|
[ESP215]<CALIBRATE>[pwd=<user password>]
|
||||||
|
|
||||||
|
* Play sound
|
||||||
|
No parameter just play beep
|
||||||
|
[ESP250]F=<frequency> D=<duration> [pwd=<user password>]
|
||||||
|
|
||||||
* Get full EEPROM settings content
|
* Get full EEPROM settings content
|
||||||
but do not give any passwords
|
but do not give any passwords
|
||||||
[ESP400] pwd=<admin password>
|
[ESP400] pwd=<admin password>
|
||||||
@ -95,7 +99,7 @@ ESP_BAUD_RATE 112 //4 bytes = int
|
|||||||
ESP_NOTIFICATION_TYPE 116 //1 byte = flag
|
ESP_NOTIFICATION_TYPE 116 //1 byte = flag
|
||||||
ESP_CALIBRATION 117 //1 byte = flag
|
ESP_CALIBRATION 117 //1 byte = flag
|
||||||
ESP_AP_CHANNEL 118 //1 byte = flag
|
ESP_AP_CHANNEL 118 //1 byte = flag
|
||||||
FREE 119 //1 byte = flag
|
ESP_BUZZER 119 //1 byte = flag
|
||||||
FREE 120 //1 byte = flag
|
FREE 120 //1 byte = flag
|
||||||
ESP_HTTP_PORT 121 //4 bytes = int
|
ESP_HTTP_PORT 121 //4 bytes = int
|
||||||
ESP_TELNET_PORT 125 //4 bytes = int
|
ESP_TELNET_PORT 125 //4 bytes = int
|
||||||
@ -168,3 +172,9 @@ Get will give type and settings only, not the protected T1/T2
|
|||||||
|
|
||||||
* FW Informations
|
* FW Informations
|
||||||
[ESP800]<plain> pwd=<admin password>
|
[ESP800]<plain> pwd=<admin password>
|
||||||
|
|
||||||
|
* Get state / Set Enable / Disable Serial Communication
|
||||||
|
[ESP900]<ENABLE/DISABLE>[pwd=<admin/user password>]
|
||||||
|
|
||||||
|
* Get state / Set Enable / Disable buzzer
|
||||||
|
[ESP910]<ENABLE/DISABLE>[pwd=<admin/user password>]
|
||||||
|
@ -51,6 +51,10 @@
|
|||||||
//TFT_SPI_ILI9341_320X240 3
|
//TFT_SPI_ILI9341_320X240 3
|
||||||
#define DISPLAY_DEVICE OLED_I2C_SSD1306
|
#define DISPLAY_DEVICE OLED_I2C_SSD1306
|
||||||
|
|
||||||
|
//BUZZER_DEVICE: allow to connect passive buzzer
|
||||||
|
#define BUZZER_DEVICE
|
||||||
|
|
||||||
|
|
||||||
#if defined (DISPLAY_DEVICE)
|
#if defined (DISPLAY_DEVICE)
|
||||||
//for ILI9143 edit User_Setup.h of TFT_eSPI library
|
//for ILI9143 edit User_Setup.h of TFT_eSPI library
|
||||||
#if (DISPLAY_DEVICE == OLED_I2C_SSD1306) || (DISPLAY_DEVICE == OLED_I2C_SSDSH1106)
|
#if (DISPLAY_DEVICE == OLED_I2C_SSD1306) || (DISPLAY_DEVICE == OLED_I2C_SSDSH1106)
|
||||||
@ -72,6 +76,10 @@
|
|||||||
//DHT_DEVICE: send update of temperature / humidity based on DHT 11/22
|
//DHT_DEVICE: send update of temperature / humidity based on DHT 11/22
|
||||||
//#define DHT_DEVICE
|
//#define DHT_DEVICE
|
||||||
|
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
#define ESP3D_BUZZER_PIN 5
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
|
|
||||||
#ifdef DHT_DEVICE
|
#ifdef DHT_DEVICE
|
||||||
#define ESP3D_DHT_PIN 22
|
#define ESP3D_DHT_PIN 22
|
||||||
//USE_CELSIUS
|
//USE_CELSIUS
|
||||||
|
@ -366,6 +366,13 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_
|
|||||||
response = ESP215(cmd_params, auth_type, output);
|
response = ESP215(cmd_params, auth_type, output);
|
||||||
break;
|
break;
|
||||||
#endif //DISPLAY_TOUCH_DRIVER
|
#endif //DISPLAY_TOUCH_DRIVER
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
//Play sound
|
||||||
|
//[ESP250]F=<frequency> D=<duration> [pwd=<user password>]
|
||||||
|
case 250:
|
||||||
|
response = ESP250(cmd_params, auth_type, output);
|
||||||
|
break;
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#endif //DISPLAY_DEVICE
|
#endif //DISPLAY_DEVICE
|
||||||
//Get full ESP3D settings
|
//Get full ESP3D settings
|
||||||
//[ESP400]<pwd=admin>
|
//[ESP400]<pwd=admin>
|
||||||
@ -448,7 +455,13 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_
|
|||||||
case 900:
|
case 900:
|
||||||
response = ESP900(cmd_params, auth_type, output);
|
response = ESP900(cmd_params, auth_type, output);
|
||||||
break;
|
break;
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
//Get state / Set Enable / Disable buzzer
|
||||||
|
//[ESP910]<ENABLE/DISABLE>
|
||||||
|
case 910:
|
||||||
|
response = ESP910(cmd_params, auth_type, output);
|
||||||
|
break;
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
default:
|
default:
|
||||||
output->printERROR ("Invalid Command");
|
output->printERROR ("Invalid Command");
|
||||||
response = false;
|
response = false;
|
||||||
|
@ -108,6 +108,10 @@ public:
|
|||||||
#endif //FILESYSTEM_FEATURE
|
#endif //FILESYSTEM_FEATURE
|
||||||
bool ESP800(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
bool ESP800(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||||
bool ESP900(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
bool ESP900(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
bool ESP910(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||||
|
bool ESP250(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Commands esp3d_commands;
|
extern Commands esp3d_commands;
|
||||||
|
70
esp3d/src/core/espcmd/ESP250.cpp
Normal file
70
esp3d/src/core/espcmd/ESP250.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
ESP250.cpp - ESP3D command class
|
||||||
|
|
||||||
|
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
#include "../../include/esp3d_config.h"
|
||||||
|
#if defined (BUZZER_DEVICE)
|
||||||
|
#include "../commands.h"
|
||||||
|
#include "../esp3doutput.h"
|
||||||
|
#include "../settings_esp3d.h"
|
||||||
|
#include "../../modules/authentication/authentication_service.h"
|
||||||
|
#include "../../modules/buzzer/buzzer.h"
|
||||||
|
//Play sound
|
||||||
|
//[ESP250]F=<frequency> D=<duration> [pwd=<user password>]
|
||||||
|
bool Commands::ESP250(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||||
|
{
|
||||||
|
bool response = true;
|
||||||
|
String parameter;
|
||||||
|
#ifdef AUTHENTICATION_FEATURE
|
||||||
|
if (auth_type == LEVEL_GUEST) {
|
||||||
|
output->printERROR("Wrong authentication!", 401);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void)auth_type;
|
||||||
|
#endif //AUTHENTICATION_FEATURE
|
||||||
|
if (!esp3d_buzzer.started()) {
|
||||||
|
output->printERROR ("Buzzer disabled");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
parameter = get_param (cmd_params, "");
|
||||||
|
//get
|
||||||
|
if (parameter.length() == 0) {
|
||||||
|
esp3d_buzzer.beep();
|
||||||
|
} else {
|
||||||
|
int f,d;
|
||||||
|
//frequency
|
||||||
|
parameter = get_param (cmd_params, "F=");
|
||||||
|
if (parameter.length() == 0) {
|
||||||
|
output->printERROR ("No frequency");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
f = parameter.toInt();
|
||||||
|
parameter = get_param (cmd_params, "D=");
|
||||||
|
if (parameter.length() == 0) {
|
||||||
|
output->printERROR ("No duration");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
d = parameter.toInt();
|
||||||
|
esp3d_buzzer.playsound(f,d);
|
||||||
|
}
|
||||||
|
output->printMSG ("ok");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //BUZZER_DEVICE
|
@ -385,6 +385,14 @@ bool Commands::ESP400(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->print (Settings_ESP3D::get_min_string_size(ESP_NOTIFICATION_SETTINGS));
|
output->print (Settings_ESP3D::get_min_string_size(ESP_NOTIFICATION_SETTINGS));
|
||||||
output->printLN ("\"}");
|
output->printLN ("\"}");
|
||||||
#endif //NOTIFICATION_FEATURE
|
#endif //NOTIFICATION_FEATURE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
//Buzzer state
|
||||||
|
output->print (",{\"F\":\"printer\",\"P\":\"");
|
||||||
|
output->print (ESP_BUZZER);
|
||||||
|
output->print ("\",\"T\":\"B\",\"V\":\"");
|
||||||
|
output->print (Settings_ESP3D::read_byte(ESP_BUZZER));
|
||||||
|
output->printLN ("\",\"H\":\"Buzzer\",\"O\":[{\"No\":\"0\"},{\"Yes\":\"1\"}]}");
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
//Target FW
|
//Target FW
|
||||||
output->print (",{\"F\":\"printer\",\"P\":\"");
|
output->print (",{\"F\":\"printer\",\"P\":\"");
|
||||||
output->print (ESP_TARGET_FW);
|
output->print (ESP_TARGET_FW);
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#ifdef DHT_DEVICE
|
#ifdef DHT_DEVICE
|
||||||
#include "../../modules/dht/dht.h"
|
#include "../../modules/dht/dht.h"
|
||||||
#endif //DHT_DEVICE
|
#endif //DHT_DEVICE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
#include "../../modules/buzzer/buzzer.h"
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
//Set EEPROM setting
|
//Set EEPROM setting
|
||||||
//[ESP401]P=<position> T=<type> V=<value> pwd=<user/admin password>
|
//[ESP401]P=<position> T=<type> V=<value> pwd=<user/admin password>
|
||||||
bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||||
@ -66,6 +69,15 @@ bool Commands::ESP401(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
esp3d_DHT.begin();
|
esp3d_DHT.begin();
|
||||||
break;
|
break;
|
||||||
#endif //DHT_DEVICE
|
#endif //DHT_DEVICE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
case ESP_BUZZER:
|
||||||
|
if (sval.toInt() == 1) {
|
||||||
|
esp3d_buzzer.begin();
|
||||||
|
} else if (sval.toInt() == 0) {
|
||||||
|
esp3d_buzzer.end();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,10 @@
|
|||||||
#ifdef NOTIFICATION_FEATURE
|
#ifdef NOTIFICATION_FEATURE
|
||||||
#include "../../modules/notifications/notifications_service.h"
|
#include "../../modules/notifications/notifications_service.h"
|
||||||
#endif //NOTIFICATION_FEATURE
|
#endif //NOTIFICATION_FEATURE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
#include "../../modules/buzzer/buzzer.h"
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
|
|
||||||
//Get ESP current status
|
//Get ESP current status
|
||||||
//output is JSON or plain text according parameter
|
//output is JSON or plain text according parameter
|
||||||
//[ESP420]<plain>
|
//[ESP420]<plain>
|
||||||
@ -974,6 +978,21 @@ bool Commands::ESP420(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->printLN("");
|
output->printLN("");
|
||||||
}
|
}
|
||||||
#endif //TIMESTAMP_FEATURE
|
#endif //TIMESTAMP_FEATURE
|
||||||
|
if (!plain) {
|
||||||
|
output->print (",{\"id\":\"");
|
||||||
|
}
|
||||||
|
output->print ("Serial communication");
|
||||||
|
if (!plain) {
|
||||||
|
output->print ("\",\"value\":\"");
|
||||||
|
} else {
|
||||||
|
output->print (": ");
|
||||||
|
}
|
||||||
|
output->print (serial_service.started()?"Enabled":"Disabled");
|
||||||
|
if (!plain) {
|
||||||
|
output->print ("\"}");
|
||||||
|
} else {
|
||||||
|
output->printLN("");
|
||||||
|
}
|
||||||
#if defined (NOTIFICATION_FEATURE)
|
#if defined (NOTIFICATION_FEATURE)
|
||||||
if (!plain) {
|
if (!plain) {
|
||||||
output->print (",{\"id\":\"");
|
output->print (",{\"id\":\"");
|
||||||
@ -1016,6 +1035,23 @@ bool Commands::ESP420(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->printLN("");
|
output->printLN("");
|
||||||
}
|
}
|
||||||
#endif //DHT_DEVICE
|
#endif //DHT_DEVICE
|
||||||
|
#if defined (BUZZER_DEVICE)
|
||||||
|
if (!plain) {
|
||||||
|
output->print (",{\"id\":\"");
|
||||||
|
}
|
||||||
|
output->print ("Buzzer");
|
||||||
|
if (!plain) {
|
||||||
|
output->print ("\",\"value\":\"");
|
||||||
|
} else {
|
||||||
|
output->print (": ");
|
||||||
|
}
|
||||||
|
output->print (esp3d_buzzer.started()?"Enabled":"Disabled");
|
||||||
|
if (!plain) {
|
||||||
|
output->print ("\"}");
|
||||||
|
} else {
|
||||||
|
output->printLN("");
|
||||||
|
}
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#if defined (ESP_DEBUG_FEATURE)
|
#if defined (ESP_DEBUG_FEATURE)
|
||||||
//debug
|
//debug
|
||||||
if (!plain) {
|
if (!plain) {
|
||||||
|
@ -57,7 +57,7 @@ bool Commands::ESP900(const char* cmd_params, level_authenticate_type auth_type,
|
|||||||
output->printMSG ("Serial communication disabled");
|
output->printMSG ("Serial communication disabled");
|
||||||
serial_service.end();
|
serial_service.end();
|
||||||
} else {
|
} else {
|
||||||
output->printERROR("Cannot enable serial communication!", 500);
|
output->printERROR("Incorrect command!");
|
||||||
response = false;
|
response = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
70
esp3d/src/core/espcmd/ESP910.cpp
Normal file
70
esp3d/src/core/espcmd/ESP910.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
ESP910.cpp - ESP3D command class
|
||||||
|
|
||||||
|
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
#include "../../include/esp3d_config.h"
|
||||||
|
#include "../commands.h"
|
||||||
|
#include "../esp3doutput.h"
|
||||||
|
#include "../settings_esp3d.h"
|
||||||
|
#include "../../modules/authentication/authentication_service.h"
|
||||||
|
#include "../../modules/buzzer/buzzer.h"
|
||||||
|
//Get state / Set Enable / Disable buzzer
|
||||||
|
//[ESP910]<ENABLE/DISABLE>[pwd=<admin password>]
|
||||||
|
bool Commands::ESP910(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
|
||||||
|
{
|
||||||
|
bool response = true;
|
||||||
|
String parameter;
|
||||||
|
#ifdef AUTHENTICATION_FEATURE
|
||||||
|
if (auth_type == LEVEL_GUEST) {
|
||||||
|
output->printERROR("Wrong authentication!", 401);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void)auth_type;
|
||||||
|
#endif //AUTHENTICATION_FEATURE
|
||||||
|
parameter = get_param (cmd_params, "");
|
||||||
|
//get
|
||||||
|
if (parameter.length() == 0) {
|
||||||
|
if (esp3d_buzzer.started()) {
|
||||||
|
output->printMSG("ENABLED");
|
||||||
|
} else {
|
||||||
|
output->printMSG("DISABLED");
|
||||||
|
}
|
||||||
|
} else { //set
|
||||||
|
if (!Settings_ESP3D::write_byte (ESP_BUZZER, (parameter == "ENABLE")?1:0)) {
|
||||||
|
output->printERROR ("Set failed!");
|
||||||
|
response = false;
|
||||||
|
}
|
||||||
|
if (parameter == "ENABLE" ) {
|
||||||
|
|
||||||
|
if (esp3d_buzzer.begin()) {
|
||||||
|
output->printMSG ("Buzzer enabled");
|
||||||
|
} else {
|
||||||
|
output->printERROR("Cannot enable buzzer!", 500);
|
||||||
|
response = false;
|
||||||
|
}
|
||||||
|
} else if (parameter == "DISABLE" ) {
|
||||||
|
output->printMSG ("Buzzer disabled");
|
||||||
|
esp3d_buzzer.end();
|
||||||
|
} else {
|
||||||
|
output->printERROR("Incorrect command!");
|
||||||
|
response = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
@ -75,7 +75,9 @@
|
|||||||
#endif //ETH_FEATURE
|
#endif //ETH_FEATURE
|
||||||
#endif //BLUETOOTH_FEATURE
|
#endif //BLUETOOTH_FEATURE
|
||||||
#endif //WIFI_FEATURE
|
#endif //WIFI_FEATURE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
#define DEFAULT_BUZZER_STATE 1
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
|
|
||||||
#define DEFAULT_ESP_BYTE 0
|
#define DEFAULT_ESP_BYTE 0
|
||||||
#define DEFAULT_ESP_STRING_SIZE 0
|
#define DEFAULT_ESP_STRING_SIZE 0
|
||||||
@ -219,6 +221,11 @@ uint8_t Settings_ESP3D::get_default_byte_value(int pos)
|
|||||||
case ESP_RADIO_MODE:
|
case ESP_RADIO_MODE:
|
||||||
res = DEFAULT_ESP_RADIO_MODE;
|
res = DEFAULT_ESP_RADIO_MODE;
|
||||||
break;
|
break;
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
case ESP_BUZZER:
|
||||||
|
res = DEFAULT_BUZZER_STATE;
|
||||||
|
break;
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#ifdef NOTIFICATION_FEATURE
|
#ifdef NOTIFICATION_FEATURE
|
||||||
case ESP_NOTIFICATION_TYPE:
|
case ESP_NOTIFICATION_TYPE:
|
||||||
res = DEFAULT_NOTIFICATION_TYPE;
|
res = DEFAULT_NOTIFICATION_TYPE;
|
||||||
@ -975,7 +982,10 @@ bool Settings_ESP3D::reset()
|
|||||||
Settings_ESP3D::write_uint32 (ESP_CALIBRATION_4, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_4));
|
Settings_ESP3D::write_uint32 (ESP_CALIBRATION_4, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_4));
|
||||||
Settings_ESP3D::write_uint32 (ESP_CALIBRATION_5, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_5));
|
Settings_ESP3D::write_uint32 (ESP_CALIBRATION_5, Settings_ESP3D::get_default_int32_value(ESP_CALIBRATION_5));
|
||||||
#endif // DISPLAY_DEVICE && DISPLAY_TOUCH_DRIVER
|
#endif // DISPLAY_DEVICE && DISPLAY_TOUCH_DRIVER
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
//Buzzer state
|
||||||
|
Settings_ESP3D::write_byte(ESP_BUZZER,Settings_ESP3D::get_default_byte_value(ESP_BUZZER));
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#if defined (WIFI_FEATURE) || defined (BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
|
#if defined (WIFI_FEATURE) || defined (BLUETOOTH_FEATURE) || defined (ETH_FEATURE)
|
||||||
//Hostname
|
//Hostname
|
||||||
Settings_ESP3D::write_string(ESP_HOSTNAME,Settings_ESP3D::get_default_string_value(ESP_HOSTNAME).c_str());
|
Settings_ESP3D::write_string(ESP_HOSTNAME,Settings_ESP3D::get_default_string_value(ESP_HOSTNAME).c_str());
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#define ESP_NOTIFICATION_TYPE 116 //1 byte = flag
|
#define ESP_NOTIFICATION_TYPE 116 //1 byte = flag
|
||||||
#define ESP_CALIBRATION 117 //1 byte = flag
|
#define ESP_CALIBRATION 117 //1 byte = flag
|
||||||
#define ESP_AP_CHANNEL 118 //1 byte = flag
|
#define ESP_AP_CHANNEL 118 //1 byte = flag
|
||||||
//#define ESP_AP_AUTH_TYPE 119 //1 byte = flag
|
#define ESP_BUZZER 119 //1 byte = flag
|
||||||
//#define ESP_SSID_VISIBLE 120 //1 byte = flag
|
//#define ESP_SSID_VISIBLE 120 //1 byte = flag
|
||||||
#define ESP_HTTP_PORT 121 //4 bytes = int
|
#define ESP_HTTP_PORT 121 //4 bytes = int
|
||||||
#define ESP_TELNET_PORT 125 //4 bytes = int
|
#define ESP_TELNET_PORT 125 //4 bytes = int
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#define RECOVERY_FEATURE
|
#define RECOVERY_FEATURE
|
||||||
#endif //PIN_RESET_FEATURE || SD_RECOVERY_FEATURE
|
#endif //PIN_RESET_FEATURE || SD_RECOVERY_FEATURE
|
||||||
|
|
||||||
#if defined(DISPLAY_DEVICE) || defined(DHT_DEVICE) || defined(RECOVERY_FEATURE)
|
#if defined(DISPLAY_DEVICE) || defined(DHT_DEVICE) || defined(RECOVERY_FEATURE) || defined(BUZZER_DEVICE)
|
||||||
#define CONNECTED_DEVICES_FEATURE
|
#define CONNECTED_DEVICES_FEATURE
|
||||||
#endif //DISPLAY_DEVICE || DHT_DEVICE
|
#endif //DISPLAY_DEVICE || DHT_DEVICE
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define _VERSION_ESP3D_H
|
#define _VERSION_ESP3D_H
|
||||||
|
|
||||||
//version and sources location
|
//version and sources location
|
||||||
#define FW_VERSION "3.0.0.a9"
|
#define FW_VERSION "3.0.0.a10"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
||||||
|
|
||||||
#endif //_VERSION_ESP3D_H
|
#endif //_VERSION_ESP3D_H
|
||||||
|
@ -20,10 +20,11 @@
|
|||||||
|
|
||||||
#include "../../include/esp3d_config.h"
|
#include "../../include/esp3d_config.h"
|
||||||
|
|
||||||
#ifdef BUZZER_FEATURE
|
#ifdef BUZZER_DEVICE
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
#include "buzzer.h"
|
#include "buzzer.h"
|
||||||
BuzzerDevice buzzer;
|
#include "../../core/settings_esp3d.h"
|
||||||
|
BuzzerDevice esp3d_buzzer;
|
||||||
Ticker buzzer_tick;
|
Ticker buzzer_tick;
|
||||||
#define BUZZER_CHANNEL 1
|
#define BUZZER_CHANNEL 1
|
||||||
#define BEEP_DURATION 200
|
#define BEEP_DURATION 200
|
||||||
@ -34,11 +35,11 @@ extern void tone(uint8_t _pin, unsigned int frequency, unsigned long duration);
|
|||||||
|
|
||||||
void process()
|
void process()
|
||||||
{
|
{
|
||||||
if (buzzer.started()) {
|
if (esp3d_buzzer.started()) {
|
||||||
tone_data * current = buzzer.getNextTone();
|
tone_data * current = esp3d_buzzer.getNextTone();
|
||||||
if (current) {
|
if (current) {
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
tone(BUZZER_PIN, (unsigned int)current->frequency, (unsigned long) current->duration);
|
tone(ESP3D_BUZZER_PIN, (unsigned int)current->frequency, (unsigned long) current->duration);
|
||||||
#endif //ARDUINO_ARCH_ESP8266
|
#endif //ARDUINO_ARCH_ESP8266
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcWriteTone(BUZZER_CHANNEL, current->frequency);
|
ledcWriteTone(BUZZER_CHANNEL, current->frequency);
|
||||||
@ -52,25 +53,41 @@ BuzzerDevice::BuzzerDevice()
|
|||||||
{
|
{
|
||||||
_head = nullptr;
|
_head = nullptr;
|
||||||
_tail = nullptr;
|
_tail = nullptr;
|
||||||
|
_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuzzerDevice::begin()
|
bool BuzzerDevice::begin()
|
||||||
{
|
{
|
||||||
|
if(_started) {
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
if (Settings_ESP3D::read_byte(ESP_BUZZER) == 1) {
|
||||||
_started = true;
|
_started = true;
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcAttachPin(BUZZER_PIN, BUZZER_CHANNEL);
|
ledcAttachPin(ESP3D_BUZZER_PIN, BUZZER_CHANNEL);
|
||||||
#endif //ARDUINO_ARCH_ESP32
|
#endif //ARDUINO_ARCH_ESP32
|
||||||
|
}
|
||||||
|
return _started;
|
||||||
}
|
}
|
||||||
void BuzzerDevice::end()
|
void BuzzerDevice::end()
|
||||||
{
|
{
|
||||||
|
if(!_started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
purgeData();
|
purgeData();
|
||||||
no_tone();
|
//no_tone();
|
||||||
|
_started = false;
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcDetachPin(BUZZER_PIN);
|
ledcDetachPin(ESP3D_BUZZER_PIN);
|
||||||
#endif //ARDUINO_ARCH_ESP32
|
#endif //ARDUINO_ARCH_ESP32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BuzzerDevice::handle()
|
||||||
|
{
|
||||||
|
//Nothing to do as handled by ticker
|
||||||
|
}
|
||||||
|
|
||||||
void BuzzerDevice::beep(int count, int delay, int frequency)
|
void BuzzerDevice::beep(int count, int delay, int frequency)
|
||||||
{
|
{
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
@ -86,7 +103,7 @@ void BuzzerDevice::beep(int count, int delay, int frequency)
|
|||||||
void BuzzerDevice::no_tone()
|
void BuzzerDevice::no_tone()
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
tone(BUZZER_PIN, 0, 0);
|
tone(ESP3D_BUZZER_PIN, 0, 0);
|
||||||
#endif //ARDUINO_ARCH_ESP8266
|
#endif //ARDUINO_ARCH_ESP8266
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcWrite(BUZZER_CHANNEL, 0);
|
ledcWrite(BUZZER_CHANNEL, 0);
|
||||||
@ -169,4 +186,4 @@ void BuzzerDevice::playsound(int frequency, int duration)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //BUZZER_FEATURE
|
#endif //BUZZER_DEVICE
|
||||||
|
@ -38,8 +38,9 @@ public:
|
|||||||
{
|
{
|
||||||
return _started;
|
return _started;
|
||||||
}
|
}
|
||||||
void begin();
|
bool begin();
|
||||||
void end();
|
void end();
|
||||||
|
void handle();
|
||||||
tone_data * getNextTone();
|
tone_data * getNextTone();
|
||||||
bool isPlaying();
|
bool isPlaying();
|
||||||
void waitWhilePlaying();
|
void waitWhilePlaying();
|
||||||
@ -53,5 +54,5 @@ private:
|
|||||||
void no_tone();
|
void no_tone();
|
||||||
|
|
||||||
};
|
};
|
||||||
extern BuzzerDevice buzzer;
|
extern BuzzerDevice esp3d_buzzer;
|
||||||
#endif //_BUZZER_H
|
#endif //_BUZZER_H
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#ifdef DHT_DEVICE
|
#ifdef DHT_DEVICE
|
||||||
#include "../dht/dht.h"
|
#include "../dht/dht.h"
|
||||||
#endif //DHT_DEVICE
|
#endif //DHT_DEVICE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
#include "../buzzer/buzzer.h"
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#ifdef RECOVERY_FEATURE
|
#ifdef RECOVERY_FEATURE
|
||||||
#include "../recovery/recovery_service.h"
|
#include "../recovery/recovery_service.h"
|
||||||
#endif //RECOVERY_FEATURE
|
#endif //RECOVERY_FEATURE
|
||||||
@ -60,6 +63,12 @@ bool DevicesServices::begin()
|
|||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
#endif //DHT_DEVICE
|
#endif //DHT_DEVICE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
if (!esp3d_buzzer.begin()) {
|
||||||
|
log_esp3d("Error starting buzzer device");
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#ifdef RECOVERY_FEATURE
|
#ifdef RECOVERY_FEATURE
|
||||||
if (!recovery_service.begin()) {
|
if (!recovery_service.begin()) {
|
||||||
log_esp3d("Error starting recorery service");
|
log_esp3d("Error starting recorery service");
|
||||||
@ -81,6 +90,9 @@ void DevicesServices::end()
|
|||||||
#ifdef RECOVERY_FEATURE
|
#ifdef RECOVERY_FEATURE
|
||||||
recovery_service.end();
|
recovery_service.end();
|
||||||
#endif //RECOVERY_FEATURE
|
#endif //RECOVERY_FEATURE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
esp3d_buzzer.end();
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#ifdef DISPLAY_DEVICE
|
#ifdef DISPLAY_DEVICE
|
||||||
esp3d_display.end();
|
esp3d_display.end();
|
||||||
#endif //DISPLAY_DEVICE
|
#endif //DISPLAY_DEVICE
|
||||||
@ -98,6 +110,9 @@ void DevicesServices::handle()
|
|||||||
#ifdef DHT_DEVICE
|
#ifdef DHT_DEVICE
|
||||||
esp3d_DHT.handle();
|
esp3d_DHT.handle();
|
||||||
#endif //DHT_DEVICE
|
#endif //DHT_DEVICE
|
||||||
|
#ifdef BUZZER_DEVICE
|
||||||
|
esp3d_buzzer.handle();
|
||||||
|
#endif //BUZZER_DEVICE
|
||||||
#ifdef RECOVERY_FEATURE
|
#ifdef RECOVERY_FEATURE
|
||||||
recovery_service.handle();
|
recovery_service.handle();
|
||||||
#endif //RECOVERY_FEATURE
|
#endif //RECOVERY_FEATURE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user