mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
button with name
This commit is contained in:
37
include/Cmd.h
Normal file
37
include/Cmd.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
extern void cmd_init();
|
||||||
|
extern void itemInit();
|
||||||
|
extern void button();
|
||||||
|
extern void buttonSet();
|
||||||
|
extern void buttonChange();
|
||||||
|
extern void pinSet();
|
||||||
|
extern void pinChange();
|
||||||
|
extern void handle_time_init();
|
||||||
|
extern void pwm();
|
||||||
|
extern void switch_();
|
||||||
|
extern void pwmSet();
|
||||||
|
extern void stepper();
|
||||||
|
extern void stepperSet();
|
||||||
|
extern void servo_();
|
||||||
|
extern void servoSet();
|
||||||
|
extern void serialBegin();
|
||||||
|
extern void serialWrite();
|
||||||
|
extern void logging();
|
||||||
|
extern void inputDigit();
|
||||||
|
extern void digitSet();
|
||||||
|
extern void inputTime();
|
||||||
|
extern void button();
|
||||||
|
extern void timeSet();
|
||||||
|
extern void text();
|
||||||
|
extern void textSet();
|
||||||
|
extern void mqttOrderSend();
|
||||||
|
extern void httpOrderSend();
|
||||||
|
extern void firmwareVersion();
|
||||||
|
extern void firmwareUpdate();
|
||||||
|
extern void loadScenario();
|
||||||
|
|
||||||
|
extern void fileExecute(const String& filename);
|
||||||
|
extern void stringExecute(String& cmdStr);
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
#define LED_PIN 2
|
#define LED_PIN 2
|
||||||
#define FLASH_4MB true
|
#define FLASH_4MB true
|
||||||
#define MQTT_RECONNECT_INTERVAL 20000
|
#define MQTT_RECONNECT_INTERVAL 20000
|
||||||
// 1000 * 60 * 60 * 2
|
|
||||||
#define TELEMETRY_UPDATE_INTERVAL 0
|
#define TELEMETRY_UPDATE_INTERVAL 7200000
|
||||||
|
|
||||||
#define DEVICE_CONFIG_FILE "dev_conf.txt"
|
#define DEVICE_CONFIG_FILE "dev_conf.txt"
|
||||||
#define DEVICE_SCENARIO_FILE "dev_scen.txt"
|
#define DEVICE_SCENARIO_FILE "dev_scen.txt"
|
||||||
|
|||||||
@@ -129,46 +129,8 @@ extern int sensors_reading_map[15];
|
|||||||
* Global functions
|
* Global functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Cmd
|
|
||||||
extern void cmd_init();
|
|
||||||
extern void button();
|
|
||||||
extern void buttonSet();
|
|
||||||
extern void buttonChange();
|
|
||||||
extern void pinSet();
|
|
||||||
extern void pinChange();
|
|
||||||
extern void handle_time_init();
|
|
||||||
extern void pwm();
|
|
||||||
extern void switch_();
|
|
||||||
extern void pwmSet();
|
|
||||||
extern void stepper();
|
|
||||||
extern void stepperSet();
|
|
||||||
extern void servo_();
|
|
||||||
extern void servoSet();
|
|
||||||
extern void serialBegin();
|
|
||||||
extern void serialWrite();
|
|
||||||
extern void logging();
|
|
||||||
extern void inputDigit();
|
|
||||||
extern void digitSet();
|
|
||||||
extern void inputTime();
|
|
||||||
extern void button();
|
|
||||||
extern void timeSet();
|
|
||||||
extern void text();
|
|
||||||
extern void textSet();
|
|
||||||
extern void mqttOrderSend();
|
|
||||||
extern void httpOrderSend();
|
|
||||||
extern void firmwareVersion();
|
|
||||||
extern void firmwareUpdate();
|
|
||||||
extern void loadScenario();
|
|
||||||
|
|
||||||
extern void fileExecute(const String& filename);
|
|
||||||
extern void stringExecute(String& cmdStr);
|
|
||||||
// Init
|
|
||||||
extern void loadConfig();
|
|
||||||
extern void all_init();
|
|
||||||
extern void statistics_init();
|
|
||||||
extern void loadScenario();
|
|
||||||
extern void Device_init();
|
|
||||||
extern void prsets_init();
|
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
extern void logging();
|
extern void logging();
|
||||||
|
|||||||
11
include/Init.h
Normal file
11
include/Init.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern void loadConfig();
|
||||||
|
extern void all_init();
|
||||||
|
extern void statistics_init();
|
||||||
|
extern void loadScenario();
|
||||||
|
extern void Device_init();
|
||||||
|
extern void prsets_init();
|
||||||
|
extern void handle_uptime();
|
||||||
|
extern void handle_statistics();
|
||||||
|
extern void telemetry_init();
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Print.h>
|
#include <Print.h>
|
||||||
|
#include "Cmd.h"
|
||||||
|
|
||||||
class Runner {
|
class Runner {
|
||||||
public:
|
public:
|
||||||
|
|||||||
101
src/Cmd.cpp
101
src/Cmd.cpp
@@ -1,3 +1,5 @@
|
|||||||
|
#include "Cmd.h"
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Module/Terminal.h"
|
#include "Module/Terminal.h"
|
||||||
#include "Servo/Servos.h"
|
#include "Servo/Servos.h"
|
||||||
@@ -105,9 +107,14 @@ void cmd_init() {
|
|||||||
handle_time_init();
|
handle_time_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================================================
|
|
||||||
//==========================================Модуль кнопок===================================================
|
//==========================================Модуль кнопок===================================================
|
||||||
//button out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
//button out light toggle Кнопки Свет 1 pin[12] inv[1] st[1]
|
||||||
|
//void button() {
|
||||||
|
// void itemInit();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//==========================================================================================================
|
||||||
|
|
||||||
void button() {
|
void button() {
|
||||||
String command = sCmd.order();
|
String command = sCmd.order();
|
||||||
pm.info("create '" + command + "'");
|
pm.info("create '" + command + "'");
|
||||||
@@ -137,107 +144,33 @@ void button() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println(pin);
|
|
||||||
Serial.println(inv);
|
|
||||||
Serial.println(state);
|
|
||||||
|
|
||||||
createWidget(descr, page, order, file, key);
|
createWidget(descr, page, order, file, key);
|
||||||
|
|
||||||
sCmd.addCommand(key.c_str(), buttonSet);
|
sCmd.addCommand(key.c_str(), buttonSet);
|
||||||
|
|
||||||
if (pin != "") {
|
if (pin != "") {
|
||||||
pinMode(pin.toInt(), OUTPUT);
|
pinMode(pin.toInt(), OUTPUT);
|
||||||
|
jsonWriteStr(configOptionJson, key + "_pin", pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != "") {
|
if (state != "") {
|
||||||
digitalWrite(pin.toInt(), state.toInt());
|
digitalWrite(pin.toInt(), state.toInt());
|
||||||
|
jsonWriteStr(configLiveJson, key, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void button() {
|
|
||||||
// pm.info("create 'button'");
|
|
||||||
// String number = sCmd.next();
|
|
||||||
// String param = sCmd.next();
|
|
||||||
// String widget = sCmd.next();
|
|
||||||
// String page = sCmd.next();
|
|
||||||
// String state = sCmd.next();
|
|
||||||
// String pageNumber = sCmd.next();
|
|
||||||
//
|
|
||||||
// jsonWriteStr(configOptionJson, "button_param" + number, param);
|
|
||||||
// jsonWriteStr(configLiveJson, "button" + number, state);
|
|
||||||
//
|
|
||||||
// if (isDigitStr(param)) {
|
|
||||||
// pinMode(param.toInt(), OUTPUT);
|
|
||||||
// digitalWrite(param.toInt(), state.toInt());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (param == "scen") {
|
|
||||||
// jsonWriteStr(configSetupJson, "scen", state);
|
|
||||||
// loadScenario();
|
|
||||||
// saveConfig();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (param.indexOf("line") != -1) {
|
|
||||||
// String str = param;
|
|
||||||
// while (str.length()) {
|
|
||||||
// if (str == "") return;
|
|
||||||
// String tmp = selectToMarker(str, ","); //line1,
|
|
||||||
// String number = deleteBeforeDelimiter(tmp, "e"); //1,
|
|
||||||
// number.replace(",", "");
|
|
||||||
// Serial.println(number);
|
|
||||||
// int number_int = number.toInt();
|
|
||||||
// scenario_line_status[number_int] = state.toInt();
|
|
||||||
// str = deleteBeforeDelimiter(str, ",");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// createWidget(widget, page, pageNumber, "toggle", "button" + number);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void buttonSet() {
|
void buttonSet() {
|
||||||
String order = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String state = sCmd.next();
|
||||||
|
|
||||||
//Serial.println(order);
|
int pin = jsonReadInt(configOptionJson, key + "_pin");
|
||||||
|
digitalWrite(pin, state.toInt());
|
||||||
|
|
||||||
eventGen(order, "");
|
eventGen(key, "");
|
||||||
jsonWriteStr(configLiveJson, order, state);
|
jsonWriteStr(configLiveJson, key, state);
|
||||||
MqttClient::publishStatus(order, state);
|
MqttClient::publishStatus(key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void buttonSet() {
|
|
||||||
// String button_number = sCmd.next();
|
|
||||||
// String button_state = sCmd.next();
|
|
||||||
// String button_param = jsonReadStr(configOptionJson, "button_param" + button_number);
|
|
||||||
//
|
|
||||||
// if (button_param != "na" || button_param != "scen" || button_param.indexOf("line") != -1) {
|
|
||||||
// digitalWrite(button_param.toInt(), button_state.toInt());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (button_param == "scen") {
|
|
||||||
// jsonWriteStr(configSetupJson, "scen", button_state);
|
|
||||||
// loadScenario();
|
|
||||||
// saveConfig();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (button_param.indexOf("line") != -1) {
|
|
||||||
// String str = button_param;
|
|
||||||
// while (str.length() != 0) {
|
|
||||||
// if (str == "") return;
|
|
||||||
// String tmp = selectToMarker(str, ","); //line1,
|
|
||||||
// String number = deleteBeforeDelimiter(tmp, "e"); //1,
|
|
||||||
// number.replace(",", "");
|
|
||||||
// Serial.println(number);
|
|
||||||
// int number_int = number.toInt();
|
|
||||||
// scenario_line_status[number_int] = button_state.toInt();
|
|
||||||
// str = deleteBeforeDelimiter(str, ",");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// eventGen("button", button_number);
|
|
||||||
// jsonWriteStr(configLiveJson, "button" + button_number, button_state);
|
|
||||||
// MqttClient::publishStatus("button" + button_number, button_state);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void buttonChange() {
|
void buttonChange() {
|
||||||
String button_number = sCmd.next();
|
String button_number = sCmd.next();
|
||||||
if (!isDigitStr(button_number)) {
|
if (!isDigitStr(button_number)) {
|
||||||
@@ -545,6 +478,8 @@ void servoSet() {
|
|||||||
MqttClient::publishStatus("servo" + number, String(value, DEC));
|
MqttClient::publishStatus("servo" + number, String(value, DEC));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
//====================================================================================================================================================
|
||||||
|
//=============================================================Модуль сериал порта=======================================================================
|
||||||
|
|
||||||
#ifdef SERIAL_ENABLED
|
#ifdef SERIAL_ENABLED
|
||||||
void serialBegin() {
|
void serialBegin() {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Init.h"
|
||||||
|
#include "Cmd.h"
|
||||||
|
|
||||||
void handle_uptime();
|
|
||||||
void handle_statistics();
|
|
||||||
void telemetry_init();
|
|
||||||
|
|
||||||
void loadConfig() {
|
void loadConfig() {
|
||||||
configSetupJson = readFile("config.json", 4096);
|
configSetupJson = readFile("config.json", 4096);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "MqttClient.h"
|
#include "MqttClient.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Init.h"
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
|
||||||
static const char* MODULE = "Mqtt";
|
static const char* MODULE = "Mqtt";
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Cmd.h"
|
||||||
|
|
||||||
static const char* MODULE = "Scen";
|
static const char* MODULE = "Scen";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Init.h"
|
||||||
|
|
||||||
static const char* MODULE = "Web";
|
static const char* MODULE = "Web";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Init.h"
|
||||||
|
#include "Cmd.h"
|
||||||
#include "HttpServer.h"
|
#include "HttpServer.h"
|
||||||
#include "Bus/BusScannerFactory.h"
|
#include "Bus/BusScannerFactory.h"
|
||||||
#include "Utils/Timings.h"
|
#include "Utils/Timings.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user