mirror of https://github.com/arendst/Tasmota.git
Add command ``GpioRead`` (#19814)
* Add command ``GpioRead`` * change output
This commit is contained in:
parent
6efe2ab514
commit
356de1a16a
|
@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
|
|||
- I2C bus2 support to HYTxxx temperature and humidity sensor
|
||||
- I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor
|
||||
- I2C bus2 support to LM75AD temperature sensor
|
||||
- Add command ``GpioRead``
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
|
|
@ -302,6 +302,7 @@
|
|||
#define D_CMND_GPIO "GPIO"
|
||||
#define D_JSON_NOT_SUPPORTED "Not supported"
|
||||
#define D_CMND_GPIOS "GPIOs"
|
||||
#define D_CMND_GPIOREAD "GPIORead"
|
||||
#define D_CMND_PWM "PWM"
|
||||
#define D_CMND_PWMFREQUENCY "PWMFrequency"
|
||||
#define D_CMND_PWMRANGE "PWMRange"
|
||||
|
|
|
@ -27,7 +27,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
|
|||
D_CMND_POWERONSTATE "|" D_CMND_PULSETIME "|" D_CMND_BLINKTIME "|" D_CMND_BLINKCOUNT "|" D_CMND_SAVEDATA "|"
|
||||
D_CMND_SO "|" D_CMND_SETOPTION "|" D_CMND_TEMPERATURE_RESOLUTION "|" D_CMND_HUMIDITY_RESOLUTION "|" D_CMND_PRESSURE_RESOLUTION "|" D_CMND_POWER_RESOLUTION "|"
|
||||
D_CMND_VOLTAGE_RESOLUTION "|" D_CMND_FREQUENCY_RESOLUTION "|" D_CMND_CURRENT_RESOLUTION "|" D_CMND_ENERGY_RESOLUTION "|" D_CMND_WEIGHT_RESOLUTION "|"
|
||||
D_CMND_MODULE "|" D_CMND_MODULES "|" D_CMND_GPIO "|" D_CMND_GPIOS "|" D_CMND_TEMPLATE "|" D_CMND_PWM "|" D_CMND_PWMFREQUENCY "|" D_CMND_PWMRANGE "|"
|
||||
D_CMND_MODULE "|" D_CMND_MODULES "|" D_CMND_GPIO "|" D_CMND_GPIOREAD "|" D_CMND_GPIOS "|" D_CMND_TEMPLATE "|" D_CMND_PWM "|" D_CMND_PWMFREQUENCY "|" D_CMND_PWMRANGE "|"
|
||||
D_CMND_BUTTONDEBOUNCE "|" D_CMND_SWITCHDEBOUNCE "|" D_CMND_SYSLOG "|" D_CMND_LOGHOST "|" D_CMND_LOGPORT "|"
|
||||
D_CMND_SERIALBUFFER "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALCONFIG "|" D_CMND_SERIALDELIMITER "|"
|
||||
D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|" D_CMND_WIFI "|" D_CMND_DNSTIMEOUT "|"
|
||||
|
@ -67,7 +67,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
|
|||
&CmndPowerOnState, &CmndPulsetime, &CmndBlinktime, &CmndBlinkcount, &CmndSavedata,
|
||||
&CmndSetoption, &CmndSetoption, &CmndTemperatureResolution, &CmndHumidityResolution, &CmndPressureResolution, &CmndPowerResolution,
|
||||
&CmndVoltageResolution, &CmndFrequencyResolution, &CmndCurrentResolution, &CmndEnergyResolution, &CmndWeightResolution,
|
||||
&CmndModule, &CmndModules, &CmndGpio, &CmndGpios, &CmndTemplate, &CmndPwm, &CmndPwmfrequency, &CmndPwmrange,
|
||||
&CmndModule, &CmndModules, &CmndGpio, &CmndGpioRead, &CmndGpios, &CmndTemplate, &CmndPwm, &CmndPwmfrequency, &CmndPwmrange,
|
||||
&CmndButtonDebounce, &CmndSwitchDebounce, &CmndSyslog, &CmndLoghost, &CmndLogport,
|
||||
&CmndSerialBuffer, &CmndSerialSend, &CmndBaudrate, &CmndSerialConfig, &CmndSerialDelimiter,
|
||||
&CmndIpAddress, &CmndNtpServer, &CmndAp, &CmndSsid, &CmndPassword, &CmndHostname, &CmndWifiConfig, &CmndWifi, &CmndDnsTimeout,
|
||||
|
@ -1768,6 +1768,27 @@ void CmndGpio(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Perform a digitalRead on each configured PGIO
|
||||
void CmndGpioRead(void)
|
||||
{
|
||||
myio template_gp;
|
||||
TemplateGpios(&template_gp);
|
||||
bool jsflg = false;
|
||||
Response_P(PSTR("{\"" D_CMND_GPIOREAD "\":{"));
|
||||
for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) {
|
||||
uint32_t sensor_type = template_gp.io[i];
|
||||
if ((sensor_type != GPIO_NONE) && (AGPIO(GPIO_USER) != sensor_type)) {
|
||||
if (jsflg) {
|
||||
ResponseAppend_P(PSTR(","));
|
||||
}
|
||||
jsflg = true;
|
||||
bool state = digitalRead(i);
|
||||
ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":%d"), i, state);
|
||||
}
|
||||
}
|
||||
ResponseAppend_P(PSTR("}}"));
|
||||
}
|
||||
|
||||
void ShowGpios(const uint16_t *NiceList, uint32_t size, uint32_t offset, uint32_t &lines) {
|
||||
uint32_t ridx;
|
||||
uint32_t midx;
|
||||
|
|
Loading…
Reference in New Issue