mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 22:52:19 +03:00
libretiny
This commit is contained in:
@@ -9,7 +9,7 @@ IoTGpio::~IoTGpio(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifndef LIBRETINY
|
||||
void IoTGpio::pinMode(int pin, uint8_t mode) {
|
||||
int pinH = pin/100;
|
||||
if (_drivers[pinH]) _drivers[pinH]->pinMode(pin - pinH*100, mode);
|
||||
@@ -21,7 +21,19 @@ void IoTGpio::digitalWrite(int pin, uint8_t val) {
|
||||
if (_drivers[pinH]) _drivers[pinH]->digitalWrite(pin - pinH*100, val);
|
||||
else ::digitalWrite(pin, val);
|
||||
}
|
||||
#else
|
||||
void IoTGpio::pinMode(int pin, uint8_t mode) {
|
||||
int pinH = pin/100;
|
||||
if (_drivers[pinH]) _drivers[pinH]->pinMode(pin - pinH*100, mode);
|
||||
else ::pinMode(pin, (PinMode)mode);
|
||||
}
|
||||
|
||||
void IoTGpio::digitalWrite(int pin, uint8_t val) {
|
||||
int pinH = pin/100;
|
||||
if (_drivers[pinH]) _drivers[pinH]->digitalWrite(pin - pinH*100, val);
|
||||
else ::digitalWrite(pin, (PinStatus)val);
|
||||
}
|
||||
#endif
|
||||
int IoTGpio::digitalRead(int pin) {
|
||||
int pinH = pin/100;
|
||||
if (_drivers[pinH]) return _drivers[pinH]->digitalRead(pin - pinH*100);
|
||||
@@ -51,7 +63,11 @@ void IoTGpio::analogWrite(int pin, int val) {
|
||||
void IoTGpio::digitalInvert(int pin) {
|
||||
int pinH = pin/100;
|
||||
if (_drivers[pinH]) _drivers[pinH]->digitalInvert(pin - pinH*100);
|
||||
else ::digitalWrite(pin, 1 - ::digitalRead(pin));
|
||||
#ifdef LIBRETINY
|
||||
else ::digitalWrite(pin, (PinStatus)(1 - ::digitalRead(pin)));
|
||||
#else
|
||||
else ::digitalWrite(pin, (1 - ::digitalRead(pin)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -414,11 +414,11 @@ IoTValue sysExecute(SysOp command, std::vector<IoTValue> ¶m) {
|
||||
case sysop_deepSleep:
|
||||
if (param.size()) {
|
||||
Serial.printf("Ушел спать на %d сек...", (int)param[0].valD);
|
||||
#ifdef ESP32
|
||||
#if defined(ESP32)
|
||||
esp_sleep_enable_timer_wakeup(param[0].valD * 1000000);
|
||||
delay(1000);
|
||||
esp_deep_sleep_start();
|
||||
#else
|
||||
#elif defined(ESP8266)
|
||||
ESP.deepSleep(param[0].valD * 1000000);
|
||||
#endif
|
||||
}
|
||||
@@ -435,7 +435,7 @@ IoTValue sysExecute(SysOp command, std::vector<IoTValue> ¶m) {
|
||||
if (param.size() == 2) {
|
||||
// Serial.printf("Call from sysExecute %s %s\n", param[0].valS.c_str(), param[1].valS.c_str());
|
||||
String tmpStr = param[1].valS;
|
||||
if (param[1].isDecimal) tmpStr = param[1].valD;
|
||||
if (param[1].isDecimal) tmpStr = String(param[1].valD);
|
||||
value.valD = mqtt.publish(param[0].valS.c_str(), tmpStr.c_str(), false);
|
||||
}
|
||||
break;
|
||||
@@ -658,7 +658,7 @@ int IoTScenario::gettok() {
|
||||
LastChar = getLastChar();
|
||||
|
||||
if (isalpha(LastChar) || LastChar == '_') { // идентификатор: [a-zA-Z][a-zA-Z0-9]*
|
||||
IdentifierStr = (char)LastChar;
|
||||
IdentifierStr = String((char)LastChar);
|
||||
while (isalnum((LastChar = getLastChar())) || LastChar == '_') {
|
||||
IdentifierStr += (char)LastChar;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user