diff --git a/lib/AM2320/AM2320.cpp b/lib/AM2320/AM2320.cpp index 1e2016421..dad106c89 100644 --- a/lib/AM2320/AM2320.cpp +++ b/lib/AM2320/AM2320.cpp @@ -4,7 +4,7 @@ // AM2321 Temperature & Humidity Sensor library for Arduino // Сделана Тимофеевым Е.Н. из AM2320-master -unsigned int CRC16(byte *ptr, byte length) +unsigned int CRC16(uint8_t *ptr, uint8_t length) { unsigned int crc = 0xFFFF; uint8_t s = 0x00; @@ -27,7 +27,7 @@ AM2320::AM2320() int AM2320::Read() { - byte buf[8]; + uint8_t buf[8]; for(int s = 0; s < 8; s++) buf[s] = 0x00; Wire.beginTransmission(AM2320_address); diff --git a/lib/Adafruit_BME680/Adafruit_BME680.cpp b/lib/Adafruit_BME680/Adafruit_BME680.cpp index 29526ec18..faa52336d 100644 --- a/lib/Adafruit_BME680/Adafruit_BME680.cpp +++ b/lib/Adafruit_BME680/Adafruit_BME680.cpp @@ -559,7 +559,7 @@ int8_t i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *reg_data, _wire->beginTransmission((uint8_t)dev_id); _wire->write((uint8_t)reg_addr); _wire->endTransmission(); - if (len != _wire->requestFrom((uint8_t)dev_id, (byte)len)) { + if (len != _wire->requestFrom((uint8_t)dev_id, (uint8_t)len)) { #ifdef BME680_DEBUG Serial.print("Failed to read "); Serial.print(len); diff --git a/lib/Blynk/src_off/Adapters/BlynkEthernet.h b/lib/Blynk/src_off/Adapters/BlynkEthernet.h index 51bdbea17..0e0da4ccf 100644 --- a/lib/Blynk/src_off/Adapters/BlynkEthernet.h +++ b/lib/Blynk/src_off/Adapters/BlynkEthernet.h @@ -54,7 +54,7 @@ public: void begin( const char* auth, const char* domain = BLYNK_DEFAULT_DOMAIN, uint16_t port = BLYNK_SERVER_PORT, - const byte mac[] = NULL) + const uint8_t mac[] = NULL) { BLYNK_LOG1(BLYNK_F("Getting IP...")); if (!Ethernet.begin(SelectMacAddress(auth, mac))) { @@ -75,7 +75,7 @@ public: uint16_t port, IPAddress local, IPAddress dns, - const byte mac[] = NULL) + const uint8_t mac[] = NULL) { BLYNK_LOG1(BLYNK_F("Using static IP")); Ethernet.begin(SelectMacAddress(auth, mac), local, dns); @@ -96,7 +96,7 @@ public: IPAddress dns, IPAddress gateway, IPAddress subnet, - const byte mac[] = NULL) + const uint8_t mac[] = NULL) { BLYNK_LOG1(BLYNK_F("Using static IP")); Ethernet.begin(SelectMacAddress(auth, mac), local, dns, gateway, subnet); @@ -113,7 +113,7 @@ public: void begin( const char* auth, IPAddress addr, uint16_t port = BLYNK_SERVER_PORT, - const byte mac[] = NULL) + const uint8_t mac[] = NULL) { BLYNK_LOG1(BLYNK_F("Getting IP...")); if (!Ethernet.begin(SelectMacAddress(auth, mac))) { @@ -133,7 +133,7 @@ public: IPAddress addr, uint16_t port, IPAddress local, - const byte mac[] = NULL) + const uint8_t mac[] = NULL) { BLYNK_LOG1(BLYNK_F("Using static IP")); Ethernet.begin(SelectMacAddress(auth, mac), local); @@ -154,7 +154,7 @@ public: IPAddress dns, IPAddress gateway, IPAddress subnet, - const byte mac[] = NULL) + const uint8_t mac[] = NULL) { BLYNK_LOG1(BLYNK_F("Using static IP")); Ethernet.begin(SelectMacAddress(auth, mac), local, dns, gateway, subnet); @@ -169,10 +169,10 @@ public: private: - byte* SelectMacAddress(const char* token, const byte mac[]) + uint8_t* SelectMacAddress(const char* token, const uint8_t mac[]) { if (mac != NULL) { - return (byte*)mac; + return (uint8_t*)mac; } macAddress[0] = 0xFE; @@ -198,7 +198,7 @@ private: } private: - byte macAddress[6]; + uint8_t macAddress[6]; }; diff --git a/lib/Blynk/src_off/BlynkSimpleEthernetSSL.h b/lib/Blynk/src_off/BlynkSimpleEthernetSSL.h index 47f8fa81b..b4eeb2863 100644 --- a/lib/Blynk/src_off/BlynkSimpleEthernetSSL.h +++ b/lib/Blynk/src_off/BlynkSimpleEthernetSSL.h @@ -37,7 +37,7 @@ unsigned long ntpGetTime() { static const char timeServer[] = "time.nist.gov"; const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message - byte packetBuffer[NTP_PACKET_SIZE]; + uint8_t packetBuffer[NTP_PACKET_SIZE]; EthernetUDP Udp; Udp.begin(8888); diff --git a/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.h b/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.h index 23e2aeaf2..c309ae6fc 100644 --- a/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.h +++ b/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.h @@ -38,8 +38,8 @@ class PingClass { public: PingClass(); - bool ping(IPAddress dest, byte count = 5); - bool ping(const char* host, byte count = 5); + bool ping(IPAddress dest, uint8_t count = 5); + bool ping(const char* host, uint8_t count = 5); int averageTime(); @@ -50,7 +50,7 @@ class PingClass { IPAddress _dest; ping_option _options; - static byte _expected_count, _errors, _success; + static uint8_t _expected_count, _errors, _success; static int _avg_time; }; diff --git a/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.impl.h b/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.impl.h index 6a550a1ba..dbc50ee25 100644 --- a/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.impl.h +++ b/lib/ESPEasy_ESP8266Ping/src/ESP8266Ping.impl.h @@ -23,7 +23,7 @@ extern "C" void esp_yield(); PingClass::PingClass() {} -bool PingClass::ping(IPAddress dest, byte count) { +bool PingClass::ping(IPAddress dest, uint8_t count) { _expected_count = count; _errors = 0; _success = 0; @@ -52,7 +52,7 @@ bool PingClass::ping(IPAddress dest, byte count) { return (_success > 0); } -bool PingClass::ping(const char* host, byte count) { +bool PingClass::ping(const char* host, uint8_t count) { IPAddress remote_addr; if (WiFi.hostByName(host, remote_addr)) @@ -106,7 +106,7 @@ void PingClass::_ping_recv_cb(void *opt, void *resp) { } } -byte PingClass::_expected_count = 0; -byte PingClass::_errors = 0; -byte PingClass::_success = 0; +uint8_t PingClass::_expected_count = 0; +uint8_t PingClass::_errors = 0; +uint8_t PingClass::_success = 0; int PingClass::_avg_time = 0; diff --git a/lib/HT16K33/HT16K33.cpp b/lib/HT16K33/HT16K33.cpp index c98f17aa0..5cd7de688 100644 --- a/lib/HT16K33/HT16K33.cpp +++ b/lib/HT16K33/HT16K33.cpp @@ -40,7 +40,7 @@ void CHT16K33::TransmitRowBuffer(void) // Display Memory Wire.beginTransmission(_addr); Wire.write(0); // start data at address 0 - for (byte i=0; i<8; i++) + for (uint8_t i=0; i<8; i++) { Wire.write(_rowBuffer[i] & 0xFF); Wire.write(_rowBuffer[i] >> 8); @@ -50,7 +50,7 @@ void CHT16K33::TransmitRowBuffer(void) void CHT16K33::ClearRowBuffer(void) { - for (byte i=0; i<8; i++) + for (uint8_t i=0; i<8; i++) _rowBuffer[i] = 0; }; @@ -129,7 +129,7 @@ uint8_t CHT16K33::ReadKeys(void) Wire.requestFrom(_addr, (uint8_t)6); if (Wire.available() == 6) { - for (byte i=0; i<3; i++) + for (uint8_t i=0; i<3; i++) { _keyBuffer[i] = Wire.read() | (Wire.read() << 8); } @@ -137,10 +137,10 @@ uint8_t CHT16K33::ReadKeys(void) // Wire.endTransmission(); } - for (byte i=0; i<3; i++) + for (uint8_t i=0; i<3; i++) { - byte mask = 1; - for (byte k=0; k<12; k++) + uint8_t mask = 1; + for (uint8_t k=0; k<12; k++) { if (_keyBuffer[i] & mask) { diff --git a/lib/HT16K33/HT16K33.h b/lib/HT16K33/HT16K33.h index 00ca8a991..d3e66b431 100644 --- a/lib/HT16K33/HT16K33.h +++ b/lib/HT16K33/HT16K33.h @@ -26,7 +26,7 @@ protected: uint8_t _addr; uint16_t _rowBuffer[8]; uint16_t _keyBuffer[3]; - byte _keydown; + uint8_t _keydown; static const uint8_t _digits[16]; }; diff --git a/lib/HeatpumpIR/HitachiHeatpumpIR.cpp b/lib/HeatpumpIR/HitachiHeatpumpIR.cpp index ad5fd40f4..33b59838a 100644 --- a/lib/HeatpumpIR/HitachiHeatpumpIR.cpp +++ b/lib/HeatpumpIR/HitachiHeatpumpIR.cpp @@ -125,7 +125,7 @@ void HitachiHeatpumpIR::sendHitachi(IRSender& IR, uint8_t powerMode, uint8_t ope //Checksum calculation int checksum = 1086; - for (byte i = 0; i < 27; i++) { + for (uint8_t i = 0; i < 27; i++) { checksum -= hitachiTemplate[i]; } hitachiTemplate[27] = checksum; diff --git a/lib/HeatpumpIR/IRSenderPWM.cpp b/lib/HeatpumpIR/IRSenderPWM.cpp index 5274ced0a..d46cff69d 100644 --- a/lib/HeatpumpIR/IRSenderPWM.cpp +++ b/lib/HeatpumpIR/IRSenderPWM.cpp @@ -14,7 +14,7 @@ #if defined(__SAM3X8E__) || defined(__SAM3X8H__) // Arduino Due uint32_t IR_USE_PWM_PINMASK; - byte IR_USE_PWM_CH; + uint8_t IR_USE_PWM_CH; #endif IRSenderPWM::IRSenderPWM(uint8_t pin) : IRSender(pin) diff --git a/lib/HeatpumpIR/R51MHeatpumpIR.cpp b/lib/HeatpumpIR/R51MHeatpumpIR.cpp index 0be76bd3e..945de53d4 100644 --- a/lib/HeatpumpIR/R51MHeatpumpIR.cpp +++ b/lib/HeatpumpIR/R51MHeatpumpIR.cpp @@ -12,7 +12,7 @@ R51MHeatpumpIR::R51MHeatpumpIR() : HeatpumpIR() void R51MHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd) { - const static byte tempMap [] PROGMEM = {0,1,3,2,6,7,5,4,12,13,9,8,10,11 }; + const static uint8_t tempMap [] PROGMEM = {0,1,3,2,6,7,5,4,12,13,9,8,10,11 }; // Sensible defaults for the heat pump mode uint8_t data[] = { 0xB2, 0x0F, 0x00 }; // The actual data is in this part diff --git a/lib/I2Cdevlib/I2Cdev.cpp b/lib/I2Cdevlib/I2Cdev.cpp index e5e9d5406..21d4e1887 100644 --- a/lib/I2Cdevlib/I2Cdev.cpp +++ b/lib/I2Cdevlib/I2Cdev.cpp @@ -746,8 +746,8 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; // added by Jeff Rowberg 2013-05-07: // Arduino Wire-style "beginTransmission" function // (takes 7-bit device address like the Wire method, NOT 8-bit: 0x68, not 0xD0/0xD1) - byte Fastwire::beginTransmission(byte device) { - byte twst, retry; + uint8_t Fastwire::beginTransmission(uint8_t device) { + uint8_t twst, retry; retry = 2; do { TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO) | (1 << TWSTA); @@ -766,8 +766,8 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; return 0; } - byte Fastwire::writeBuf(byte device, byte address, byte *data, byte num) { - byte twst, retry; + uint8_t Fastwire::writeBuf(uint8_t device, uint8_t address, uint8_t *data, uint8_t num) { + uint8_t twst, retry; retry = 2; do { @@ -793,7 +793,7 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; twst = TWSR & 0xF8; if (twst != TW_MT_DATA_ACK) return 6; - for (byte i = 0; i < num; i++) { + for (uint8_t i = 0; i < num; i++) { //Serial.print(data[i], HEX); //Serial.print(" "); TWDR = data[i]; // send data to the previously addressed device @@ -807,8 +807,8 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; return 0; } - byte Fastwire::write(byte value) { - byte twst; + uint8_t Fastwire::write(uint8_t value) { + uint8_t twst; //Serial.println(value, HEX); TWDR = value; // send data TWCR = (1 << TWINT) | (1 << TWEN); @@ -818,8 +818,8 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; return 0; } - byte Fastwire::readBuf(byte device, byte address, byte *data, byte num) { - byte twst, retry; + uint8_t Fastwire::readBuf(uint8_t device, uint8_t address, uint8_t *data, uint8_t num) { + uint8_t twst, retry; retry = 2; do { @@ -885,7 +885,7 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; TWCR = 0; } - byte Fastwire::stop() { + uint8_t Fastwire::stop() { TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO); if (!waitInt()) return 1; return 0; @@ -1000,7 +1000,7 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT; twi_Write_Vars *ptwv = 0; static void (*fNextInterruptFunction)(void) = 0; - void twi_Finish(byte bRetVal) { + void twi_Finish(uint8_t bRetVal) { if (ptwv) { free(ptwv); ptwv = 0; diff --git a/lib/I2Cdevlib/I2Cdev.h b/lib/I2Cdevlib/I2Cdev.h index 4c0a2e7a2..007281de6 100644 --- a/lib/I2Cdevlib/I2Cdev.h +++ b/lib/I2Cdevlib/I2Cdev.h @@ -156,12 +156,12 @@ class I2Cdev { public: static void setup(int khz, boolean pullup); - static byte beginTransmission(byte device); - static byte write(byte value); - static byte writeBuf(byte device, byte address, byte *data, byte num); - static byte readBuf(byte device, byte address, byte *data, byte num); + static uint8_t beginTransmission(uint8_t device); + static uint8_t write(uint8_t value); + static uint8_t writeBuf(uint8_t device, uint8_t address, uint8_t *data, uint8_t num); + static uint8_t readBuf(uint8_t device, uint8_t address, uint8_t *data, uint8_t num); static void reset(); - static byte stop(); + static uint8_t stop(); }; #endif diff --git a/lib/IRremoteESP8266/examples/IRMQTTServer/IRMQTTServer.h b/lib/IRremoteESP8266/examples/IRMQTTServer/IRMQTTServer.h index e1094aae0..a270f669a 100644 --- a/lib/IRremoteESP8266/examples/IRMQTTServer/IRMQTTServer.h +++ b/lib/IRremoteESP8266/examples/IRMQTTServer/IRMQTTServer.h @@ -362,7 +362,7 @@ const char* kMqttTopics[] = { KEY_JSON}; // KEY_JSON needs to be the last one. -void mqttCallback(char* topic, byte* payload, unsigned int length); +void mqttCallback(char* topic, uint8_t* payload, unsigned int length); String listOfCommandTopics(void); void handleSendMqttDiscovery(void); void subscribing(const String topic_name); @@ -371,7 +371,7 @@ void mqttLog(const char* str); bool mountSpiffs(void); bool reconnect(void); void receivingMQTT(String const topic_name, String const callback_str); -void callback(char* topic, byte* payload, unsigned int length); +void callback(char* topic, uint8_t* payload, unsigned int length); void sendMQTTDiscovery(const char *topic); void doBroadcast(TimerMs *timer, const uint32_t interval, IRac *climates[], const bool retain, diff --git a/lib/MFRC522/MFRC522.cpp b/lib/MFRC522/MFRC522.cpp index a4f70e6dd..e06ae4b97 100644 --- a/lib/MFRC522/MFRC522.cpp +++ b/lib/MFRC522/MFRC522.cpp @@ -20,7 +20,7 @@ MFRC522::MFRC522(): MFRC522(SS, UINT8_MAX) { // SS is defined in pins_arduino.h, * Constructor. * Prepares the output pins. */ -MFRC522::MFRC522( byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). +MFRC522::MFRC522( uint8_t resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). ): MFRC522(SS, resetPowerDownPin) { // SS is defined in pins_arduino.h } // End constructor @@ -28,8 +28,8 @@ MFRC522::MFRC522( byte resetPowerDownPin ///< Arduino pin connected to MFRC522's * Constructor. * Prepares the output pins. */ -MFRC522::MFRC522( byte chipSelectPin, ///< Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) - byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). +MFRC522::MFRC522( uint8_t chipSelectPin, ///< Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) + uint8_t resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low). If there is no connection from the CPU to NRSTPD, set this to UINT8_MAX. In this case, only soft reset will be used in PCD_Init(). ) { _chipSelectPin = chipSelectPin; _resetPowerDownPin = resetPowerDownPin; @@ -44,7 +44,7 @@ MFRC522::MFRC522( byte chipSelectPin, ///< Arduino pin connected to MFRC522's S * The interface is described in the datasheet section 8.1.2. */ void MFRC522::PCD_WriteRegister( PCD_Register reg, ///< The register to write to. One of the PCD_Register enums. - byte value ///< The value to write. + uint8_t value ///< The value to write. ) { SPI.beginTransaction(SPISettings(MFRC522_SPICLOCK, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus digitalWrite(_chipSelectPin, LOW); // Select slave @@ -59,13 +59,13 @@ void MFRC522::PCD_WriteRegister( PCD_Register reg, ///< The register to write to * The interface is described in the datasheet section 8.1.2. */ void MFRC522::PCD_WriteRegister( PCD_Register reg, ///< The register to write to. One of the PCD_Register enums. - byte count, ///< The number of bytes to write to the register - byte *values ///< The values to write. Byte array. + uint8_t count, ///< The number of bytes to write to the register + uint8_t *values ///< The values to write. Byte array. ) { SPI.beginTransaction(SPISettings(MFRC522_SPICLOCK, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus digitalWrite(_chipSelectPin, LOW); // Select slave SPI.transfer(reg); // MSB == 0 is for writing. LSB is not used in address. Datasheet section 8.1.2.3. - for (byte index = 0; index < count; index++) { + for (uint8_t index = 0; index < count; index++) { SPI.transfer(values[index]); } digitalWrite(_chipSelectPin, HIGH); // Release slave again @@ -76,9 +76,9 @@ void MFRC522::PCD_WriteRegister( PCD_Register reg, ///< The register to write to * Reads a byte from the specified register in the MFRC522 chip. * The interface is described in the datasheet section 8.1.2. */ -byte MFRC522::PCD_ReadRegister( PCD_Register reg ///< The register to read from. One of the PCD_Register enums. +uint8_t MFRC522::PCD_ReadRegister( PCD_Register reg ///< The register to read from. One of the PCD_Register enums. ) { - byte value; + uint8_t value; SPI.beginTransaction(SPISettings(MFRC522_SPICLOCK, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus digitalWrite(_chipSelectPin, LOW); // Select slave SPI.transfer(0x80 | reg); // MSB == 1 is for reading. LSB is not used in address. Datasheet section 8.1.2.3. @@ -93,25 +93,25 @@ byte MFRC522::PCD_ReadRegister( PCD_Register reg ///< The register to read from. * The interface is described in the datasheet section 8.1.2. */ void MFRC522::PCD_ReadRegister( PCD_Register reg, ///< The register to read from. One of the PCD_Register enums. - byte count, ///< The number of bytes to read - byte *values, ///< Byte array to store the values in. - byte rxAlign ///< Only bit positions rxAlign..7 in values[0] are updated. + uint8_t count, ///< The number of bytes to read + uint8_t *values, ///< Byte array to store the values in. + uint8_t rxAlign ///< Only bit positions rxAlign..7 in values[0] are updated. ) { if (count == 0) { return; } //Serial.print(F("Reading ")); Serial.print(count); Serial.println(F(" bytes from register.")); - byte address = 0x80 | reg; // MSB == 1 is for reading. LSB is not used in address. Datasheet section 8.1.2.3. - byte index = 0; // Index in values array. + uint8_t address = 0x80 | reg; // MSB == 1 is for reading. LSB is not used in address. Datasheet section 8.1.2.3. + uint8_t index = 0; // Index in values array. SPI.beginTransaction(SPISettings(MFRC522_SPICLOCK, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus digitalWrite(_chipSelectPin, LOW); // Select slave count--; // One read is performed outside of the loop SPI.transfer(address); // Tell MFRC522 which address we want to read if (rxAlign) { // Only update bit positions rxAlign..7 in values[0] // Create bit mask for bit positions rxAlign..7 - byte mask = (0xFF << rxAlign) & 0xFF; + uint8_t mask = (0xFF << rxAlign) & 0xFF; // Read value and tell that we want to read the same address again. - byte value = SPI.transfer(address); + uint8_t value = SPI.transfer(address); // Apply mask to both current value of values[0] and the new data in value. values[0] = (values[0] & ~mask) | (value & mask); index++; @@ -129,9 +129,9 @@ void MFRC522::PCD_ReadRegister( PCD_Register reg, ///< The register to read from * Sets the bits given in mask in register reg. */ void MFRC522::PCD_SetRegisterBitMask( PCD_Register reg, ///< The register to update. One of the PCD_Register enums. - byte mask ///< The bits to set. + uint8_t mask ///< The bits to set. ) { - byte tmp; + uint8_t tmp; tmp = PCD_ReadRegister(reg); PCD_WriteRegister(reg, tmp | mask); // set bit mask } // End PCD_SetRegisterBitMask() @@ -140,9 +140,9 @@ void MFRC522::PCD_SetRegisterBitMask( PCD_Register reg, ///< The register to upd * Clears the bits given in mask from register reg. */ void MFRC522::PCD_ClearRegisterBitMask( PCD_Register reg, ///< The register to update. One of the PCD_Register enums. - byte mask ///< The bits to clear. + uint8_t mask ///< The bits to clear. ) { - byte tmp; + uint8_t tmp; tmp = PCD_ReadRegister(reg); PCD_WriteRegister(reg, tmp & (~mask)); // clear bit mask } // End PCD_ClearRegisterBitMask() @@ -153,9 +153,9 @@ void MFRC522::PCD_ClearRegisterBitMask( PCD_Register reg, ///< The register to u * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PCD_CalculateCRC( byte *data, ///< In: Pointer to the data to transfer to the FIFO for CRC calculation. - byte length, ///< In: The number of bytes to transfer. - byte *result ///< Out: Pointer to result buffer. Result is written to result[0..1], low byte first. +MFRC522::StatusCode MFRC522::PCD_CalculateCRC( uint8_t *data, ///< In: Pointer to the data to transfer to the FIFO for CRC calculation. + uint8_t length, ///< In: The number of bytes to transfer. + uint8_t *result ///< Out: Pointer to result buffer. Result is written to result[0..1], low uint8_t first. ) { PCD_WriteRegister(CommandReg, PCD_Idle); // Stop any active command. PCD_WriteRegister(DivIrqReg, 0x04); // Clear the CRCIRq interrupt request bit @@ -169,7 +169,7 @@ MFRC522::StatusCode MFRC522::PCD_CalculateCRC( byte *data, ///< In: Pointer to // Wait for the CRC calculation to complete. Each iteration of the while-loop takes 17.73us. for (uint16_t i = 5000; i > 0; i--) { // DivIrqReg[7..0] bits are: Set2 reserved reserved MfinActIRq reserved CRCIRq reserved reserved - byte n = PCD_ReadRegister(DivIrqReg); + uint8_t n = PCD_ReadRegister(DivIrqReg); if (n & 0x04) { // CRCIRq bit set - calculation done PCD_WriteRegister(CommandReg, PCD_Idle); // Stop calculating CRC for new content in the FIFO. // Transfer the result from the registers to the result buffer @@ -239,7 +239,7 @@ void MFRC522::PCD_Init() { /** * Initializes the MFRC522 chip. */ -void MFRC522::PCD_Init( byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) +void MFRC522::PCD_Init( uint8_t resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) ) { PCD_Init(SS, resetPowerDownPin); // SS is defined in pins_arduino.h } // End PCD_Init() @@ -247,8 +247,8 @@ void MFRC522::PCD_Init( byte resetPowerDownPin ///< Arduino pin connected to MFR /** * Initializes the MFRC522 chip. */ -void MFRC522::PCD_Init( byte chipSelectPin, ///< Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) - byte resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) +void MFRC522::PCD_Init( uint8_t chipSelectPin, ///< Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) + uint8_t resetPowerDownPin ///< Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) ) { _chipSelectPin = chipSelectPin; _resetPowerDownPin = resetPowerDownPin; @@ -276,7 +276,7 @@ void MFRC522::PCD_Reset() { * After a reset these pins are disabled. */ void MFRC522::PCD_AntennaOn() { - byte value = PCD_ReadRegister(TxControlReg); + uint8_t value = PCD_ReadRegister(TxControlReg); if ((value & 0x03) != 0x03) { PCD_WriteRegister(TxControlReg, value | 0x03); } @@ -296,7 +296,7 @@ void MFRC522::PCD_AntennaOff() { * * @return Value of the RxGain, scrubbed to the 3 bits used. */ -byte MFRC522::PCD_GetAntennaGain() { +uint8_t MFRC522::PCD_GetAntennaGain() { return PCD_ReadRegister(RFCfgReg) & (0x07<<4); } // End PCD_GetAntennaGain() @@ -305,7 +305,7 @@ byte MFRC522::PCD_GetAntennaGain() { * See 9.3.3.6 / table 98 in http://www.nxp.com/documents/data_sheet/MFRC522.pdf * NOTE: Given mask is scrubbed with (0x07<<4)=01110000b as RCFfgReg may use reserved bits. */ -void MFRC522::PCD_SetAntennaGain(byte mask) { +void MFRC522::PCD_SetAntennaGain(uint8_t mask) { if (PCD_GetAntennaGain() != mask) { // only bother if there is a change PCD_ClearRegisterBitMask(RFCfgReg, (0x07<<4)); // clear needed to allow 000 pattern PCD_SetRegisterBitMask(RFCfgReg, mask & (0x07<<4)); // only set RxGain[2:0] bits @@ -324,7 +324,7 @@ bool MFRC522::PCD_PerformSelfTest() { PCD_Reset(); // 2. Clear the internal buffer by writing 25 bytes of 00h - byte ZEROES[25] = {0x00}; + uint8_t ZEROES[25] = {0x00}; PCD_WriteRegister(FIFOLevelReg, 0x80); // flush the FIFO buffer PCD_WriteRegister(FIFODataReg, 25, ZEROES); // write 25 bytes of 00h to FIFO PCD_WriteRegister(CommandReg, PCD_Mem); // transfer to internal buffer @@ -339,7 +339,7 @@ bool MFRC522::PCD_PerformSelfTest() { PCD_WriteRegister(CommandReg, PCD_CalcCRC); // 6. Wait for self-test to complete - byte n; + uint8_t n; for (uint8_t i = 0; i < 0xFF; i++) { // The datasheet does not specify exact completion condition except // that FIFO buffer should contain 64 bytes. @@ -356,7 +356,7 @@ bool MFRC522::PCD_PerformSelfTest() { PCD_WriteRegister(CommandReg, PCD_Idle); // Stop calculating CRC for new content in the FIFO. // 7. Read out resulting 64 bytes from the FIFO buffer. - byte result[64]; + uint8_t result[64]; PCD_ReadRegister(FIFODataReg, 64, result, 0); // Auto self-test done @@ -364,10 +364,10 @@ bool MFRC522::PCD_PerformSelfTest() { PCD_WriteRegister(AutoTestReg, 0x00); // Determine firmware version (see section 9.3.4.8 in spec) - byte version = PCD_ReadRegister(VersionReg); + uint8_t version = PCD_ReadRegister(VersionReg); // Pick the appropriate reference values - const byte *reference; + const uint8_t *reference; switch (version) { case 0x88: // Fudan Semiconductor FM17522 clone reference = FM17522_firmware_reference; @@ -405,13 +405,13 @@ bool MFRC522::PCD_PerformSelfTest() { //For more details about power control, refer to the datasheet - page 33 (8.6) void MFRC522::PCD_SoftPowerDown(){//Note : Only soft power down mode is available throught software - byte val = PCD_ReadRegister(CommandReg); // Read state of the command register + uint8_t val = PCD_ReadRegister(CommandReg); // Read state of the command register val |= (1<<4);// set PowerDown bit ( bit 4 ) to 1 PCD_WriteRegister(CommandReg, val);//write new value to the command register } void MFRC522::PCD_SoftPowerUp(){ - byte val = PCD_ReadRegister(CommandReg); // Read state of the command register + uint8_t val = PCD_ReadRegister(CommandReg); // Read state of the command register val &= ~(1<<4);// set PowerDown bit ( bit 4 ) to 0 PCD_WriteRegister(CommandReg, val);//write new value to the command register // wait until PowerDown bit is cleared (this indicates end of wake up procedure) @@ -435,15 +435,15 @@ void MFRC522::PCD_SoftPowerUp(){ * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PCD_TransceiveData( byte *sendData, ///< Pointer to the data to transfer to the FIFO. - byte sendLen, ///< Number of bytes to transfer to the FIFO. - byte *backData, ///< nullptr or pointer to buffer if data should be read back after executing the command. - byte *backLen, ///< In: Max number of bytes to write to *backData. Out: The number of bytes returned. - byte *validBits, ///< In/Out: The number of valid bits in the last byte. 0 for 8 valid bits. Default nullptr. - byte rxAlign, ///< In: Defines the bit position in backData[0] for the first bit received. Default 0. +MFRC522::StatusCode MFRC522::PCD_TransceiveData( uint8_t *sendData, ///< Pointer to the data to transfer to the FIFO. + uint8_t sendLen, ///< Number of bytes to transfer to the FIFO. + uint8_t *backData, ///< nullptr or pointer to buffer if data should be read back after executing the command. + uint8_t *backLen, ///< In: Max number of bytes to write to *backData. Out: The number of bytes returned. + uint8_t *validBits, ///< In/Out: The number of valid bits in the last uint8_t. 0 for 8 valid bits. Default nullptr. + uint8_t rxAlign, ///< In: Defines the bit position in backData[0] for the first bit received. Default 0. bool checkCRC ///< In: True => The last two bytes of the response is assumed to be a CRC_A that must be validated. ) { - byte waitIRq = 0x30; // RxIRq and IdleIRq + uint8_t waitIRq = 0x30; // RxIRq and IdleIRq return PCD_CommunicateWithPICC(PCD_Transceive, waitIRq, sendData, sendLen, backData, backLen, validBits, rxAlign, checkCRC); } // End PCD_TransceiveData() @@ -453,19 +453,19 @@ MFRC522::StatusCode MFRC522::PCD_TransceiveData( byte *sendData, ///< Pointer t * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC( byte command, ///< The command to execute. One of the PCD_Command enums. - byte waitIRq, ///< The bits in the ComIrqReg register that signals successful completion of the command. - byte *sendData, ///< Pointer to the data to transfer to the FIFO. - byte sendLen, ///< Number of bytes to transfer to the FIFO. - byte *backData, ///< nullptr or pointer to buffer if data should be read back after executing the command. - byte *backLen, ///< In: Max number of bytes to write to *backData. Out: The number of bytes returned. - byte *validBits, ///< In/Out: The number of valid bits in the last byte. 0 for 8 valid bits. - byte rxAlign, ///< In: Defines the bit position in backData[0] for the first bit received. Default 0. +MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC( uint8_t command, ///< The command to execute. One of the PCD_Command enums. + uint8_t waitIRq, ///< The bits in the ComIrqReg register that signals successful completion of the command. + uint8_t *sendData, ///< Pointer to the data to transfer to the FIFO. + uint8_t sendLen, ///< Number of bytes to transfer to the FIFO. + uint8_t *backData, ///< nullptr or pointer to buffer if data should be read back after executing the command. + uint8_t *backLen, ///< In: Max number of bytes to write to *backData. Out: The number of bytes returned. + uint8_t *validBits, ///< In/Out: The number of valid bits in the last uint8_t. 0 for 8 valid bits. + uint8_t rxAlign, ///< In: Defines the bit position in backData[0] for the first bit received. Default 0. bool checkCRC ///< In: True => The last two bytes of the response is assumed to be a CRC_A that must be validated. ) { // Prepare values for BitFramingReg - byte txLastBits = validBits ? *validBits : 0; - byte bitFraming = (rxAlign << 4) + txLastBits; // RxAlign = BitFramingReg[6..4]. TxLastBits = BitFramingReg[2..0] + uint8_t txLastBits = validBits ? *validBits : 0; + uint8_t bitFraming = (rxAlign << 4) + txLastBits; // RxAlign = BitFramingReg[6..4]. TxLastBits = BitFramingReg[2..0] PCD_WriteRegister(CommandReg, PCD_Idle); // Stop any active command. PCD_WriteRegister(ComIrqReg, 0x7F); // Clear all seven interrupt request bits @@ -483,7 +483,7 @@ MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC( byte command, ///< The co // TODO check/modify for other architectures than Arduino Uno 16bit uint16_t i; for (i = 2000; i > 0; i--) { - byte n = PCD_ReadRegister(ComIrqReg); // ComIrqReg[7..0] bits are: Set1 TxIRq RxIRq IdleIRq HiAlertIRq LoAlertIRq ErrIRq TimerIRq + uint8_t n = PCD_ReadRegister(ComIrqReg); // ComIrqReg[7..0] bits are: Set1 TxIRq RxIRq IdleIRq HiAlertIRq LoAlertIRq ErrIRq TimerIRq if (n & waitIRq) { // One of the interrupts that signal success has been set. break; } @@ -497,22 +497,22 @@ MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC( byte command, ///< The co } // Stop now if any errors except collisions were detected. - byte errorRegValue = PCD_ReadRegister(ErrorReg); // ErrorReg[7..0] bits are: WrErr TempErr reserved BufferOvfl CollErr CRCErr ParityErr ProtocolErr + uint8_t errorRegValue = PCD_ReadRegister(ErrorReg); // ErrorReg[7..0] bits are: WrErr TempErr reserved BufferOvfl CollErr CRCErr ParityErr ProtocolErr if (errorRegValue & 0x13) { // BufferOvfl ParityErr ProtocolErr return STATUS_ERROR; } - byte _validBits = 0; + uint8_t _validBits = 0; // If the caller wants data back, get it from the MFRC522. if (backData && backLen) { - byte n = PCD_ReadRegister(FIFOLevelReg); // Number of bytes in the FIFO + uint8_t n = PCD_ReadRegister(FIFOLevelReg); // Number of bytes in the FIFO if (n > *backLen) { return STATUS_NO_ROOM; } *backLen = n; // Number of bytes returned PCD_ReadRegister(FIFODataReg, n, backData, rxAlign); // Get received data from FIFO - _validBits = PCD_ReadRegister(ControlReg) & 0x07; // RxLastBits[2:0] indicates the number of valid bits in the last received byte. If this value is 000b, the whole byte is valid. + _validBits = PCD_ReadRegister(ControlReg) & 0x07; // RxLastBits[2:0] indicates the number of valid bits in the last received uint8_t. If this value is 000b, the whole uint8_t is valid. if (validBits) { *validBits = _validBits; } @@ -534,7 +534,7 @@ MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC( byte command, ///< The co return STATUS_CRC_WRONG; } // Verify CRC_A - do our own calculation and store the control in controlBuffer. - byte controlBuffer[2]; + uint8_t controlBuffer[2]; MFRC522::StatusCode status = PCD_CalculateCRC(&backData[0], *backLen - 2, &controlBuffer[0]); if (status != STATUS_OK) { return status; @@ -553,8 +553,8 @@ MFRC522::StatusCode MFRC522::PCD_CommunicateWithPICC( byte command, ///< The co * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PICC_RequestA( byte *bufferATQA, ///< The buffer to store the ATQA (Answer to request) in - byte *bufferSize ///< Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK. +MFRC522::StatusCode MFRC522::PICC_RequestA( uint8_t *bufferATQA, ///< The buffer to store the ATQA (Answer to request) in + uint8_t *bufferSize ///< Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK. ) { return PICC_REQA_or_WUPA(PICC_CMD_REQA, bufferATQA, bufferSize); } // End PICC_RequestA() @@ -565,8 +565,8 @@ MFRC522::StatusCode MFRC522::PICC_RequestA( byte *bufferATQA, ///< The buffer to * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PICC_WakeupA( byte *bufferATQA, ///< The buffer to store the ATQA (Answer to request) in - byte *bufferSize ///< Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK. +MFRC522::StatusCode MFRC522::PICC_WakeupA( uint8_t *bufferATQA, ///< The buffer to store the ATQA (Answer to request) in + uint8_t *bufferSize ///< Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK. ) { return PICC_REQA_or_WUPA(PICC_CMD_WUPA, bufferATQA, bufferSize); } // End PICC_WakeupA() @@ -577,18 +577,18 @@ MFRC522::StatusCode MFRC522::PICC_WakeupA( byte *bufferATQA, ///< The buffer to * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PICC_REQA_or_WUPA( byte command, ///< The command to send - PICC_CMD_REQA or PICC_CMD_WUPA - byte *bufferATQA, ///< The buffer to store the ATQA (Answer to request) in - byte *bufferSize ///< Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK. +MFRC522::StatusCode MFRC522::PICC_REQA_or_WUPA( uint8_t command, ///< The command to send - PICC_CMD_REQA or PICC_CMD_WUPA + uint8_t *bufferATQA, ///< The buffer to store the ATQA (Answer to request) in + uint8_t *bufferSize ///< Buffer size, at least two bytes. Also number of bytes returned if STATUS_OK. ) { - byte validBits; + uint8_t validBits; MFRC522::StatusCode status; if (bufferATQA == nullptr || *bufferSize < 2) { // The ATQA response is 2 bytes long. return STATUS_NO_ROOM; } PCD_ClearRegisterBitMask(CollReg, 0x80); // ValuesAfterColl=1 => Bits received after collision are cleared. - validBits = 7; // For REQA and WUPA we need the short frame format - transmit only 7 bits of the last (and only) byte. TxLastBits = BitFramingReg[2..0] + validBits = 7; // For REQA and WUPA we need the short frame format - transmit only 7 bits of the last (and only) uint8_t. TxLastBits = BitFramingReg[2..0] status = PCD_TransceiveData(&command, 1, bufferATQA, bufferSize, &validBits); if (status != STATUS_OK) { return status; @@ -617,24 +617,24 @@ MFRC522::StatusCode MFRC522::PICC_REQA_or_WUPA( byte command, ///< The command * @return STATUS_OK on success, STATUS_??? otherwise. */ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct. Normally output, but can also be used to supply a known UID. - byte validBits ///< The number of known UID bits supplied in *uid. Normally 0. If set you must also supply uid->size. + uint8_t validBits ///< The number of known UID bits supplied in *uid. Normally 0. If set you must also supply uid->size. ) { bool uidComplete; bool selectDone; bool useCascadeTag; - byte cascadeLevel = 1; + uint8_t cascadeLevel = 1; MFRC522::StatusCode result; - byte count; - byte checkBit; - byte index; - byte uidIndex; // The first index in uid->uidByte[] that is used in the current Cascade Level. + uint8_t count; + uint8_t checkBit; + uint8_t index; + uint8_t uidIndex; // The first index in uid->uidByte[] that is used in the current Cascade Level. int8_t currentLevelKnownBits; // The number of known UID bits in the current Cascade Level. - byte buffer[9]; // The SELECT/ANTICOLLISION commands uses a 7 byte standard frame + 2 bytes CRC_A - byte bufferUsed; // The number of bytes used in the buffer, ie the number of bytes to transfer to the FIFO. - byte rxAlign; // Used in BitFramingReg. Defines the bit position for the first bit received. - byte txLastBits; // Used in BitFramingReg. The number of valid bits in the last transmitted byte. - byte *responseBuffer; - byte responseLength; + uint8_t buffer[9]; // The SELECT/ANTICOLLISION commands uses a 7 uint8_t standard frame + 2 bytes CRC_A + uint8_t bufferUsed; // The number of bytes used in the buffer, ie the number of bytes to transfer to the FIFO. + uint8_t rxAlign; // Used in BitFramingReg. Defines the bit position for the first bit received. + uint8_t txLastBits; // Used in BitFramingReg. The number of valid bits in the last transmitted uint8_t. + uint8_t *responseBuffer; + uint8_t responseLength; // Description of buffer structure: // Byte 0: SEL Indicates the Cascade Level: PICC_CMD_SEL_CL1, PICC_CMD_SEL_CL2 or PICC_CMD_SEL_CL3 @@ -704,9 +704,9 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct if (useCascadeTag) { buffer[index++] = PICC_CMD_CT; } - byte bytesToCopy = currentLevelKnownBits / 8 + (currentLevelKnownBits % 8 ? 1 : 0); // The number of bytes needed to represent the known bits for this level. + uint8_t bytesToCopy = currentLevelKnownBits / 8 + (currentLevelKnownBits % 8 ? 1 : 0); // The number of bytes needed to represent the known bits for this level. if (bytesToCopy) { - byte maxBytes = useCascadeTag ? 3 : 4; // Max 4 bytes in each Cascade Level. Only 3 left if we use the Cascade Tag + uint8_t maxBytes = useCascadeTag ? 3 : 4; // Max 4 bytes in each Cascade Level. Only 3 left if we use the Cascade Tag if (bytesToCopy > maxBytes) { bytesToCopy = maxBytes; } @@ -758,11 +758,11 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct // Transmit the buffer and receive the response. result = PCD_TransceiveData(buffer, bufferUsed, responseBuffer, &responseLength, &txLastBits, rxAlign); if (result == STATUS_COLLISION) { // More than one PICC in the field => collision. - byte valueOfCollReg = PCD_ReadRegister(CollReg); // CollReg[7..0] bits are: ValuesAfterColl reserved CollPosNotValid CollPos[4:0] + uint8_t valueOfCollReg = PCD_ReadRegister(CollReg); // CollReg[7..0] bits are: ValuesAfterColl reserved CollPosNotValid CollPos[4:0] if (valueOfCollReg & 0x20) { // CollPosNotValid return STATUS_COLLISION; // Without a valid collision position we cannot continue } - byte collisionPos = valueOfCollReg & 0x1F; // Values 0-31, 0 means bit 32. + uint8_t collisionPos = valueOfCollReg & 0x1F; // Values 0-31, 0 means bit 32. if (collisionPos == 0) { collisionPos = 32; } @@ -835,7 +835,7 @@ MFRC522::StatusCode MFRC522::PICC_Select( Uid *uid, ///< Pointer to Uid struct */ MFRC522::StatusCode MFRC522::PICC_HaltA() { MFRC522::StatusCode result; - byte buffer[4]; + uint8_t buffer[4]; // Build command buffer buffer[0] = PICC_CMD_HLTA; @@ -877,25 +877,25 @@ MFRC522::StatusCode MFRC522::PICC_HaltA() { * * @return STATUS_OK on success, STATUS_??? otherwise. Probably STATUS_TIMEOUT if you supply the wrong key. */ -MFRC522::StatusCode MFRC522::PCD_Authenticate(byte command, ///< PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B - byte blockAddr, ///< The block number. See numbering in the comments in the .h file. +MFRC522::StatusCode MFRC522::PCD_Authenticate(uint8_t command, ///< PICC_CMD_MF_AUTH_KEY_A or PICC_CMD_MF_AUTH_KEY_B + uint8_t blockAddr, ///< The block number. See numbering in the comments in the .h file. MIFARE_Key *key, ///< Pointer to the Crypteo1 key to use (6 bytes) Uid *uid ///< Pointer to Uid struct. The first 4 bytes of the UID is used. ) { - byte waitIRq = 0x10; // IdleIRq + uint8_t waitIRq = 0x10; // IdleIRq // Build command buffer - byte sendData[12]; + uint8_t sendData[12]; sendData[0] = command; sendData[1] = blockAddr; - for (byte i = 0; i < MF_KEY_SIZE; i++) { // 6 key bytes + for (uint8_t i = 0; i < MF_KEY_SIZE; i++) { // 6 key bytes sendData[2+i] = key->keyByte[i]; } // Use the last uid bytes as specified in http://cache.nxp.com/documents/application_note/AN10927.pdf // section 3.2.5 "MIFARE Classic Authentication". // The only missed case is the MF1Sxxxx shortcut activation, - // but it requires cascade tag (CT) byte, that is not part of uid. - for (byte i = 0; i < 4; i++) { // The last 4 bytes of the UID + // but it requires cascade tag (CT) uint8_t, that is not part of uid. + for (uint8_t i = 0; i < 4; i++) { // The last 4 bytes of the UID sendData[8+i] = uid->uidByte[i+uid->size-4]; } @@ -928,9 +928,9 @@ void MFRC522::PCD_StopCrypto1() { * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Read( byte blockAddr, ///< MIFARE Classic: The block (0-0xff) number. MIFARE Ultralight: The first page to return data from. - byte *buffer, ///< The buffer to store the data in - byte *bufferSize ///< Buffer size, at least 18 bytes. Also number of bytes returned if STATUS_OK. +MFRC522::StatusCode MFRC522::MIFARE_Read( uint8_t blockAddr, ///< MIFARE Classic: The block (0-0xff) number. MIFARE Ultralight: The first page to return data from. + uint8_t *buffer, ///< The buffer to store the data in + uint8_t *bufferSize ///< Buffer size, at least 18 bytes. Also number of bytes returned if STATUS_OK. ) { MFRC522::StatusCode result; @@ -963,9 +963,9 @@ MFRC522::StatusCode MFRC522::MIFARE_Read( byte blockAddr, ///< MIFARE Classic: * * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Write( byte blockAddr, ///< MIFARE Classic: The block (0-0xff) number. MIFARE Ultralight: The page (2-15) to write to. - byte *buffer, ///< The 16 bytes to write to the PICC - byte bufferSize ///< Buffer size, must be at least 16 bytes. Exactly 16 bytes are written. +MFRC522::StatusCode MFRC522::MIFARE_Write( uint8_t blockAddr, ///< MIFARE Classic: The block (0-0xff) number. MIFARE Ultralight: The page (2-15) to write to. + uint8_t *buffer, ///< The 16 bytes to write to the PICC + uint8_t bufferSize ///< Buffer size, must be at least 16 bytes. Exactly 16 bytes are written. ) { MFRC522::StatusCode result; @@ -976,7 +976,7 @@ MFRC522::StatusCode MFRC522::MIFARE_Write( byte blockAddr, ///< MIFARE Classic: // Mifare Classic protocol requires two communications to perform a write. // Step 1: Tell the PICC we want to write to block blockAddr. - byte cmdBuffer[2]; + uint8_t cmdBuffer[2]; cmdBuffer[0] = PICC_CMD_MF_WRITE; cmdBuffer[1] = blockAddr; result = PCD_MIFARE_Transceive(cmdBuffer, 2); // Adds CRC_A and checks that the response is MF_ACK. @@ -994,13 +994,13 @@ MFRC522::StatusCode MFRC522::MIFARE_Write( byte blockAddr, ///< MIFARE Classic: } // End MIFARE_Write() /** - * Writes a 4 byte page to the active MIFARE Ultralight PICC. + * Writes a 4 uint8_t page to the active MIFARE Ultralight PICC. * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Ultralight_Write( byte page, ///< The page (2-15) to write to. - byte *buffer, ///< The 4 bytes to write to the PICC - byte bufferSize ///< Buffer size, must be at least 4 bytes. Exactly 4 bytes are written. +MFRC522::StatusCode MFRC522::MIFARE_Ultralight_Write( uint8_t page, ///< The page (2-15) to write to. + uint8_t *buffer, ///< The 4 bytes to write to the PICC + uint8_t bufferSize ///< Buffer size, must be at least 4 bytes. Exactly 4 bytes are written. ) { MFRC522::StatusCode result; @@ -1010,7 +1010,7 @@ MFRC522::StatusCode MFRC522::MIFARE_Ultralight_Write( byte page, ///< The page } // Build commmand buffer - byte cmdBuffer[6]; + uint8_t cmdBuffer[6]; cmdBuffer[0] = PICC_CMD_UL_WRITE; cmdBuffer[1] = page; memcpy(&cmdBuffer[2], buffer, 4); @@ -1031,7 +1031,7 @@ MFRC522::StatusCode MFRC522::MIFARE_Ultralight_Write( byte page, ///< The page * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Decrement( byte blockAddr, ///< The block (0-0xff) number. +MFRC522::StatusCode MFRC522::MIFARE_Decrement( uint8_t blockAddr, ///< The block (0-0xff) number. int32_t delta ///< This number is subtracted from the value of block blockAddr. ) { return MIFARE_TwoStepHelper(PICC_CMD_MF_DECREMENT, blockAddr, delta); @@ -1045,7 +1045,7 @@ MFRC522::StatusCode MFRC522::MIFARE_Decrement( byte blockAddr, ///< The block (0 * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Increment( byte blockAddr, ///< The block (0-0xff) number. +MFRC522::StatusCode MFRC522::MIFARE_Increment( uint8_t blockAddr, ///< The block (0-0xff) number. int32_t delta ///< This number is added to the value of block blockAddr. ) { return MIFARE_TwoStepHelper(PICC_CMD_MF_INCREMENT, blockAddr, delta); @@ -1059,7 +1059,7 @@ MFRC522::StatusCode MFRC522::MIFARE_Increment( byte blockAddr, ///< The block (0 * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Restore( byte blockAddr ///< The block (0-0xff) number. +MFRC522::StatusCode MFRC522::MIFARE_Restore( uint8_t blockAddr ///< The block (0-0xff) number. ) { // The datasheet describes Restore as a two step operation, but does not explain what data to transfer in step 2. // Doing only a single step does not work, so I chose to transfer 0L in step two. @@ -1071,12 +1071,12 @@ MFRC522::StatusCode MFRC522::MIFARE_Restore( byte blockAddr ///< The block (0-0x * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_TwoStepHelper( byte command, ///< The command to use - byte blockAddr, ///< The block (0-0xff) number. +MFRC522::StatusCode MFRC522::MIFARE_TwoStepHelper( uint8_t command, ///< The command to use + uint8_t blockAddr, ///< The block (0-0xff) number. int32_t data ///< The data to transfer in step 2 ) { MFRC522::StatusCode result; - byte cmdBuffer[2]; // We only need room for 2 bytes. + uint8_t cmdBuffer[2]; // We only need room for 2 bytes. // Step 1: Tell the PICC the command and block address cmdBuffer[0] = command; @@ -1087,7 +1087,7 @@ MFRC522::StatusCode MFRC522::MIFARE_TwoStepHelper( byte command, ///< The comman } // Step 2: Transfer the data - result = PCD_MIFARE_Transceive( (byte *)&data, 4, true); // Adds CRC_A and accept timeout as success. + result = PCD_MIFARE_Transceive( (uint8_t *)&data, 4, true); // Adds CRC_A and accept timeout as success. if (result != STATUS_OK) { return result; } @@ -1102,10 +1102,10 @@ MFRC522::StatusCode MFRC522::MIFARE_TwoStepHelper( byte command, ///< The comman * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_Transfer( byte blockAddr ///< The block (0-0xff) number. +MFRC522::StatusCode MFRC522::MIFARE_Transfer( uint8_t blockAddr ///< The block (0-0xff) number. ) { MFRC522::StatusCode result; - byte cmdBuffer[2]; // We only need room for 2 bytes. + uint8_t cmdBuffer[2]; // We only need room for 2 bytes. // Tell the PICC we want to transfer the result into block blockAddr. cmdBuffer[0] = PICC_CMD_MF_TRANSFER; @@ -1128,10 +1128,10 @@ MFRC522::StatusCode MFRC522::MIFARE_Transfer( byte blockAddr ///< The block (0-0 * @param[out] value Current value of the Value Block. * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_GetValue(byte blockAddr, int32_t *value) { +MFRC522::StatusCode MFRC522::MIFARE_GetValue(uint8_t blockAddr, int32_t *value) { MFRC522::StatusCode status; - byte buffer[18]; - byte size = sizeof(buffer); + uint8_t buffer[18]; + uint8_t size = sizeof(buffer); // Read the block status = MIFARE_Read(blockAddr, buffer, &size); @@ -1153,8 +1153,8 @@ MFRC522::StatusCode MFRC522::MIFARE_GetValue(byte blockAddr, int32_t *value) { * @param[in] value New value of the Value Block. * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::MIFARE_SetValue(byte blockAddr, int32_t value) { - byte buffer[18]; +MFRC522::StatusCode MFRC522::MIFARE_SetValue(uint8_t blockAddr, int32_t value) { + uint8_t buffer[18]; // Translate the int32_t into 4 bytes; repeated 2x in value block buffer[0] = buffer[ 8] = (value & 0xFF); @@ -1183,17 +1183,17 @@ MFRC522::StatusCode MFRC522::MIFARE_SetValue(byte blockAddr, int32_t value) { * @param[in] pACK result success???. * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PCD_NTAG216_AUTH(byte* passWord, byte pACK[]) //Authenticate with 32bit password +MFRC522::StatusCode MFRC522::PCD_NTAG216_AUTH(uint8_t* passWord, uint8_t pACK[]) //Authenticate with 32bit password { // TODO: Fix cmdBuffer length and rxlength. They really should match. // (Better still, rxlength should not even be necessary.) MFRC522::StatusCode result; - byte cmdBuffer[18]; // We need room for 16 bytes data and 2 bytes CRC_A. + uint8_t cmdBuffer[18]; // We need room for 16 bytes data and 2 bytes CRC_A. cmdBuffer[0] = 0x1B; //Comando de autentificacion - for (byte i = 0; i<4; i++) + for (uint8_t i = 0; i<4; i++) cmdBuffer[i+1] = passWord[i]; result = PCD_CalculateCRC(cmdBuffer, 5, &cmdBuffer[5]); @@ -1203,10 +1203,10 @@ MFRC522::StatusCode MFRC522::PCD_NTAG216_AUTH(byte* passWord, byte pACK[]) //Aut } // Transceive the data, store the reply in cmdBuffer[] - byte waitIRq = 0x30; // RxIRq and IdleIRq -// byte cmdBufferSize = sizeof(cmdBuffer); - byte validBits = 0; - byte rxlength = 5; + uint8_t waitIRq = 0x30; // RxIRq and IdleIRq +// uint8_t cmdBufferSize = sizeof(cmdBuffer); + uint8_t validBits = 0; + uint8_t rxlength = 5; result = PCD_CommunicateWithPICC(PCD_Transceive, waitIRq, cmdBuffer, 7, cmdBuffer, &rxlength, &validBits); pACK[0] = cmdBuffer[0]; @@ -1230,12 +1230,12 @@ MFRC522::StatusCode MFRC522::PCD_NTAG216_AUTH(byte* passWord, byte pACK[]) //Aut * * @return STATUS_OK on success, STATUS_??? otherwise. */ -MFRC522::StatusCode MFRC522::PCD_MIFARE_Transceive( byte *sendData, ///< Pointer to the data to transfer to the FIFO. Do NOT include the CRC_A. - byte sendLen, ///< Number of bytes in sendData. +MFRC522::StatusCode MFRC522::PCD_MIFARE_Transceive( uint8_t *sendData, ///< Pointer to the data to transfer to the FIFO. Do NOT include the CRC_A. + uint8_t sendLen, ///< Number of bytes in sendData. bool acceptTimeout ///< True => A timeout is also success ) { MFRC522::StatusCode result; - byte cmdBuffer[18]; // We need room for 16 bytes data and 2 bytes CRC_A. + uint8_t cmdBuffer[18]; // We need room for 16 bytes data and 2 bytes CRC_A. // Sanity check if (sendData == nullptr || sendLen > 16) { @@ -1251,9 +1251,9 @@ MFRC522::StatusCode MFRC522::PCD_MIFARE_Transceive( byte *sendData, ///< Pointe sendLen += 2; // Transceive the data, store the reply in cmdBuffer[] - byte waitIRq = 0x30; // RxIRq and IdleIRq - byte cmdBufferSize = sizeof(cmdBuffer); - byte validBits = 0; + uint8_t waitIRq = 0x30; // RxIRq and IdleIRq + uint8_t cmdBufferSize = sizeof(cmdBuffer); + uint8_t validBits = 0; result = PCD_CommunicateWithPICC(PCD_Transceive, waitIRq, cmdBuffer, sendLen, cmdBuffer, &cmdBufferSize, &validBits); if (acceptTimeout && result == STATUS_TIMEOUT) { return STATUS_OK; @@ -1297,7 +1297,7 @@ const __FlashStringHelper *MFRC522::GetStatusCodeName(MFRC522::StatusCode code / * * @return PICC_Type */ -MFRC522::PICC_Type MFRC522::PICC_GetType(byte sak ///< The SAK byte returned from PICC_Select(). +MFRC522::PICC_Type MFRC522::PICC_GetType(uint8_t sak ///< The SAK uint8_t returned from PICC_Select(). ) { // http://www.nxp.com/documents/application_note/AN10833.pdf // 3.2 Coding of Select Acknowledge (SAK) @@ -1348,7 +1348,7 @@ const __FlashStringHelper *MFRC522::PICC_GetTypeName(PICC_Type piccType ///< One */ void MFRC522::PCD_DumpVersionToSerial() { // Get the MFRC522 firmware version - byte v = PCD_ReadRegister(VersionReg); + uint8_t v = PCD_ReadRegister(VersionReg); Serial.print(F("Firmware Version: 0x")); Serial.print(v, HEX); // Lookup which version @@ -1384,7 +1384,7 @@ void MFRC522::PICC_DumpToSerial(Uid *uid ///< Pointer to Uid struct returned fro case PICC_TYPE_MIFARE_1K: case PICC_TYPE_MIFARE_4K: // All keys are set to FFFFFFFFFFFFh at chip delivery from the factory. - for (byte i = 0; i < 6; i++) { + for (uint8_t i = 0; i < 6; i++) { key.keyByte[i] = 0xFF; } PICC_DumpMifareClassicToSerial(uid, piccType, &key); @@ -1419,7 +1419,7 @@ void MFRC522::PICC_DumpDetailsToSerial(Uid *uid ///< Pointer to Uid struct retur ) { // UID Serial.print(F("Card UID:")); - for (byte i = 0; i < uid->size; i++) { + for (uint8_t i = 0; i < uid->size; i++) { if(uid->uidByte[i] < 0x10) Serial.print(F(" 0")); else @@ -1448,7 +1448,7 @@ void MFRC522::PICC_DumpMifareClassicToSerial( Uid *uid, ///< Pointer to Uid st PICC_Type piccType, ///< One of the PICC_Type enums. MIFARE_Key *key ///< Key A used for all sectors. ) { - byte no_of_sectors = 0; + uint8_t no_of_sectors = 0; switch (piccType) { case PICC_TYPE_MIFARE_MINI: // Has 5 sectors * 4 blocks/sector * 16 bytes/block = 320 bytes. @@ -1487,11 +1487,11 @@ void MFRC522::PICC_DumpMifareClassicToSerial( Uid *uid, ///< Pointer to Uid st */ void MFRC522::PICC_DumpMifareClassicSectorToSerial(Uid *uid, ///< Pointer to Uid struct returned from a successful PICC_Select(). MIFARE_Key *key, ///< Key A for the sector. - byte sector ///< The sector to dump, 0..39. + uint8_t sector ///< The sector to dump, 0..39. ) { MFRC522::StatusCode status; - byte firstBlock; // Address of lowest address to dump actually last block dumped) - byte no_of_blocks; // Number of blocks in sector + uint8_t firstBlock; // Address of lowest address to dump actually last block dumped) + uint8_t no_of_blocks; // Number of blocks in sector bool isSectorTrailer; // Set to true while handling the "last" (ie highest address) in the sector. // The access bits are stored in a peculiar fashion. @@ -1502,11 +1502,11 @@ void MFRC522::PICC_DumpMifareClassicSectorToSerial(Uid *uid, ///< Pointer to U // g[0] Access bits for block 0 (for sectors 0-31) or blocks 0-4 (for sectors 32-39) // Each group has access bits [C1 C2 C3]. In this code C1 is MSB and C3 is LSB. // The four CX bits are stored together in a nible cx and an inverted nible cx_. - byte c1, c2, c3; // Nibbles - byte c1_, c2_, c3_; // Inverted nibbles + uint8_t c1, c2, c3; // Nibbles + uint8_t c1_, c2_, c3_; // Inverted nibbles bool invertedError; // True if one of the inverted nibbles did not match - byte g[4]; // Access bits for each of the four groups. - byte group; // 0-3 - active group for access bits + uint8_t g[4]; // Access bits for each of the four groups. + uint8_t group; // 0-3 - active group for access bits bool firstInGroup; // True for the first block dumped in the group // Determine position and size of sector. @@ -1523,9 +1523,9 @@ void MFRC522::PICC_DumpMifareClassicSectorToSerial(Uid *uid, ///< Pointer to U } // Dump blocks, highest address first. - byte byteCount; - byte buffer[18]; - byte blockAddr; + uint8_t byteCount; + uint8_t buffer[18]; + uint8_t blockAddr; isSectorTrailer = true; invertedError = false; // Avoid "unused variable" warning. for (int8_t blockOffset = no_of_blocks - 1; blockOffset >= 0; blockOffset--) { @@ -1571,7 +1571,7 @@ void MFRC522::PICC_DumpMifareClassicSectorToSerial(Uid *uid, ///< Pointer to U continue; } // Dump data - for (byte index = 0; index < 16; index++) { + for (uint8_t index = 0; index < 16; index++) { if(buffer[index] < 0x10) Serial.print(F(" 0")); else @@ -1635,13 +1635,13 @@ void MFRC522::PICC_DumpMifareClassicSectorToSerial(Uid *uid, ///< Pointer to U */ void MFRC522::PICC_DumpMifareUltralightToSerial() { MFRC522::StatusCode status; - byte byteCount; - byte buffer[18]; - byte i; + uint8_t byteCount; + uint8_t buffer[18]; + uint8_t i; Serial.println(F("Page 0 1 2 3")); // Try the mpages of the original Ultralight. Ultralight C has more pages. - for (byte page = 0; page < 16; page +=4) { // Read returns data for 4 pages at a time. + for (uint8_t page = 0; page < 16; page +=4) { // Read returns data for 4 pages at a time. // Read pages byteCount = sizeof(buffer); status = MIFARE_Read(page, buffer, &byteCount); @@ -1651,7 +1651,7 @@ void MFRC522::PICC_DumpMifareUltralightToSerial() { break; } // Dump data - for (byte offset = 0; offset < 4; offset++) { + for (uint8_t offset = 0; offset < 4; offset++) { i = page + offset; if(i < 10) Serial.print(F(" ")); // Pad with spaces @@ -1659,7 +1659,7 @@ void MFRC522::PICC_DumpMifareUltralightToSerial() { Serial.print(F(" ")); // Pad with spaces Serial.print(i); Serial.print(F(" ")); - for (byte index = 0; index < 4; index++) { + for (uint8_t index = 0; index < 4; index++) { i = 4 * offset + index; if(buffer[i] < 0x10) Serial.print(F(" 0")); @@ -1675,15 +1675,15 @@ void MFRC522::PICC_DumpMifareUltralightToSerial() { /** * Calculates the bit pattern needed for the specified access bits. In the [C1 C2 C3] tuples C1 is MSB (=4) and C3 is LSB (=1). */ -void MFRC522::MIFARE_SetAccessBits( byte *accessBitBuffer, ///< Pointer to byte 6, 7 and 8 in the sector trailer. Bytes [0..2] will be set. - byte g0, ///< Access bits [C1 C2 C3] for block 0 (for sectors 0-31) or blocks 0-4 (for sectors 32-39) - byte g1, ///< Access bits C1 C2 C3] for block 1 (for sectors 0-31) or blocks 5-9 (for sectors 32-39) - byte g2, ///< Access bits C1 C2 C3] for block 2 (for sectors 0-31) or blocks 10-14 (for sectors 32-39) - byte g3 ///< Access bits C1 C2 C3] for the sector trailer, block 3 (for sectors 0-31) or block 15 (for sectors 32-39) +void MFRC522::MIFARE_SetAccessBits( uint8_t *accessBitBuffer, ///< Pointer to uint8_t 6, 7 and 8 in the sector trailer. Bytes [0..2] will be set. + uint8_t g0, ///< Access bits [C1 C2 C3] for block 0 (for sectors 0-31) or blocks 0-4 (for sectors 32-39) + uint8_t g1, ///< Access bits C1 C2 C3] for block 1 (for sectors 0-31) or blocks 5-9 (for sectors 32-39) + uint8_t g2, ///< Access bits C1 C2 C3] for block 2 (for sectors 0-31) or blocks 10-14 (for sectors 32-39) + uint8_t g3 ///< Access bits C1 C2 C3] for the sector trailer, block 3 (for sectors 0-31) or block 15 (for sectors 32-39) ) { - byte c1 = ((g3 & 4) << 1) | ((g2 & 4) << 0) | ((g1 & 4) >> 1) | ((g0 & 4) >> 2); - byte c2 = ((g3 & 2) << 2) | ((g2 & 2) << 1) | ((g1 & 2) << 0) | ((g0 & 2) >> 1); - byte c3 = ((g3 & 1) << 3) | ((g2 & 1) << 2) | ((g1 & 1) << 1) | ((g0 & 1) << 0); + uint8_t c1 = ((g3 & 4) << 1) | ((g2 & 4) << 0) | ((g1 & 4) >> 1) | ((g0 & 4) >> 2); + uint8_t c2 = ((g3 & 2) << 2) | ((g2 & 2) << 1) | ((g1 & 2) << 0) | ((g0 & 2) >> 1); + uint8_t c3 = ((g3 & 1) << 3) | ((g2 & 1) << 2) | ((g1 & 1) << 1) | ((g0 & 1) << 0); accessBitBuffer[0] = (~c2 & 0xF) << 4 | (~c1 & 0xF); accessBitBuffer[1] = c1 << 4 | (~c3 & 0xF); @@ -1713,12 +1713,12 @@ bool MFRC522::MIFARE_OpenUidBackdoor(bool logErrors) { PICC_HaltA(); // 50 00 57 CD - byte cmd = 0x40; - byte validBits = 7; /* Our command is only 7 bits. After receiving card response, + uint8_t cmd = 0x40; + uint8_t validBits = 7; /* Our command is only 7 bits. After receiving card response, this will contain amount of valid response bits. */ - byte response[32]; // Card's response is written here - byte received; - MFRC522::StatusCode status = PCD_TransceiveData(&cmd, (byte)1, response, &received, &validBits, (byte)0, false); // 40 + uint8_t response[32]; // Card's response is written here + uint8_t received; + MFRC522::StatusCode status = PCD_TransceiveData(&cmd, (uint8_t)1, response, &received, &validBits, (uint8_t)0, false); // 40 if(status != STATUS_OK) { if(logErrors) { Serial.println(F("Card did not respond to 0x40 after HALT command. Are you sure it is a UID changeable one?")); @@ -1740,7 +1740,7 @@ bool MFRC522::MIFARE_OpenUidBackdoor(bool logErrors) { cmd = 0x43; validBits = 8; - status = PCD_TransceiveData(&cmd, (byte)1, response, &received, &validBits, (byte)0, false); // 43 + status = PCD_TransceiveData(&cmd, (uint8_t)1, response, &received, &validBits, (uint8_t)0, false); // 43 if(status != STATUS_OK) { if(logErrors) { Serial.println(F("Error in communication at command 0x43, after successfully executing 0x40")); @@ -1772,9 +1772,9 @@ bool MFRC522::MIFARE_OpenUidBackdoor(bool logErrors) { * It assumes a default KEY A of 0xFFFFFFFFFFFF. * Make sure to have selected the card before this function is called. */ -bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { +bool MFRC522::MIFARE_SetUid(uint8_t *newUid, uint8_t uidSize, bool logErrors) { - // UID + BCC byte can not be larger than 16 together + // UID + BCC uint8_t can not be larger than 16 together if (!newUid || !uidSize || uidSize > 15) { if (logErrors) { Serial.println(F("New UID buffer empty, size 0, or size > 15 given")); @@ -1784,15 +1784,15 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { // Authenticate for reading MIFARE_Key key = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - MFRC522::StatusCode status = PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, (byte)1, &key, &uid); + MFRC522::StatusCode status = PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, (uint8_t)1, &key, &uid); if (status != STATUS_OK) { if (status == STATUS_TIMEOUT) { // We get a read timeout if no card is selected yet, so let's select one // Wake the card up again if sleeping -// byte atqa_answer[2]; -// byte atqa_size = 2; +// uint8_t atqa_answer[2]; +// uint8_t atqa_size = 2; // PICC_WakeupA(atqa_answer, &atqa_size); if (!PICC_IsNewCardPresent() || !PICC_ReadCardSerial()) { @@ -1800,7 +1800,7 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { return false; } - status = PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, (byte)1, &key, &uid); + status = PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, (uint8_t)1, &key, &uid); if (status != STATUS_OK) { // We tried, time to give up if (logErrors) { @@ -1820,9 +1820,9 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { } // Read block 0 - byte block0_buffer[18]; - byte byteCount = sizeof(block0_buffer); - status = MIFARE_Read((byte)0, block0_buffer, &byteCount); + uint8_t block0_buffer[18]; + uint8_t byteCount = sizeof(block0_buffer); + status = MIFARE_Read((uint8_t)0, block0_buffer, &byteCount); if (status != STATUS_OK) { if (logErrors) { Serial.print(F("MIFARE_Read() failed: ")); @@ -1832,14 +1832,14 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { return false; } - // Write new UID to the data we just read, and calculate BCC byte - byte bcc = 0; + // Write new UID to the data we just read, and calculate BCC uint8_t + uint8_t bcc = 0; for (uint8_t i = 0; i < uidSize; i++) { block0_buffer[i] = newUid[i]; bcc ^= newUid[i]; } - // Write BCC byte to buffer + // Write BCC uint8_t to buffer block0_buffer[uidSize] = bcc; // Stop encrypted traffic so we can send raw bytes @@ -1854,7 +1854,7 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { } // Write modified block 0 back to card - status = MIFARE_Write((byte)0, block0_buffer, (byte)16); + status = MIFARE_Write((uint8_t)0, block0_buffer, (uint8_t)16); if (status != STATUS_OK) { if (logErrors) { Serial.print(F("MIFARE_Write() failed: ")); @@ -1864,8 +1864,8 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { } // Wake the card up again - byte atqa_answer[2]; - byte atqa_size = 2; + uint8_t atqa_answer[2]; + uint8_t atqa_size = 2; PICC_WakeupA(atqa_answer, &atqa_size); return true; @@ -1877,10 +1877,10 @@ bool MFRC522::MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors) { bool MFRC522::MIFARE_UnbrickUidSector(bool logErrors) { MIFARE_OpenUidBackdoor(logErrors); - byte block0_buffer[] = {0x01, 0x02, 0x03, 0x04, 0x04, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t block0_buffer[] = {0x01, 0x02, 0x03, 0x04, 0x04, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Write modified block 0 back to card - MFRC522::StatusCode status = MIFARE_Write((byte)0, block0_buffer, (byte)16); + MFRC522::StatusCode status = MIFARE_Write((uint8_t)0, block0_buffer, (uint8_t)16); if (status != STATUS_OK) { if (logErrors) { Serial.print(F("MIFARE_Write() failed: ")); @@ -1902,8 +1902,8 @@ bool MFRC522::MIFARE_UnbrickUidSector(bool logErrors) { * @return bool */ bool MFRC522::PICC_IsNewCardPresent() { - byte bufferATQA[2]; - byte bufferSize = sizeof(bufferATQA); + uint8_t bufferATQA[2]; + uint8_t bufferSize = sizeof(bufferATQA); // Reset baud rates PCD_WriteRegister(TxModeReg, 0x00); diff --git a/lib/MFRC522/MFRC522.h b/lib/MFRC522/MFRC522.h index 597c4a5d5..2c8ea5b73 100644 --- a/lib/MFRC522/MFRC522.h +++ b/lib/MFRC522/MFRC522.h @@ -28,7 +28,7 @@ // // Version 0.0 (0x90) // Philips Semiconductors; Preliminary Specification Revision 2.0 - 01 August 2005; 16.1 self-test -const byte MFRC522_firmware_referenceV0_0[] PROGMEM = { +const uint8_t MFRC522_firmware_referenceV0_0[] PROGMEM = { 0x00, 0x87, 0x98, 0x0f, 0x49, 0xFF, 0x07, 0x19, 0xBF, 0x22, 0x30, 0x49, 0x59, 0x63, 0xAD, 0xCA, 0x7F, 0xE3, 0x4E, 0x03, 0x5C, 0x4E, 0x49, 0x50, @@ -40,7 +40,7 @@ const byte MFRC522_firmware_referenceV0_0[] PROGMEM = { }; // Version 1.0 (0x91) // NXP Semiconductors; Rev. 3.8 - 17 September 2014; 16.1.1 self-test -const byte MFRC522_firmware_referenceV1_0[] PROGMEM = { +const uint8_t MFRC522_firmware_referenceV1_0[] PROGMEM = { 0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C, 0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73, 0x10, 0xE6, 0xD2, 0xAA, 0x5E, 0xA1, 0x3E, 0x5A, @@ -52,7 +52,7 @@ const byte MFRC522_firmware_referenceV1_0[] PROGMEM = { }; // Version 2.0 (0x92) // NXP Semiconductors; Rev. 3.8 - 17 September 2014; 16.1.1 self-test -const byte MFRC522_firmware_referenceV2_0[] PROGMEM = { +const uint8_t MFRC522_firmware_referenceV2_0[] PROGMEM = { 0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95, 0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE, 0x9D, 0x3B, 0xA7, 0x00, 0x21, 0x5B, 0x89, 0x82, @@ -64,7 +64,7 @@ const byte MFRC522_firmware_referenceV2_0[] PROGMEM = { }; // Clone // Fudan Semiconductor FM17522 (0x88) -const byte FM17522_firmware_reference[] PROGMEM = { +const uint8_t FM17522_firmware_reference[] PROGMEM = { 0x00, 0xD6, 0x78, 0x8C, 0xE2, 0xAA, 0x0C, 0x18, 0x2A, 0xB8, 0x7A, 0x7F, 0xD3, 0x6A, 0xCF, 0x0B, 0xB1, 0x37, 0x63, 0x4B, 0x69, 0xAE, 0x91, 0xC7, @@ -78,13 +78,13 @@ const byte FM17522_firmware_reference[] PROGMEM = { class MFRC522 { public: // Size of the MFRC522 FIFO - static constexpr byte FIFO_SIZE = 64; // The FIFO is 64 bytes. + static constexpr uint8_t FIFO_SIZE = 64; // The FIFO is 64 bytes. // Default value for unused pin static constexpr uint8_t UNUSED_PIN = UINT8_MAX; // MFRC522 registers. Described in chapter 9 of the datasheet. - // When using SPI all addresses are shifted one bit left in the "SPI address byte" (section 8.1.2.3) - enum PCD_Register : byte { + // When using SPI all addresses are shifted one bit left in the "SPI address uint8_t" (section 8.1.2.3) + enum PCD_Register : uint8_t { // Page 0: Command and status // 0x00 // reserved for future use CommandReg = 0x01 << 1, // starts and stops command execution @@ -95,7 +95,7 @@ public: ErrorReg = 0x06 << 1, // error bits showing the error status of the last command executed Status1Reg = 0x07 << 1, // communication status bits Status2Reg = 0x08 << 1, // receiver and transmitter status bits - FIFODataReg = 0x09 << 1, // input and output of 64 byte FIFO buffer + FIFODataReg = 0x09 << 1, // input and output of 64 uint8_t FIFO buffer FIFOLevelReg = 0x0A << 1, // number of bytes stored in the FIFO buffer WaterLevelReg = 0x0B << 1, // level for FIFO underflow and overflow warning ControlReg = 0x0C << 1, // miscellaneous control registers @@ -159,10 +159,10 @@ public: }; // MFRC522 commands. Described in chapter 10 of the datasheet. - enum PCD_Command : byte { + enum PCD_Command : uint8_t { PCD_Idle = 0x00, // no action, cancels current command execution PCD_Mem = 0x01, // stores 25 bytes into the internal buffer - PCD_GenerateRandomID = 0x02, // generates a 10-byte random ID number + PCD_GenerateRandomID = 0x02, // generates a 10-uint8_t random ID number PCD_CalcCRC = 0x03, // activates the CRC coprocessor or performs a self-test PCD_Transmit = 0x04, // transmits data from the FIFO buffer PCD_NoCmdChange = 0x07, // no command change, can be used to modify the CommandReg register bits without affecting the command, for example, the PowerDown bit @@ -174,7 +174,7 @@ public: // MFRC522 RxGain[2:0] masks, defines the receiver's signal voltage gain factor (on the PCD). // Described in 9.3.3.6 / table 98 of the datasheet at http://www.nxp.com/documents/data_sheet/MFRC522.pdf - enum PCD_RxGain : byte { + enum PCD_RxGain : uint8_t { RxGain_18dB = 0x00 << 4, // 000b - 18 dB, minimum RxGain_23dB = 0x01 << 4, // 001b - 23 dB RxGain_18dB_2 = 0x02 << 4, // 010b - 18 dB, it seems 010b is a duplicate for 000b @@ -189,7 +189,7 @@ public: }; // Commands sent to the PICC. - enum PICC_Command : byte { + enum PICC_Command : uint8_t { // The commands used by the PCD to manage communication with several PICCs (ISO 14443-3, Type A, section 6.4) PICC_CMD_REQA = 0x26, // REQuest command, Type A. Invites PICCs in state IDLE to go to READY and prepare for anticollision or selection. 7 bit frame. PICC_CMD_WUPA = 0x52, // Wake-UP command, Type A. Invites PICCs in state IDLE and HALT to go to READY(*) and prepare for anticollision or selection. 7 bit frame. @@ -204,15 +204,15 @@ public: // The read/write commands can also be used for MIFARE Ultralight. PICC_CMD_MF_AUTH_KEY_A = 0x60, // Perform authentication with Key A PICC_CMD_MF_AUTH_KEY_B = 0x61, // Perform authentication with Key B - PICC_CMD_MF_READ = 0x30, // Reads one 16 byte block from the authenticated sector of the PICC. Also used for MIFARE Ultralight. - PICC_CMD_MF_WRITE = 0xA0, // Writes one 16 byte block to the authenticated sector of the PICC. Called "COMPATIBILITY WRITE" for MIFARE Ultralight. + PICC_CMD_MF_READ = 0x30, // Reads one 16 uint8_t block from the authenticated sector of the PICC. Also used for MIFARE Ultralight. + PICC_CMD_MF_WRITE = 0xA0, // Writes one 16 uint8_t block to the authenticated sector of the PICC. Called "COMPATIBILITY WRITE" for MIFARE Ultralight. PICC_CMD_MF_DECREMENT = 0xC0, // Decrements the contents of a block and stores the result in the internal data register. PICC_CMD_MF_INCREMENT = 0xC1, // Increments the contents of a block and stores the result in the internal data register. PICC_CMD_MF_RESTORE = 0xC2, // Reads the contents of a block into the internal data register. PICC_CMD_MF_TRANSFER = 0xB0, // Writes the contents of the internal data register to a block. // The commands used for MIFARE Ultralight (from http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf, Section 8.6) // The PICC_CMD_MF_READ and PICC_CMD_MF_WRITE can also be used for MIFARE Ultralight. - PICC_CMD_UL_WRITE = 0xA2 // Writes one 4 byte page to the PICC. + PICC_CMD_UL_WRITE = 0xA2 // Writes one 4 uint8_t page to the PICC. }; // MIFARE constants that does not fit anywhere else @@ -223,7 +223,7 @@ public: // PICC types we can detect. Remember to update PICC_GetTypeName() if you add more. // last value set to 0xff, then compiler uses less ram, it seems some optimisations are triggered - enum PICC_Type : byte { + enum PICC_Type : uint8_t { PICC_TYPE_UNKNOWN , PICC_TYPE_ISO_14443_4 , // PICC compliant with ISO/IEC 14443-4 PICC_TYPE_ISO_18092 , // PICC compliant with ISO/IEC 18092 (NFC) @@ -239,7 +239,7 @@ public: // Return codes from the functions in this class. Remember to update GetStatusCodeName() if you add more. // last value set to 0xff, then compiler uses less ram, it seems some optimisations are triggered - enum StatusCode : byte { + enum StatusCode : uint8_t { STATUS_OK , // Success STATUS_ERROR , // Error in communication STATUS_COLLISION , // Collission detected @@ -253,14 +253,14 @@ public: // A struct used for passing the UID of a PICC. typedef struct { - byte size; // Number of bytes in the UID. 4, 7 or 10. - byte uidByte[10]; - byte sak; // The SAK (Select acknowledge) byte returned from the PICC after successful selection. + uint8_t size; // Number of bytes in the UID. 4, 7 or 10. + uint8_t uidByte[10]; + uint8_t sak; // The SAK (Select acknowledge) uint8_t returned from the PICC after successful selection. } Uid; // A struct used for passing a MIFARE Crypto1 key typedef struct { - byte keyByte[MF_KEY_SIZE]; + uint8_t keyByte[MF_KEY_SIZE]; } MIFARE_Key; // Member variables @@ -270,31 +270,31 @@ public: // Functions for setting up the Arduino ///////////////////////////////////////////////////////////////////////////////////// MFRC522(); - MFRC522(byte resetPowerDownPin); - MFRC522(byte chipSelectPin, byte resetPowerDownPin); + MFRC522(uint8_t resetPowerDownPin); + MFRC522(uint8_t chipSelectPin, uint8_t resetPowerDownPin); ///////////////////////////////////////////////////////////////////////////////////// // Basic interface functions for communicating with the MFRC522 ///////////////////////////////////////////////////////////////////////////////////// - void PCD_WriteRegister(PCD_Register reg, byte value); - void PCD_WriteRegister(PCD_Register reg, byte count, byte *values); - byte PCD_ReadRegister(PCD_Register reg); - void PCD_ReadRegister(PCD_Register reg, byte count, byte *values, byte rxAlign = 0); - void PCD_SetRegisterBitMask(PCD_Register reg, byte mask); - void PCD_ClearRegisterBitMask(PCD_Register reg, byte mask); - StatusCode PCD_CalculateCRC(byte *data, byte length, byte *result); + void PCD_WriteRegister(PCD_Register reg, uint8_t value); + void PCD_WriteRegister(PCD_Register reg, uint8_t count, uint8_t *values); + uint8_t PCD_ReadRegister(PCD_Register reg); + void PCD_ReadRegister(PCD_Register reg, uint8_t count, uint8_t *values, uint8_t rxAlign = 0); + void PCD_SetRegisterBitMask(PCD_Register reg, uint8_t mask); + void PCD_ClearRegisterBitMask(PCD_Register reg, uint8_t mask); + StatusCode PCD_CalculateCRC(uint8_t *data, uint8_t length, uint8_t *result); ///////////////////////////////////////////////////////////////////////////////////// // Functions for manipulating the MFRC522 ///////////////////////////////////////////////////////////////////////////////////// void PCD_Init(); - void PCD_Init(byte resetPowerDownPin); - void PCD_Init(byte chipSelectPin, byte resetPowerDownPin); + void PCD_Init(uint8_t resetPowerDownPin); + void PCD_Init(uint8_t chipSelectPin, uint8_t resetPowerDownPin); void PCD_Reset(); void PCD_AntennaOn(); void PCD_AntennaOff(); - byte PCD_GetAntennaGain(); - void PCD_SetAntennaGain(byte mask); + uint8_t PCD_GetAntennaGain(); + void PCD_SetAntennaGain(uint8_t mask); bool PCD_PerformSelfTest(); ///////////////////////////////////////////////////////////////////////////////////// @@ -306,40 +306,40 @@ public: ///////////////////////////////////////////////////////////////////////////////////// // Functions for communicating with PICCs ///////////////////////////////////////////////////////////////////////////////////// - StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false); - StatusCode PCD_CommunicateWithPICC(byte command, byte waitIRq, byte *sendData, byte sendLen, byte *backData = nullptr, byte *backLen = nullptr, byte *validBits = nullptr, byte rxAlign = 0, bool checkCRC = false); - StatusCode PICC_RequestA(byte *bufferATQA, byte *bufferSize); - StatusCode PICC_WakeupA(byte *bufferATQA, byte *bufferSize); - StatusCode PICC_REQA_or_WUPA(byte command, byte *bufferATQA, byte *bufferSize); - virtual StatusCode PICC_Select(Uid *uid, byte validBits = 0); + StatusCode PCD_TransceiveData(uint8_t *sendData, uint8_t sendLen, uint8_t *backData, uint8_t *backLen, uint8_t *validBits = nullptr, uint8_t rxAlign = 0, bool checkCRC = false); + StatusCode PCD_CommunicateWithPICC(uint8_t command, uint8_t waitIRq, uint8_t *sendData, uint8_t sendLen, uint8_t *backData = nullptr, uint8_t *backLen = nullptr, uint8_t *validBits = nullptr, uint8_t rxAlign = 0, bool checkCRC = false); + StatusCode PICC_RequestA(uint8_t *bufferATQA, uint8_t *bufferSize); + StatusCode PICC_WakeupA(uint8_t *bufferATQA, uint8_t *bufferSize); + StatusCode PICC_REQA_or_WUPA(uint8_t command, uint8_t *bufferATQA, uint8_t *bufferSize); + virtual StatusCode PICC_Select(Uid *uid, uint8_t validBits = 0); StatusCode PICC_HaltA(); ///////////////////////////////////////////////////////////////////////////////////// // Functions for communicating with MIFARE PICCs ///////////////////////////////////////////////////////////////////////////////////// - StatusCode PCD_Authenticate(byte command, byte blockAddr, MIFARE_Key *key, Uid *uid); + StatusCode PCD_Authenticate(uint8_t command, uint8_t blockAddr, MIFARE_Key *key, Uid *uid); void PCD_StopCrypto1(); - StatusCode MIFARE_Read(byte blockAddr, byte *buffer, byte *bufferSize); - StatusCode MIFARE_Write(byte blockAddr, byte *buffer, byte bufferSize); - StatusCode MIFARE_Ultralight_Write(byte page, byte *buffer, byte bufferSize); - StatusCode MIFARE_Decrement(byte blockAddr, int32_t delta); - StatusCode MIFARE_Increment(byte blockAddr, int32_t delta); - StatusCode MIFARE_Restore(byte blockAddr); - StatusCode MIFARE_Transfer(byte blockAddr); - StatusCode MIFARE_GetValue(byte blockAddr, int32_t *value); - StatusCode MIFARE_SetValue(byte blockAddr, int32_t value); - StatusCode PCD_NTAG216_AUTH(byte *passWord, byte pACK[]); + StatusCode MIFARE_Read(uint8_t blockAddr, uint8_t *buffer, uint8_t *bufferSize); + StatusCode MIFARE_Write(uint8_t blockAddr, uint8_t *buffer, uint8_t bufferSize); + StatusCode MIFARE_Ultralight_Write(uint8_t page, uint8_t *buffer, uint8_t bufferSize); + StatusCode MIFARE_Decrement(uint8_t blockAddr, int32_t delta); + StatusCode MIFARE_Increment(uint8_t blockAddr, int32_t delta); + StatusCode MIFARE_Restore(uint8_t blockAddr); + StatusCode MIFARE_Transfer(uint8_t blockAddr); + StatusCode MIFARE_GetValue(uint8_t blockAddr, int32_t *value); + StatusCode MIFARE_SetValue(uint8_t blockAddr, int32_t value); + StatusCode PCD_NTAG216_AUTH(uint8_t *passWord, uint8_t pACK[]); ///////////////////////////////////////////////////////////////////////////////////// // Support functions ///////////////////////////////////////////////////////////////////////////////////// - StatusCode PCD_MIFARE_Transceive(byte *sendData, byte sendLen, bool acceptTimeout = false); + StatusCode PCD_MIFARE_Transceive(uint8_t *sendData, uint8_t sendLen, bool acceptTimeout = false); // old function used too much memory, now name moved to flash; if you need char, copy from flash to memory - //const char *GetStatusCodeName(byte code); + //const char *GetStatusCodeName(uint8_t code); static const __FlashStringHelper *GetStatusCodeName(StatusCode code); - static PICC_Type PICC_GetType(byte sak); + static PICC_Type PICC_GetType(uint8_t sak); // old function used too much memory, now name moved to flash; if you need char, copy from flash to memory - //const char *PICC_GetTypeName(byte type); + //const char *PICC_GetTypeName(uint8_t type); static const __FlashStringHelper *PICC_GetTypeName(PICC_Type type); // Support functions for debuging @@ -347,13 +347,13 @@ public: void PICC_DumpToSerial(Uid *uid); void PICC_DumpDetailsToSerial(Uid *uid); void PICC_DumpMifareClassicToSerial(Uid *uid, PICC_Type piccType, MIFARE_Key *key); - void PICC_DumpMifareClassicSectorToSerial(Uid *uid, MIFARE_Key *key, byte sector); + void PICC_DumpMifareClassicSectorToSerial(Uid *uid, MIFARE_Key *key, uint8_t sector); void PICC_DumpMifareUltralightToSerial(); // Advanced functions for MIFARE - void MIFARE_SetAccessBits(byte *accessBitBuffer, byte g0, byte g1, byte g2, byte g3); + void MIFARE_SetAccessBits(uint8_t *accessBitBuffer, uint8_t g0, uint8_t g1, uint8_t g2, uint8_t g3); bool MIFARE_OpenUidBackdoor(bool logErrors); - bool MIFARE_SetUid(byte *newUid, byte uidSize, bool logErrors); + bool MIFARE_SetUid(uint8_t *newUid, uint8_t uidSize, bool logErrors); bool MIFARE_UnbrickUidSector(bool logErrors); ///////////////////////////////////////////////////////////////////////////////////// @@ -363,9 +363,9 @@ public: virtual bool PICC_ReadCardSerial(); protected: - byte _chipSelectPin; // Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) - byte _resetPowerDownPin; // Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) - StatusCode MIFARE_TwoStepHelper(byte command, byte blockAddr, int32_t data); + uint8_t _chipSelectPin; // Arduino pin connected to MFRC522's SPI slave select input (Pin 24, NSS, active low) + uint8_t _resetPowerDownPin; // Arduino pin connected to MFRC522's reset and power down input (Pin 6, NRSTPD, active low) + StatusCode MIFARE_TwoStepHelper(uint8_t command, uint8_t blockAddr, int32_t data); }; #endif diff --git a/lib/MechInputs/QEIx4.cpp b/lib/MechInputs/QEIx4.cpp index b62eb113b..bb260f53e 100644 --- a/lib/MechInputs/QEIx4.cpp +++ b/lib/MechInputs/QEIx4.cpp @@ -110,7 +110,7 @@ QEIx4* QEIx4::__instance[4] = { 0 }; QEIx4::QEIx4() { - for (byte i=0; i<4; i++) + for (uint8_t i=0; i<4; i++) if (__instance[i] == 0) { __instance[i] = this; @@ -130,7 +130,7 @@ QEIx4::QEIx4() QEIx4::~QEIx4() { - for (byte i=0; i<4; i++) + for (uint8_t i=0; i<4; i++) if (__instance[i] == this) { __instance[i] = 0; @@ -229,7 +229,7 @@ void ICACHE_RAM_ATTR QEIx4::processStateMachine() void ICACHE_RAM_ATTR QEIx4::ISR() { - for (byte i=0; i<4; i++) + for (uint8_t i=0; i<4; i++) if (__instance[i]) { __instance[i]->processStateMachine(); diff --git a/lib/RN2483-Arduino-Library/examples/TheThingsUno-GPSshield-TTN-Mapper-binary/TinyGPS++.cpp b/lib/RN2483-Arduino-Library/examples/TheThingsUno-GPSshield-TTN-Mapper-binary/TinyGPS++.cpp index ec234670b..57ff618cb 100644 --- a/lib/RN2483-Arduino-Library/examples/TheThingsUno-GPSshield-TTN-Mapper-binary/TinyGPS++.cpp +++ b/lib/RN2483-Arduino-Library/examples/TheThingsUno-GPSshield-TTN-Mapper-binary/TinyGPS++.cpp @@ -159,7 +159,7 @@ bool TinyGPSPlus::endOfTermHandler() // If it's the checksum term, and the checksum checks out, commit if (isChecksumTerm) { - byte checksum = 16 * fromHex(term[0]) + fromHex(term[1]); + uint8_t checksum = 16 * fromHex(term[0]) + fromHex(term[1]); if (checksum == parity) { passedChecksumCount++; diff --git a/lib/RN2483-Arduino-Library/src/rn2xx3.cpp b/lib/RN2483-Arduino-Library/src/rn2xx3.cpp index 57014aa88..fb3a07a11 100644 --- a/lib/RN2483-Arduino-Library/src/rn2xx3.cpp +++ b/lib/RN2483-Arduino-Library/src/rn2xx3.cpp @@ -43,7 +43,7 @@ bool rn2xx3::autobaud() { delay(1000); } - _rn2xx3_handler._serial.write((byte)0x00); + _rn2xx3_handler._serial.write((uint8_t)0x00); _rn2xx3_handler._serial.write(0x55); _rn2xx3_handler._serial.println(); @@ -127,7 +127,7 @@ RN2xx3_datatypes::TX_return_type rn2xx3::tx(const String& data, uint8_t port) return txUncnf(data, port); // we are unsure which mode we're in. Better not to wait for acks. } -RN2xx3_datatypes::TX_return_type rn2xx3::txBytes(const byte *data, uint8_t size, uint8_t port) +RN2xx3_datatypes::TX_return_type rn2xx3::txBytes(const uint8_t *data, uint8_t size, uint8_t port) { const String dataToTx = rn2xx3_helper::base16encode(data, size); return txCommand(F("mac tx uncnf "), dataToTx, false, port); diff --git a/lib/RN2483-Arduino-Library/src/rn2xx3.h b/lib/RN2483-Arduino-Library/src/rn2xx3.h index 11131afa6..808bcdf65 100644 --- a/lib/RN2483-Arduino-Library/src/rn2xx3.h +++ b/lib/RN2483-Arduino-Library/src/rn2xx3.h @@ -161,7 +161,7 @@ public: * This method expects a raw byte array as first parameter. * The second parameter is the count of the bytes to send. */ - RN2xx3_datatypes::TX_return_type txBytes(const byte *, + RN2xx3_datatypes::TX_return_type txBytes(const uint8_t *, uint8_t size, uint8_t port = 1); diff --git a/lib/RN2483-Arduino-Library/src/rn2xx3_helper.cpp b/lib/RN2483-Arduino-Library/src/rn2xx3_helper.cpp index 647eba8dc..91caa4536 100644 --- a/lib/RN2483-Arduino-Library/src/rn2xx3_helper.cpp +++ b/lib/RN2483-Arduino-Library/src/rn2xx3_helper.cpp @@ -86,7 +86,7 @@ String rn2xx3_helper::base16encode(const String& input_c) return output; } -String rn2xx3_helper::base16encode(const byte *data, uint8_t size) +String rn2xx3_helper::base16encode(const uint8_t *data, uint8_t size) { String dataToTx; diff --git a/lib/RN2483-Arduino-Library/src/rn2xx3_helper.h b/lib/RN2483-Arduino-Library/src/rn2xx3_helper.h index c93a3e71d..6f66236cd 100644 --- a/lib/RN2483-Arduino-Library/src/rn2xx3_helper.h +++ b/lib/RN2483-Arduino-Library/src/rn2xx3_helper.h @@ -31,7 +31,7 @@ public: * Encode binary data to a HEX string as needed when passed * to the RN2xx3 module. */ - static String base16encode(const byte *data, uint8_t size); + static String base16encode(const uint8_t *data, uint8_t size); }; diff --git a/lib/Regexp/src/Regexp.cpp b/lib/Regexp/src/Regexp.cpp index 472997050..a813690fa 100644 --- a/lib/Regexp/src/Regexp.cpp +++ b/lib/Regexp/src/Regexp.cpp @@ -257,10 +257,9 @@ PATTERNS // for throwing errors static jmp_buf regexp_error_return; -typedef unsigned char byte; // error codes raised during regexp processing -static byte error (const char err) +static uint8_t error (const char err) { // does not return longjmp (regexp_error_return, err); diff --git a/lib/SerialDevices/SensorSerialBuffer.cpp b/lib/SerialDevices/SensorSerialBuffer.cpp index f69b6ed42..e6a6c0651 100644 --- a/lib/SerialDevices/SensorSerialBuffer.cpp +++ b/lib/SerialDevices/SensorSerialBuffer.cpp @@ -34,23 +34,23 @@ CSensorSerialBuffer::CSensorSerialBuffer() void CSensorSerialBuffer::Clear () { - for (byte i=0; irequestFrom(((uint8_t)(((DeviceAddr) >> 1) & 0x7F)), (byte)NumByteToRead); + dev_i2c->requestFrom(((uint8_t)(((DeviceAddr) >> 1) & 0x7F)), (uint8_t)NumByteToRead); int i = 0; while (dev_i2c->available()) diff --git a/lib/TinyGPSPlus-1.0.2/src/TinyGPS++.cpp b/lib/TinyGPSPlus-1.0.2/src/TinyGPS++.cpp index ed4485c42..61d286f75 100644 --- a/lib/TinyGPSPlus-1.0.2/src/TinyGPS++.cpp +++ b/lib/TinyGPSPlus-1.0.2/src/TinyGPS++.cpp @@ -172,7 +172,7 @@ bool TinyGPSPlus::endOfTermHandler() // If it's the checksum term, and the checksum checks out, commit if (isChecksumTerm) { - byte checksum = 16 * fromHex(term[0]) + fromHex(term[1]); + uint8_t checksum = 16 * fromHex(term[0]) + fromHex(term[1]); if (checksum == parity) { passedChecksumCount++; @@ -447,7 +447,7 @@ void TinyGPSSatellites::commit() satsTracked = 0; satsVisible = 0; bestSNR = 0; - for (byte i = 0; i < _GPS_MAX_ARRAY_LENGTH; ++i) { + for (uint8_t i = 0; i < _GPS_MAX_ARRAY_LENGTH; ++i) { if (id[i] != 0) { if (snr[i] != 0) { ++satsTracked; @@ -531,7 +531,7 @@ void TinyGPSSatellites::setSatId(const char *term) ++pos; uint32_t value = atol(term); if (id[pos] != value) { - id[pos] = static_cast(value); + id[pos] = static_cast(value); snr[pos] = 0; } } @@ -551,7 +551,7 @@ void TinyGPSSatellites::setMessageSeqNr(const char *term, uint8_t sentenceSystem int32_t seqNr = atol(term); int32_t newPos = (seqNr - 1) * 4 + (sentenceSystem * _GPS_MAX_NR_ACTIVE_SATELLITES); if (newPos >= 0 && newPos < _GPS_MAX_ARRAY_LENGTH) { - for (byte i = newPos; i < (newPos + 4) && i < _GPS_MAX_ARRAY_LENGTH; ++i) { + for (uint8_t i = newPos; i < (newPos + 4) && i < _GPS_MAX_ARRAY_LENGTH; ++i) { id[i] = 0; snr[i] = 0; } diff --git a/lib/esp8266-oled-ssd1306/OLEDDisplay.cpp b/lib/esp8266-oled-ssd1306/OLEDDisplay.cpp index 3caecc5b2..600286e36 100644 --- a/lib/esp8266-oled-ssd1306/OLEDDisplay.cpp +++ b/lib/esp8266-oled-ssd1306/OLEDDisplay.cpp @@ -409,15 +409,15 @@ void OLEDDisplay::drawStringInternal(int16_t xMove, int16_t yMove, char* text, u int16_t xPos = xMove + cursorX; int16_t yPos = yMove + cursorY; - byte code = text[j]; + uint8_t code = text[j]; if (code >= firstChar) { - byte charCode = code - firstChar; + uint8_t charCode = code - firstChar; // 4 Bytes per char code - byte msbJumpToChar = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES ); // MSB \ JumpAddress - byte lsbJumpToChar = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_LSB); // LSB / - byte charByteSize = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_SIZE); // Size - byte currentCharWidth = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_WIDTH); // Width + uint8_t msbJumpToChar = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES ); // MSB \ JumpAddress + uint8_t lsbJumpToChar = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_LSB); // LSB / + uint8_t charByteSize = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_SIZE); // Size + uint8_t currentCharWidth = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_WIDTH); // Width // Test if the char is drawable if (!(msbJumpToChar == 255 && lsbJumpToChar == 255)) { @@ -740,7 +740,7 @@ void inline OLEDDisplay::drawInternal(int16_t xMove, int16_t yMove, int16_t widt yOffset = initYOffset; } - byte currentByte = pgm_read_byte(data + offset + i); + uint8_t currentByte = pgm_read_byte(data + offset + i); int16_t xPos = xMove + (i / rasterHeight); int16_t yPos = ((yMove >> 3) + (i % rasterHeight)) * this->width(); @@ -787,7 +787,7 @@ void inline OLEDDisplay::drawInternal(int16_t xMove, int16_t yMove, int16_t widt } // Code form http://playground.arduino.cc/Main/Utf8ascii -uint8_t OLEDDisplay::utf8ascii(byte ascii) { +uint8_t OLEDDisplay::utf8ascii(uint8_t ascii) { static uint8_t LASTCHAR; if ( ascii < 128 ) { // Standard ASCII-set 0..0x7F handling diff --git a/lib/esp8266-oled-ssd1306/OLEDDisplay.h b/lib/esp8266-oled-ssd1306/OLEDDisplay.h index 87a70195f..88955f6df 100644 --- a/lib/esp8266-oled-ssd1306/OLEDDisplay.h +++ b/lib/esp8266-oled-ssd1306/OLEDDisplay.h @@ -164,7 +164,7 @@ class OLEDDisplay : public Print { void drawVerticalLine(int16_t x, int16_t y, int16_t length); // Draws a rounded progress bar with the outer dimensions given by width and height. Progress is - // a unsigned byte value between 0 and 100 + // a unsigned uint8_t value between 0 and 100 void drawProgressBar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress); // Draw a bitmap in the internal image format @@ -277,7 +277,7 @@ class OLEDDisplay : public Print { // converts utf8 characters to extended ascii static char* utf8ascii(String s); - static byte utf8ascii(byte ascii); + static uint8_t utf8ascii(uint8_t ascii); void inline drawInternal(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const char *data, uint16_t offset, uint16_t bytesInData) __attribute__((always_inline)); diff --git a/lib/esp8266-oled-ssd1306/OLEDDisplayUi.cpp b/lib/esp8266-oled-ssd1306/OLEDDisplayUi.cpp index 976bbac42..85d1e9944 100644 --- a/lib/esp8266-oled-ssd1306/OLEDDisplayUi.cpp +++ b/lib/esp8266-oled-ssd1306/OLEDDisplayUi.cpp @@ -363,7 +363,7 @@ void OLEDDisplayUi::drawIndicator() { uint16_t frameStartPos = (12 * frameCount / 2); const char *image; uint16_t x = 0, y = 0; - for (byte i = 0; i < this->frameCount; i++) { + for (uint8_t i = 0; i < this->frameCount; i++) { switch (this->indicatorPosition){ case TOP: diff --git a/lib/esp8266-oled-ssd1306/SH1106Brzo.h b/lib/esp8266-oled-ssd1306/SH1106Brzo.h index 385630b32..4acdfd86e 100644 --- a/lib/esp8266-oled-ssd1306/SH1106Brzo.h +++ b/lib/esp8266-oled-ssd1306/SH1106Brzo.h @@ -85,7 +85,7 @@ class SH1106Brzo : public OLEDDisplay { // holdes true for all values of pos if (minBoundY == ~0) return; - byte k = 0; + uint8_t k = 0; uint8_t sendBuffer[17]; sendBuffer[0] = 0x40; diff --git a/lib/esp8266-oled-ssd1306/SH1106Wire.h b/lib/esp8266-oled-ssd1306/SH1106Wire.h index 3aeb5caf8..25650e8cc 100644 --- a/lib/esp8266-oled-ssd1306/SH1106Wire.h +++ b/lib/esp8266-oled-ssd1306/SH1106Wire.h @@ -90,7 +90,7 @@ class SH1106Wire : public OLEDDisplay { uint8_t minBoundXp2H = (minBoundX + 2) & 0x0F; uint8_t minBoundXp2L = 0x10 | ((minBoundX + 2) >> 4 ); - byte k = 0; + uint8_t k = 0; for (y = minBoundY; y <= maxBoundY; y++) { sendCommand(0xB0 + y); sendCommand(minBoundXp2H); diff --git a/lib/esp8266-oled-ssd1306/SSD1306Brzo.h b/lib/esp8266-oled-ssd1306/SSD1306Brzo.h index 3b99d82d2..35708d205 100644 --- a/lib/esp8266-oled-ssd1306/SSD1306Brzo.h +++ b/lib/esp8266-oled-ssd1306/SSD1306Brzo.h @@ -94,7 +94,7 @@ class SSD1306Brzo : public OLEDDisplay { sendCommand(minBoundY); sendCommand(maxBoundY); - byte k = 0; + uint8_t k = 0; uint8_t sendBuffer[17]; sendBuffer[0] = 0x40; brzo_i2c_start_transaction(this->_address, BRZO_I2C_SPEED); diff --git a/lib/esp8266-oled-ssd1306/SSD1306Wire.h b/lib/esp8266-oled-ssd1306/SSD1306Wire.h index 383a8c8f6..95421f0c7 100644 --- a/lib/esp8266-oled-ssd1306/SSD1306Wire.h +++ b/lib/esp8266-oled-ssd1306/SSD1306Wire.h @@ -89,7 +89,7 @@ class SSD1306Wire : public OLEDDisplay { sendCommand(minBoundY); sendCommand(maxBoundY); - byte k = 0; + uint8_t k = 0; for (y = minBoundY; y <= maxBoundY; y++) { for (x = minBoundX; x <= maxBoundX; x++) { if (k == 0) { diff --git a/src/ESPEasy-Globals.h b/src/ESPEasy-Globals.h index 4cd5b871f..8e1118d44 100644 --- a/src/ESPEasy-Globals.h +++ b/src/ESPEasy-Globals.h @@ -60,9 +60,9 @@ struct pinStatesStruct { pinStatesStruct() : value(0), plugin(0), index(0), mode(0) {} uint16_t value; - byte plugin; - byte index; - byte mode; + uint8_t plugin; + uint8_t index; + uint8_t mode; } pinStates[PINSTATE_TABLE_MAX]; */ diff --git a/src/_C004.ino b/src/_C004.ino index 4583894f8..1cb7ad832 100644 --- a/src/_C004.ino +++ b/src/_C004.ino @@ -107,7 +107,7 @@ bool do_process_c004_delay_queue(int controller_number, const C004_queue_element postDataStr += element.txt[0]; // FIXME TD-er: Is this correct? // See: https://nl.mathworks.com/help/thingspeak/writedata.html } else { - for (byte x = 0; x < element.valueCount; x++) + for (uint8_t x = 0; x < element.valueCount; x++) { postDataStr += F("&field"); postDataStr += element.idx + x; diff --git a/src/_C005.ino b/src/_C005.ino index 0af805982..0f5002678 100644 --- a/src/_C005.ino +++ b/src/_C005.ino @@ -138,9 +138,9 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String& LoadTaskSettings(event->TaskIndex); parseControllerVariables(pubname, event, false); - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { // MFD: skip publishing for values with empty labels (removes unnecessary publishing of unwanted values) if (ExtraTaskSettings.TaskDeviceValueNames[x][0] == 0) { diff --git a/src/_C006.ino b/src/_C006.ino index 8bbe3c73b..cdd7fd225 100644 --- a/src/_C006.ino +++ b/src/_C006.ino @@ -72,7 +72,7 @@ bool CPlugin_006(CPlugin::Function function, struct EventStruct *event, String& String tmpTopic = event->String1.substring(1); String topicSplit[10]; int SlashIndex = tmpTopic.indexOf('/'); - byte count = 0; + uint8_t count = 0; while (SlashIndex > 0 && count < 10 - 1) { @@ -119,9 +119,9 @@ bool CPlugin_006(CPlugin::Function function, struct EventStruct *event, String& LoadTaskSettings(event->TaskIndex); parseControllerVariables(pubname, event, false); - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { String tmppubname = pubname; parseSingleControllerVariable(tmppubname, event, x, false); diff --git a/src/_C007.ino b/src/_C007.ino index 56a1bdab0..fed5abbbd 100644 --- a/src/_C007.ino +++ b/src/_C007.ino @@ -57,7 +57,7 @@ bool CPlugin_007(CPlugin::Function function, struct EventStruct *event, String& addLog(LOG_LEVEL_ERROR, F("emoncms : No support for Sensor_VType::SENSOR_TYPE_STRING")); break; } - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); if ((valueCount == 0) || (valueCount > VARS_PER_TASK)) { addLog(LOG_LEVEL_ERROR, F("emoncms : Unknown sensortype or too many sensor values")); @@ -98,7 +98,7 @@ bool do_process_c007_delay_queue(int controller_number, const C007_queue_element url += Settings.Unit; url += F("&json="); - for (byte i = 0; i < element.valueCount; ++i) { + for (uint8_t i = 0; i < element.valueCount; ++i) { url += (i == 0) ? '{' : ','; url += F("field"); url += element.idx + i; diff --git a/src/_C008.ino b/src/_C008.ino index 6bc1db188..cb88f6153 100644 --- a/src/_C008.ino +++ b/src/_C008.ino @@ -74,7 +74,7 @@ bool CPlugin_008(CPlugin::Function function, struct EventStruct *event, String& } - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); success = C008_DelayHandler->addToQueue(C008_queue_element(event, valueCount)); if (success) { @@ -87,7 +87,7 @@ bool CPlugin_008(CPlugin::Function function, struct EventStruct *event, String& LoadTaskSettings(event->TaskIndex); parseControllerVariables(pubname, event, true); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { String tmppubname = pubname; bool isvalid; diff --git a/src/_C009.ino b/src/_C009.ino index 67b1f6647..d4b2f7f24 100644 --- a/src/_C009.ino +++ b/src/_C009.ino @@ -157,7 +157,7 @@ bool do_process_c009_delay_queue(int controller_number, const C009_queue_element jsonString += F("\"SENSOR\":{"); { // char itemNames[valueCount][2]; - for (byte x = 0; x < element.valueCount; x++) + for (uint8_t x = 0; x < element.valueCount; x++) { // Each sensor value get an own object (0..n) // sprintf(itemNames[x],"%d",x); diff --git a/src/_C010.ino b/src/_C010.ino index f3632e498..fcacee8a8 100644 --- a/src/_C010.ino +++ b/src/_C010.ino @@ -57,7 +57,7 @@ bool CPlugin_010(CPlugin::Function function, struct EventStruct *event, String& if (C010_DelayHandler == nullptr) { break; } - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); if (valueCount == 0) { break; @@ -80,7 +80,7 @@ bool CPlugin_010(CPlugin::Function function, struct EventStruct *event, String& parseControllerVariables(pubname, event, false); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { bool isvalid; String formattedValue = formatUserVar(event, x, isvalid); diff --git a/src/_C011.ino b/src/_C011.ino index b8921d469..4435a5743 100644 --- a/src/_C011.ino +++ b/src/_C011.ino @@ -90,10 +90,10 @@ bool CPlugin_011(CPlugin::Function function, struct EventStruct *event, String& } addTableSeparator(F("HTTP Config"), 2, 3); { - byte choice = 0; + uint8_t choice = 0; const __FlashStringHelper * methods[] = { F("GET"), F("POST"), F("PUT"), F("HEAD"), F("PATCH") }; - for (byte i = 0; i < 5; i++) + for (uint8_t i = 0; i < 5; i++) { if (HttpMethod.equals(methods[i])) { choice = i; @@ -132,10 +132,10 @@ bool CPlugin_011(CPlugin::Function function, struct EventStruct *event, String& std::shared_ptr customConfig(new C011_ConfigStruct); if (customConfig) { - byte choice = 0; + uint8_t choice = 0; String methods[] = { F("GET"), F("POST"), F("PUT"), F("HEAD"), F("PATCH") }; - for (byte i = 0; i < 5; i++) + for (uint8_t i = 0; i < 5; i++) { if (methods[i].equals(customConfig->HttpMethod)) { choice = i; @@ -152,7 +152,7 @@ bool CPlugin_011(CPlugin::Function function, struct EventStruct *event, String& strlcpy(customConfig->HttpHeader, httpheader.c_str(), sizeof(customConfig->HttpHeader)); strlcpy(customConfig->HttpBody, httpbody.c_str(), sizeof(customConfig->HttpBody)); customConfig->zero_last(); - SaveCustomControllerSettings(event->ControllerIndex, (byte *)customConfig.get(), sizeof(C011_ConfigStruct)); + SaveCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C011_ConfigStruct)); } break; } @@ -216,7 +216,7 @@ bool load_C011_ConfigStruct(controllerIndex_t ControllerIndex, String& HttpMetho if (!customConfig) { return false; } - LoadCustomControllerSettings(ControllerIndex, (byte *)customConfig.get(), sizeof(C011_ConfigStruct)); + LoadCustomControllerSettings(ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C011_ConfigStruct)); customConfig->zero_last(); HttpMethod = customConfig->HttpMethod; HttpUri = customConfig->HttpUri; @@ -276,11 +276,11 @@ boolean Create_schedule_HTTP_C011(struct EventStruct *event) // parses the string and returns only the the number of name/values we want // according to the parameter numberOfValuesWanted -void DeleteNotNeededValues(String& s, byte numberOfValuesWanted) +void DeleteNotNeededValues(String& s, uint8_t numberOfValuesWanted) { numberOfValuesWanted++; - for (byte i = 1; i < 5; i++) + for (uint8_t i = 1; i < 5; i++) { String startToken; startToken += '%'; @@ -338,7 +338,7 @@ void ReplaceTokenByValue(String& s, struct EventStruct *event, bool sendBinary) addLog(LOG_LEVEL_DEBUG_MORE, F("HTTP before parsing: ")); addLog(LOG_LEVEL_DEBUG_MORE, s); } - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); DeleteNotNeededValues(s, valueCount); diff --git a/src/_C012.ino b/src/_C012.ino index fc4faccfe..f21d09896 100644 --- a/src/_C012.ino +++ b/src/_C012.ino @@ -57,10 +57,10 @@ bool CPlugin_012(CPlugin::Function function, struct EventStruct *event, String& LoadTaskSettings(event->TaskIndex); // Collect the values at the same run, to make sure all are from the same sample - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); C012_queue_element element(event, valueCount); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { bool isvalid; String formattedValue = formatUserVar(event, x, isvalid); diff --git a/src/_C013.ino b/src/_C013.ino index 19344202a..3909c9a0e 100644 --- a/src/_C013.ino +++ b/src/_C013.ino @@ -79,7 +79,7 @@ bool CPlugin_013(CPlugin::Function function, struct EventStruct *event, String& // ******************************************************************************** // Generic UDP message // ******************************************************************************** -void C013_SendUDPTaskInfo(byte destUnit, byte sourceTaskIndex, byte destTaskIndex) +void C013_SendUDPTaskInfo(uint8_t destUnit, uint8_t sourceTaskIndex, uint8_t destTaskIndex) { if (!NetworkConnected(10)) { return; @@ -103,20 +103,20 @@ void C013_SendUDPTaskInfo(byte destUnit, byte sourceTaskIndex, byte destTaskInde LoadTaskSettings(infoReply.sourceTaskIndex); safe_strncpy(infoReply.taskName, getTaskDeviceName(infoReply.sourceTaskIndex), sizeof(infoReply.taskName)); - for (byte x = 0; x < VARS_PER_TASK; x++) { + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { safe_strncpy(infoReply.ValueNames[x], ExtraTaskSettings.TaskDeviceValueNames[x], sizeof(infoReply.ValueNames[x])); } if (destUnit != 0) { infoReply.destUnit = destUnit; - C013_sendUDP(destUnit, (byte *)&infoReply, sizeof(C013_SensorInfoStruct)); + C013_sendUDP(destUnit, (uint8_t *)&infoReply, sizeof(C013_SensorInfoStruct)); delay(10); } else { for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { if (it->first != Settings.Unit) { infoReply.destUnit = it->first; - C013_sendUDP(it->first, (byte *)&infoReply, sizeof(C013_SensorInfoStruct)); + C013_sendUDP(it->first, (uint8_t *)&infoReply, sizeof(C013_SensorInfoStruct)); delay(10); } } @@ -124,7 +124,7 @@ void C013_SendUDPTaskInfo(byte destUnit, byte sourceTaskIndex, byte destTaskInde delay(50); } -void C013_SendUDPTaskData(byte destUnit, byte sourceTaskIndex, byte destTaskIndex) +void C013_SendUDPTaskData(uint8_t destUnit, uint8_t sourceTaskIndex, uint8_t destTaskIndex) { if (!NetworkConnected(10)) { return; @@ -135,7 +135,7 @@ void C013_SendUDPTaskData(byte destUnit, byte sourceTaskIndex, byte destTaskInde dataReply.sourceTaskIndex = sourceTaskIndex; dataReply.destTaskIndex = destTaskIndex; - for (byte x = 0; x < VARS_PER_TASK; x++) { + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { const userVarIndex_t userVarIndex = dataReply.sourceTaskIndex * VARS_PER_TASK + x; if (validUserVarIndex(userVarIndex)) { @@ -146,13 +146,13 @@ void C013_SendUDPTaskData(byte destUnit, byte sourceTaskIndex, byte destTaskInde if (destUnit != 0) { dataReply.destUnit = destUnit; - C013_sendUDP(destUnit, (byte *)&dataReply, sizeof(C013_SensorDataStruct)); + C013_sendUDP(destUnit, (uint8_t *)&dataReply, sizeof(C013_SensorDataStruct)); delay(10); } else { for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { if (it->first != Settings.Unit) { dataReply.destUnit = it->first; - C013_sendUDP(it->first, (byte *)&dataReply, sizeof(C013_SensorDataStruct)); + C013_sendUDP(it->first, (uint8_t *)&dataReply, sizeof(C013_SensorDataStruct)); delay(10); } } @@ -163,7 +163,7 @@ void C013_SendUDPTaskData(byte destUnit, byte sourceTaskIndex, byte destTaskInde /*********************************************************************************************\ Send UDP message (unit 255=broadcast) \*********************************************************************************************/ -void C013_sendUDP(byte unit, byte *data, byte size) +void C013_sendUDP(uint8_t unit, uint8_t *data, uint8_t size) { if (!NetworkConnected(10)) { return; @@ -221,7 +221,7 @@ void C013_Receive(struct EventStruct *event) { { String log = (F("C013 : msg ")); - for (byte x = 1; x < 6; x++) + for (uint8_t x = 1; x < 6; x++) { log += ' '; log += (int)event->Data[x]; @@ -245,7 +245,7 @@ void C013_Receive(struct EventStruct *event) { if (event->Par2 < count) { count = event->Par2; } - memcpy((byte *)&infoReply, (byte *)event->Data, count); + memcpy((uint8_t *)&infoReply, (uint8_t *)event->Data, count); if (infoReply.isValid()) { // to prevent flash wear out (bugs in communication?) we can only write to an empty task @@ -263,7 +263,7 @@ void C013_Receive(struct EventStruct *event) { } safe_strncpy(ExtraTaskSettings.TaskDeviceName, infoReply.taskName, sizeof(infoReply.taskName)); - for (byte x = 0; x < VARS_PER_TASK; x++) { + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { safe_strncpy(ExtraTaskSettings.TaskDeviceValueNames[x], infoReply.ValueNames[x], sizeof(infoReply.ValueNames[x])); } ExtraTaskSettings.TaskIndex = infoReply.destTaskIndex; @@ -286,15 +286,15 @@ void C013_Receive(struct EventStruct *event) { int count = sizeof(C013_SensorDataStruct); if (event->Par2 < count) { count = event->Par2; } - memcpy((byte *)&dataReply, (byte *)event->Data, count); + memcpy((uint8_t *)&dataReply, (uint8_t *)event->Data, count); if (dataReply.isValid()) { // only if this task has a remote feed, update values - const byte remoteFeed = Settings.TaskDeviceDataFeed[dataReply.destTaskIndex]; + const uint8_t remoteFeed = Settings.TaskDeviceDataFeed[dataReply.destTaskIndex]; if ((remoteFeed != 0) && (remoteFeed == dataReply.sourceUnit)) { - for (byte x = 0; x < VARS_PER_TASK; x++) + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { UserVar[dataReply.destTaskIndex * VARS_PER_TASK + x] = dataReply.Values[x]; } diff --git a/src/_C014.ino b/src/_C014.ino index 7b7049aa8..3a008c552 100644 --- a/src/_C014.ino +++ b/src/_C014.ino @@ -41,7 +41,7 @@ #define CPLUGIN_014_GPIO_VALUE "gpio" // name for gpio value i.e. "gpio1" #define CPLUGIN_014_CMD_VALUE_NAME "Command" // human readabele name for command value -byte msgCounter=0; // counter for send Messages (currently for information / log only! +uint8_t msgCounter=0; // counter for send Messages (currently for information / log only! String CPlugin_014_pubname; bool CPlugin_014_mqtt_retainFlag = false; @@ -333,12 +333,12 @@ bool CPlugin_014(CPlugin::Function function, struct EventStruct *event, String& { // device enabled valuesList=""; - const byte valueCount = getValueCountForTask(x); + const uint8_t valueCount = getValueCountForTask(x); if (!Device[DeviceIndex].SendDataOption) // check if device is not sending data = assume that it can receive. { if (Device[DeviceIndex].Number==86) // Homie receiver { - for (byte varNr = 0; varNr < valueCount; varNr++) { + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { if (validPluginID_fullcheck(Settings.TaskDeviceNumber[x])) { if (ExtraTaskSettings.TaskDeviceValueNames[varNr][0]!=0) { // do not send if Value Name is empty! CPLUGIN_014_addToList(valuesList,ExtraTaskSettings.TaskDeviceValueNames[varNr]); @@ -388,10 +388,10 @@ bool CPlugin_014(CPlugin::Function function, struct EventStruct *event, String& // ignore cutom values for now! Assume all Values are standard float. // String customValuesStr; // customValues = PluginCall(PLUGIN_WEBFORM_SHOW_VALUES, &TempEvent, customValuesStr); - byte customValues = false; + uint8_t customValues = false; if (!customValues) { // standard Values - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { if (validPluginID_fullcheck(Settings.TaskDeviceNumber[x])) { @@ -705,8 +705,8 @@ bool CPlugin_014(CPlugin::Function function, struct EventStruct *event, String& parseControllerVariables(pubname, event, false); LoadTaskSettings(event->TaskIndex); - byte valueCount = getValueCountForTask(event->TaskIndex); - for (byte x = 0; x < valueCount; x++) + uint8_t valueCount = getValueCountForTask(event->TaskIndex); + for (uint8_t x = 0; x < valueCount; x++) { String tmppubname = pubname; String value; diff --git a/src/_C015.ino b/src/_C015.ino index 1ad293bc0..2603eb751 100644 --- a/src/_C015.ino +++ b/src/_C015.ino @@ -107,7 +107,7 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String& case CPlugin::Function::CPLUGIN_WEBFORM_LOAD: { char thumbprint[60]; - LoadCustomControllerSettings(event->ControllerIndex, (byte *)&thumbprint, sizeof(thumbprint)); + LoadCustomControllerSettings(event->ControllerIndex, (uint8_t *)&thumbprint, sizeof(thumbprint)); if (strlen(thumbprint) != 59) { strcpy(thumbprint, CPLUGIN_015_DEFAULT_THUMBPRINT); @@ -148,7 +148,7 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String& if (!safe_strncpy(thumbprint, webArg("c015_thumbprint"), 60) || (strlen(thumbprint) != 59)) { addHtmlError(error); } - SaveCustomControllerSettings(event->ControllerIndex, (byte *)&thumbprint, sizeof(thumbprint)); + SaveCustomControllerSettings(event->ControllerIndex, (uint8_t *)&thumbprint, sizeof(thumbprint)); # endif // ifdef CPLUGIN_015_SSL } break; @@ -165,7 +165,7 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String& } // Collect the values at the same run, to make sure all are from the same sample - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); success = C015_DelayHandler->addToQueue(C015_queue_element(event, valueCount)); @@ -177,7 +177,7 @@ bool CPlugin_015(CPlugin::Function function, struct EventStruct *event, String& C015_queue_element& element = C015_DelayHandler->sendQueue.back(); LoadTaskSettings(event->TaskIndex); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { bool isvalid; String formattedValue = formatUserVar(event, x, isvalid); @@ -287,7 +287,7 @@ boolean Blynk_keep_connection_c015(int controllerIndex, ControllerSettingsStruct # ifdef CPLUGIN_015_SSL char thumbprint[60]; - LoadCustomControllerSettings(controllerIndex, (byte *)&thumbprint, sizeof(thumbprint)); + LoadCustomControllerSettings(controllerIndex, (uint8_t *)&thumbprint, sizeof(thumbprint)); if (strlen(thumbprint) != 59) { if (loglevelActiveFor(LOG_LEVEL_INFO)) { @@ -425,7 +425,7 @@ boolean Blynk_send_c015(const String& value, int vPin, unsigned int clientTimeou // This is called for all virtual pins, that don't have BLYNK_WRITE handler BLYNK_WRITE_DEFAULT() { - byte vPin = request.pin; + uint8_t vPin = request.pin; float pinValue = param.asFloat(); if (loglevelActiveFor(LOG_LEVEL_INFO)) { diff --git a/src/_C016.ino b/src/_C016.ino index 758c8d40c..193c3672e 100644 --- a/src/_C016.ino +++ b/src/_C016.ino @@ -97,7 +97,7 @@ bool CPlugin_016(CPlugin::Function function, struct EventStruct *event, String& case CPlugin::Function::CPLUGIN_PROTOCOL_SEND: { // Collect the values at the same run, to make sure all are from the same sample - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); C016_queue_element element(event, valueCount, node_time.getUnixTime()); success = ControllerCache.write((uint8_t *)&element, sizeof(element)); diff --git a/src/_C018.ino b/src/_C018.ino index 55b70b99a..069ba96a3 100644 --- a/src/_C018.ino +++ b/src/_C018.ino @@ -114,7 +114,7 @@ struct C018_data_struct { return myLora->command_finished(); } - bool txUncnfBytes(const byte *data, uint8_t size, uint8_t port) { + bool txUncnfBytes(const uint8_t *data, uint8_t size, uint8_t port) { bool res = myLora->txBytes(data, size, port) != RN2xx3_datatypes::TX_return_type::TX_FAIL; C018_logError(F("txUncnfBytes()")); @@ -574,7 +574,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String& if (!customConfig) { break; } - LoadCustomControllerSettings(event->ControllerIndex, (byte *)customConfig.get(), sizeof(C018_ConfigStruct)); + LoadCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C018_ConfigStruct)); customConfig->validate(); baudrate = customConfig->baudrate; rxpin = customConfig->rxpin; @@ -729,7 +729,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String& customConfig->stackVersion = getFormItemInt(F("ttnstack"), customConfig->stackVersion); customConfig->adr = isFormItemChecked(F("adr")); serialHelper_webformSave(customConfig->serialPort, customConfig->rxpin, customConfig->txpin); - SaveCustomControllerSettings(event->ControllerIndex, (byte *)customConfig.get(), sizeof(C018_ConfigStruct)); + SaveCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C018_ConfigStruct)); } break; } @@ -854,7 +854,7 @@ bool C018_init(struct EventStruct *event) { if (!customConfig) { return false; } - LoadCustomControllerSettings(event->ControllerIndex, (byte *)customConfig.get(), sizeof(C018_ConfigStruct)); + LoadCustomControllerSettings(event->ControllerIndex, (uint8_t *)customConfig.get(), sizeof(C018_ConfigStruct)); customConfig->validate(); if (!C018_data->init(customConfig->serialPort, customConfig->rxpin, customConfig->txpin, customConfig->baudrate, diff --git a/src/_N001_Email.ino b/src/_N001_Email.ino index 83615116b..5ad734bc9 100644 --- a/src/_N001_Email.ino +++ b/src/_N001_Email.ino @@ -53,7 +53,7 @@ boolean NPlugin_001(NPlugin::Function function, struct EventStruct *event, Strin // if (command == F("email")) // { // MakeNotificationSettings(NotificationSettings); - // LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct)); + // LoadNotificationSettings(event->NotificationIndex, (uint8_t*)&NotificationSettings, sizeof(NotificationSettingsStruct)); // NPlugin_001_send(NotificationSettings.Domain, NotificationSettings.Receiver, NotificationSettings.Sender, NotificationSettings.Subject, NotificationSettings.Body, NotificationSettings.Server, NotificationSettings.Port); // success = true; // } @@ -63,7 +63,7 @@ boolean NPlugin_001(NPlugin::Function function, struct EventStruct *event, Strin case NPlugin::Function::NPLUGIN_NOTIFY: { MakeNotificationSettings(NotificationSettings); - LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct)); + LoadNotificationSettings(event->NotificationIndex, (uint8_t*)&NotificationSettings, sizeof(NotificationSettingsStruct)); NotificationSettings.validate(); String subject = NotificationSettings.Subject; String body; diff --git a/src/_N002_Buzzer.ino b/src/_N002_Buzzer.ino index aee351c6e..0b13e41b8 100644 --- a/src/_N002_Buzzer.ino +++ b/src/_N002_Buzzer.ino @@ -44,7 +44,7 @@ boolean NPlugin_002(NPlugin::Function function, struct EventStruct *event, Strin // if (command == F("buzzer")) // { // MakeNotificationSettings(NotificationSettings); - // LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct)); + // LoadNotificationSettings(event->NotificationIndex, (uint8_t*)&NotificationSettings, sizeof(NotificationSettingsStruct)); // success = true; // } // break; @@ -53,7 +53,7 @@ boolean NPlugin_002(NPlugin::Function function, struct EventStruct *event, Strin case NPlugin::Function::NPLUGIN_NOTIFY: { MakeNotificationSettings(NotificationSettings); - LoadNotificationSettings(event->NotificationIndex, (byte*)&NotificationSettings, sizeof(NotificationSettingsStruct)); + LoadNotificationSettings(event->NotificationIndex, (uint8_t*)&NotificationSettings, sizeof(NotificationSettingsStruct)); NotificationSettings.validate(); //this reserves IRAM and uninitialized RAM tone_espEasy(NotificationSettings.Pin1, 440, 500); diff --git a/src/_P001_Switch.ino b/src/_P001_Switch.ino index 43a0560f2..bde5395fc 100644 --- a/src/_P001_Switch.ino +++ b/src/_P001_Switch.ino @@ -64,12 +64,12 @@ #define PLUGIN_001_LONGPRESS_BOTH 3 -boolean Plugin_001(byte function, struct EventStruct *event, String& string) +boolean Plugin_001(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; - // static byte switchstate[TASKS_MAX]; - // static byte outputstate[TASKS_MAX]; + // static uint8_t switchstate[TASKS_MAX]; + // static uint8_t outputstate[TASKS_MAX]; // static int8_t PinMonitor[GPIO_MAX]; // static int8_t PinMonitorState[GPIO_MAX]; @@ -126,7 +126,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) { const __FlashStringHelper * options[2] = { F("Switch"), F("Dimmer") }; int optionValues[2] = { PLUGIN_001_TYPE_SWITCH, PLUGIN_001_TYPE_DIMMER }; - const byte switchtype = P001_getSwitchType(event); + const uint8_t switchtype = P001_getSwitchType(event); addFormSelector(F("Switch Type"), F("p001_type"), 2, options, optionValues, switchtype); if (switchtype == PLUGIN_001_TYPE_DIMMER) @@ -136,7 +136,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) } { - byte choice = PCONFIG(2); + uint8_t choice = PCONFIG(2); const __FlashStringHelper * buttonOptions[3] = {F("Normal Switch"), F("Push Button Active Low"), F("Push Button Active High") }; int buttonOptionValues[3] = { PLUGIN_001_BUTTON_TYPE_NORMAL_SWITCH, PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_LOW, PLUGIN_001_BUTTON_TYPE_PUSH_ACTIVE_HIGH }; @@ -156,7 +156,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) } { - byte choiceDC = PCONFIG(4); + uint8_t choiceDC = PCONFIG(4); const __FlashStringHelper * buttonDC[4] = { F("Disabled"), F("Active only on LOW (EVENT=3)"), @@ -180,7 +180,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) } { - byte choiceLP = PCONFIG(5); + uint8_t choiceLP = PCONFIG(5); const __FlashStringHelper * buttonLP[4] = { F("Disabled"), F("Active only on LOW (EVENT= 10 [NORMAL] or 11 [INVERSED])"), @@ -341,7 +341,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) for (std::map::iterator it=globalMapPortStatus.begin(); it!=globalMapPortStatus.end(); ++it) { if ((it->second.monitor || it->second.command || it->second.init) && getPluginFromKey(it->first)==PLUGIN_ID_001) { const uint16_t port = getPortFromKey(it->first); - byte state = Plugin_001_read_switch_state(port, it->second.mode); + uint8_t state = Plugin_001_read_switch_state(port, it->second.mode); if (it->second.state != state || it->second.forceMonitor) { if (!it->second.task) it->second.state = state; //do not update state if task flag=1 otherwise it will not be picked up by 10xSEC function @@ -368,7 +368,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) const portStatusStruct currentStatus = globalMapPortStatus[key]; // if (currentStatus.monitor || currentStatus.command || currentStatus.init) { - byte state = GPIO_Read_Switch_State(event->Par1, currentStatus.mode); + uint8_t state = GPIO_Read_Switch_State(event->Par1, currentStatus.mode); if ((currentStatus.state != state) || (currentStatus.forceMonitor && currentStatus.monitor)) { if (!currentStatus.task) globalMapPortStatus[key].state = state; //do not update state if task flag=1 otherwise it will not be picked up by 10xSEC function @@ -492,7 +492,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) // send if output needs to be changed if (currentOutputState != new_outputState || currentStatus.forceEvent) { - byte output_value; + uint8_t output_value; currentStatus.output = new_outputState; boolean sendState = new_outputState; @@ -576,8 +576,8 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) if (deltaLP >= (unsigned long)lround(PCONFIG_FLOAT(2))) { - byte output_value; - byte needToSendEvent = false; + uint8_t output_value; + uint8_t needToSendEvent = false; PCONFIG(6) = true; @@ -635,7 +635,7 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) } } else { if (PCONFIG_LONG(3) == 1) { // Safe Button detected. Send EVENT value = 4 - const byte SAFE_BUTTON_EVENT = 4; + const uint8_t SAFE_BUTTON_EVENT = 4; // Reset SafeButton counter PCONFIG_LONG(3) = 0; @@ -764,8 +764,8 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string) } // TD-er: Needed to fix a mistake in earlier fixes. -byte P001_getSwitchType(struct EventStruct *event) { - byte choice = PCONFIG(0); +uint8_t P001_getSwitchType(struct EventStruct *event) { + uint8_t choice = PCONFIG(0); switch (choice) { case 2: // Old implementation for Dimmer diff --git a/src/_P002_ADC.ino b/src/_P002_ADC.ino index 12c6e7d63..c5e254391 100644 --- a/src/_P002_ADC.ino +++ b/src/_P002_ADC.ino @@ -92,7 +92,7 @@ private: int16_t OversamplingMaxVal = 0; }; -boolean Plugin_002(byte function, struct EventStruct *event, String& string) +boolean Plugin_002(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P003_Pulse.ino b/src/_P003_Pulse.ino index 5121d6d61..860621c58 100644 --- a/src/_P003_Pulse.ino +++ b/src/_P003_Pulse.ino @@ -55,7 +55,7 @@ bool validIntFromString(const String& tBuf, int & result); -boolean Plugin_003(byte function, struct EventStruct *event, String& string) +boolean Plugin_003(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -103,7 +103,7 @@ boolean Plugin_003(byte function, struct EventStruct *event, String& string) , PCONFIG(P003_IDX_DEBOUNCETIME)); { - byte choice = PCONFIG(P003_IDX_COUNTERTYPE); + uint8_t choice = PCONFIG(P003_IDX_COUNTERTYPE); const __FlashStringHelper *options[P003_NR_COUNTERTYPES] = P003_COUNTERTYPE_LIST; addFormSelector(F("Counter Type"), F("p003_countertype"), P003_NR_COUNTERTYPES, options, NULL, choice); if (choice != 0) { @@ -262,7 +262,7 @@ boolean Plugin_003(byte function, struct EventStruct *event, String& string) // to the first active P003 task instance // Legacy: Allow for an optional taskIndex parameter. - byte tidx = 1; + uint8_t tidx = 1; if (command == F("setpulsecountertotal")) { tidx = 2; } diff --git a/src/_P004_Dallas.ino b/src/_P004_Dallas.ino index 2efbb973d..5d1798059 100644 --- a/src/_P004_Dallas.ino +++ b/src/_P004_Dallas.ino @@ -28,7 +28,7 @@ # define P004_SENSOR_TYPE_INDEX 2 # define P004_NR_OUTPUT_VALUES getValueCountFromSensorType(static_cast(PCONFIG(P004_SENSOR_TYPE_INDEX))) -String Plugin_004_valuename(byte value_nr, bool displayString) { +String Plugin_004_valuename(uint8_t value_nr, bool displayString) { String name = F("Temperature"); if (value_nr != 0) { @@ -41,7 +41,7 @@ String Plugin_004_valuename(byte value_nr, bool displayString) { return name; } -boolean Plugin_004(byte function, struct EventStruct *event, String& string) +boolean Plugin_004(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -72,7 +72,7 @@ boolean Plugin_004(byte function, struct EventStruct *event, String& string) case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P004_NR_OUTPUT_VALUES) { safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], @@ -103,8 +103,8 @@ boolean Plugin_004(byte function, struct EventStruct *event, String& string) case PLUGIN_SET_DEFAULTS: { - PCONFIG(P004_SENSOR_TYPE_INDEX) = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); - for (byte i = 0; i < VARS_PER_TASK; ++i) { + PCONFIG(P004_SENSOR_TYPE_INDEX) = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { ExtraTaskSettings.TaskDeviceValueDecimals[i] = 2; } @@ -210,7 +210,7 @@ boolean Plugin_004(byte function, struct EventStruct *event, String& string) LoadTaskSettings(event->TaskIndex); uint8_t addr[8]; - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P004_NR_OUTPUT_VALUES) { Dallas_plugin_get_addr(addr, event->TaskIndex, i); @@ -243,7 +243,7 @@ boolean Plugin_004(byte function, struct EventStruct *event, String& string) if (nullptr != P004_data) { // Address index 0 is already set - for (byte i = 1; i < P004_NR_OUTPUT_VALUES; ++i) { + for (uint8_t i = 1; i < P004_NR_OUTPUT_VALUES; ++i) { Dallas_plugin_get_addr(addr, event->TaskIndex, i); P004_data->add_addr(addr, i); } @@ -273,7 +273,7 @@ boolean Plugin_004(byte function, struct EventStruct *event, String& string) P004_data->collect_values(); - for (byte i = 0; i < P004_NR_OUTPUT_VALUES; ++i) { + for (uint8_t i = 0; i < P004_NR_OUTPUT_VALUES; ++i) { float value = 0; if (P004_data->read_temp(value, i)) diff --git a/src/_P005_DHT.ino b/src/_P005_DHT.ino index a70e1d4ae..4e4ae2137 100644 --- a/src/_P005_DHT.ino +++ b/src/_P005_DHT.ino @@ -26,7 +26,7 @@ uint8_t Plugin_005_DHT_Pin; -boolean Plugin_005(byte function, struct EventStruct *event, String& string) +boolean Plugin_005(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -144,9 +144,9 @@ boolean P005_waitState(int state) * Perform the actual reading + interpreting of data. \*********************************************************************************************/ bool P005_do_plugin_read(struct EventStruct *event) { - byte i; + uint8_t i; - byte Par3 = PCONFIG(0); + uint8_t Par3 = PCONFIG(0); Plugin_005_DHT_Pin = CONFIG_PIN1; pinMode(Plugin_005_DHT_Pin, OUTPUT); @@ -181,7 +181,7 @@ bool P005_do_plugin_read(struct EventStruct *event) { if(!P005_waitState(0)) {interrupts(); P005_log(event, P005_error_no_reading); return false; } bool readingAborted = false; - byte dht_dat[5]; + uint8_t dht_dat[5]; for (i = 0; i < 5 && !readingAborted; i++) { int data = Plugin_005_read_dht_dat(); @@ -196,7 +196,7 @@ bool P005_do_plugin_read(struct EventStruct *event) { return false; // Checksum calculation is a Rollover Checksum by design! - byte dht_check_sum = (dht_dat[0] + dht_dat[1] + dht_dat[2] + dht_dat[3]) & 0xFF; // check check_sum + uint8_t dht_check_sum = (dht_dat[0] + dht_dat[1] + dht_dat[2] + dht_dat[3]) & 0xFF; // check check_sum if (dht_dat[4] != dht_check_sum) { P005_log(event, P005_error_checksum_error); @@ -242,8 +242,8 @@ bool P005_do_plugin_read(struct EventStruct *event) { \*********************************************************************************************/ int Plugin_005_read_dht_dat(void) { - byte i = 0; - byte result = 0; + uint8_t i = 0; + uint8_t result = 0; for (i = 0; i < 8; i++) { if (!P005_waitState(1)) return -1; diff --git a/src/_P006_BMP085.ino b/src/_P006_BMP085.ino index 0f66b2bea..b565d0532 100644 --- a/src/_P006_BMP085.ino +++ b/src/_P006_BMP085.ino @@ -15,7 +15,7 @@ #define PLUGIN_VALUENAME2_006 "Pressure" -boolean Plugin_006(byte function, struct EventStruct *event, String& string) +boolean Plugin_006(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P007_PCF8591.ino b/src/_P007_PCF8591.ino index 4534dd8c1..eef433115 100644 --- a/src/_P007_PCF8591.ino +++ b/src/_P007_PCF8591.ino @@ -12,11 +12,11 @@ #define PLUGIN_NAME_007 "Analog input - PCF8591" #define PLUGIN_VALUENAME1_007 "Analog" -boolean Plugin_007(byte function, struct EventStruct *event, String& string) +boolean Plugin_007(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; - // static byte portValue = 0; + // static uint8_t portValue = 0; switch (function) { @@ -50,8 +50,8 @@ boolean Plugin_007(byte function, struct EventStruct *event, String& string) case PLUGIN_READ: { - byte unit = (CONFIG_PORT - 1) / 4; - byte port = CONFIG_PORT - (unit * 4); + uint8_t unit = (CONFIG_PORT - 1) / 4; + uint8_t port = CONFIG_PORT - (unit * 4); uint8_t address = 0x48 + unit; // get the current pin value diff --git a/src/_P008_RFID.ino b/src/_P008_RFID.ino index b8d6232a3..7e036e72c 100644 --- a/src/_P008_RFID.ino +++ b/src/_P008_RFID.ino @@ -24,10 +24,10 @@ No initial history available. void Plugin_008_interrupt1() ICACHE_RAM_ATTR; void Plugin_008_interrupt2() ICACHE_RAM_ATTR; -volatile byte Plugin_008_bitCount = 0; // Count the number of bits received. +volatile uint8_t Plugin_008_bitCount = 0; // Count the number of bits received. uint64_t Plugin_008_keyBuffer = 0; // A 64-bit-long keyBuffer into which the number is stored. -byte Plugin_008_timeoutCount = 0; -byte Plugin_008_WiegandSize = 26; // size of a tag via wiegand (26-bits or 36-bits) +uint8_t Plugin_008_timeoutCount = 0; +uint8_t Plugin_008_WiegandSize = 26; // size of a tag via wiegand (26-bits or 36-bits) boolean Plugin_008_init = false; @@ -51,7 +51,7 @@ uint64_t castHexAsDec(uint64_t hexValue) { return result; } -boolean Plugin_008(byte function, struct EventStruct *event, String& string) +boolean Plugin_008(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -206,7 +206,7 @@ boolean Plugin_008(byte function, struct EventStruct *event, String& string) } case PLUGIN_WEBFORM_LOAD: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); { const __FlashStringHelper * options[2]; options[0] = F("26 Bits"); diff --git a/src/_P009_MCP.ino b/src/_P009_MCP.ino index 3ae83ec18..530e83bb0 100644 --- a/src/_P009_MCP.ino +++ b/src/_P009_MCP.ino @@ -52,7 +52,7 @@ #define PLUGIN_009_LONGPRESS_HIGH 2 #define PLUGIN_009_LONGPRESS_BOTH 3 -boolean Plugin_009(byte function, struct EventStruct *event, String& string) +boolean Plugin_009(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -111,7 +111,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string) PCONFIG_FLOAT(1) = PLUGIN_009_DOUBLECLICK_MIN_INTERVAL; } - byte choiceDC = PCONFIG(4); + uint8_t choiceDC = PCONFIG(4); { const __FlashStringHelper * buttonDC[4]; buttonDC[0] = F("Disabled"); @@ -135,7 +135,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string) { - byte choiceLP = PCONFIG(5); + uint8_t choiceLP = PCONFIG(5); const __FlashStringHelper * buttonLP[4]; buttonLP[0] = F("Disabled"); buttonLP[1] = F("Active only on LOW (EVENT= 10 [NORMAL] or 11 [INVERSED])"); @@ -330,7 +330,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string) } currentStatus.state = state; - byte output_value; + uint8_t output_value; // boolean sendState = switchstate[event->TaskIndex]; boolean sendState = currentStatus.state; @@ -399,7 +399,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string) if (deltaLP >= (unsigned long)lround(PCONFIG_FLOAT(2))) { - byte output_value; + uint8_t output_value; PCONFIG(6) = true; // fired = true boolean sendState = state; @@ -570,13 +570,13 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string) // MCP23017 read // ******************************************************************************** /* -int8_t Plugin_009_Read(byte Par1) +int8_t Plugin_009_Read(uint8_t Par1) { int8_t state = -1; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16); + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16); uint8_t address = 0x20 + unit; - byte IOBankValueReg = 0x12; + uint8_t IOBankValueReg = 0x12; if (port > 8) { @@ -602,15 +602,15 @@ int8_t Plugin_009_Read(byte Par1) // MCP23017 write // ******************************************************************************** /* -boolean Plugin_009_Write(byte Par1, byte Par2) +boolean Plugin_009_Write(uint8_t Par1, uint8_t Par2) { boolean success = false; - byte portvalue = 0; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16); + uint8_t portvalue = 0; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16); uint8_t address = 0x20 + unit; - byte IOBankConfigReg = 0; - byte IOBankValueReg = 0x12; + uint8_t IOBankConfigReg = 0; + uint8_t IOBankValueReg = 0x12; if (port > 8) { @@ -668,14 +668,14 @@ boolean Plugin_009_Write(byte Par1, byte Par2) // MCP23017 config // ******************************************************************************** /* -void Plugin_009_Config(byte Par1, byte Par2) +void Plugin_009_Config(uint8_t Par1, uint8_t Par2) { // boolean success = false; - byte portvalue = 0; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16); + uint8_t portvalue = 0; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16); uint8_t address = 0x20 + unit; - byte IOBankConfigReg = 0xC; + uint8_t IOBankConfigReg = 0xC; if (port > 8) { diff --git a/src/_P010_BH1750.ino b/src/_P010_BH1750.ino index 57720e059..e18eb5506 100644 --- a/src/_P010_BH1750.ino +++ b/src/_P010_BH1750.ino @@ -15,7 +15,7 @@ # define PLUGIN_VALUENAME1_010 "Lux" -boolean Plugin_010(byte function, struct EventStruct *event, String& string) +boolean Plugin_010(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -51,7 +51,7 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); /* String options[2]; @@ -69,7 +69,7 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte choiceMode = PCONFIG(1); + uint8_t choiceMode = PCONFIG(1); const __FlashStringHelper * optionsMode[4]; optionsMode[0] = F("RESOLUTION_LOW"); optionsMode[1] = F("RESOLUTION_NORMAL"); diff --git a/src/_P011_PME.ino b/src/_P011_PME.ino index 1659baec8..65c6e56c1 100644 --- a/src/_P011_PME.ino +++ b/src/_P011_PME.ino @@ -16,7 +16,7 @@ #define PLUGIN_011_I2C_ADDRESS 0x7f -boolean Plugin_011(byte function, struct EventStruct *event, String& string) +boolean Plugin_011(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -51,7 +51,7 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); const __FlashStringHelper * options[2] = { F("Digital"), F("Analog") }; addFormSelector(F("Port Type"), F("p011"), 2, options, NULL, choice); @@ -222,8 +222,8 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string) } else { - byte port = event->Par2; // port 0-13 is digital, ports 20-27 are mapped to A0-A7 - byte type = 0; // digital + uint8_t port = event->Par2; // port 0-13 is digital, ports 20-27 are mapped to A0-A7 + uint8_t type = 0; // digital if (port > 13) { @@ -266,7 +266,7 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string) // ******************************************************************************** // PME read // ******************************************************************************** -int Plugin_011_Read(byte Par1, byte Par2) +int Plugin_011_Read(uint8_t Par1, uint8_t Par2) { int value = -1; uint8_t address = PLUGIN_011_I2C_ADDRESS; @@ -285,11 +285,11 @@ int Plugin_011_Read(byte Par1, byte Par2) Wire.endTransmission(); delay(1); // remote unit needs some time for conversion... Wire.requestFrom(address, (uint8_t)0x4); - byte buffer[4]; + uint8_t buffer[4]; if (Wire.available() == 4) { - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { buffer[x] = Wire.read(); } value = buffer[0] + 256 * buffer[1]; @@ -300,7 +300,7 @@ int Plugin_011_Read(byte Par1, byte Par2) // ******************************************************************************** // PME write // ******************************************************************************** -void Plugin_011_Write(byte Par1, byte Par2) +void Plugin_011_Write(uint8_t Par1, uint8_t Par2) { uint8_t address = 0x7f; diff --git a/src/_P012_LCD.ino b/src/_P012_LCD.ino index 3de457061..195e87979 100644 --- a/src/_P012_LCD.ino +++ b/src/_P012_LCD.ino @@ -32,7 +32,7 @@ # define P012_MODE PCONFIG(3) # define P012_INVERSE_BTN PCONFIG(4) -boolean Plugin_012(byte function, struct EventStruct *event, String& string) +boolean Plugin_012(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -67,12 +67,12 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = P012_I2C_ADDR; + uint8_t choice = P012_I2C_ADDR; // String options[16]; int optionValues[16]; - for (byte x = 0; x < 16; x++) + for (uint8_t x = 0; x < 16; x++) { if (x < 8) { optionValues[x] = 0x20 + x; @@ -91,7 +91,7 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { { - byte choice2 = P012_SIZE; + uint8_t choice2 = P012_SIZE; const __FlashStringHelper * options2[2]; options2[0] = F("2 x 16"); options2[1] = F("4 x 20"); @@ -103,7 +103,7 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string) String strings[P12_Nlines]; LoadCustomTaskSettings(event->TaskIndex, strings, P12_Nlines, P12_Nchars); - for (byte varNr = 0; varNr < P12_Nlines; varNr++) + for (uint8_t varNr = 0; varNr < P12_Nlines; varNr++) { addFormTextBox(String(F("Line ")) + (varNr + 1), getPluginCustomArgName(varNr), strings[varNr], P12_Nchars); } @@ -141,7 +141,7 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string) char deviceTemplate[P12_Nlines][P12_Nchars]; String error; - for (byte varNr = 0; varNr < P12_Nlines; varNr++) + for (uint8_t varNr = 0; varNr < P12_Nlines; varNr++) { if (!safe_strncpy(deviceTemplate[varNr], webArg(getPluginCustomArgName(varNr)), P12_Nchars)) { error += getCustomTaskSettingsError(varNr); @@ -151,7 +151,7 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string) if (error.length() > 0) { addHtmlError(error); } - SaveCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemplate, sizeof(deviceTemplate)); + SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate)); success = true; break; } @@ -209,9 +209,9 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string) if (nullptr != P012_data) { // FIXME TD-er: This is a huge stack allocated object. char deviceTemplate[P12_Nlines][P12_Nchars]; - LoadCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemplate, sizeof(deviceTemplate)); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate)); - for (byte x = 0; x < P012_data->Plugin_012_rows; x++) + for (uint8_t x = 0; x < P012_data->Plugin_012_rows; x++) { String tmpString = deviceTemplate[x]; diff --git a/src/_P013_HCSR04.ino b/src/_P013_HCSR04.ino index c2bdc8d1f..2695caaf1 100644 --- a/src/_P013_HCSR04.ino +++ b/src/_P013_HCSR04.ino @@ -34,9 +34,9 @@ std::map > P_013_sensordefs; // Forward declaration const __FlashStringHelper * Plugin_013_getErrorStatusString(taskIndex_t taskIndex); -boolean Plugin_013(byte function, struct EventStruct *event, String& string) +boolean Plugin_013(uint8_t function, struct EventStruct *event, String& string) { - static byte switchstate[TASKS_MAX]; + static uint8_t switchstate[TASKS_MAX]; boolean success = false; switch (function) @@ -259,7 +259,7 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string) if (operatingMode == OPMODE_STATE) { - byte state = 0; + uint8_t state = 0; float value = Plugin_013_read(event->TaskIndex); if (value != NO_ECHO) { diff --git a/src/_P014_SI7021.ino b/src/_P014_SI7021.ino index e916ecf92..e6e7aebe5 100644 --- a/src/_P014_SI7021.ino +++ b/src/_P014_SI7021.ino @@ -235,7 +235,7 @@ struct P014_data_struct : public PluginTaskData_base { Wire.write(SI7021_READ_REG); Wire.endTransmission(); - // request 1 byte result + // request 1 uint8_t result Wire.requestFrom(SI7021_I2C_ADDRESS, 1); if (Wire.available() >= 1) { @@ -372,7 +372,7 @@ struct P014_data_struct : public PluginTaskData_base { uint8_t res = 0; }; -boolean Plugin_014(byte function, struct EventStruct *event, String& string) +boolean Plugin_014(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -411,7 +411,7 @@ boolean Plugin_014(byte function, struct EventStruct *event, String& string) { #define SI7021_RESOLUTION_OPTION 4 - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); const __FlashStringHelper * options[SI7021_RESOLUTION_OPTION]; int optionValues[SI7021_RESOLUTION_OPTION]; optionValues[0] = SI7021_RESOLUTION_14T_12RH; diff --git a/src/_P015_TSL2561.ino b/src/_P015_TSL2561.ino index 06932f6be..9b6bdd654 100644 --- a/src/_P015_TSL2561.ino +++ b/src/_P015_TSL2561.ino @@ -28,7 +28,7 @@ #define P015_GAIN PCONFIG(3) -boolean Plugin_015(byte function, struct EventStruct *event, String& string) +boolean Plugin_015(uint8_t function, struct EventStruct *event, String& string) { bool success = false; diff --git a/src/_P016_IR.ino b/src/_P016_IR.ino index 972bdbdce..7ab7f1906 100644 --- a/src/_P016_IR.ino +++ b/src/_P016_IR.ino @@ -113,7 +113,7 @@ IRrecv *irReceiver = NULL; bool bEnableIRcodeAdding = false; boolean displayRawToReadableB32Hex(String &outputStr, decode_results results); -boolean Plugin_016(byte function, struct EventStruct *event, String &string) +boolean Plugin_016(uint8_t function, struct EventStruct *event, String &string) { boolean success = false; @@ -423,7 +423,7 @@ boolean Plugin_016(byte function, struct EventStruct *event, String &string) if (nullptr != P016_data) { // convert result to uint32_t - uint32_t iCode = ((uint32_t) results.decode_type) * 0x1000000; // Bits 31-24 (upper byte) for decode_type + uint32_t iCode = ((uint32_t) results.decode_type) * 0x1000000; // Bits 31-24 (upper uint8_t) for decode_type if (results.repeat) iCode += 0x800000; // Bit 23 for repeat char strCode[P16_Cchars]; diff --git a/src/_P017_PN532.ino b/src/_P017_PN532.ino index 7e2242ef0..4db5285bb 100644 --- a/src/_P017_PN532.ino +++ b/src/_P017_PN532.ino @@ -35,7 +35,7 @@ uint8_t Plugin_017_pn532_packetbuffer[64]; uint8_t Plugin_017_command; -boolean Plugin_017(byte function, struct EventStruct *event, String& string) +boolean Plugin_017(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -107,7 +107,7 @@ boolean Plugin_017(byte function, struct EventStruct *event, String& string) // if (!Settings.WireClockStretchLimit) // Wire.setClockStretchLimit(2000); - for (byte x = 0; x < 3; x++) + for (uint8_t x = 0; x < 3; x++) { if (Plugin_017_Init(CONFIG_PIN3)) { break; @@ -134,8 +134,8 @@ boolean Plugin_017(byte function, struct EventStruct *event, String& string) case PLUGIN_TEN_PER_SECOND: { static unsigned long tempcounter = 0; - static byte counter; - static byte errorCount = 0; + static uint8_t counter; + static uint8_t errorCount = 0; counter++; @@ -153,7 +153,7 @@ boolean Plugin_017(byte function, struct EventStruct *event, String& string) counter = 0; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; uint8_t uidLength; - byte error = Plugin_017_readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); + uint8_t error = Plugin_017_readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); if (error == 1) { @@ -325,7 +325,7 @@ void Plugin_017_powerDown(void) /*********************************************************************************************\ * PN532 read tag \*********************************************************************************************/ -byte Plugin_017_readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength) +uint8_t Plugin_017_readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength) { Plugin_017_pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET; Plugin_017_pn532_packetbuffer[1] = 1; // max 1 cards at once @@ -403,7 +403,7 @@ int8_t Plugin_017_writeCommand(const uint8_t *header, uint8_t hlen) Wire.write(checksum); Wire.write(PN532_POSTAMBLE); - byte status = Wire.endTransmission(); + uint8_t status = Wire.endTransmission(); if (status != 0) { return PN532_INVALID_FRAME; @@ -480,7 +480,7 @@ int8_t Plugin_017_readAckFrame() do { if (Wire.requestFrom(PN532_I2C_ADDRESS, sizeof(PN532_ACK) + 1)) { - if (Wire.read() & 1) { // check first byte --- status + if (Wire.read() & 1) { // check first uint8_t --- status break; // PN532 is ready } } diff --git a/src/_P018_Dust.ino b/src/_P018_Dust.ino index c23c337da..6a8954719 100644 --- a/src/_P018_Dust.ino +++ b/src/_P018_Dust.ino @@ -13,9 +13,9 @@ #define PLUGIN_VALUENAME1_018 "Dust" boolean Plugin_018_init = false; -byte Plugin_GP2Y10_LED_Pin = 0; +uint8_t Plugin_GP2Y10_LED_Pin = 0; -boolean Plugin_018(byte function, struct EventStruct *event, String& string) +boolean Plugin_018(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -70,7 +70,7 @@ boolean Plugin_018(byte function, struct EventStruct *event, String& string) { Plugin_GP2Y10_LED_Pin = CONFIG_PIN1; noInterrupts(); - byte x; + uint8_t x; int value; value = 0; for (x = 0; x < 25; x++) diff --git a/src/_P019_PCF8574.ino b/src/_P019_PCF8574.ino index 885435d50..64171ea7f 100644 --- a/src/_P019_PCF8574.ino +++ b/src/_P019_PCF8574.ino @@ -51,7 +51,7 @@ #define PLUGIN_019_LONGPRESS_HIGH 2 #define PLUGIN_019_LONGPRESS_BOTH 3 -boolean Plugin_019(byte function, struct EventStruct *event, String& string) +boolean Plugin_019(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -111,7 +111,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string) } { - byte choiceDC = PCONFIG(4); + uint8_t choiceDC = PCONFIG(4); const __FlashStringHelper * buttonDC[4]; buttonDC[0] = F("Disabled"); buttonDC[1] = F("Active only on LOW (EVENT=3)"); @@ -133,7 +133,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string) } { - byte choiceLP = PCONFIG(5); + uint8_t choiceLP = PCONFIG(5); const __FlashStringHelper * buttonLP[4]; buttonLP[0] = F("Disabled"); buttonLP[1] = F("Active only on LOW (EVENT= 10 [NORMAL] or 11 [INVERSED])"); @@ -384,7 +384,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string) } currentStatus.state = state; - byte output_value; + uint8_t output_value; // boolean sendState = switchstate[event->TaskIndex]; boolean sendState = currentStatus.state; @@ -453,7 +453,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string) if (deltaLP >= (unsigned long)lround(PCONFIG_FLOAT(2))) { - byte output_value; + uint8_t output_value; PCONFIG(6) = true; // fired = true boolean sendState = state; @@ -486,7 +486,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string) } } else { if (PCONFIG_LONG(3) == 1) { // Safe Button detected. Send EVENT value = 4 - const byte SAFE_BUTTON_EVENT = 4; + const uint8_t SAFE_BUTTON_EVENT = 4; // Reset SafeButton counter PCONFIG_LONG(3) = 0; @@ -630,11 +630,11 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string) // PCF8574 read // ******************************************************************************** // @giig1967g-20181023: changed to int8_t -int8_t Plugin_019_Read(byte Par1) +int8_t Plugin_019_Read(uint8_t Par1) { int8_t state = -1; - byte unit = (Par1 - 1) / 8; - byte port = Par1 - (unit * 8); + uint8_t unit = (Par1 - 1) / 8; + uint8_t port = Par1 - (unit * 8); uint8_t address = 0x20 + unit; if (unit > 7) { address += 0x10; } @@ -665,7 +665,7 @@ uint8_t Plugin_019_ReadAllPins(uint8_t address) // ******************************************************************************** // PCF8574 write // ******************************************************************************** -boolean Plugin_019_Write(byte Par1, byte Par2) +boolean Plugin_019_Write(uint8_t Par1, uint8_t Par2) { uint8_t unit = (Par1 - 1) / 8; uint8_t port = Par1 - (unit * 8); diff --git a/src/_P020_Ser2Net.ino b/src/_P020_Ser2Net.ino index 6642aef2e..089df9feb 100644 --- a/src/_P020_Ser2Net.ino +++ b/src/_P020_Ser2Net.ino @@ -37,7 +37,7 @@ # define P020_DEFAULT_BAUDRATE 115200 -boolean Plugin_020(byte function, struct EventStruct *event, String& string) +boolean Plugin_020(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -92,10 +92,10 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string) { addFormNumericBox(F("TCP Port"), F("p020_port"), P020_SERVER_PORT, 0); addFormNumericBox(F("Baud Rate"), F("p020_baud"), P020_BAUDRATE, 0); - byte serialConfChoice = serialHelper_convertOldSerialConfig(P020_SERIAL_CONFIG); + uint8_t serialConfChoice = serialHelper_convertOldSerialConfig(P020_SERIAL_CONFIG); serialHelper_serialconfig_webformLoad(event, serialConfChoice); { - byte choice = P020_SERIAL_PROCESSING; + uint8_t choice = P020_SERIAL_PROCESSING; const __FlashStringHelper * options[3]; options[0] = F("None"); options[1] = F("Generic"); @@ -174,7 +174,7 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string) // serial0 on esp32 is Ser2net: port=2 rxPin=3 txPin=1; serial1 on esp32 is Ser2net: port=4 rxPin=13 txPin=15; Serial2 on esp32 is // Ser2net: port=4 rxPin=16 txPin=17 - byte serialconfig = serialHelper_convertOldSerialConfig(P020_SERIAL_CONFIG); + uint8_t serialconfig = serialHelper_convertOldSerialConfig(P020_SERIAL_CONFIG); task->serialBegin(port, rxPin, txPin, P020_BAUDRATE, serialconfig); task->startServer(P020_SERVER_PORT); diff --git a/src/_P021_Level.ino b/src/_P021_Level.ino index 9760ba4ea..47b4b3d92 100644 --- a/src/_P021_Level.ino +++ b/src/_P021_Level.ino @@ -12,10 +12,10 @@ #define PLUGIN_NAME_021 "Regulator - Level Control" #define PLUGIN_VALUENAME1_021 "Output" -boolean Plugin_021(byte function, struct EventStruct *event, String& string) +boolean Plugin_021(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; - static byte switchstate[TASKS_MAX]; + static uint8_t switchstate[TASKS_MAX]; switch (function) { @@ -121,9 +121,9 @@ boolean Plugin_021(byte function, struct EventStruct *event, String& string) { // we're checking a var from another task, so calculate that basevar taskIndex_t TaskIndex = PCONFIG(0); - byte BaseVarIndex = TaskIndex * VARS_PER_TASK + PCONFIG(1); + uint8_t BaseVarIndex = TaskIndex * VARS_PER_TASK + PCONFIG(1); float value = UserVar[BaseVarIndex]; - byte state = switchstate[event->TaskIndex]; + uint8_t state = switchstate[event->TaskIndex]; // compare with threshold value float valueLowThreshold = PCONFIG_FLOAT(0) - (PCONFIG_FLOAT(1) / 2); float valueHighThreshold = PCONFIG_FLOAT(0) + (PCONFIG_FLOAT(1) / 2); diff --git a/src/_P022_PCA9685.ino b/src/_P022_PCA9685.ino index 6bdafe8cb..a6a03540f 100644 --- a/src/_P022_PCA9685.ino +++ b/src/_P022_PCA9685.ino @@ -21,7 +21,7 @@ // FIXME TD-er: This plugin uses a lot of calls to the P022_data_struct, which could be combined in single functions. -boolean Plugin_022(byte function, struct EventStruct *event, String& string) +boolean Plugin_022(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; int address = 0; diff --git a/src/_P023_OLED.ino b/src/_P023_OLED.ino index 25f60dcc8..e1569392b 100644 --- a/src/_P023_OLED.ino +++ b/src/_P023_OLED.ino @@ -20,7 +20,7 @@ #define PLUGIN_NAME_023 "Display - OLED SSD1306" #define PLUGIN_VALUENAME1_023 "OLED" -boolean Plugin_023(byte function, struct EventStruct *event, String& string) +boolean Plugin_023(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -55,7 +55,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); /*String options[2] = { F("3C"), F("3D") };*/ int optionValues[2] = { 0x3C, 0x3D }; @@ -68,19 +68,19 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string) addFormCheckBox(F("Use SH1106 controller"), F("p023_use_sh1106"), PCONFIG(5)); { - byte choice2 = PCONFIG(1); + uint8_t choice2 = PCONFIG(1); const __FlashStringHelper * options2[2] = { F("Normal"), F("Rotated") }; int optionValues2[2] = { 1, 2 }; addFormSelector(F("Rotation"), F("p023_rotate"), 2, options2, optionValues2, choice2); } { - byte choice3 = PCONFIG(3); + uint8_t choice3 = PCONFIG(3); const __FlashStringHelper * options3[3] = { F("128x64"), F("128x32"), F("64x48") }; int optionValues3[3] = { 1, 3, 2 }; addFormSelector(F("Display Size"), F("p023_size"), 3, options3, optionValues3, choice3); } { - byte choice4 = PCONFIG(4); + uint8_t choice4 = PCONFIG(4); const __FlashStringHelper * options4[2] = { F("Normal"), F("Optimized") }; int optionValues4[2] = { 1, 2 }; addFormSelector(F("Font Width"), F("p023_font_spacing"), 2, options4, optionValues4, choice4); @@ -89,7 +89,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string) String strings[P23_Nlines]; LoadCustomTaskSettings(event->TaskIndex, strings, P23_Nlines, P23_Nchars); - for (byte varNr = 0; varNr < 8; varNr++) + for (uint8_t varNr = 0; varNr < 8; varNr++) { addFormTextBox(String(F("Line ")) + (varNr + 1), getPluginCustomArgName(varNr), strings[varNr], 64); } @@ -118,7 +118,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string) char deviceTemplate[P23_Nlines][P23_Nchars]; String error; - for (byte varNr = 0; varNr < P23_Nlines; varNr++) + for (uint8_t varNr = 0; varNr < P23_Nlines; varNr++) { if (!safe_strncpy(deviceTemplate[varNr], webArg(getPluginCustomArgName(varNr)), P23_Nchars)) { error += getCustomTaskSettingsError(varNr); @@ -128,18 +128,18 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string) if (error.length() > 0) { addHtmlError(error); } - SaveCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemplate, sizeof(deviceTemplate)); + SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate)); success = true; break; } case PLUGIN_INIT: { - byte address = PCONFIG(0); - byte type = 0; + uint8_t address = PCONFIG(0); + uint8_t type = 0; P023_data_struct::Spacing font_spacing = P023_data_struct::Spacing::normal; - byte displayTimer = PCONFIG(2); - byte use_sh1106 = PCONFIG(5); + uint8_t displayTimer = PCONFIG(2); + uint8_t use_sh1106 = PCONFIG(5); switch (PCONFIG(3)) { @@ -228,7 +228,7 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string) String strings[P23_Nlines]; LoadCustomTaskSettings(event->TaskIndex, strings, P23_Nlines, P23_Nchars); - for (byte x = 0; x < 8; x++) + for (uint8_t x = 0; x < 8; x++) { if (strings[x].length()) { diff --git a/src/_P024_MLX90614.ino b/src/_P024_MLX90614.ino index 776847679..184b28af2 100644 --- a/src/_P024_MLX90614.ino +++ b/src/_P024_MLX90614.ino @@ -15,11 +15,11 @@ #define PLUGIN_NAME_024 "Environment - MLX90614" #define PLUGIN_VALUENAME1_024 "Temperature" -boolean Plugin_024(byte function, struct EventStruct *event, String& string) +boolean Plugin_024(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; - // static byte portValue = 0; + // static uint8_t portValue = 0; switch (function) { case PLUGIN_DEVICE_ADD: @@ -54,7 +54,7 @@ boolean Plugin_024(byte function, struct EventStruct *event, String& string) { #define MLX90614_OPTION 2 - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); const __FlashStringHelper * options[MLX90614_OPTION]; int optionValues[MLX90614_OPTION]; optionValues[0] = (0x07); @@ -76,7 +76,7 @@ boolean Plugin_024(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { - byte unit = CONFIG_PORT; + uint8_t unit = CONFIG_PORT; uint8_t address = 0x5A + unit; initPluginTaskData(event->TaskIndex, new (std::nothrow) P024_data_struct(address)); diff --git a/src/_P025_ADS1115.ino b/src/_P025_ADS1115.ino index 9c34b1ef3..ae9bd6732 100644 --- a/src/_P025_ADS1115.ino +++ b/src/_P025_ADS1115.ino @@ -14,11 +14,11 @@ #define PLUGIN_VALUENAME1_025 "Analog" -boolean Plugin_025(byte function, struct EventStruct *event, String& string) +boolean Plugin_025(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; - // static byte portValue = 0; + // static uint8_t portValue = 0; switch (function) { case PLUGIN_DEVICE_ADD: @@ -52,7 +52,7 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { #define ADS1115_I2C_OPTION 4 - byte addr = PCONFIG(0); + uint8_t addr = PCONFIG(0); int optionValues[ADS1115_I2C_OPTION] = { 0x48, 0x49, 0x4A, 0x4B }; addFormSelectorI2C(F("i2c_addr"), ADS1115_I2C_OPTION, optionValues, addr); break; @@ -60,7 +60,7 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte port = CONFIG_PORT; + uint8_t port = CONFIG_PORT; if (port > 0) // map old port logic to new gain and mode settings { @@ -74,7 +74,7 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string) { #define ADS1115_PGA_OPTION 6 - byte pga = PCONFIG(1); + uint8_t pga = PCONFIG(1); const __FlashStringHelper * pgaOptions[ADS1115_PGA_OPTION] = { F("2/3x gain (FS=6.144V)"), F("1x gain (FS=4.096V)"), @@ -88,7 +88,7 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string) { #define ADS1115_MUX_OPTION 8 - byte mux = PCONFIG(2); + uint8_t mux = PCONFIG(2); const __FlashStringHelper * muxOptions[ADS1115_MUX_OPTION] = { F("AIN0 - AIN1 (Differential)"), F("AIN0 - AIN3 (Differential)"), @@ -141,8 +141,8 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { // int value = 0; - // byte unit = (CONFIG_PORT - 1) / 4; - // byte port = CONFIG_PORT - (unit * 4); + // uint8_t unit = (CONFIG_PORT - 1) / 4; + // uint8_t port = CONFIG_PORT - (unit * 4); // uint8_t address = 0x48 + unit; const uint8_t address = PCONFIG(0); const uint8_t pga = PCONFIG(1); diff --git a/src/_P026_Sysinfo.ino b/src/_P026_Sysinfo.ino index ab3724fb5..52d1b8fa8 100644 --- a/src/_P026_Sysinfo.ino +++ b/src/_P026_Sysinfo.ino @@ -22,7 +22,7 @@ #define P026_NR_OUTPUT_OPTIONS 13 -const __FlashStringHelper * Plugin_026_valuename(byte value_nr, bool displayString) { +const __FlashStringHelper * Plugin_026_valuename(uint8_t value_nr, bool displayString) { switch (value_nr) { case 0: return displayString ? F("Uptime") : F("uptime"); case 1: return displayString ? F("Free RAM") : F("freeheap"); @@ -43,7 +43,7 @@ const __FlashStringHelper * Plugin_026_valuename(byte value_nr, bool displayStri return F(""); } -boolean Plugin_026(byte function, struct EventStruct *event, String& string) +boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -69,10 +69,10 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string) case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P026_NR_OUTPUT_VALUES) { - const byte pconfigIndex = i + P026_QUERY1_CONFIG_POS; - byte choice = PCONFIG(pconfigIndex); + const uint8_t pconfigIndex = i + P026_QUERY1_CONFIG_POS; + uint8_t choice = PCONFIG(pconfigIndex); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], Plugin_026_valuename(choice, false), @@ -104,10 +104,10 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string) { PCONFIG(0) = 0; // "Uptime" - for (byte i = 1; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 1; i < VARS_PER_TASK; ++i) { PCONFIG(i) = 11; // "None" } - PCONFIG(P026_SENSOR_TYPE_INDEX) = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); + PCONFIG(P026_SENSOR_TYPE_INDEX) = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); success = true; break; } @@ -118,7 +118,7 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string) int indices[P026_NR_OUTPUT_OPTIONS]; int index = 0; - for (byte option = 0; option < P026_NR_OUTPUT_OPTIONS; ++option) { + for (uint8_t option = 0; option < P026_NR_OUTPUT_OPTIONS; ++option) { if (option != 11) { options[index] = Plugin_026_valuename(option, true); indices[index] = option; @@ -129,8 +129,8 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string) options[index] = Plugin_026_valuename(11, true); indices[index] = 11; - for (byte i = 0; i < P026_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P026_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P026_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P026_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P026_NR_OUTPUT_OPTIONS, options, indices); } success = true; @@ -140,9 +140,9 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SAVE: { // Save output selector parameters. - for (byte i = 0; i < P026_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P026_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < P026_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P026_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, Plugin_026_valuename(choice, false)); } success = true; diff --git a/src/_P027_INA219.ino b/src/_P027_INA219.ino index 5abeddcc4..e435065b5 100644 --- a/src/_P027_INA219.ino +++ b/src/_P027_INA219.ino @@ -17,7 +17,7 @@ #define P027_I2C_ADDR (uint8_t)PCONFIG(1) -boolean Plugin_027(byte function, struct EventStruct *event, String& string) +boolean Plugin_027(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -63,7 +63,7 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { { - byte choiceMode = PCONFIG(0); + uint8_t choiceMode = PCONFIG(0); const __FlashStringHelper * optionsMode[3]; optionsMode[0] = F("32V, 2A"); optionsMode[1] = F("32V, 1A"); @@ -75,7 +75,7 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string) addFormSelector(F("Measure range"), F("p027_range"), 3, optionsMode, optionValuesMode, choiceMode); } { - byte choiceMeasureType = PCONFIG(2); + uint8_t choiceMeasureType = PCONFIG(2); const __FlashStringHelper * options[4] = { F("Voltage"), F("Current"), F("Power"), F("Voltage/Current/Power") }; addFormSelector(F("Measurement Type"), F("p027_measuretype"), 4, options, NULL, choiceMeasureType); } diff --git a/src/_P028_BME280.ino b/src/_P028_BME280.ino index 6e7f98f7f..ef3818151 100644 --- a/src/_P028_BME280.ino +++ b/src/_P028_BME280.ino @@ -17,7 +17,7 @@ #define PLUGIN_VALUENAME3_028 "Pressure" -boolean Plugin_028(byte function, struct EventStruct *event, String& string) +boolean Plugin_028(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P029_Output.ino b/src/_P029_Output.ino index 6baa36620..f71712442 100644 --- a/src/_P029_Output.ino +++ b/src/_P029_Output.ino @@ -9,7 +9,7 @@ #define PLUGIN_ID_029 29 #define PLUGIN_NAME_029 "Output - Domoticz MQTT Helper" #define PLUGIN_VALUENAME1_029 "Output" -boolean Plugin_029(byte function, struct EventStruct *event, String& string) +boolean Plugin_029(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -46,7 +46,7 @@ boolean Plugin_029(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { // We need the index of the controller we are: 0-CONTROLLER_MAX - byte controllerNr = 0; + uint8_t controllerNr = 0; for (controllerIndex_t i=0; i < CONTROLLER_MAX; i++) { // if (Settings.Protocol[i] == CPLUGIN_ID_002) { controllerNr = i; } -> error: 'CPLUGIN_ID_002' was not declared in this scope diff --git a/src/_P030_BMP280.ino b/src/_P030_BMP280.ino index 595e97ee2..c53468381 100644 --- a/src/_P030_BMP280.ino +++ b/src/_P030_BMP280.ino @@ -67,7 +67,7 @@ int32_t bmp280_t_fine; boolean Plugin_030_init[2] = { false, false }; -boolean Plugin_030(byte function, struct EventStruct *event, String& string) +boolean Plugin_030(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -104,7 +104,7 @@ boolean Plugin_030(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); /*String options[2] = { F("0x76 - default settings (SDO Low)"), F("0x77 - alternate settings (SDO HIGH)") };*/ int optionValues[2] = { 0x76, 0x77 }; diff --git a/src/_P031_SHT1X.ino b/src/_P031_SHT1X.ino index 32f856c0f..452d9ff4c 100644 --- a/src/_P031_SHT1X.ino +++ b/src/_P031_SHT1X.ino @@ -35,7 +35,7 @@ public: P031_data_struct() {} - byte init(byte data_pin, byte clock_pin, bool pullUp, byte clockdelay) { + uint8_t init(uint8_t data_pin, uint8_t clock_pin, bool pullUp, uint8_t clockdelay) { _dataPin = data_pin; _clockPin = clock_pin; _clockdelay = clockdelay; @@ -131,13 +131,13 @@ public: delay(11); } - byte readStatus() + uint8_t readStatus() { sendCommand(SHT1X_CMD_READ_STATUS); return readData(8); } - void sendCommand(const byte cmd) + void sendCommand(const uint8_t cmd) { sendCommandTime = millis(); pinMode(_dataPin, OUTPUT); @@ -181,7 +181,7 @@ public: int val = 0; if (bits == 16) { - // Read most significant byte + // Read most significant uint8_t val = p031_shiftIn(_dataPin, _clockPin, MSBFIRST); val <<= 8; @@ -195,7 +195,7 @@ public: pinMode(_dataPin, input_mode); } - // Read least significant byte + // Read least significant uint8_t val |= p031_shiftIn(_dataPin, _clockPin, MSBFIRST); // Keep DATA pin high to skip CRC @@ -247,15 +247,15 @@ public: unsigned long sendCommandTime = 0; int input_mode = 0; - byte _dataPin = 0; - byte _clockPin = 0; - byte state = P031_IDLE; - byte _clockdelay = 0; + uint8_t _dataPin = 0; + uint8_t _clockPin = 0; + uint8_t state = P031_IDLE; + uint8_t _clockdelay = 0; }; -boolean Plugin_031(byte function, struct EventStruct *event, String& string) +boolean Plugin_031(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -321,12 +321,12 @@ boolean Plugin_031(byte function, struct EventStruct *event, String& string) if (nullptr == P031_data) { return success; } - byte status = P031_data->init( + uint8_t status = P031_data->init( CONFIG_PIN1, CONFIG_PIN2, Settings.TaskDevicePin1PullUp[event->TaskIndex], PCONFIG(0)); if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { - String log = F("SHT1X : Status byte: "); + String log = F("SHT1X : Status uint8_t: "); log += String(status, HEX); log += F(" - resolution: "); log += ((status & 1) ? F("low") : F("high")); diff --git a/src/_P032_MS5611.ino b/src/_P032_MS5611.ino index 90c502b35..5c823d535 100644 --- a/src/_P032_MS5611.ino +++ b/src/_P032_MS5611.ino @@ -15,7 +15,7 @@ #define PLUGIN_VALUENAME1_032 "Temperature" #define PLUGIN_VALUENAME2_032 "Pressure" -boolean Plugin_032(byte function, struct EventStruct *event, String& string) +boolean Plugin_032(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -52,7 +52,7 @@ boolean Plugin_032(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); /*String options[2] = { F("0x77 - default I2C address"), F("0x76 - alternate I2C address") };*/ int optionValues[2] = { 0x77, 0x76 }; diff --git a/src/_P033_Dummy.ino b/src/_P033_Dummy.ino index b97397a78..7cb31a55e 100644 --- a/src/_P033_Dummy.ino +++ b/src/_P033_Dummy.ino @@ -9,7 +9,7 @@ # define PLUGIN_ID_033 33 # define PLUGIN_NAME_033 "Generic - Dummy Device" # define PLUGIN_VALUENAME1_033 "Dummy" -boolean Plugin_033(byte function, struct EventStruct *event, String& string) +boolean Plugin_033(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -66,7 +66,7 @@ boolean Plugin_033(byte function, struct EventStruct *event, String& string) event->sensorType = static_cast(PCONFIG(0)); if (loglevelActiveFor(LOG_LEVEL_INFO)) { - for (byte x = 0; x < getValueCountFromSensorType(static_cast(PCONFIG(0))); x++) + for (uint8_t x = 0; x < getValueCountFromSensorType(static_cast(PCONFIG(0))); x++) { String log = F("Dummy: value "); log += x + 1; diff --git a/src/_P034_DHT12.ino b/src/_P034_DHT12.ino index fcc7319ef..7f4b2fc7f 100644 --- a/src/_P034_DHT12.ino +++ b/src/_P034_DHT12.ino @@ -15,7 +15,7 @@ #define DHT12_I2C_ADDRESS 0x5C // I2C address for the sensor -boolean Plugin_034(byte function, struct EventStruct *event, String& string) +boolean Plugin_034(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -52,12 +52,12 @@ boolean Plugin_034(byte function, struct EventStruct *event, String& string) case PLUGIN_READ: { - byte dht_dat[5]; + uint8_t dht_dat[5]; - // byte dht_in; - byte i; + // uint8_t dht_in; + uint8_t i; - // byte Retry = 0; + // uint8_t Retry = 0; boolean error = false; Wire.beginTransmission(DHT12_I2C_ADDRESS); // start transmission to device @@ -76,7 +76,7 @@ boolean Plugin_034(byte function, struct EventStruct *event, String& string) if (!error) { // Checksum calculation is a Rollover Checksum by design! - byte dht_check_sum = dht_dat[0] + dht_dat[1] + dht_dat[2] + dht_dat[3]; // check check_sum + uint8_t dht_check_sum = dht_dat[0] + dht_dat[1] + dht_dat[2] + dht_dat[3]; // check check_sum if (dht_dat[4] == dht_check_sum) { diff --git a/src/_P035_IRTX.ino b/src/_P035_IRTX.ino index 6c2a17bb5..9d7f9022d 100644 --- a/src/_P035_IRTX.ino +++ b/src/_P035_IRTX.ino @@ -56,7 +56,7 @@ IRsend *Plugin_035_irSender = nullptr; #define P35_Ntimings 250 //Defines the ammount of timings that can be stored. Used in RAW and RAW2 encodings -boolean Plugin_035(byte function, struct EventStruct *event, String &command) +boolean Plugin_035(uint8_t function, struct EventStruct *event, String &command) { bool success = false; @@ -543,9 +543,9 @@ bool parseStringAndSendAirCon(const int irtype, const String str) // (The correct size, and a legacy shorter size.) // Guess which one we are being presented with based on the number of // hexadecimal digits provided. i.e. Zero-pad if you need to to get - // the correct length/byte size. + // the correct length/uint8_t size. // This should provide backward compatiblity with legacy messages. - stateSize = inputLength / 2; // Every two hex chars is a byte. + stateSize = inputLength / 2; // Every two hex chars is a uint8_t. // Use at least the minimum size. stateSize = std::max(stateSize, kDaikinStateLengthShort); // If we think it isn't a "short" message. @@ -559,8 +559,8 @@ bool parseStringAndSendAirCon(const int irtype, const String str) // Fujitsu has four distinct & different size states, so make a best guess // which one we are being presented with based on the number of // hexadecimal digits provided. i.e. Zero-pad if you need to to get - // the correct length/byte size. - stateSize = inputLength / 2; // Every two hex chars is a byte. + // the correct length/uint8_t size. + stateSize = inputLength / 2; // Every two hex chars is a uint8_t. // Use at least the minimum size. stateSize = std::max(stateSize, (uint16_t) (kFujitsuAcStateLengthShort - 1)); @@ -575,8 +575,8 @@ bool parseStringAndSendAirCon(const int irtype, const String str) // HitachiAc3 has two distinct & different size states, so make a best // guess which one we are being presented with based on the number of // hexadecimal digits provided. i.e. Zero-pad if you need to to get - // the correct length/byte size. - stateSize = inputLength / 2; // Every two hex chars is a byte. + // the correct length/uint8_t size. + stateSize = inputLength / 2; // Every two hex chars is a uint8_t. // Use at least the minimum size. stateSize = std::max(stateSize, (uint16_t) (kHitachiAc3MinStateLength)); @@ -592,8 +592,8 @@ bool parseStringAndSendAirCon(const int irtype, const String str) // MWM has variable size states, so make a best guess // which one we are being presented with based on the number of // hexadecimal digits provided. i.e. Zero-pad if you need to to get - // the correct length/byte size. - stateSize = inputLength / 2; // Every two hex chars is a byte. + // the correct length/uint8_t size. + stateSize = inputLength / 2; // Every two hex chars is a uint8_t. // Use at least the minimum size. stateSize = std::max(stateSize, (uint16_t) 3); // Cap the maximum size. @@ -603,8 +603,8 @@ bool parseStringAndSendAirCon(const int irtype, const String str) // Samsung has two distinct & different size states, so make a best guess // which one we are being presented with based on the number of // hexadecimal digits provided. i.e. Zero-pad if you need to to get - // the correct length/byte size. - stateSize = inputLength / 2; // Every two hex chars is a byte. + // the correct length/uint8_t size. + stateSize = inputLength / 2; // Every two hex chars is a uint8_t. // Use at least the minimum size. stateSize = std::max(stateSize, (uint16_t) (kSamsungAcStateLength)); // If we think it isn't a "normal" message. @@ -630,7 +630,7 @@ bool parseStringAndSendAirCon(const int irtype, const String str) return false; } - // Ptr to the least significant byte of the resulting state for this protocol. + // Ptr to the least significant uint8_t of the resulting state for this protocol. uint8_t *statePtr = &state[stateSize - 1]; // Convert the string into a state array of the correct length. @@ -652,12 +652,12 @@ bool parseStringAndSendAirCon(const int irtype, const String str) return false; } if (i % 2 == 1) - { // Odd: Upper half of the byte. + { // Odd: Upper half of the uint8_t. *statePtr += (c << 4); - statePtr--; // Advance up to the next least significant byte of state. + statePtr--; // Advance up to the next least significant uint8_t of state. } else - { // Even: Lower half of the byte. + { // Even: Lower half of the uint8_t. *statePtr = c; } } diff --git a/src/_P036_FrameOLED.ino b/src/_P036_FrameOLED.ino index 2508b7824..fbfec5c3b 100644 --- a/src/_P036_FrameOLED.ino +++ b/src/_P036_FrameOLED.ino @@ -59,7 +59,7 @@ // CHG: Using a calculation to reduce line content for scrolling pages instead of a while loop // CHG: Using SetBit and GetBit functions to change the content of PCONFIG_LONG(0) // CHG: Memory usage reduced (only P036_DisplayLinesV1 is now used) -// CHG: using uint8_t and uint16_t instead of byte and word +// CHG: using uint8_t and uint16_t instead of uint8_t and word // @uwekaditz: 2019-11-17 // CHG: commands for P036 // 1. Display commands: oledframedcmd display [on, off, low, med, high] diff --git a/src/_P037_MQTTImport.ino b/src/_P037_MQTTImport.ino index 1dc684aa7..59f94ae93 100644 --- a/src/_P037_MQTTImport.ino +++ b/src/_P037_MQTTImport.ino @@ -27,7 +27,7 @@ #define PLUGIN_VALUENAME4_037 "Value4" -boolean Plugin_037(byte function, struct EventStruct *event, String& string) +boolean Plugin_037(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -67,9 +67,9 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { char deviceTemplate[VARS_PER_TASK][41]; // variable for saving the subscription topics - LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t*)&deviceTemplate, sizeof(deviceTemplate)); - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { addFormTextBox(String(F("MQTT Topic ")) + (varNr + 1), String(F("p037_template")) + (varNr + 1), deviceTemplate[varNr], 40); @@ -82,7 +82,7 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string) { String error; char deviceTemplate[VARS_PER_TASK][41]; // variable for saving the subscription topics - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { String argName = F("p037_template"); argName += varNr + 1; @@ -94,7 +94,7 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string) addHtmlError(error); } - SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + SaveCustomTaskSettings(event->TaskIndex, (uint8_t*)&deviceTemplate, sizeof(deviceTemplate)); success = true; break; @@ -148,9 +148,9 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string) char deviceTemplate[VARS_PER_TASK][41]; // variable for saving the subscription topics LoadTaskSettings(event->TaskIndex); - LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t*)&deviceTemplate, sizeof(deviceTemplate)); - for (byte x = 0; x < VARS_PER_TASK; x++) + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { String subscriptionTopic = deviceTemplate[x]; subscriptionTopic.trim(); @@ -220,10 +220,10 @@ bool MQTTSubscribe_037(struct EventStruct *event) { // We must subscribe to the topics. char deviceTemplate[VARS_PER_TASK][41]; // variable for saving the subscription topics - LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t*)&deviceTemplate, sizeof(deviceTemplate)); // Now loop over all import variables and subscribe to those that are not blank - for (byte x = 0; x < VARS_PER_TASK; x++) + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { String subscribeTo = deviceTemplate[x]; diff --git a/src/_P038_NeoPixel.ino b/src/_P038_NeoPixel.ino index 2cac76039..bee1239d1 100644 --- a/src/_P038_NeoPixel.ino +++ b/src/_P038_NeoPixel.ino @@ -40,7 +40,7 @@ Adafruit_NeoPixel *Plugin_038_pixels; int MaxPixels = 0; -boolean Plugin_038(byte function, struct EventStruct *event, String& string) +boolean Plugin_038(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -96,7 +96,7 @@ boolean Plugin_038(byte function, struct EventStruct *event, String& string) { if (!Plugin_038_pixels) { - byte striptype = PCONFIG(1); + uint8_t striptype = PCONFIG(1); if (striptype == 1) Plugin_038_pixels = new Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRB + NEO_KHZ800); else if (striptype == 2) diff --git a/src/_P039_Thermosensors.ino b/src/_P039_Thermosensors.ino index 8adaedbf4..d43796aae 100644 --- a/src/_P039_Thermosensors.ino +++ b/src/_P039_Thermosensors.ino @@ -233,7 +233,7 @@ #define LM7x_CONV_RDY 0x02u -boolean Plugin_039(byte function, struct EventStruct *event, String& string) +boolean Plugin_039(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -417,7 +417,7 @@ boolean Plugin_039(byte function, struct EventStruct *event, String& string) addFormSubHeader(F("Sensor Family Selection")); } - const byte family = P039_FAM_TYPE; + const uint8_t family = P039_FAM_TYPE; { const __FlashStringHelper * Foptions[2] = {F("Thermocouple"), F("RTD")}; const int FoptionValues[2] = {P039_TC, P039_RTD}; @@ -425,7 +425,7 @@ boolean Plugin_039(byte function, struct EventStruct *event, String& string) addFormNote(F("Set sensor family of connected sensor - thermocouple or RTD.")); } - const byte choice = P039_MAX_TYPE; + const uint8_t choice = P039_MAX_TYPE; if (family == P039_TC){ @@ -578,7 +578,7 @@ boolean Plugin_039(byte function, struct EventStruct *event, String& string) // Get the MAX Type (6675 / 31855 / 31856) - byte MaxType = P039_MAX_TYPE; + uint8_t MaxType = P039_MAX_TYPE; float Plugin_039_Celsius = NAN; @@ -651,7 +651,7 @@ boolean Plugin_039(byte function, struct EventStruct *event, String& string) uint8_t CS_pin_no = get_SPI_CS_Pin(event); // Get the MAX Type (6675 / 31855 / 31856) - byte MaxType = P039_MAX_TYPE; + uint8_t MaxType = P039_MAX_TYPE; switch (MaxType) { @@ -1027,7 +1027,7 @@ float readMax31856(struct EventStruct *event) // "transfer" 0x0 starting at address 0x00 and read the all registers from the Chip transfer_n_ByteSPI(CS_pin_no, (MAX31856_NO_REG + 1), &messageBuffer[0]); - // transfer data from messageBuffer and get rid of initial address byte + // transfer data from messageBuffer and get rid of initial address uint8_t for (uint8_t i = 0u; i < MAX31856_NO_REG; ++i) { registers[i] = messageBuffer[i+1]; } diff --git a/src/_P040_ID12.ino b/src/_P040_ID12.ino index 648c22012..7d20dfed9 100644 --- a/src/_P040_ID12.ino +++ b/src/_P040_ID12.ino @@ -13,7 +13,7 @@ boolean Plugin_040_init = false; -boolean Plugin_040(byte function, struct EventStruct *event, String& string) +boolean Plugin_040(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -71,11 +71,11 @@ boolean Plugin_040(byte function, struct EventStruct *event, String& string) { if (Plugin_040_init) { - byte val = 0; - byte code[6]; - byte checksum = 0; - byte bytesread = 0; - byte tempbyte = 0; + uint8_t val = 0; + uint8_t code[6]; + uint8_t checksum = 0; + uint8_t bytesread = 0; + uint8_t tempbyte = 0; if ((val = Serial.read()) == 2) { // check for header @@ -96,13 +96,13 @@ boolean Plugin_040(byte function, struct EventStruct *event, String& string) val = 10 + val - 'A'; } - // Every two hex-digits, add byte to code: + // Every two hex-digits, add uint8_t to code: if ( (bytesread & 1) == 1) { // make some space for this hex-digit by // shifting the previous hex-digit with 4 bits to the left: code[bytesread >> 1] = (val | (tempbyte << 4)); - if (bytesread >> 1 != 5) { // If we're at the checksum byte, + if (bytesread >> 1 != 5) { // If we're at the checksum uint8_t, checksum ^= code[bytesread >> 1]; // Calculate the checksum... (XOR) }; } @@ -136,7 +136,7 @@ boolean Plugin_040(byte function, struct EventStruct *event, String& string) unsigned long key = 0, old_key = 0; old_key = UserVar.getSensorTypeLong(event->TaskIndex); - for (byte i = 1; i < 5; i++) key = key | (((unsigned long) code[i] << ((4 - i) * 8))); + for (uint8_t i = 1; i < 5; i++) key = key | (((unsigned long) code[i] << ((4 - i) * 8))); bool new_key = false; if (old_key != key) { UserVar.setSensorTypeLong(event->TaskIndex, key); diff --git a/src/_P041_NeoClock.ino b/src/_P041_NeoClock.ino index 7e9bd1db0..f0cd6f45c 100644 --- a/src/_P041_NeoClock.ino +++ b/src/_P041_NeoClock.ino @@ -8,9 +8,9 @@ #define NUM_LEDS 114 -byte Plugin_041_red = 0; -byte Plugin_041_green = 0; -byte Plugin_041_blue = 0; +uint8_t Plugin_041_red = 0; +uint8_t Plugin_041_green = 0; +uint8_t Plugin_041_blue = 0; Adafruit_NeoPixel *Plugin_041_pixels; @@ -18,7 +18,7 @@ Adafruit_NeoPixel *Plugin_041_pixels; #define PLUGIN_ID_041 41 #define PLUGIN_NAME_041 "Output - NeoPixel (Word Clock)" #define PLUGIN_VALUENAME1_041 "Clock" -boolean Plugin_041(byte function, struct EventStruct *event, String& string) +boolean Plugin_041(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -151,8 +151,8 @@ boolean Plugin_041(byte function, struct EventStruct *event, String& string) void Plugin_041_update() { - byte Hours = node_time.hour(); - byte Minutes = node_time.minute(); + uint8_t Hours = node_time.hour(); + uint8_t Minutes = node_time.minute(); resetAndBlack(); timeToStrip(Hours, Minutes); Plugin_041_pixels->show(); // This sends the updated pixel color to the hardware. diff --git a/src/_P042_Candle.ino b/src/_P042_Candle.ino index e44bb2005..8ab5323d6 100644 --- a/src/_P042_Candle.ino +++ b/src/_P042_Candle.ino @@ -76,10 +76,10 @@ enum ColorType { ColorSelected }; -byte Candle_red = 0; -byte Candle_green = 0; -byte Candle_blue = 0; -byte Candle_bright = 128; +uint8_t Candle_red = 0; +uint8_t Candle_green = 0; +uint8_t Candle_blue = 0; +uint8_t Candle_bright = 128; SimType Candle_type = TypeSimpleCandle; ColorType Candle_color = ColorDefault; @@ -98,7 +98,7 @@ Adafruit_NeoPixel *Candle_pixels; #define PLUGIN_VALUENAME2_042 "Brightness" #define PLUGIN_VALUENAME3_042 "Type" -boolean Plugin_042(byte function, struct EventStruct *event, String& string) +boolean Plugin_042(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -158,7 +158,7 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string) options[6] = F("Strobe"); options[7] = F("Color Fader"); - byte choice = PCONFIG(4); + uint8_t choice = PCONFIG(4); if (choice > sizeof(options) - 1) { choice = 2; @@ -440,9 +440,9 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string) if (!val_Color.isEmpty()) { long number = strtol( &val_Color[0], NULL, 16); // Split RGB to r, g, b values - byte r = number >> 16; - byte g = number >> 8 & 0xFF; - byte b = number & 0xFF; + uint8_t r = number >> 16; + uint8_t g = number >> 8 & 0xFF; + uint8_t b = number & 0xFF; PCONFIG(0) = r; // R PCONFIG(1) = g; // G @@ -642,7 +642,7 @@ void type_ColorFader() { } // Calc HSV - // void RGBtoHSV(byte r, byte g, byte b, double hsv[3]) + // void RGBtoHSV(uint8_t r, uint8_t g, uint8_t b, double hsv[3]) RGBtoHSV(Candle_red, Candle_green, Candle_blue, hsv); // Calc RGB with new V @@ -719,7 +719,7 @@ void HSVtoRGB(int hue, int sat, int val, int colors[3]) { } // Convert RGB Color to HSV Color -void RGBtoHSV(byte r, byte g, byte b, double hsv[3]) { +void RGBtoHSV(uint8_t r, uint8_t g, uint8_t b, double hsv[3]) { double rd = (double) r/255; double gd = (double) g/255; double bd = (double) b/255; diff --git a/src/_P043_ClkOutput.ino b/src/_P043_ClkOutput.ino index 5b89cb0c7..a8491564e 100644 --- a/src/_P043_ClkOutput.ino +++ b/src/_P043_ClkOutput.ino @@ -12,7 +12,7 @@ #define PLUGIN_VALUENAME1_043 "Output" #define PLUGIN_043_MAX_SETTINGS 8 -boolean Plugin_043(byte function, struct EventStruct *event, String& string) +boolean Plugin_043(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -58,7 +58,7 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string) options[1] = F("Off"); options[2] = F("On"); - for (byte x = 0; x < PLUGIN_043_MAX_SETTINGS; x++) + for (uint8_t x = 0; x < PLUGIN_043_MAX_SETTINGS; x++) { addFormTextBox(String(F("Day,Time ")) + (x + 1), String(F("p043_clock")) + (x), timeLong2String(ExtraTaskSettings.TaskDevicePluginConfigLong[x]), 32); // addHtml(F("Day,Time ")); @@ -70,7 +70,7 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string) // addHtml("'>"); addHtml(' '); - byte choice = ExtraTaskSettings.TaskDevicePluginConfig[x]; + uint8_t choice = ExtraTaskSettings.TaskDevicePluginConfig[x]; addSelector(String(F("p043_state")) + (x), 3, options, NULL, NULL, choice); } success = true; @@ -79,7 +79,7 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SAVE: { - for (byte x = 0; x < PLUGIN_043_MAX_SETTINGS; x++) + for (uint8_t x = 0; x < PLUGIN_043_MAX_SETTINGS; x++) { String argc = F("p043_clock"); argc += x; @@ -104,14 +104,14 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string) case PLUGIN_CLOCK_IN: { LoadTaskSettings(event->TaskIndex); - for (byte x = 0; x < PLUGIN_043_MAX_SETTINGS; x++) + for (uint8_t x = 0; x < PLUGIN_043_MAX_SETTINGS; x++) { unsigned long clockEvent = (unsigned long)node_time.minute() % 10 | (unsigned long)(node_time.minute() / 10) << 4 | (unsigned long)(node_time.hour() % 10) << 8 | (unsigned long)(node_time.hour() / 10) << 12 | (unsigned long)node_time.weekday() << 16; unsigned long clockSet = ExtraTaskSettings.TaskDevicePluginConfigLong[x]; if (matchClockEvent(clockEvent,clockSet)) { - byte state = ExtraTaskSettings.TaskDevicePluginConfig[x]; + uint8_t state = ExtraTaskSettings.TaskDevicePluginConfig[x]; if (state != 0) { state--; diff --git a/src/_P044_P1WifiGateway.ino b/src/_P044_P1WifiGateway.ino index 8e77639e1..fd72bd335 100644 --- a/src/_P044_P1WifiGateway.ino +++ b/src/_P044_P1WifiGateway.ino @@ -28,7 +28,7 @@ -boolean Plugin_044(byte function, struct EventStruct *event, String& string) +boolean Plugin_044(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -56,7 +56,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string) addFormNumericBox(F("TCP Port"), F("p044_port"), P044_WIFI_SERVER_PORT, 0); addFormNumericBox(F("Baud Rate"), F("p044_baud"), P044_BAUDRATE, 0); - byte serialConfChoice = serialHelper_convertOldSerialConfig(P044_SERIAL_CONFIG); + uint8_t serialConfChoice = serialHelper_convertOldSerialConfig(P044_SERIAL_CONFIG); serialHelper_serialconfig_webformLoad(event, serialConfChoice); // FIXME TD-er: Why isn't this using the normal pin selection functions? @@ -108,7 +108,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string) int txPin; // FIXME TD-er: Must use proper pin settings and standard ESPEasySerial wrapper ESPeasySerialType::getSerialTypePins(ESPEasySerialPort::serial0, rxPin, txPin); - byte serialconfig = serialHelper_convertOldSerialConfig(P044_SERIAL_CONFIG); + uint8_t serialconfig = serialHelper_convertOldSerialConfig(P044_SERIAL_CONFIG); task->serialBegin(ESPEasySerialPort::not_set, rxPin, txPin, P044_BAUDRATE, serialconfig); task->startServer(P044_WIFI_SERVER_PORT); diff --git a/src/_P045_MPU6050.ino b/src/_P045_MPU6050.ino index ea63e6dc7..fa8c499a8 100644 --- a/src/_P045_MPU6050.ino +++ b/src/_P045_MPU6050.ino @@ -72,7 +72,7 @@ #define PLUGIN_VALUENAME1_045 "" -boolean Plugin_045(byte function, struct EventStruct *event, String& string) +boolean Plugin_045(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -104,7 +104,7 @@ boolean Plugin_045(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); // Setup webform for address selection @@ -123,7 +123,7 @@ boolean Plugin_045(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte choice = PCONFIG(1); + uint8_t choice = PCONFIG(1); { const __FlashStringHelper * options[10]; options[0] = F("Movement detection"); @@ -236,9 +236,9 @@ boolean Plugin_045(byte function, struct EventStruct *event, String& string) { // Check if all (enabled, so !=0) thresholds are exceeded, if one fails then thresexceed (thesholds exceeded) is reset to false; boolean thresexceed = true; - byte count = 0; // Counter to check if not all thresholdvalues are set to 0 or disabled + uint8_t count = 0; // Counter to check if not all thresholdvalues are set to 0 or disabled - for (byte i = 0; i < 3; i++) + for (uint8_t i = 0; i < 3; i++) { // for each axis: if (PCONFIG(i + 2) != 0) { // not disabled, check threshold diff --git a/src/_P046_VentusW266.ino b/src/_P046_VentusW266.ino index b40da02bf..a694922ea 100644 --- a/src/_P046_VentusW266.ino +++ b/src/_P046_VentusW266.ino @@ -52,14 +52,14 @@ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 // hh=header > This is actually not part of the real payload but a wanted artifact of the sniffing method. // hh=humidity (bcd) > Humidity is bcd encoded -// tlth=temperature-low/temphigh (*10) > Temperature is stored as a 16bit integer holding the temperature in Celsius * 10 but low byte first. -// b=battery (1=low) > This byte is 00 but 01 when the battery of the transmitter runs low +// tlth=temperature-low/temphigh (*10) > Temperature is stored as a 16bit integer holding the temperature in Celsius * 10 but low uint8_t first. +// b=battery (1=low) > This uint8_t is 00 but 01 when the battery of the transmitter runs low // wb=bearing (cw0-15) > The windbearing in 16 clockwise steps (0 = north, 4 = east, 8 = south and C = west) -// alah=windaverage-low/high (m/s/2) > A 16 bit int holding the wind avarage in m/s * 2, low byte first -// rlrh=rainfall-low/high (1/4mm) > A 16 bit int holding the wind gust in m/s * 2, low byte first +// alah=windaverage-low/high (m/s/2) > A 16 bit int holding the wind avarage in m/s * 2, low uint8_t first +// rlrh=rainfall-low/high (1/4mm) > A 16 bit int holding the wind gust in m/s * 2, low uint8_t first // uv=uvindex (*10) > The UV value * 10 // ld=lightningstorm-distance (km, 3F is max) > The distance to the stormfront in km -// lllh=strikecount-low/high (#) > A 16 bit integer holding the number of detected lightning strikes, low byte first +// lllh=strikecount-low/high (#) > A 16 bit integer holding the number of detected lightning strikes, low uint8_t first // crc > poly 0x31, init 0xff, revin&revout, xorout 0x00. Like Maxim 1-wire but with a 0xff initvalue. Crc is calculated over bytes 1-22 // Events: @@ -91,7 +91,7 @@ #define PLUGIN_VALUENAME2_046 "" #define PLUGIN_VALUENAME3_046 "" -#define Plugin_046_MagicByte 0x7F // When we read this byte on MOSI, switch to MISO +#define Plugin_046_MagicByte 0x7F // When we read this uint8_t on MOSI, switch to MISO #define Plugin_046_RAW_BUFFER_SIZE 24 // Payload is 23 bytes, added space for header #define Plugin_046_Payload 23 @@ -101,15 +101,15 @@ struct P046_data_struct { int8_t Plugin_046_nSELpin = -1; int8_t Plugin_046_MISOpin = -1; // Vars used in data collection: - byte Plugin_046_ISR_Buffer[Plugin_046_RAW_BUFFER_SIZE]; // Buffer used in ISR routine - //Test data: volatile byte Plugin_046_databuffer[] = {0x7F, 0x98, 0x33, 0x1A, 0xB0, 0x00, 0x00, 0xB0, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x3F, 0x8A, 0x25, 0x00, 0x49, 0x00}; // Buffer used by other instances - byte Plugin_046_databuffer[Plugin_046_RAW_BUFFER_SIZE]; // Buffer used by other instances + uint8_t Plugin_046_ISR_Buffer[Plugin_046_RAW_BUFFER_SIZE]; // Buffer used in ISR routine + //Test data: volatile uint8_t Plugin_046_databuffer[] = {0x7F, 0x98, 0x33, 0x1A, 0xB0, 0x00, 0x00, 0xB0, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x3F, 0x8A, 0x25, 0x00, 0x49, 0x00}; // Buffer used by other instances + uint8_t Plugin_046_databuffer[Plugin_046_RAW_BUFFER_SIZE]; // Buffer used by other instances bool Plugin_046_ReceiveActive = false; // Active session in progress bool Plugin_046_MasterSlave = false; // Which pin o read? false=MOSI, true=MISO bool Plugin_046_newData = false; // "Valid" data ready, please process - byte Plugin_046_bitpointer; // Pointer for received bit - byte Plugin_046_bytepointer; // Pointer for ISR receive buffer - byte Plugin_046_receivedData; // Byte to store received bits + uint8_t Plugin_046_bitpointer; // Pointer for received bit + uint8_t Plugin_046_bytepointer; // Pointer for ISR receive buffer + uint8_t Plugin_046_receivedData; // Byte to store received bits }; @@ -130,7 +130,7 @@ volatile int Plugin_046_strikesph = 0; void Plugin_046_ISR_nSEL() ICACHE_RAM_ATTR; // Interrupt routines void Plugin_046_ISR_SCLK() ICACHE_RAM_ATTR; -boolean Plugin_046(byte function, struct EventStruct *event, String& string) +boolean Plugin_046(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -152,9 +152,9 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); { - const byte nrchoices = 9; + const uint8_t nrchoices = 9; const __FlashStringHelper * options[nrchoices]; options[0] = F("Main + Temp/Hygro"); options[1] = F("Wind"); @@ -163,9 +163,9 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string) options[4] = F("Lightning strikes"); options[5] = F("Lightning distance"); - options[6] = F("Unknown 1, byte 6"); - options[7] = F("Unknown 2, byte 16"); - options[8] = F("Unknown 3, byte 19"); + options[6] = F("Unknown 1, uint8_t 6"); + options[7] = F("Unknown 2, uint8_t 16"); + options[8] = F("Unknown 3, uint8_t 19"); addFormSelector(F("Plugin function"), F("p046"), nrchoices, options, NULL, choice); } @@ -282,7 +282,7 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string) P046_data = new P046_data_struct(); } - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); switch (choice) { case (0): @@ -373,7 +373,7 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string) if (P046_data->Plugin_046_databuffer[0] == Plugin_046_MagicByte) // buffer[0] should be the MagicByte if valid { UserVar[event->BaseVarIndex + 1] = 0; - byte choice = PCONFIG(0); // Which instance? + uint8_t choice = PCONFIG(0); // Which instance? switch (choice) { case (0): @@ -381,7 +381,7 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string) int myTemp = int((P046_data->Plugin_046_databuffer[5] * 256) + P046_data->Plugin_046_databuffer[4]); if (myTemp > 0x8000) { myTemp |= 0xffff0000; } // int @ esp8266 = 32 bits! float temperature = float(myTemp) / 10.0f; // Temperature - byte myHum = (P046_data->Plugin_046_databuffer[2] >> 4) * 10 + (P046_data->Plugin_046_databuffer[2] & 0x0f); + uint8_t myHum = (P046_data->Plugin_046_databuffer[2] >> 4) * 10 + (P046_data->Plugin_046_databuffer[2] & 0x0f); float humidity = float(myHum); UserVar[event->BaseVarIndex] = temperature; UserVar[event->BaseVarIndex + 1] = humidity; @@ -516,7 +516,7 @@ void Plugin_046_ISR_SCLK() // Interrupt on P046_data->Plugin_046_MasterSlave = true; } P046_data->Plugin_046_ISR_Buffer[P046_data->Plugin_046_bytepointer] = P046_data->Plugin_046_receivedData; - P046_data->Plugin_046_bytepointer++; // TReady for the next byte ... + P046_data->Plugin_046_bytepointer++; // TReady for the next uint8_t ... if (P046_data->Plugin_046_bytepointer > Plugin_046_RAW_BUFFER_SIZE) { P046_data->Plugin_046_ReceiveActive = false; // We don't want a bufferoverflow, so abort P046_data->Plugin_046_MasterSlave = false; diff --git a/src/_P047_i2c-soil-moisture-sensor.ino b/src/_P047_i2c-soil-moisture-sensor.ino index 42fadd28a..3034c5e5f 100644 --- a/src/_P047_i2c-soil-moisture-sensor.ino +++ b/src/_P047_i2c-soil-moisture-sensor.ino @@ -24,8 +24,8 @@ // Soil Moisture Sensor Register Addresses #define SOILMOISTURESENSOR_GET_CAPACITANCE 0x00 // (r) 2 bytes -#define SOILMOISTURESENSOR_SET_ADDRESS 0x01 // (w) 1 byte -#define SOILMOISTURESENSOR_GET_ADDRESS 0x02 // (r) 1 byte +#define SOILMOISTURESENSOR_SET_ADDRESS 0x01 // (w) 1 uint8_t +#define SOILMOISTURESENSOR_GET_ADDRESS 0x02 // (r) 1 uint8_t #define SOILMOISTURESENSOR_MEASURE_LIGHT 0x03 // (w) n/a #define SOILMOISTURESENSOR_GET_LIGHT 0x04 // (r) 2 bytes #define SOILMOISTURESENSOR_GET_TEMPERATURE 0x05 // (r) 2 bytes @@ -41,7 +41,7 @@ #define P047_CHANGE_ADDR PCONFIG(4) -boolean Plugin_047(byte function, struct EventStruct *event, String& string) +boolean Plugin_047(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -221,7 +221,7 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string) // **************************************************************************/ // Read temperature // **************************************************************************/ -float Plugin_047_readTemperature(byte i2cAddr) +float Plugin_047_readTemperature(uint8_t i2cAddr) { return I2C_readS16_reg(i2cAddr, SOILMOISTURESENSOR_GET_TEMPERATURE); } @@ -229,19 +229,19 @@ float Plugin_047_readTemperature(byte i2cAddr) // **************************************************************************/ // Read light // **************************************************************************/ -float Plugin_047_readLight(byte i2cAddr) { +float Plugin_047_readLight(uint8_t i2cAddr) { return I2C_read16_reg(i2cAddr, SOILMOISTURESENSOR_GET_LIGHT); } // **************************************************************************/ // Read moisture // **************************************************************************/ -unsigned int Plugin_047_readMoisture(byte i2cAddr) { +unsigned int Plugin_047_readMoisture(uint8_t i2cAddr) { return I2C_read16_reg(i2cAddr, SOILMOISTURESENSOR_GET_CAPACITANCE); } // Read Sensor Version -uint8_t Plugin_047_getVersion(byte i2cAddr) { +uint8_t Plugin_047_getVersion(uint8_t i2cAddr) { return I2C_read8_reg(i2cAddr, SOILMOISTURESENSOR_GET_VERSION); } @@ -251,7 +251,7 @@ uint8_t Plugin_047_getVersion(byte i2cAddr) { * effective if second parameter is true. * * Method returns true if the new address is set successfully on sensor.* *----------------------------------------------------------------------*/ -bool Plugin_047_setAddress(byte i2cAddr, int new_i2cAddr) { +bool Plugin_047_setAddress(uint8_t i2cAddr, int new_i2cAddr) { I2C_write8_reg(i2cAddr, SOILMOISTURESENSOR_SET_ADDRESS, new_i2cAddr); I2C_write8_reg(i2cAddr, SOILMOISTURESENSOR_SET_ADDRESS, new_i2cAddr); I2C_write8(i2cAddr, SOILMOISTURESENSOR_RESET); diff --git a/src/_P048_Motorshield_v2.ino b/src/_P048_Motorshield_v2.ino index 0a5a18ff5..b2ef65a27 100644 --- a/src/_P048_Motorshield_v2.ino +++ b/src/_P048_Motorshield_v2.ino @@ -24,7 +24,7 @@ #define Plugin_048_MotorStepsPerRevolution PCONFIG(1) #define Plugin_048_StepperSpeed PCONFIG(2) -boolean Plugin_048(byte function, struct EventStruct *event, String& string) { +boolean Plugin_048(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; Adafruit_MotorShield AFMS; @@ -144,7 +144,7 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) { if (param3.equalsIgnoreCase(F("Forward"))) { - byte speed = 255; + uint8_t speed = 255; if (param4_is_int && (p4_int >= 0) && (p4_int <= 255)) { speed = p4_int; @@ -164,7 +164,7 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) { if (param3.equalsIgnoreCase(F("Backward"))) { - byte speed = 255; + uint8_t speed = 255; if (param4_is_int && (p4_int >= 0) && (p4_int <= 255)) { speed = p4_int; diff --git a/src/_P049_MHZ19.ino b/src/_P049_MHZ19.ino index 2ec748daf..f3cbd4a62 100644 --- a/src/_P049_MHZ19.ino +++ b/src/_P049_MHZ19.ino @@ -51,7 +51,7 @@ enum MHZ19Types { }; -enum mhzCommands : byte { mhzCmdReadPPM, +enum mhzCommands : uint8_t { mhzCmdReadPPM, mhzCmdCalibrateZero, mhzCmdABCEnable, mhzCmdABCDisable, @@ -64,14 +64,14 @@ enum mhzCommands : byte { mhzCmdReadPPM, #endif // ifdef ENABLE_DETECTION_RANGE_COMMANDS }; -// 9 byte commands: +// 9 uint8_t commands: // mhzCmdReadPPM[] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79}; // mhzCmdCalibrateZero[] = {0xFF,0x01,0x87,0x00,0x00,0x00,0x00,0x00,0x78}; // mhzCmdABCEnable[] = {0xFF,0x01,0x79,0xA0,0x00,0x00,0x00,0x00,0xE6}; // mhzCmdABCDisable[] = {0xFF,0x01,0x79,0x00,0x00,0x00,0x00,0x00,0x86}; // mhzCmdReset[] = {0xFF,0x01,0x8d,0x00,0x00,0x00,0x00,0x00,0x72}; -/* It seems the offsets [3]..[4] for the detection range setting (command byte 0x99) are wrong in the latest +/* It seems the offsets [3]..[4] for the detection range setting (command uint8_t 0x99) are wrong in the latest * online data sheet: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf * According to the MH-Z19B datasheet version 1.2, valid from: 2017.03.22 (received 2018-03-07) * the offset should be [6]..[7] instead. @@ -96,7 +96,7 @@ enum mhzCommands : byte { mhzCmdReadPPM, // mhzCmdMeasurementRange3000[] = {0xFF,0x01,0x99,0x00,0x00,0x00,0x0B,0xB8,0xA3}; // mhzCmdMeasurementRange5000[] = {0xFF,0x01,0x99,0x00,0x00,0x00,0x13,0x88,0xCB}; // Removing redundant data, just keeping offsets [2], [6]..[7]: -const PROGMEM byte mhzCmdData[][3] = { +const PROGMEM uint8_t mhzCmdData[][3] = { { 0x86, 0x00, 0x00 }, { 0x87, 0x00, 0x00 }, { 0x79, 0xA0, 0x00 }, @@ -179,22 +179,22 @@ struct P049_data_struct : public PluginTaskData_base { } } - byte calculateChecksum() const { - byte checksum = 0; + uint8_t calculateChecksum() const { + uint8_t checksum = 0; - for (byte i = 1; i < 8; i++) { + for (uint8_t i = 1; i < 8; i++) { checksum += mhzResp[i]; } checksum = 0xFF - checksum; return checksum + 1; } - size_t send_mhzCmd(byte CommandId) + size_t send_mhzCmd(uint8_t CommandId) { if (!isInitialized()) { return 0; } // The receive buffer "mhzResp" is re-used to send a command here: - mhzResp[0] = 0xFF; // Start byte, fixed + mhzResp[0] = 0xFF; // Start uint8_t, fixed mhzResp[1] = 0x01; // Sensor number, 0x01 by default memcpy_P(&mhzResp[2], mhzCmdData[CommandId], sizeof(mhzCmdData[0])); mhzResp[6] = mhzResp[3]; mhzResp[7] = mhzResp[4]; @@ -213,7 +213,7 @@ struct P049_data_struct : public PluginTaskData_base { if (!isInitialized()) { return false; } // send read PPM command - byte nbBytesSent = send_mhzCmd(mhzCmdReadPPM); + uint8_t nbBytesSent = send_mhzCmd(mhzCmdReadPPM); if (nbBytesSent != 9) { return false; @@ -227,7 +227,7 @@ struct P049_data_struct : public PluginTaskData_base { while (!timeOutReached(timer) && (counter < 9)) { if (easySerial->available() > 0) { - byte value = easySerial->read(); + uint8_t value = easySerial->read(); if (((counter == 0) && (value == 0xFF)) || (counter > 0)) { mhzResp[counter++] = value; @@ -287,7 +287,7 @@ struct P049_data_struct : public PluginTaskData_base { ++nrUnknownResponses; return false; } - byte checksum = calculateChecksum(); + uint8_t checksum = calculateChecksum(); return mhzResp[8] == checksum; } ++nrUnknownResponses; @@ -320,7 +320,7 @@ struct P049_data_struct : public PluginTaskData_base { unsigned long lastInitTimestamp = 0; ESPeasySerial *easySerial = nullptr; - byte mhzResp[9] = {0}; // 9 byte response buffer + uint8_t mhzResp[9] = {0}; // 9 uint8_t response buffer // Default of the sensor is to run ABC bool ABC_Disable = false; bool ABC_MustApply = false; @@ -384,7 +384,7 @@ boolean Plugin_049_Check_and_ApplyFilter(unsigned int prevVal, unsigned int& new return true; } -boolean Plugin_049(byte function, struct EventStruct *event, String& string) +boolean Plugin_049(uint8_t function, struct EventStruct *event, String& string) { bool success = false; @@ -437,13 +437,13 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); const __FlashStringHelper * options[2] = { F("Normal"), F("ABC disabled") }; int optionValues[2] = { ABC_enabled, ABC_disabled }; addFormSelector(F("Auto Base Calibration"), F("p049_abcdisable"), 2, options, optionValues, choice); } { - byte choiceFilter = PCONFIG(1); + uint8_t choiceFilter = PCONFIG(1); const __FlashStringHelper * filteroptions[5] = { F("Skip Unstable"), F("Use Unstable"), F("Fast Response"), F("Medium Response"), F("Slow Response") }; int filteroptionValues[5] = { diff --git a/src/_P050_TCS34725.ino b/src/_P050_TCS34725.ino index aa392c010..1614c8b28 100644 --- a/src/_P050_TCS34725.ino +++ b/src/_P050_TCS34725.ino @@ -34,7 +34,7 @@ #define P050_OPTION_RGB_EVENTS // #endif -boolean Plugin_050(byte function, struct EventStruct *event, String& string) +boolean Plugin_050(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -87,7 +87,7 @@ boolean Plugin_050(byte function, struct EventStruct *event, String& string) } case PLUGIN_WEBFORM_LOAD: { - byte choiceMode = PCONFIG(0); + uint8_t choiceMode = PCONFIG(0); { const __FlashStringHelper * optionsMode[6]; optionsMode[0] = F("2.4 ms"); @@ -106,7 +106,7 @@ boolean Plugin_050(byte function, struct EventStruct *event, String& string) addFormSelector(F("Integration Time"), F("p050_integrationTime"), 6, optionsMode, optionValuesMode, choiceMode); } - byte choiceMode2 = PCONFIG(1); + uint8_t choiceMode2 = PCONFIG(1); { const __FlashStringHelper * optionsMode2[4]; optionsMode2[0] = F("1x"); diff --git a/src/_P051_AM2320.ino b/src/_P051_AM2320.ino index ffaac2382..cffa54b9b 100644 --- a/src/_P051_AM2320.ino +++ b/src/_P051_AM2320.ino @@ -22,7 +22,7 @@ #define PLUGIN_VALUENAME2_051 "Humidity" -boolean Plugin_051(byte function, struct EventStruct *event, String& string) +boolean Plugin_051(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P052_SenseAir.ino b/src/_P052_SenseAir.ino index 6bbdd9b71..0d5862e7c 100644 --- a/src/_P052_SenseAir.ino +++ b/src/_P052_SenseAir.ino @@ -125,7 +125,7 @@ struct P052_data_struct : public PluginTaskData_base { unsigned int _plugin_052_last_measurement = 0; -const __FlashStringHelper * Plugin_052_valuename(byte value_nr, bool displayString) { +const __FlashStringHelper * Plugin_052_valuename(uint8_t value_nr, bool displayString) { switch (value_nr) { case 0: return displayString ? F("Empty") : F(""); case 1: return displayString ? F("Carbon Dioxide") : F("co2"); @@ -141,7 +141,7 @@ const __FlashStringHelper * Plugin_052_valuename(byte value_nr, bool displayStri return F(""); } -boolean Plugin_052(byte function, struct EventStruct *event, String& string) { +boolean Plugin_052(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -167,10 +167,10 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { } case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P052_NR_OUTPUT_VALUES) { - const byte pconfigIndex = i + P052_QUERY1_CONFIG_POS; - byte choice = PCONFIG(pconfigIndex); + const uint8_t pconfigIndex = i + P052_QUERY1_CONFIG_POS; + uint8_t choice = PCONFIG(pconfigIndex); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], Plugin_052_valuename(choice, false), @@ -214,7 +214,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { PCONFIG(P052_SENSOR_TYPE_INDEX) = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); PCONFIG(0) = 1; // "CO2" - for (byte i = 1; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 1; i < VARS_PER_TASK; ++i) { PCONFIG(i) = 0; // "Empty" } @@ -280,12 +280,12 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { { const __FlashStringHelper * options[P052_NR_OUTPUT_OPTIONS]; - for (byte i = 0; i < P052_NR_OUTPUT_OPTIONS; ++i) { + for (uint8_t i = 0; i < P052_NR_OUTPUT_OPTIONS; ++i) { options[i] = Plugin_052_valuename(i, true); } - for (byte i = 0; i < P052_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P052_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P052_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P052_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P052_NR_OUTPUT_OPTIONS, options); } } @@ -314,7 +314,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { chksumStats += reads_nodata; addHtml(chksumStats); - byte errorcode = 0; + uint8_t errorcode = 0; int value = P052_data->modbus.readInputRegister(0x06, errorcode); if (errorcode == 0) { @@ -338,7 +338,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { } { - byte errorcode = 0; + uint8_t errorcode = 0; //int meas_mode = P052_data->modbus.readHoldingRegister(0x0A, errorcode); //bool has_meas_mode = errorcode == 0; int period = P052_data->modbus.readHoldingRegister(0x0B, errorcode); @@ -372,7 +372,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { /* // ABC functionality disabled for now, due to a bug in the firmware. // See https://github.com/letscontrolit/ESPEasy/issues/759 - byte choiceABCperiod = PCONFIG(4); + uint8_t choiceABCperiod = PCONFIG(4); const __FlashStringHelper * optionsABCperiod[9] = { F("disable"), F("1 h"), F("12 h"), F("1 day"), F("2 days"), F("4 days"), F("7 days"), F("14 days"), F("30 days") }; addFormSelector(F("ABC period"), F("p052_ABC_period"), 9, optionsABCperiod, @@ -387,9 +387,9 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { case PLUGIN_WEBFORM_SAVE: { // Save output selector parameters. - for (byte i = 0; i < P052_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P052_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < P052_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P052_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, Plugin_052_valuename(choice, false)); } @@ -401,7 +401,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { uint16_t mode = getFormItemInt(F("p052_mode"), 65535); if (((mode == 0) || (mode == 1))) { - byte errorcode; + uint8_t errorcode; int readVal = P052_data->modbus.readHoldingRegister(0x0A, errorcode); if ((errorcode == 0) && (readVal != mode)) { @@ -413,7 +413,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { uint16_t period = getFormItemInt(F("p052_period"), 0); if (period > 1) { - byte errorcode; + uint8_t errorcode; int readVal = P052_data->modbus.readHoldingRegister(0x0B, errorcode); if ((errorcode == 0) && (readVal != period)) { @@ -425,7 +425,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { uint16_t samp_meas = getFormItemInt(F("p052_samp_meas"), 0); if ((samp_meas > 0) && (samp_meas <= 1024)) { - byte errorcode; + uint8_t errorcode; int readVal = P052_data->modbus.readHoldingRegister(0x0C, errorcode); if ((errorcode == 0) && (readVal != samp_meas)) { @@ -474,7 +474,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { // See https://github.com/letscontrolit/ESPEasy/issues/759 const int periodInHours[9] = {0, 1, 12, (24*1), (24*2), (24*4), (24*7), (24*14), (24*30) }; - byte choiceABCperiod = PCONFIG(1); + uint8_t choiceABCperiod = PCONFIG(1); Plugin_052_setABCperiod(periodInHours[choiceABCperiod]); */ @@ -506,7 +506,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { String logPrefix; for (int varnr = 0; varnr < P052_NR_OUTPUT_VALUES; ++varnr) { - byte errorcode = 0; + uint8_t errorcode = 0; float value = 0; switch (PCONFIG(varnr)) { @@ -608,7 +608,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) { } bool Plugin_052_check_error_status() { - byte error_status = P052_data->modbus.read_RAM_EEPROM(P052_CMD_READ_RAM, + uint8_t error_status = P052_data->modbus.read_RAM_EEPROM(P052_CMD_READ_RAM, P052_RAM_ADDR_ERROR_STATUS, 1); if (error_status == 0) return true; diff --git a/src/_P053_PMSx003.ino b/src/_P053_PMSx003.ino index a8f8f089c..5633bfc7b 100644 --- a/src/_P053_PMSx003.ino +++ b/src/_P053_PMSx003.ino @@ -51,9 +51,9 @@ void SerialRead16(uint16_t* value, uint16_t* checksum) #if 0 // Low-level logging to see data from sensor - String log = F("PMSx003 : byte high=0x"); + String log = F("PMSx003 : uint8_t high=0x"); log += String(data_high,HEX); - log += F(" byte low=0x"); + log += F(" uint8_t low=0x"); log += String(data_low,HEX); log += F(" result=0x"); log += String(*value,HEX); @@ -75,7 +75,7 @@ boolean PacketAvailable(void) // find header (buffer may be out of sync) if (!P053_easySerial->available()) return false; while ((P053_easySerial->peek() != PMSx003_SIG1) && P053_easySerial->available()) { - P053_easySerial->read(); // Read until the buffer starts with the first byte of a message, or buffer empty. + P053_easySerial->read(); // Read until the buffer starts with the first uint8_t of a message, or buffer empty. } if (P053_easySerial->available() < PMSx003_SIZE) return false; // Not enough yet for a complete packet } @@ -103,7 +103,7 @@ boolean Plugin_053_process_data(struct EventStruct *event) { return false; } - uint16_t data[13]; // byte data_low, data_high; + uint16_t data[13]; // uint8_t data_low, data_high; for (int i = 0; i < 13; i++) SerialRead16(&data[i], &checksum); @@ -154,7 +154,7 @@ boolean Plugin_053_process_data(struct EventStruct *event) { return false; } -boolean Plugin_053(byte function, struct EventStruct *event, String& string) +boolean Plugin_053(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P054_DMX512.ino b/src/_P054_DMX512.ino index 3b88831f4..e661f48c3 100644 --- a/src/_P054_DMX512.ino +++ b/src/_P054_DMX512.ino @@ -46,7 +46,7 @@ // Pin 2: DMX- (cold) // Pin 3: DMX+ (hot) -// Note: The ESP serial FIFO has size of 128 byte. Therefore it is rcommented to use DMX buffer sizes below 128 +// Note: The ESP serial FIFO has size of 128 uint8_t. Therefore it is rcommented to use DMX buffer sizes below 128 //#include <*.h> //no lib needed @@ -56,7 +56,7 @@ #define PLUGIN_ID_054 54 #define PLUGIN_NAME_054 "Communication - DMX512 TX [TESTING]" -byte* Plugin_054_DMXBuffer = 0; +uint8_t* Plugin_054_DMXBuffer = 0; int16_t Plugin_054_DMXSize = 32; static inline void PLUGIN_054_Limit(int16_t& value, int16_t min, int16_t max) @@ -68,7 +68,7 @@ static inline void PLUGIN_054_Limit(int16_t& value, int16_t min, int16_t max) } -boolean Plugin_054(byte function, struct EventStruct *event, String& string) +boolean Plugin_054(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -126,7 +126,7 @@ boolean Plugin_054(byte function, struct EventStruct *event, String& string) if (Plugin_054_DMXBuffer) delete [] Plugin_054_DMXBuffer; - Plugin_054_DMXBuffer = new byte[Plugin_054_DMXSize]; + Plugin_054_DMXBuffer = new uint8_t[Plugin_054_DMXSize]; memset(Plugin_054_DMXBuffer, 0, Plugin_054_DMXSize); success = true; @@ -144,7 +144,7 @@ boolean Plugin_054(byte function, struct EventStruct *event, String& string) String param; String paramKey; String paramVal; - byte paramIdx = 2; + uint8_t paramIdx = 2; int16_t channel = 1; int16_t value = 0; //FIXME TD-er: Same code in _P057 @@ -248,7 +248,7 @@ boolean Plugin_054(byte function, struct EventStruct *event, String& string) //send DMX data Serial1.begin(250000, SERIAL_8N2); - Serial1.write(0); //start byte + Serial1.write(0); //start uint8_t Serial1.write(Plugin_054_DMXBuffer, Plugin_054_DMXSize); } break; diff --git a/src/_P055_Chiming.ino b/src/_P055_Chiming.ino index 961169dc4..664b1e7b5 100644 --- a/src/_P055_Chiming.ino +++ b/src/_P055_Chiming.ino @@ -67,12 +67,12 @@ public: long millisPauseTime; int pin[4]; - byte lowActive; - byte chimeClock; + uint8_t lowActive; + uint8_t chimeClock; char FIFO[PLUGIN_055_FIFO_SIZE]; - byte FIFO_IndexR; - byte FIFO_IndexW; + uint8_t FIFO_IndexR; + uint8_t FIFO_IndexW; void Plugin_055_Data() { @@ -80,7 +80,7 @@ public: millisChimeTime = 60; millisPauseTime = 400; - for (byte i=0; i<4; i++) + for (uint8_t i=0; i<4; i++) pin[i] = -1; lowActive = false; chimeClock = true; @@ -93,7 +93,7 @@ public: static CPlugin_055_Data* Plugin_055_Data = NULL; -boolean Plugin_055(byte function, struct EventStruct *event, String& string) +boolean Plugin_055(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -188,7 +188,7 @@ boolean Plugin_055(byte function, struct EventStruct *event, String& string) Plugin_055_Data->chimeClock = PCONFIG(2); String log = F("Chime: GPIO: "); - for (byte i=0; i<4; i++) + for (uint8_t i=0; i<4; i++) { int pin = Settings.TaskDevicePin[i][event->TaskIndex]; Plugin_055_Data->pin[i] = pin; @@ -253,8 +253,8 @@ boolean Plugin_055(byte function, struct EventStruct *event, String& string) break; String tokens; - byte hours = node_time.hour(); - byte minutes = node_time.minute(); + uint8_t hours = node_time.hour(); + uint8_t minutes = node_time.minute(); if (Plugin_055_Data->chimeClock) { @@ -274,7 +274,7 @@ boolean Plugin_055(byte function, struct EventStruct *event, String& string) if (hours == 0) hours = 12; - byte index = hours; + uint8_t index = hours; tokens = parseString(tokens, index); Plugin_055_AddStringFIFO(tokens); @@ -298,7 +298,7 @@ boolean Plugin_055(byte function, struct EventStruct *event, String& string) { if (timeDiff(millisAct, Plugin_055_Data->millisStateEnd) <= 0) // end reached? { - for (byte i=0; i<4; i++) + for (uint8_t i=0; i<4; i++) { if (Plugin_055_Data->pin[i] >= 0) digitalWrite(Plugin_055_Data->pin[i], Plugin_055_Data->lowActive); @@ -346,8 +346,8 @@ boolean Plugin_055(byte function, struct EventStruct *event, String& string) case '8': case '9': { - byte mask = 1; - for (byte i=0; i<4; i++) + uint8_t mask = 1; + for (uint8_t i=0; i<4; i++) { if (Plugin_055_Data->pin[i] >= 0) if (c & mask) @@ -430,7 +430,7 @@ void Plugin_055_AddStringFIFO(const String& param) if (param.isEmpty()) return; - byte i = 0; + uint8_t i = 0; char c = param[i]; char c_last = '\0'; @@ -476,7 +476,7 @@ void Plugin_055_WriteChime(const String& name, const String& tokens) addLog(LOG_LEVEL_INFO, log); } -byte Plugin_055_ReadChime(const String& name, String& tokens) +uint8_t Plugin_055_ReadChime(const String& name, String& tokens) { String fileName = F("chime_"); fileName += name; diff --git a/src/_P056_SDS011-Dust.ino b/src/_P056_SDS011-Dust.ino index 1421191e9..987e9a5a3 100644 --- a/src/_P056_SDS011-Dust.ino +++ b/src/_P056_SDS011-Dust.ino @@ -25,7 +25,7 @@ CjkSDS011 *Plugin_056_SDS = NULL; -boolean Plugin_056(byte function, struct EventStruct *event, String& string) +boolean Plugin_056(uint8_t function, struct EventStruct *event, String& string) { bool success = false; diff --git a/src/_P057_HT16K33_LED.ino b/src/_P057_HT16K33_LED.ino index 4d62964f4..9d9904f85 100644 --- a/src/_P057_HT16K33_LED.ino +++ b/src/_P057_HT16K33_LED.ino @@ -72,7 +72,7 @@ #include "src/PluginStructs/P057_data_struct.h" -boolean Plugin_057(byte function, struct EventStruct *event, String& string) +boolean Plugin_057(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -103,7 +103,7 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte addr = PCONFIG(0); + uint8_t addr = PCONFIG(0); int optionValues[8] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 }; addFormSelectorI2C(F("i2c_addr"), 8, optionValues, addr); @@ -153,7 +153,7 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { - byte address = PCONFIG(0); + uint8_t address = PCONFIG(0); initPluginTaskData(event->TaskIndex, new (std::nothrow) P057_data_struct(address)); P057_data_struct *P057_data = @@ -181,7 +181,7 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) String text = parseStringToEnd(string, 2); if (text.length() > 0) { - byte seg = 0; + uint8_t seg = 0; P057_data->ledMatrix.ClearRowBuffer(); @@ -212,7 +212,7 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) String param; String paramKey; String paramVal; - byte paramIdx = 2; + uint8_t paramIdx = 2; uint8_t seg = 0; uint16_t value = 0; @@ -235,7 +235,7 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) if (loglevelActiveFor(LOG_LEVEL_INFO)) { String log = F("MX : "); - for (byte i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) { log += String(P057_data->ledMatrix.GetRow(i), 16); log += F("h, "); @@ -247,7 +247,7 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) else if (param == F("test")) { - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { P057_data->ledMatrix.SetRow(i, 1 << i); } success = true; @@ -327,8 +327,8 @@ boolean Plugin_057(byte function, struct EventStruct *event, String& string) break; } - byte hours = node_time.hour(); - byte minutes = node_time.minute(); + uint8_t hours = node_time.hour(); + uint8_t minutes = node_time.minute(); // P057_data->ledMatrix.ClearRowBuffer(); P057_data->ledMatrix.SetDigit(PCONFIG(5), minutes % 10); diff --git a/src/_P058_HT16K33_KeyPad.ino b/src/_P058_HT16K33_KeyPad.ino index 05bfd9c8b..027727257 100644 --- a/src/_P058_HT16K33_KeyPad.ino +++ b/src/_P058_HT16K33_KeyPad.ino @@ -38,7 +38,7 @@ #include "src/PluginStructs/P058_data_struct.h" -boolean Plugin_058(byte function, struct EventStruct *event, String& string) +boolean Plugin_058(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -75,7 +75,7 @@ boolean Plugin_058(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte addr = PCONFIG(0); + uint8_t addr = PCONFIG(0); int optionValues[8] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 }; addFormSelectorI2C(F("i2c_addr"), 8, optionValues, addr); @@ -98,7 +98,7 @@ boolean Plugin_058(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { - byte address = PCONFIG(0); + uint8_t address = PCONFIG(0); initPluginTaskData(event->TaskIndex, new (std::nothrow) P058_data_struct(address)); P058_data_struct *P058_data = diff --git a/src/_P059_Encoder.ino b/src/_P059_Encoder.ino index a7e9e825f..751878fdd 100644 --- a/src/_P059_Encoder.ino +++ b/src/_P059_Encoder.ino @@ -26,7 +26,7 @@ std::map > P_059_sensordefs; -boolean Plugin_059(byte function, struct EventStruct *event, String& string) +boolean Plugin_059(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -114,7 +114,7 @@ boolean Plugin_059(byte function, struct EventStruct *event, String& string) ExtraTaskSettings.TaskDeviceValueDecimals[event->BaseVarIndex] = 0; String log = F("QEI : GPIO: "); - for (byte i=0; i<3; i++) + for (uint8_t i=0; i<3; i++) { int pin = PIN(i); if (pin >= 0) diff --git a/src/_P060_MCP3221.ino b/src/_P060_MCP3221.ino index 26b5a6570..af355a9fa 100644 --- a/src/_P060_MCP3221.ino +++ b/src/_P060_MCP3221.ino @@ -17,7 +17,7 @@ #define PLUGIN_VALUENAME1_060 "Analog" -boolean Plugin_060(byte function, struct EventStruct *event, String& string) +boolean Plugin_060(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -53,7 +53,7 @@ boolean Plugin_060(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte addr = PCONFIG(0); + uint8_t addr = PCONFIG(0); int optionValues[8] = { 0x4D, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4E, 0x4F }; addFormSelectorI2C(F("i2c_addr"), 8, optionValues, addr); @@ -100,7 +100,7 @@ boolean Plugin_060(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { - byte address = PCONFIG(0); + uint8_t address = PCONFIG(0); initPluginTaskData(event->TaskIndex, new (std::nothrow) P060_data_struct(address)); P060_data_struct *P060_data = diff --git a/src/_P061_KeyPad.ino b/src/_P061_KeyPad.ino index 25bbb610b..20ff0bcc2 100644 --- a/src/_P061_KeyPad.ino +++ b/src/_P061_KeyPad.ino @@ -62,7 +62,7 @@ -boolean Plugin_061(byte function, struct EventStruct *event, String& string) +boolean Plugin_061(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -99,7 +99,7 @@ boolean Plugin_061(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte addr = PCONFIG(0); + uint8_t addr = PCONFIG(0); int optionValues[16] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F }; addFormSelectorI2C(F("i2c_addr"), (PCONFIG(1) == 0) ? 8 : 16, optionValues, addr); @@ -145,9 +145,9 @@ boolean Plugin_061(byte function, struct EventStruct *event, String& string) case PLUGIN_FIFTY_PER_SECOND: { - static byte lastScanCode = 0xFF; - static byte sentScanCode = 0xFF; - byte actScanCode = 0; + static uint8_t lastScanCode = 0xFF; + static uint8_t sentScanCode = 0xFF; + uint8_t actScanCode = 0; switch (PCONFIG(1)) { @@ -216,7 +216,7 @@ boolean Plugin_061(byte function, struct EventStruct *event, String& string) #define MCP23017_OLATB 0x15 // OUTPUT LATCH REGISTER OL7 OL6 OL5 OL4 OL3 OL2 OL1 OL0 0000 0000 -void MCP23017_setReg(byte addr, byte reg, byte data) +void MCP23017_setReg(uint8_t addr, uint8_t reg, uint8_t data) { Wire.beginTransmission(addr); Wire.write(reg); @@ -224,7 +224,7 @@ void MCP23017_setReg(byte addr, byte reg, byte data) Wire.endTransmission(); } -byte MCP23017_getReg(byte addr, byte reg) +uint8_t MCP23017_getReg(uint8_t addr, uint8_t reg) { Wire.beginTransmission(addr); Wire.write(reg); @@ -238,7 +238,7 @@ byte MCP23017_getReg(byte addr, byte reg) return 0xFF; } -void MCP23017_KeyPadMatrixInit(byte addr) +void MCP23017_KeyPadMatrixInit(uint8_t addr) { MCP23017_setReg(addr, MCP23017_IODIRA, 0x00); // port A to output MCP23017_setReg(addr, MCP23017_GPIOA, 0x00); // port A to low @@ -247,10 +247,10 @@ void MCP23017_KeyPadMatrixInit(byte addr) MCP23017_setReg(addr, MCP23017_GPPUB, 0xFF); // port B pullup on } -byte MCP23017_KeyPadMatrixScan(byte addr) +uint8_t MCP23017_KeyPadMatrixScan(uint8_t addr) { - byte rowMask = 1; - byte colData; + uint8_t rowMask = 1; + uint8_t colData; colData = MCP23017_getReg(addr, MCP23017_GPIOB); @@ -258,7 +258,7 @@ byte MCP23017_KeyPadMatrixScan(byte addr) return 0; // no key pressed! } - for (byte row = 0; row <= 8; row++) + for (uint8_t row = 0; row <= 8; row++) { if (row == 0) { MCP23017_setReg(addr, MCP23017_IODIRA, 0xFF); // no bit of port A to output @@ -273,9 +273,9 @@ byte MCP23017_KeyPadMatrixScan(byte addr) if (colData != 0xFF) // any key pressed? { - byte colMask = 1; + uint8_t colMask = 1; - for (byte col = 1; col <= 8; col++) + for (uint8_t col = 1; col <= 8; col++) { if ((colData & colMask) == 0) // this key pressed? { @@ -293,14 +293,14 @@ byte MCP23017_KeyPadMatrixScan(byte addr) // PCF8574 Matrix ////////////////////////////////////////////////////////////// -void PCF8574_setReg(byte addr, byte data) +void PCF8574_setReg(uint8_t addr, uint8_t data) { Wire.beginTransmission(addr); Wire.write(data); Wire.endTransmission(); } -byte PCF8574_getReg(byte addr) +uint8_t PCF8574_getReg(uint8_t addr) { Wire.requestFrom(addr, (uint8_t)0x1); @@ -311,15 +311,15 @@ byte PCF8574_getReg(byte addr) return 0xFF; } -void PCF8574_KeyPadMatrixInit(byte addr) +void PCF8574_KeyPadMatrixInit(uint8_t addr) { PCF8574_setReg(addr, 0xF0); // low nibble to output 0 } -byte PCF8574_KeyPadMatrixScan(byte addr) +uint8_t PCF8574_KeyPadMatrixScan(uint8_t addr) { - byte rowMask = 1; - byte colData; + uint8_t rowMask = 1; + uint8_t colData; colData = PCF8574_getReg(addr) & 0xF0; @@ -327,7 +327,7 @@ byte PCF8574_KeyPadMatrixScan(byte addr) return 0; // no key pressed! } - for (byte row = 0; row <= 4; row++) + for (uint8_t row = 0; row <= 4; row++) { if (row == 0) { PCF8574_setReg(addr, 0xFF); // no bit of port A to output @@ -342,9 +342,9 @@ byte PCF8574_KeyPadMatrixScan(byte addr) if (colData != 0xF0) // any key pressed? { - byte colMask = 0x10; + uint8_t colMask = 0x10; - for (byte col = 1; col <= 4; col++) + for (uint8_t col = 1; col <= 4; col++) { if ((colData & colMask) == 0) // this key pressed? { @@ -362,23 +362,23 @@ byte PCF8574_KeyPadMatrixScan(byte addr) // PCF8574 Direct ////////////////////////////////////////////////////////////// -void PCF8574_KeyPadDirectInit(byte addr) +void PCF8574_KeyPadDirectInit(uint8_t addr) { PCF8574_setReg(addr, 0xFF); // all to input } -byte PCF8574_KeyPadDirectScan(byte addr) +uint8_t PCF8574_KeyPadDirectScan(uint8_t addr) { - byte colData; + uint8_t colData; colData = PCF8574_getReg(addr); if (colData == 0xFF) { // no key pressed? return 0; // no key pressed! } - byte colMask = 0x01; + uint8_t colMask = 0x01; - for (byte col = 1; col <= 8; col++) + for (uint8_t col = 1; col <= 8; col++) { if ((colData & colMask) == 0) // this key pressed? { diff --git a/src/_P062_MPR121_KeyPad.ino b/src/_P062_MPR121_KeyPad.ino index b9b9cd3d4..311abb8b1 100644 --- a/src/_P062_MPR121_KeyPad.ino +++ b/src/_P062_MPR121_KeyPad.ino @@ -35,7 +35,7 @@ #define P062_DEFAULT_TOUCH_TRESHOLD 12 // Defaults got from MPR_121 source #define P062_DEFAULT_RELEASE_TRESHOLD 6 -boolean Plugin_062(byte function, struct EventStruct *event, String& string) +boolean Plugin_062(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -72,7 +72,7 @@ boolean Plugin_062(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte addr = PCONFIG(0); + uint8_t addr = PCONFIG(0); int optionValues[4] = { 0x5A, 0x5B, 0x5C, 0x5D }; addFormSelectorI2C(F("i2c_addr"), 4, optionValues, addr); @@ -289,7 +289,7 @@ boolean Plugin_062(byte function, struct EventStruct *event, String& string) uint16_t colMask = 0x01; log.reserve(55); - for (byte col = 0; col < P062_MaxTouchObjects; col++) + for (uint8_t col = 0; col < P062_MaxTouchObjects; col++) { if (key & colMask) // this key pressed? { diff --git a/src/_P063_TTP229_KeyPad.ino b/src/_P063_TTP229_KeyPad.ino index 99b62516b..ad64ad622 100644 --- a/src/_P063_TTP229_KeyPad.ino +++ b/src/_P063_TTP229_KeyPad.ino @@ -44,7 +44,7 @@ uint16_t readTTP229(int16_t pinSCL, int16_t pinSDO) delayMicroseconds(10); pinMode(pinSDO, INPUT); - for (byte i = 0; i < 16; i++) + for (uint8_t i = 0; i < 16; i++) { digitalWrite(pinSCL, HIGH); delayMicroseconds(1); @@ -59,7 +59,7 @@ uint16_t readTTP229(int16_t pinSCL, int16_t pinSDO) } -boolean Plugin_063(byte function, struct EventStruct *event, String& string) +boolean Plugin_063(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -172,7 +172,7 @@ boolean Plugin_063(byte function, struct EventStruct *event, String& string) if (key && PCONFIG(1)) { uint16_t colMask = 0x01; - for (byte col = 1; col <= 16; col++) + for (uint8_t col = 1; col <= 16; col++) { if (key & colMask) // this key pressed? { diff --git a/src/_P064_APDS9960.ino b/src/_P064_APDS9960.ino index 9b2d4cb43..708717507 100644 --- a/src/_P064_APDS9960.ino +++ b/src/_P064_APDS9960.ino @@ -54,7 +54,7 @@ #include "src/PluginStructs/P064_data_struct.h" -boolean Plugin_064(byte function, struct EventStruct *event, String& string) +boolean Plugin_064(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -99,7 +99,7 @@ boolean Plugin_064(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte addr = 0x39; // P064_ADDR; chip has only 1 address + uint8_t addr = 0x39; // P064_ADDR; chip has only 1 address int optionValues[1] = { 0x39 }; addFormSelectorI2C(F("i2c_addr"), 1, optionValues, addr); // Only for display I2C address diff --git a/src/_P065_DRF0299_MP3.ino b/src/_P065_DRF0299_MP3.ino index 0597c3ff9..99d38c68d 100644 --- a/src/_P065_DRF0299_MP3.ino +++ b/src/_P065_DRF0299_MP3.ino @@ -41,7 +41,7 @@ ESPeasySerial* P065_easySerial = NULL; -boolean Plugin_065(byte function, struct EventStruct *event, String& string) +boolean Plugin_065(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -194,25 +194,25 @@ void Plugin_065_SetEQ(int8_t eq) Plugin_065_SendCmd(0x07, eq); } -void Plugin_065_SendCmd(byte cmd, int16_t data) +void Plugin_065_SendCmd(uint8_t cmd, int16_t data) { if (!P065_easySerial) return; - byte buffer[10] = { 0x7E, 0xFF, 0x06, 0, 0x00, 0, 0, 0, 0, 0xEF }; + uint8_t buffer[10] = { 0x7E, 0xFF, 0x06, 0, 0x00, 0, 0, 0, 0, 0xEF }; buffer[3] = cmd; - buffer[5] = data >> 8; // high byte - buffer[6] = data & 0xFF; // low byte + buffer[5] = data >> 8; // high uint8_t + buffer[6] = data & 0xFF; // low uint8_t int16_t checksum = -(buffer[1] + buffer[2] + buffer[3] + buffer[4] + buffer[5] + buffer[6]); - buffer[7] = checksum >> 8; // high byte - buffer[8] = checksum & 0xFF; // low byte + buffer[7] = checksum >> 8; // high uint8_t + buffer[8] = checksum & 0xFF; // low uint8_t - P065_easySerial->write(buffer, 10); //Send the byte array + P065_easySerial->write(buffer, 10); //Send the uint8_t array String log = F("MP3 : Send Cmd "); - for (byte i=0; i<10; i++) + for (uint8_t i=0; i<10; i++) { log += String(buffer[i], 16); log += ' '; diff --git a/src/_P066_VEML6040.ino b/src/_P066_VEML6040.ino index 4cc3b8c02..8b97db0cc 100644 --- a/src/_P066_VEML6040.ino +++ b/src/_P066_VEML6040.ino @@ -24,7 +24,7 @@ #include -boolean Plugin_066(byte function, struct EventStruct *event, String& string) +boolean Plugin_066(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -180,7 +180,7 @@ boolean Plugin_066(byte function, struct EventStruct *event, String& string) // VEML6040 ///////////////////////////////////////////////////////////// -void VEML6040_setControlReg(byte data) +void VEML6040_setControlReg(uint8_t data) { Wire.beginTransmission(VEML6040_ADDR); Wire.write(0); // command 0=control register @@ -189,7 +189,7 @@ void VEML6040_setControlReg(byte data) Wire.endTransmission(); } -float VEML6040_GetValue(byte reg) +float VEML6040_GetValue(uint8_t reg) { Wire.beginTransmission(VEML6040_ADDR); Wire.write(reg); @@ -205,7 +205,7 @@ float VEML6040_GetValue(byte reg) return -1.0f; } -void VEML6040_Init(byte it) +void VEML6040_Init(uint8_t it) { VEML6040_setControlReg(it << 4); // IT=it, TRIG=0, AF=0, SD=0 } @@ -222,7 +222,7 @@ float Plugin_066_CalcCCT(float R, float G, float B) return CCT; } -float Plugin_066_CalcAmbientLight(float G, byte it) +float Plugin_066_CalcAmbientLight(float G, uint8_t it) { float Sensitivity[6] = { 0.25168f, 0.12584f, 0.06292f, 0.03146f, 0.01573f, 0.007865f }; diff --git a/src/_P067_HX711_Load_Cell.ino b/src/_P067_HX711_Load_Cell.ino index 1779bf03a..af456fd1a 100644 --- a/src/_P067_HX711_Load_Cell.ino +++ b/src/_P067_HX711_Load_Cell.ino @@ -32,10 +32,10 @@ #define BIT_POS_CALIB_CHAN_A 5 #define BIT_POS_CALIB_CHAN_B 6 -std::map Plugin_067_OversamplingValueChanA; -std::map Plugin_067_OversamplingCountChanA; -std::map Plugin_067_OversamplingValueChanB; -std::map Plugin_067_OversamplingCountChanB; +std::map Plugin_067_OversamplingValueChanA; +std::map Plugin_067_OversamplingCountChanA; +std::map Plugin_067_OversamplingValueChanB; +std::map Plugin_067_OversamplingCountChanB; enum {modeAoff, modeA64, modeA128}; enum {modeBoff, modeB32}; @@ -97,7 +97,7 @@ int32_t readHX711(int16_t pinSCL, int16_t pinDOUT, int16_t config0, uint8_t *cha nextChannel = chanB32; } - for (byte i = 0; i < 24; i++) + for (uint8_t i = 0; i < 24; i++) { digitalWrite(pinSCL, HIGH); delayMicroseconds(1); @@ -108,7 +108,7 @@ int32_t readHX711(int16_t pinSCL, int16_t pinDOUT, int16_t config0, uint8_t *cha mask >>= 1; } - for (byte i = 0; i < (nextChannel + 1); i++) + for (uint8_t i = 0; i < (nextChannel + 1); i++) { digitalWrite(pinSCL, HIGH); delayMicroseconds(1); @@ -140,7 +140,7 @@ void int2float(int16_t valInt0, int16_t valInt1, float *valFloat) *valFloat = offset; } -boolean Plugin_067(byte function, struct EventStruct *event, String& string) +boolean Plugin_067(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P068_SHT3x.ino b/src/_P068_SHT3x.ino index 0902ec1ad..7577b565f 100644 --- a/src/_P068_SHT3x.ino +++ b/src/_P068_SHT3x.ino @@ -148,7 +148,7 @@ bool SHT3X::CRC8(uint8_t MSB, uint8_t LSB, uint8_t CRC) // PLUGIN // ============================================= -boolean Plugin_068(byte function, struct EventStruct *event, String& string) +boolean Plugin_068(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P069_LM75A.ino b/src/_P069_LM75A.ino index 1f99715b3..c03237ae8 100644 --- a/src/_P069_LM75A.ino +++ b/src/_P069_LM75A.ino @@ -22,7 +22,7 @@ #include "src/PluginStructs/P069_data_struct.h" -boolean Plugin_069(byte function, struct EventStruct *event, String& string) +boolean Plugin_069(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P070_NeoPixel_Clock.ino b/src/_P070_NeoPixel_Clock.ino index 428b5a110..2cdab517a 100644 --- a/src/_P070_NeoPixel_Clock.ino +++ b/src/_P070_NeoPixel_Clock.ino @@ -129,11 +129,11 @@ struct P070_data_struct : public PluginTaskData_base { } boolean display_enabled; // used to enable/disable the display. - byte brightness; // brightness of the clock "hands" - byte brightness_hour_marks; // brightness of the hour marks - byte offset_12h_mark; // position of the 12 o'clock LED on the strip + uint8_t brightness; // brightness of the clock "hands" + uint8_t brightness_hour_marks; // brightness of the hour marks + uint8_t offset_12h_mark; // position of the 12 o'clock LED on the strip boolean thick_12_mark; // thicker marking of the 12h position - byte marks[14]; // Positions of the hour marks and dials + uint8_t marks[14]; // Positions of the hour marks and dials Adafruit_NeoPixel * Plugin_070_pixels = nullptr; @@ -146,7 +146,7 @@ struct P070_data_struct : public PluginTaskData_base { #define PLUGIN_VALUENAME1_070 "Enabled" #define PLUGIN_VALUENAME2_070 "Brightness" #define PLUGIN_VALUENAME3_070 "Marks" -boolean Plugin_070(byte function, struct EventStruct *event, String& string) +boolean Plugin_070(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P071_Kamstrup401.ino b/src/_P071_Kamstrup401.ino index 3e57bf908..4862e4934 100644 --- a/src/_P071_Kamstrup401.ino +++ b/src/_P071_Kamstrup401.ino @@ -23,10 +23,10 @@ #define PLUGIN_VALUENAME2_071 "Volume" boolean Plugin_071_init = false; -byte PIN_KAMSER_RX = 0; -byte PIN_KAMSER_TX = 0; +uint8_t PIN_KAMSER_RX = 0; +uint8_t PIN_KAMSER_TX = 0; -boolean Plugin_071(byte function, struct EventStruct *event, String& string) +boolean Plugin_071(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -105,11 +105,11 @@ boolean Plugin_071(byte function, struct EventStruct *event, String& string) pinMode(PIN_KAMSER_TX,OUTPUT); //read Kamstrup - byte sendmsg1[] = { 175,163,177 }; // /#1 with even parity + uint8_t sendmsg1[] = { 175,163,177 }; // /#1 with even parity - byte r = 0; - byte to = 0; - byte i; + uint8_t r = 0; + uint8_t to = 0; + uint8_t i; char message[255]; int parityerrors; @@ -136,7 +136,7 @@ boolean Plugin_071(byte function, struct EventStruct *event, String& string) { if (kamSer.available()) { - // receive byte + // receive uint8_t r = kamSer.read(); //serialPrintln(r); if (parity_check(r)) diff --git a/src/_P072_HDC1080.ino b/src/_P072_HDC1080.ino index bcedf590a..184eea29b 100644 --- a/src/_P072_HDC1080.ino +++ b/src/_P072_HDC1080.ino @@ -15,7 +15,7 @@ #define HDC1080_I2C_ADDRESS 0x40 // I2C address for the sensor -boolean Plugin_072(byte function, struct EventStruct *event, String& string) +boolean Plugin_072(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -52,7 +52,7 @@ boolean Plugin_072(byte function, struct EventStruct *event, String& string) case PLUGIN_READ: { - byte hdc1080_msb, hdc1080_lsb; + uint8_t hdc1080_msb, hdc1080_lsb; uint16_t hdc1080_rawtemp, hdc1080_rawhum; float hdc1080_temp, hdc1080_hum; diff --git a/src/_P073_7DGT.ino b/src/_P073_7DGT.ino index 1cfda653e..5c7ab9a75 100644 --- a/src/_P073_7DGT.ino +++ b/src/_P073_7DGT.ino @@ -22,7 +22,7 @@ // "7dfont," (select the used font: 0/7DGT/Default = default, 1/Siekoo = Siekoo, 2/Siekoo_Upper = Siekoo with uppercase CHNORUX, 3/dSEG7 = dSEG7) // Siekoo: https://www.fakoo.de/siekoo (uppercase CHNORUX is a local extension) // dSEG7 : https://www.keshikan.net/fonts-e.html -// "7dbin,[byte],..." (show data binary formatted, bits clock-wise from left to right, dot, top, right 2x, bottom, left 2x, center), scroll-enabled +// "7dbin,[uint8_t],..." (show data binary formatted, bits clock-wise from left to right, dot, top, right 2x, bottom, left 2x, center), scroll-enabled // - Clock-Blink -- display is automatically updated with current time and blinking dot/lines // - Clock-NoBlink -- display is automatically updated with current time and steady dot/lines // - Clock12-Blink -- display is automatically updated with current time (12h clock) and blinking dot/lines @@ -42,7 +42,7 @@ // 'Merged' fontdata for TM1637 by converting the data for MAX7219 (bits 0-6 are swapped around), to save a little space and maintanance burden. // Added 7dfont, command for changing the font dynamically runtime. NB: The numbers digits are equal for all fonts! // Added Scroll Text option for scrolling texts longer then the display is wide -// Added 7dbin,[,...] for displaying binary formatted data bits clock-wise from left to right, dot, top, right 2x, bottom, left 2x, center), scroll-enabled +// Added 7dbin,[,...] for displaying binary formatted data bits clock-wise from left to right, dot, top, right 2x, bottom, left 2x, center), scroll-enabled // 2021-01-10, tonhuisman: Added optional . as dot display (7dtext) // Added 7ddt,, dual temperature display // Added optional removal of degree symbol on temperature display @@ -73,7 +73,7 @@ #define P073_7DDT_COMMAND // Enable 7ddt by default #define P073_EXTRA_FONTS // Enable extra fonts #define P073_SCROLL_TEXT // Enable scrolling of 7dtext by default -#define P073_7DBIN_COMMAND // Enable input of binary data via 7dbin,byte,... command +#define P073_7DBIN_COMMAND // Enable input of binary data via 7dbin,uint8_t,... command #ifndef PLUGIN_SET_TESTING // #define P073_DEBUG // Leave out some debugging on demnand, activates extra log info in the debug @@ -100,8 +100,8 @@ struct P073_data_struct : public PluginTaskData_base { ClearBuffer(); } - void FillBufferWithTime(boolean sevendgt_now, byte sevendgt_hours, - byte sevendgt_minutes, byte sevendgt_seconds, + void FillBufferWithTime(boolean sevendgt_now, uint8_t sevendgt_hours, + uint8_t sevendgt_minutes, uint8_t sevendgt_seconds, boolean flag12h) { ClearBuffer(); @@ -126,8 +126,8 @@ struct P073_data_struct : public PluginTaskData_base { showbuffer[5] = sevendgt_seconds % 10; } - void FillBufferWithDate(boolean sevendgt_now, byte sevendgt_day, - byte sevendgt_month, int sevendgt_year) { + void FillBufferWithDate(boolean sevendgt_now, uint8_t sevendgt_day, + uint8_t sevendgt_month, int sevendgt_year) { ClearBuffer(); int sevendgt_year0 = sevendgt_year; @@ -140,8 +140,8 @@ struct P073_data_struct : public PluginTaskData_base { sevendgt_year0 += 2000; } } - byte sevendgt_year1 = static_cast(sevendgt_year0 / 100); - byte sevendgt_year2 = static_cast(sevendgt_year0 % 100); + uint8_t sevendgt_year1 = static_cast(sevendgt_year0 / 100); + uint8_t sevendgt_year2 = static_cast(sevendgt_year0 % 100); showbuffer[0] = static_cast(sevendgt_day / 10); showbuffer[1] = sevendgt_day % 10; @@ -155,8 +155,8 @@ struct P073_data_struct : public PluginTaskData_base { void FillBufferWithNumber(const String& number) { ClearBuffer(); - byte p073_numlenght = number.length(); - byte p073_index = 7; + uint8_t p073_numlenght = number.length(); + uint8_t p073_index = 7; dotpos = -1; // -1 means no dot to display for (int i = p073_numlenght - 1; i >= 0 && p073_index >= 0; --i) { @@ -439,11 +439,11 @@ void LogBufferContent(String prefix) { int dotpos = 0; uint8_t showbuffer[8] = {0}; bool showperiods[8]; - byte spidata[2] = {0}; + uint8_t spidata[2] = {0}; uint8_t pin1, pin2, pin3; - byte displayModel; - byte output; - byte brightness; + uint8_t displayModel; + uint8_t output; + uint8_t brightness; bool timesep; bool shift; bool periods; @@ -482,7 +482,7 @@ private: // - pos 14 - triple lines "/" // - pos 15 - underscore "_" // - pos 16-41 - Letters from A to Z -static const byte DefaultCharTable[42] PROGMEM = { +static const uint8_t DefaultCharTable[42] PROGMEM = { B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011, B00000000, B00000001, B01100011, B00001001, B01001001, B00001000, B01110111, B00011111, @@ -530,7 +530,7 @@ static const byte DefaultCharTable[42] PROGMEM = { // - pos 40 - uppercase U "U" B00111110 // - pos 41 - uppercase X "X" B00110111 // - pos 42-67 - Letters from A to Z Siekoo style -static const byte SiekooCharTable[68] PROGMEM = { +static const uint8_t SiekooCharTable[68] PROGMEM = { B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011, B00000000, B00000001, B01100011, B00001001, B00100101, B00001000, B00010010, B01110100, @@ -554,7 +554,7 @@ static const byte SiekooCharTable[68] PROGMEM = { // - pos 14 - slash "/" // - pos 15 - underscore "_" // - pos 16-41 - Letters from A to Z dSEG7 style -static const byte Dseg7CharTable[42] PROGMEM = { +static const uint8_t Dseg7CharTable[42] PROGMEM = { B01111110, B00110000, B01101101, B01111001, B00110011, B01011011, B01011111, B01110000, B01111111, B01111011, B00000000, B00000001, B01100011, B00001001, B01001001, B00001000, B01110111, B00011111, /* AB */ @@ -624,7 +624,7 @@ uint8_t P073_mapMAX7219FontToTM1673Font(uint8_t character) { return newCharacter; } -boolean Plugin_073(byte function, struct EventStruct *event, String& string) { +boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -1573,10 +1573,10 @@ void tm1637_i2cAck(uint8_t clk_pin, uint8_t dio_pin) { } void tm1637_i2cWrite_ack(uint8_t clk_pin, uint8_t dio_pin, - uint8_t bytesToPrint[], byte length) { + uint8_t bytesToPrint[], uint8_t length) { tm1637_i2cStart(clk_pin, dio_pin); - for (byte i = 0; i < length; ++i) { + for (uint8_t i = 0; i < length; ++i) { tm1637_i2cWrite_ack(clk_pin, dio_pin, bytesToPrint[i]); } tm1637_i2cStop(clk_pin, dio_pin); @@ -1655,7 +1655,7 @@ uint8_t tm1637_separator(uint8_t value, bool sep) { return value; } -byte tm1637_getFontChar(byte index, uint8_t fontset) { +uint8_t tm1637_getFontChar(uint8_t index, uint8_t fontset) { #ifdef P073_EXTRA_FONTS switch (fontset) { case 1: // Siekoo @@ -1741,7 +1741,7 @@ void tm1637_ShowTemp6(struct EventStruct *event, bool sep) { tm1637_i2cWrite_ack(clk_pin, dio_pin, bytesToPrint, 7); } -void tm1637_ShowTimeTemp4(struct EventStruct *event, bool sep, byte bufoffset) { +void tm1637_ShowTimeTemp4(struct EventStruct *event, bool sep, uint8_t bufoffset) { P073_data_struct *P073_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -1761,7 +1761,7 @@ void tm1637_ShowTimeTemp4(struct EventStruct *event, bool sep, byte bufoffset) { tm1637_i2cWrite_ack(clk_pin, dio_pin, bytesToPrint, 5); } -void tm1637_SwapDigitInBuffer(struct EventStruct *event, byte startPos) { +void tm1637_SwapDigitInBuffer(struct EventStruct *event, uint8_t startPos) { P073_data_struct *P073_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -1796,7 +1796,7 @@ void tm1637_SwapDigitInBuffer(struct EventStruct *event, byte startPos) { } } -void tm1637_ShowBuffer(struct EventStruct *event, byte firstPos, byte lastPos) { +void tm1637_ShowBuffer(struct EventStruct *event, uint8_t firstPos, uint8_t lastPos) { P073_data_struct *P073_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -1808,14 +1808,14 @@ void tm1637_ShowBuffer(struct EventStruct *event, byte firstPos, byte lastPos) { uint8_t bytesToPrint[8] = { 0 }; bytesToPrint[0] = 0xC0; - byte length = 1; + uint8_t length = 1; if (P073_data->dotpos > -1) { P073_data->showperiods[P073_data->dotpos] = true; } for (int i = firstPos; i < lastPos; i++) { - byte p073_datashowpos1 = tm1637_separator( + uint8_t p073_datashowpos1 = tm1637_separator( tm1637_getFontChar(P073_data->showbuffer[i], P073_data->fontset), P073_data->showperiods[i]); bytesToPrint[length] = p073_datashowpos1; ++length; @@ -1834,8 +1834,8 @@ void tm1637_ShowBuffer(struct EventStruct *event, byte firstPos, byte lastPos) { #define OP_DISPLAYTEST 15 void max7219_spiTransfer(struct EventStruct *event, uint8_t din_pin, - uint8_t clk_pin, uint8_t cs_pin, volatile byte opcode, - volatile byte data) { + uint8_t clk_pin, uint8_t cs_pin, volatile uint8_t opcode, + volatile uint8_t data) { P073_data_struct *P073_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -1868,8 +1868,8 @@ void max7219_SetPowerBrightness(struct EventStruct *event, uint8_t din_pin, void max7219_SetDigit(struct EventStruct *event, uint8_t din_pin, uint8_t clk_pin, uint8_t cs_pin, int dgtpos, - byte dgtvalue, boolean showdot, bool binaryData = false) { - byte p073_tempvalue; + uint8_t dgtvalue, boolean showdot, bool binaryData = false) { + uint8_t p073_tempvalue; #ifdef P073_EXTRA_FONTS switch (PCONFIG(4)) { @@ -1957,7 +1957,7 @@ void max7219_ShowDate(struct EventStruct *event, uint8_t din_pin, return; } - byte dotflags[8] = { false, true, false, true, false, false, false, false }; + uint8_t dotflags[8] = { false, true, false, true, false, false, false, false }; for (int i = 0; i < 8; i++) { max7219_SetDigit(event, din_pin, clk_pin, cs_pin, i, diff --git a/src/_P074_TSL2591.ino b/src/_P074_TSL2591.ino index 342df60d3..26dfe2d3d 100644 --- a/src/_P074_TSL2591.ino +++ b/src/_P074_TSL2591.ino @@ -112,7 +112,7 @@ struct P074_data_struct : public PluginTaskData_base { bool startIntegrationNeeded = false; }; -boolean Plugin_074(byte function, struct EventStruct *event, String& string) { +boolean Plugin_074(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -247,10 +247,10 @@ boolean Plugin_074(byte function, struct EventStruct *event, String& string) { if (nullptr != P074_data) { uint32_t fullLuminosity; if (P074_data->getFullLuminosity(fullLuminosity)) { - // TSL2591_FULLSPECTRUM: Reads two byte value from channel 0 (visible + infrared) + // TSL2591_FULLSPECTRUM: Reads two uint8_t value from channel 0 (visible + infrared) const uint16_t full = (fullLuminosity & 0xFFFF); - // TSL2591_INFRARED: Reads two byte value from channel 1 (infrared) + // TSL2591_INFRARED: Reads two uint8_t value from channel 1 (infrared) const uint16_t ir = (fullLuminosity >> 16); // TSL2591_VISIBLE: Reads all and subtracts out just the visible! diff --git a/src/_P075_Nextion.ino b/src/_P075_Nextion.ino index 2e6ef4d36..385cf6f82 100644 --- a/src/_P075_Nextion.ino +++ b/src/_P075_Nextion.ino @@ -101,7 +101,7 @@ struct P075_data_struct : public PluginTaskData_base { // PlugIn starts here // ***************************************************************************************************** -boolean Plugin_075(byte function, struct EventStruct *event, String& string) +boolean Plugin_075(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; // static boolean AdvHwSerial = false; // Web GUI checkbox flag; false = softserial mode, true = hardware UART serial. @@ -177,7 +177,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string) P075_data_struct* P075_data = static_cast(getPluginTaskData(event->TaskIndex)); if (nullptr != P075_data) { P075_data->loadDisplayLines(event->TaskIndex); - for (byte varNr = 0; varNr < P75_Nlines; varNr++) { + for (uint8_t varNr = 0; varNr < P75_Nlines; varNr++) { addFormTextBox(String(F("Line ")) + (varNr + 1), getPluginCustomArgName(varNr), P075_data->displayLines[varNr], P75_Nchars-1); } } @@ -205,7 +205,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string) // FIXME TD-er: This is a huge object allocated on the Stack. char deviceTemplate[P75_Nlines][P75_Nchars]; String error; - for (byte varNr = 0; varNr < P75_Nlines; varNr++) + for (uint8_t varNr = 0; varNr < P75_Nlines; varNr++) { if (!safe_strncpy(deviceTemplate[varNr], webArg(getPluginCustomArgName(varNr)), P75_Nchars)) { error += getCustomTaskSettingsError(varNr); @@ -214,7 +214,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string) if (error.length() > 0) { addHtmlError(error); } - SaveCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate)); + SaveCustomTaskSettings(event->TaskIndex, (uint8_t*)&deviceTemplate, sizeof(deviceTemplate)); } if(getTaskDeviceName(event->TaskIndex).isEmpty()) { // Check to see if user entered device name. @@ -258,7 +258,7 @@ boolean Plugin_075(byte function, struct EventStruct *event, String& string) String UcTmpString; // Get optional LINE command statements. Special RSSIBAR bargraph keyword is supported. - for (byte x = 0; x < P75_Nlines; x++) { + for (uint8_t x = 0; x < P75_Nlines; x++) { if (P075_data->displayLines[x].length()) { String tmpString = P075_data->displayLines[x]; UcTmpString = P075_data->displayLines[x]; diff --git a/src/_P076_HLW8012.ino b/src/_P076_HLW8012.ino index a08639be0..a3d1b5806 100644 --- a/src/_P076_HLW8012.ino +++ b/src/_P076_HLW8012.ino @@ -38,7 +38,7 @@ HLW8012 *Plugin_076_hlw = NULL; #define HLW_VOLTAGE_RESISTOR_DOWN (1000) // Real 1.009k //----------------------------------------------------------------------------------------------- int StoredTaskIndex = -1; -byte p076_read_stage = 0; +uint8_t p076_read_stage = 0; unsigned long p076_timer = 0; double p076_hcurrent = 0.0f; @@ -88,7 +88,7 @@ bool p076_getDeviceString(int device, String& name) { return true; } -bool p076_getDeviceParameters(int device, byte &SEL_Pin, byte &CF_Pin, byte &CF1_Pin, byte &Cur_read, byte &CF_Trigger, byte &CF1_Trigger) { +bool p076_getDeviceParameters(int device, uint8_t &SEL_Pin, uint8_t &CF_Pin, uint8_t &CF1_Pin, uint8_t &Cur_read, uint8_t &CF_Trigger, uint8_t &CF1_Trigger) { switch(device) { case P076_Custom : SEL_Pin = 0; CF_Pin = 0; CF1_Pin = 0; Cur_read = LOW; CF_Trigger = LOW; CF1_Trigger = LOW; break; case P076_Sonoff : SEL_Pin = 5; CF_Pin = 14; CF1_Pin = 13; Cur_read = HIGH; CF_Trigger = CHANGE; CF1_Trigger = CHANGE; break; @@ -109,7 +109,7 @@ bool p076_getDeviceParameters(int device, byte &SEL_Pin, byte &CF_Pin, byte &CF1 -boolean Plugin_076(byte function, struct EventStruct *event, String &string) { +boolean Plugin_076(uint8_t function, struct EventStruct *event, String &string) { boolean success = false; switch (function) { @@ -153,7 +153,7 @@ boolean Plugin_076(byte function, struct EventStruct *event, String &string) { } case PLUGIN_WEBFORM_LOAD: { - byte devicePinSettings = PCONFIG(7); + uint8_t devicePinSettings = PCONFIG(7); addFormSubHeader(F("Predefined Pin settings")); { @@ -197,12 +197,12 @@ boolean Plugin_076(byte function, struct EventStruct *event, String &string) { modeCurrValues[0] = LOW; modeCurrValues[1] = HIGH; - byte currentRead = PCONFIG(4); + uint8_t currentRead = PCONFIG(4); if (currentRead != LOW && currentRead != HIGH) { currentRead = LOW; } - byte cf_trigger = PCONFIG(5); - byte cf1_trigger = PCONFIG(6); + uint8_t cf_trigger = PCONFIG(5); + uint8_t cf1_trigger = PCONFIG(6); addFormSubHeader(F("Custom Pin settings (choose Custom above)")); addFormSelector(F("SEL Current (A) Reading"), F("p076_curr_read"), 2, modeCurr, modeCurrValues, currentRead ); @@ -231,11 +231,11 @@ boolean Plugin_076(byte function, struct EventStruct *event, String &string) { case PLUGIN_WEBFORM_SAVE: { //Set Pin settings - byte selectedDevice = getFormItemInt(F("p076_preDefDevSel")); + uint8_t selectedDevice = getFormItemInt(F("p076_preDefDevSel")); PCONFIG(7) = selectedDevice; { - byte SEL_Pin, CF_Pin, CF1_Pin, Cur_read, CF_Trigger, CF1_Trigger; + uint8_t SEL_Pin, CF_Pin, CF1_Pin, Cur_read, CF_Trigger, CF1_Trigger; if (selectedDevice != 0 && p076_getDeviceParameters(selectedDevice, SEL_Pin, CF_Pin, CF1_Pin, Cur_read, CF_Trigger, CF1_Trigger)) { PCONFIG(4) = Cur_read; PCONFIG(5) = CF_Trigger; @@ -257,7 +257,7 @@ boolean Plugin_076(byte function, struct EventStruct *event, String &string) { hlwMultipliers[1] = getFormItemFloat(F("p076_voltmult")); hlwMultipliers[2] = getFormItemFloat(F("p076_powmult")); if (hlwMultipliers[0] > 1.0f && hlwMultipliers[1] > 1.0f && hlwMultipliers[2] > 1.0f) { - SaveCustomTaskSettings(event->TaskIndex, (byte *)&hlwMultipliers, + SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&hlwMultipliers, sizeof(hlwMultipliers)); if (PLUGIN_076_DEBUG) { addLog(LOG_LEVEL_INFO, F("P076: Saved Calibration from Config Page")); @@ -371,16 +371,16 @@ boolean Plugin_076(byte function, struct EventStruct *event, String &string) { case PLUGIN_INIT: { Plugin076_Reset(event->TaskIndex); // This initializes the HWL8012 library. - const byte CF_PIN = CONFIG_PIN3; - const byte CF1_PIN = CONFIG_PIN2; - const byte SEL_PIN = CONFIG_PIN1; + const uint8_t CF_PIN = CONFIG_PIN3; + const uint8_t CF1_PIN = CONFIG_PIN2; + const uint8_t SEL_PIN = CONFIG_PIN1; if (CF_PIN != -1 && CF1_PIN != -1 && SEL_PIN != -1) { Plugin_076_hlw = new (std::nothrow) HLW8012; if (Plugin_076_hlw) { - byte currentRead = PCONFIG(4); - byte cf_trigger = PCONFIG(5); - byte cf1_trigger = PCONFIG(6); + uint8_t currentRead = PCONFIG(4); + uint8_t cf_trigger = PCONFIG(5); + uint8_t cf1_trigger = PCONFIG(6); Plugin_076_hlw->begin(CF_PIN, CF1_PIN, SEL_PIN, currentRead, true); // set use_interrupts to true to use @@ -491,7 +491,7 @@ void Plugin076_SaveMultipliers() { if (StoredTaskIndex < 0) return; // Not yet initialized. double hlwMultipliers[3]; if (Plugin076_ReadMultipliers(hlwMultipliers[0], hlwMultipliers[1], hlwMultipliers[2])) { - SaveCustomTaskSettings(StoredTaskIndex, (byte *)&hlwMultipliers, + SaveCustomTaskSettings(StoredTaskIndex, (uint8_t *)&hlwMultipliers, sizeof(hlwMultipliers)); } } @@ -517,7 +517,7 @@ bool Plugin076_LoadMultipliers(taskIndex_t TaskIndex, double& current, double& v return false; } double hlwMultipliers[3]; - LoadCustomTaskSettings(TaskIndex, (byte *)&hlwMultipliers, + LoadCustomTaskSettings(TaskIndex, (uint8_t *)&hlwMultipliers, sizeof(hlwMultipliers)); if (hlwMultipliers[0] > 1.0f) { current = hlwMultipliers[0]; @@ -533,8 +533,8 @@ bool Plugin076_LoadMultipliers(taskIndex_t TaskIndex, double& current, double& v void Plugin076_Reset(taskIndex_t TaskIndex) { if (Plugin_076_hlw) { - const byte CF_PIN = Settings.TaskDevicePin3[TaskIndex]; - const byte CF1_PIN = Settings.TaskDevicePin2[TaskIndex]; + const uint8_t CF_PIN = Settings.TaskDevicePin3[TaskIndex]; + const uint8_t CF1_PIN = Settings.TaskDevicePin2[TaskIndex]; detachInterrupt(CF_PIN); detachInterrupt(CF1_PIN); delete Plugin_076_hlw; diff --git a/src/_P077_CSE7766.ino b/src/_P077_CSE7766.ino index 59cc2102f..48b6f74fa 100644 --- a/src/_P077_CSE7766.ino +++ b/src/_P077_CSE7766.ino @@ -181,7 +181,7 @@ struct P077_data_struct : public PluginTaskData_base { -boolean Plugin_077(byte function, struct EventStruct *event, String &string) { +boolean Plugin_077(uint8_t function, struct EventStruct *event, String &string) { boolean success = false; switch (function) { diff --git a/src/_P078_Eastron.ino b/src/_P078_Eastron.ino index cf9cd823b..411693609 100644 --- a/src/_P078_Eastron.ino +++ b/src/_P078_Eastron.ino @@ -51,14 +51,14 @@ boolean Plugin_078_init = false; // Forward declaration helper functions -const __FlashStringHelper * p078_getQueryString(byte query); -const __FlashStringHelper * p078_getQueryValueString(byte query); -unsigned int p078_getRegister(byte query, byte model); -float p078_readVal(byte query, byte node, unsigned int model); +const __FlashStringHelper * p078_getQueryString(uint8_t query); +const __FlashStringHelper * p078_getQueryValueString(uint8_t query); +unsigned int p078_getRegister(uint8_t query, uint8_t model); +float p078_readVal(uint8_t query, uint8_t node, unsigned int model); -boolean Plugin_078(byte function, struct EventStruct *event, String& string) +boolean Plugin_078(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -89,9 +89,9 @@ boolean Plugin_078(byte function, struct EventStruct *event, String& string) case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if ( i < P078_NR_OUTPUT_VALUES) { - byte choice = PCONFIG(i + P078_QUERY1_CONFIG_POS); + uint8_t choice = PCONFIG(i + P078_QUERY1_CONFIG_POS); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], p078_getQueryValueString(choice), @@ -186,8 +186,8 @@ boolean Plugin_078(byte function, struct EventStruct *event, String& string) for (int i = 0; i < P078_NR_OUTPUT_OPTIONS; ++i) { options[i] = p078_getQueryString(i); } - for (byte i = 0; i < P078_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P078_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P078_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P078_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P078_NR_OUTPUT_OPTIONS, options); } } @@ -200,9 +200,9 @@ boolean Plugin_078(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SAVE: { // Save output selector parameters. - for (byte i = 0; i < P078_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P078_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < P078_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P078_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, p078_getQueryValueString(choice)); } @@ -260,7 +260,7 @@ boolean Plugin_078(byte function, struct EventStruct *event, String& string) if (Plugin_078_init) { int model = P078_MODEL; - byte dev_id = P078_DEV_ID; + uint8_t dev_id = P078_DEV_ID; UserVar[event->BaseVarIndex] = p078_readVal(P078_QUERY1, dev_id, model); UserVar[event->BaseVarIndex + 1] = p078_readVal(P078_QUERY2, dev_id, model); UserVar[event->BaseVarIndex + 2] = p078_readVal(P078_QUERY3, dev_id, model); @@ -274,10 +274,10 @@ boolean Plugin_078(byte function, struct EventStruct *event, String& string) return success; } -float p078_readVal(byte query, byte node, unsigned int model) { +float p078_readVal(uint8_t query, uint8_t node, unsigned int model) { if (Plugin_078_SDM == NULL) return 0.0f; - byte retry_count = 3; + uint8_t retry_count = 3; bool success = false; float _tempvar = NAN; while (retry_count > 0 && !success) { @@ -302,7 +302,7 @@ float p078_readVal(byte query, byte node, unsigned int model) { return _tempvar; } -unsigned int p078_getRegister(byte query, byte model) { +unsigned int p078_getRegister(uint8_t query, uint8_t model) { if (model == 0) { // SDM120C switch (query) { case 0: return SDM120C_VOLTAGE; @@ -359,7 +359,7 @@ unsigned int p078_getRegister(byte query, byte model) { return 0; } -const __FlashStringHelper * p078_getQueryString(byte query) { +const __FlashStringHelper * p078_getQueryString(uint8_t query) { switch(query) { case 0: return F("Voltage (V)"); @@ -376,7 +376,7 @@ const __FlashStringHelper * p078_getQueryString(byte query) { return F(""); } -const __FlashStringHelper * p078_getQueryValueString(byte query) { +const __FlashStringHelper * p078_getQueryValueString(uint8_t query) { switch(query) { case 0: return F("V"); @@ -394,7 +394,7 @@ const __FlashStringHelper * p078_getQueryValueString(byte query) { } -int p078_storageValueToBaudrate(byte baudrate_setting) { +int p078_storageValueToBaudrate(uint8_t baudrate_setting) { unsigned int baudrate = 9600; switch (baudrate_setting) { case 0: baudrate = 1200; break; diff --git a/src/_P079_Wemos_Motorshield.ino b/src/_P079_Wemos_Motorshield.ino index 9fd7e7063..2eeaf3aad 100644 --- a/src/_P079_Wemos_Motorshield.ino +++ b/src/_P079_Wemos_Motorshield.ino @@ -74,7 +74,7 @@ // ************************************************************************************************ -boolean Plugin_079(byte function, struct EventStruct *event, String& string) +boolean Plugin_079(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; MOTOR_STATES motor_dir = MOTOR_STATES::MOTOR_FWD; @@ -221,7 +221,7 @@ boolean Plugin_079(byte function, struct EventStruct *event, String& string) case PLUGIN_WRITE: { - byte parse_error = false; + uint8_t parse_error = false; String tmpString = string; String ModeStr; diff --git a/src/_P080_DallasIButton.ino b/src/_P080_DallasIButton.ino index 2f69d7a09..e93bc6759 100644 --- a/src/_P080_DallasIButton.ino +++ b/src/_P080_DallasIButton.ino @@ -17,7 +17,7 @@ int8_t Plugin_080_DallasPin; -boolean Plugin_080(byte function, struct EventStruct *event, String& string) +boolean Plugin_080(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P081_Cron.ino b/src/_P081_Cron.ino index 92b97a933..a08c8aa72 100644 --- a/src/_P081_Cron.ino +++ b/src/_P081_Cron.ino @@ -80,7 +80,7 @@ String P081_getCronExpr(taskIndex_t taskIndex) char expression[PLUGIN_081_EXPRESSION_SIZE + 1]; ZERO_FILL(expression); - LoadCustomTaskSettings(taskIndex, (byte *)&expression, PLUGIN_081_EXPRESSION_SIZE); + LoadCustomTaskSettings(taskIndex, (uint8_t *)&expression, PLUGIN_081_EXPRESSION_SIZE); String res(expression); res.trim(); return res; @@ -114,7 +114,7 @@ time_t P081_computeNextCronTime(taskIndex_t taskIndex, time_t last) return CRON_INVALID_INSTANT; } -time_t P081_getCronExecTime(taskIndex_t taskIndex, byte varNr) +time_t P081_getCronExecTime(taskIndex_t taskIndex, uint8_t varNr) { return static_cast(UserVar.getUint32(taskIndex, varNr)); } @@ -155,7 +155,7 @@ void P081_check_or_init(struct EventStruct *event) } } -boolean Plugin_081(byte function, struct EventStruct *event, String& string) +boolean Plugin_081(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -222,7 +222,7 @@ boolean Plugin_081(byte function, struct EventStruct *event, String& string) char expression_c[PLUGIN_081_EXPRESSION_SIZE]; ZERO_FILL(expression_c); safe_strncpy(expression_c, expression, PLUGIN_081_EXPRESSION_SIZE); - log = SaveCustomTaskSettings(event->TaskIndex, (byte *)&expression_c, PLUGIN_081_EXPRESSION_SIZE); + log = SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&expression_c, PLUGIN_081_EXPRESSION_SIZE); } if (log.length() > 0) @@ -378,7 +378,7 @@ void PrintCronExp(struct cron_expr_t e) { #endif // if PLUGIN_081_DEBUG -String P081_formatExecTime(taskIndex_t taskIndex, byte varNr) { +String P081_formatExecTime(taskIndex_t taskIndex, uint8_t varNr) { time_t exec_time = P081_getCronExecTime(taskIndex, varNr); if (exec_time != CRON_INVALID_INSTANT) { diff --git a/src/_P082_GPS.ino b/src/_P082_GPS.ino index 3fde45619..68dd9aa54 100644 --- a/src/_P082_GPS.ino +++ b/src/_P082_GPS.ino @@ -58,7 +58,7 @@ volatile unsigned long P082_pps_time = 0; void Plugin_082_interrupt() ICACHE_RAM_ATTR; -boolean Plugin_082(byte function, struct EventStruct *event, String& string) { +boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -83,9 +83,9 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { } case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P082_NR_OUTPUT_VALUES) { - const byte pconfigIndex = i + P082_QUERY1_CONFIG_POS; + const uint8_t pconfigIndex = i + P082_QUERY1_CONFIG_POS; P082_query choice = static_cast(PCONFIG(pconfigIndex)); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], @@ -114,7 +114,7 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { static_cast(getPluginTaskData(event->TaskIndex)); if ((nullptr != P082_data) && P082_data->isInitialized()) { - byte varNr = VARS_PER_TASK; + uint8_t varNr = VARS_PER_TASK; pluginWebformShowValue(event->TaskIndex, varNr++, F("Fix"), String(P082_data->hasFix(P082_TIMEOUT) ? 1 : 0)); pluginWebformShowValue(event->TaskIndex, varNr++, F("Tracked"), String(P082_data->gps->satellitesStats.nrSatsTracked())); @@ -135,10 +135,10 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { { P082_TIMEOUT = P082_DEFAULT_FIX_TIMEOUT; P082_DISTANCE = P082_DISTANCE_DFLT; - P082_QUERY1 = static_cast(P082_QUERY1_DFLT); - P082_QUERY2 = static_cast(P082_QUERY2_DFLT); - P082_QUERY3 = static_cast(P082_QUERY3_DFLT); - P082_QUERY4 = static_cast(P082_QUERY4_DFLT); + P082_QUERY1 = static_cast(P082_QUERY1_DFLT); + P082_QUERY2 = static_cast(P082_QUERY2_DFLT); + P082_QUERY3 = static_cast(P082_QUERY3_DFLT); + P082_QUERY4 = static_cast(P082_QUERY4_DFLT); success = true; break; @@ -193,14 +193,14 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { { // In a separate scope to free memory of String array as soon as possible sensorTypeHelper_webformLoad_header(); - const __FlashStringHelper * options[static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)]; + const __FlashStringHelper * options[static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)]; - for (byte i = 0; i < static_cast(P082_query::P082_NR_OUTPUT_OPTIONS); ++i) { + for (uint8_t i = 0; i < static_cast(P082_query::P082_NR_OUTPUT_OPTIONS); ++i) { options[i] = Plugin_082_valuename(static_cast(i), true); } - for (byte i = 0; i < P082_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P082_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P082_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P082_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, static_cast(P082_query::P082_NR_OUTPUT_OPTIONS), options); } } @@ -222,7 +222,7 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { // Save output selector parameters. for (int i = 0; i < P082_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P082_QUERY1_CONFIG_POS; + const uint8_t pconfigIndex = i + P082_QUERY1_CONFIG_POS; const P082_query choice = static_cast(PCONFIG(pconfigIndex)); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, Plugin_082_valuename(choice, false)); } @@ -309,12 +309,12 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { if (P082_data->gps->location.isUpdated()) { const float lng = P082_data->gps->location.lng(); const float lat = P082_data->gps->location.lat(); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_LONG), lng); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_LAT), lat); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_LONG), lng); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_LAT), lat); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_DISTANCE), P082_data->_distance); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_DISTANCE), P082_data->_distance); const float dist_ref = P082_data->gps->distanceBetween(P082_LAT_REF, P082_LONG_REF, lat, lng); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_DIST_REF), dist_ref); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_DIST_REF), dist_ref); if (P082_DISTANCE > 0) { @@ -326,24 +326,24 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { if (P082_data->gps->altitude.isUpdated()) { // ToDo make unit selectable - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_ALT), P082_data->gps->altitude.meters()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_ALT), P082_data->gps->altitude.meters()); success = true; addLog(LOG_LEVEL_DEBUG, F("GPS: Altitude update.")); } if (P082_data->gps->speed.isUpdated()) { // ToDo make unit selectable - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_SPD), P082_data->gps->speed.mps()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_SPD), P082_data->gps->speed.mps()); addLog(LOG_LEVEL_DEBUG, F("GPS: Speed update.")); success = true; } } - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_SATVIS), P082_data->gps->satellitesStats.nrSatsVisible()); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_SATUSE), P082_data->gps->satellitesStats.nrSatsTracked()); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_HDOP), P082_data->gps->hdop.value() / 100.0f); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_FIXQ), P082_data->gps->location.Quality()); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_DB_MAX), P082_data->gps->satellitesStats.getBestSNR()); - P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_CHKSUM_FAIL), P082_data->gps->failedChecksum()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_SATVIS), P082_data->gps->satellitesStats.nrSatsVisible()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_SATUSE), P082_data->gps->satellitesStats.nrSatsTracked()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_HDOP), P082_data->gps->hdop.value() / 100.0f); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_FIXQ), P082_data->gps->location.Quality()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_DB_MAX), P082_data->gps->satellitesStats.getBestSNR()); + P082_setOutputValue(event, static_cast(P082_query::P082_QUERY_CHKSUM_FAIL), P082_data->gps->failedChecksum()); if (curFixStatus) { @@ -405,17 +405,17 @@ boolean Plugin_082(byte function, struct EventStruct *event, String& string) { // return decode(bytes, [header, latLng, latLng, altitude, uint16_1e2, hdop, uint8, uint8, uint24, uint24_1e1], // ['header', 'latitude', 'longitude', 'altitude', 'speed', 'hdop', 'max_snr', 'sat_tracked', 'distance_total', 'distance_ref']); // altitude type: return +(int16(bytes) / 4 - 1000).toFixed(1); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_LAT)], PackedData_latLng); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_LONG)], PackedData_latLng); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_ALT)], PackedData_altitude); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_SPD)], PackedData_uint16_1e2); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_HDOP)], PackedData_hdop); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_DB_MAX)], PackedData_uint8); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_SATUSE)], PackedData_uint8); - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_DISTANCE)] / 1000, PackedData_uint24_1e2); // Max 167772.16 km + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_LAT)], PackedData_latLng); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_LONG)], PackedData_latLng); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_ALT)], PackedData_altitude); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_SPD)], PackedData_uint16_1e2); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_HDOP)], PackedData_hdop); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_DB_MAX)], PackedData_uint8); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_SATUSE)], PackedData_uint8); + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_DISTANCE)] / 1000, PackedData_uint24_1e2); // Max 167772.16 km event->Par1 = 8; if (P082_referencePointSet(event)) { - string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_DIST_REF)], PackedData_uint24_1e1); // Max 1677.7216 km + string += LoRa_addFloat(P082_data->_cache[static_cast(P082_query::P082_QUERY_DIST_REF)], PackedData_uint24_1e1); // Max 1677.7216 km event->Par1 = 9; } @@ -433,7 +433,7 @@ bool P082_referencePointSet(struct EventStruct *event) { && (P082_LAT_REF < 0.1) && (P082_LAT_REF > -0.1) ); } -void P082_setOutputValue(struct EventStruct *event, byte outputType, float value) { +void P082_setOutputValue(struct EventStruct *event, uint8_t outputType, float value) { P082_data_struct *P082_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -441,12 +441,12 @@ void P082_setOutputValue(struct EventStruct *event, byte outputType, float value return; } - if (outputType < static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)) { + if (outputType < static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)) { P082_data->_cache[outputType] = value; } - for (byte i = 0; i < P082_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P082_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P082_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P082_QUERY1_CONFIG_POS; if (PCONFIG(pconfigIndex) == outputType) { UserVar[event->BaseVarIndex + i] = value; @@ -493,7 +493,7 @@ void P082_html_show_satStats(struct EventStruct *event, bool tracked, bool onlyG bool first = true; - for (byte i = 0; i < _GPS_MAX_ARRAY_LENGTH; ++i) { + for (uint8_t i = 0; i < _GPS_MAX_ARRAY_LENGTH; ++i) { uint8_t id = P082_data->gps->satellitesStats.id[i]; uint8_t snr = P082_data->gps->satellitesStats.snr[i]; @@ -598,12 +598,12 @@ void P082_html_show_stats(struct EventStruct *event) { } addRowLabel(F("Distance Travelled")); - addHtmlInt(static_cast(P082_data->_cache[static_cast(P082_query::P082_QUERY_DISTANCE)])); + addHtmlInt(static_cast(P082_data->_cache[static_cast(P082_query::P082_QUERY_DISTANCE)])); addUnit(F("m")); if (P082_referencePointSet(event)) { addRowLabel(F("Distance from Ref. Point")); - addHtmlInt(static_cast(P082_data->_cache[static_cast(P082_query::P082_QUERY_DIST_REF)])); + addHtmlInt(static_cast(P082_data->_cache[static_cast(P082_query::P082_QUERY_DIST_REF)])); addUnit(F("m")); } diff --git a/src/_P083_SGP30.ino b/src/_P083_SGP30.ino index 24e1750cc..23f089360 100644 --- a/src/_P083_SGP30.ino +++ b/src/_P083_SGP30.ino @@ -24,7 +24,7 @@ #define P083_ECO2_BASELINE (event->BaseVarIndex + 3) -boolean Plugin_083(byte function, struct EventStruct *event, String& string) +boolean Plugin_083(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P084_VEML6070.ino b/src/_P084_VEML6070.ino index e55f4b93f..e8ba219d6 100644 --- a/src/_P084_VEML6070.ino +++ b/src/_P084_VEML6070.ino @@ -32,7 +32,7 @@ #define VEML6070_base_value ((VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT) * (1) #define VEML6070_max_value ((VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT) * (VEML6070_UV_MAX_INDEX) -boolean Plugin_084(byte function, struct EventStruct *event, String& string) +boolean Plugin_084(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -153,7 +153,7 @@ uint16_t VEML6070_ReadUv(bool *status) return uv_raw; } -bool VEML6070_Init(byte it) +bool VEML6070_Init(uint8_t it) { boolean succes = I2C_write8(VEML6070_ADDR_L, ((it << 2) | 0x02)); diff --git a/src/_P085_AcuDC243.ino b/src/_P085_AcuDC243.ino index ac60606e0..af78e2438 100644 --- a/src/_P085_AcuDC243.ino +++ b/src/_P085_AcuDC243.ino @@ -61,7 +61,7 @@ #include "src/DataStructs/ESPEasy_packed_raw_data.h" // Forward declaration of functions: -const __FlashStringHelper * Plugin_085_valuename(byte value_nr, bool displayString); +const __FlashStringHelper * Plugin_085_valuename(uint8_t value_nr, bool displayString); struct P085_data_struct : public PluginTaskData_base { @@ -89,7 +89,7 @@ struct P085_data_struct : public PluginTaskData_base { unsigned int _plugin_085_last_measurement = 0; -boolean Plugin_085(byte function, struct EventStruct *event, String& string) { +boolean Plugin_085(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -114,10 +114,10 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) { } case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P085_NR_OUTPUT_VALUES) { - const byte pconfigIndex = i + P085_QUERY1_CONFIG_POS; - byte choice = PCONFIG(pconfigIndex); + const uint8_t pconfigIndex = i + P085_QUERY1_CONFIG_POS; + uint8_t choice = PCONFIG(pconfigIndex); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], Plugin_085_valuename(choice, false), @@ -197,7 +197,7 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) { // Calibration data is stored in the AcuDC module, not in the settings of ESPeasy. { - byte errorcode = 0; + uint8_t errorcode = 0; int value = P085_data->modbus.readHoldingRegister(0x107, errorcode); if (errorcode == 0) { @@ -261,8 +261,8 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) { options[i] = Plugin_085_valuename(i, true); } - for (byte i = 0; i < P085_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P085_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P085_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P085_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P085_NR_OUTPUT_OPTIONS, options); } } @@ -278,9 +278,9 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) { } // Save output selector parameters. - for (byte i = 0; i < P085_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P085_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < P085_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P085_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, Plugin_085_valuename(choice, false)); } P085_data_struct *P085_data = @@ -376,9 +376,9 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) { // Matching JS code: // return decode(bytes, [header, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4], // ['header', 'unit1', 'val_1', 'unit2', 'val_2', 'unit3', 'val_3', 'unit4', 'val_4']); - for (byte i = 0; i < VARS_PER_TASK; ++i) { - const byte pconfigIndex = i + P085_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { + const uint8_t pconfigIndex = i + P085_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); string += LoRa_addInt(choice, PackedData_uint8); string += LoRa_addFloat(UserVar[event->BaseVarIndex + i], PackedData_int32_1e4); } @@ -395,7 +395,7 @@ boolean Plugin_085(byte function, struct EventStruct *event, String& string) { return success; } -const __FlashStringHelper * Plugin_085_valuename(byte value_nr, bool displayString) { +const __FlashStringHelper * Plugin_085_valuename(uint8_t value_nr, bool displayString) { switch (value_nr) { case P085_QUERY_V: return displayString ? F("Voltage (V)") : F("V"); case P085_QUERY_A: return displayString ? F("Current (A)") : F("A"); @@ -410,7 +410,7 @@ const __FlashStringHelper * Plugin_085_valuename(byte value_nr, bool displayStri return F(""); } -int p085_storageValueToBaudrate(byte baudrate_setting) { +int p085_storageValueToBaudrate(uint8_t baudrate_setting) { switch (baudrate_setting) { case 0: return 1200; @@ -428,7 +428,7 @@ int p085_storageValueToBaudrate(byte baudrate_setting) { return 19200; } -float p085_readValue(byte query, struct EventStruct *event) { +float p085_readValue(uint8_t query, struct EventStruct *event) { P085_data_struct *P085_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -466,7 +466,7 @@ float p085_readValue(byte query, struct EventStruct *event) { return 0.0f; } -void p085_showValueLoadPage(byte query, struct EventStruct *event) { +void p085_showValueLoadPage(uint8_t query, struct EventStruct *event) { addRowLabel(Plugin_085_valuename(query, true)); addHtml(String(p085_readValue(query, event))); } diff --git a/src/_P086_Homie.ino b/src/_P086_Homie.ino index 8ca49e1ce..3a5e5acc9 100644 --- a/src/_P086_Homie.ino +++ b/src/_P086_Homie.ino @@ -28,7 +28,7 @@ #define PLUGIN_086_DEBUG true -boolean Plugin_086(byte function, struct EventStruct *event, String& string) +boolean Plugin_086(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -73,7 +73,7 @@ boolean Plugin_086(byte function, struct EventStruct *event, String& string) { addFormNote(F("Translation Plugin for controllers able to receive value updates according to the Homie convention.")); - byte choice = 0; + uint8_t choice = 0; String labelText; String keyName; const __FlashStringHelper * options[PLUGIN_086_VALUE_TYPES]; @@ -157,7 +157,7 @@ boolean Plugin_086(byte function, struct EventStruct *event, String& string) case PLUGIN_READ: { - for (byte x=0; xisInitialized()) { uint32_t success, error, length_last; P087_data->getSentencesReceived(success, error, length_last); - byte varNr = VARS_PER_TASK; + uint8_t varNr = VARS_PER_TASK; pluginWebformShowValue(event->TaskIndex, varNr++, F("Success"), String(success)); pluginWebformShowValue(event->TaskIndex, varNr++, F("Error"), String(error)); pluginWebformShowValue(event->TaskIndex, varNr++, F("Length Last"), String(length_last), true); @@ -152,7 +152,7 @@ boolean Plugin_087(byte function, struct EventStruct *event, String& string) { static_cast(getPluginTaskData(event->TaskIndex)); if (nullptr != P087_data) { - for (byte varNr = 0; varNr < P87_Nlines; varNr++) + for (uint8_t varNr = 0; varNr < P87_Nlines; varNr++) { P087_data->setLine(varNr, webArg(getPluginCustomArgName(varNr))); } @@ -264,7 +264,7 @@ bool Plugin_087_match_all(taskIndex_t taskIndex, String& received) return res; } -String Plugin_087_valuename(byte value_nr, bool displayString) { +String Plugin_087_valuename(uint8_t value_nr, bool displayString) { switch (value_nr) { case P087_QUERY_VALUE: return displayString ? F("Value") : F("v"); } @@ -305,12 +305,12 @@ void P087_html_show_matchForms(struct EventStruct *event) { } - byte lineNr = 0; + uint8_t lineNr = 0; uint8_t capture = 0; P087_Filter_Comp comparator = P087_Filter_Comp::Equal; String filter; - for (byte varNr = P087_FIRST_FILTER_POS; varNr < P87_Nlines; ++varNr) + for (uint8_t varNr = P087_FIRST_FILTER_POS; varNr < P87_Nlines; ++varNr) { String id = getPluginCustomArgName(varNr); diff --git a/src/_P088_HeatpumpIR.ino b/src/_P088_HeatpumpIR.ino index 2e7733373..8fb16f364 100644 --- a/src/_P088_HeatpumpIR.ino +++ b/src/_P088_HeatpumpIR.ino @@ -49,7 +49,7 @@ IRSenderIRremoteESP8266 *Plugin_088_irSender = NULL; int panasonicCKPTimer = 0; -boolean Plugin_088(byte function, struct EventStruct *event, String& string) +boolean Plugin_088(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P089_Ping.ino b/src/_P089_Ping.ino index 10f9dd91a..470439235 100644 --- a/src/_P089_Ping.ino +++ b/src/_P089_Ping.ino @@ -85,7 +85,7 @@ public: } char hostname[PLUGIN_089_HOSTNAME_SIZE]; - LoadCustomTaskSettings(event->TaskIndex, (byte*)&hostname, PLUGIN_089_HOSTNAME_SIZE); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t*)&hostname, PLUGIN_089_HOSTNAME_SIZE); /* This one lost as well, DNS dead? */ if (WiFi.hostByName(hostname, ip) == false) { @@ -130,7 +130,7 @@ public: } }; -boolean Plugin_089(byte function, struct EventStruct *event, String& string) +boolean Plugin_089(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -167,7 +167,7 @@ boolean Plugin_089(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { char hostname[PLUGIN_089_HOSTNAME_SIZE]; - LoadCustomTaskSettings(event->TaskIndex, (byte*)&hostname, PLUGIN_089_HOSTNAME_SIZE); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t*)&hostname, PLUGIN_089_HOSTNAME_SIZE); addFormTextBox(F("Hostname"), F("p089_ping_host"), hostname, PLUGIN_089_HOSTNAME_SIZE - 2); success = true; break; @@ -179,7 +179,7 @@ boolean Plugin_089(byte function, struct EventStruct *event, String& string) // Reset "Fails" if settings updated UserVar[event->BaseVarIndex] = 0; strncpy(hostname, webArg(F("p089_ping_host")).c_str() , sizeof(hostname)); - SaveCustomTaskSettings(event->TaskIndex, (byte*)&hostname, PLUGIN_089_HOSTNAME_SIZE); + SaveCustomTaskSettings(event->TaskIndex, (uint8_t*)&hostname, PLUGIN_089_HOSTNAME_SIZE); success = true; break; } diff --git a/src/_P090_CCS811.ino b/src/_P090_CCS811.ino index 4b8dcd05e..fc27b98a8 100644 --- a/src/_P090_CCS811.ino +++ b/src/_P090_CCS811.ino @@ -70,7 +70,7 @@ #define P090_READ_INTERVAL PCONFIG_LONG(0) -boolean Plugin_090(byte function, struct EventStruct *event, String& string) +boolean Plugin_090(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -279,8 +279,8 @@ boolean Plugin_090(byte function, struct EventStruct *event, String& string) if (P090_COMPENSATE_ENABLE) { // we're checking a var from another task, so calculate that basevar - byte TaskIndex = P090_TEMPERATURE_TASK_INDEX; - byte BaseVarIndex = TaskIndex * VARS_PER_TASK + P090_TEMPERATURE_TASK_VALUE; + uint8_t TaskIndex = P090_TEMPERATURE_TASK_INDEX; + uint8_t BaseVarIndex = TaskIndex * VARS_PER_TASK + P090_TEMPERATURE_TASK_VALUE; float temperature = UserVar[BaseVarIndex]; // in degrees C // convert to celsius if required int temperature_in_fahrenheit = P090_TEMPERATURE_SCALE; @@ -292,8 +292,8 @@ boolean Plugin_090(byte function, struct EventStruct *event, String& string) temp = F("F"); } - byte TaskIndex2 = P090_HUMIDITY_TASK_INDEX; - byte BaseVarIndex2 = TaskIndex2 * VARS_PER_TASK + P090_HUMIDITY_TASK_VALUE; + uint8_t TaskIndex2 = P090_HUMIDITY_TASK_INDEX; + uint8_t BaseVarIndex2 = TaskIndex2 * VARS_PER_TASK + P090_HUMIDITY_TASK_VALUE; float humidity = UserVar[BaseVarIndex2]; // in % relative #ifndef BUILD_NO_DEBUG diff --git a/src/_P091_SerSwitch.ino b/src/_P091_SerSwitch.ino index 12f398df0..68a40e33e 100644 --- a/src/_P091_SerSwitch.ino +++ b/src/_P091_SerSwitch.ino @@ -67,19 +67,19 @@ #define SER_SWITCH_LCTECH 3 #define SER_SWITCH_WIFIDIMMER 4 -static byte Plugin_091_switchstate[4]; -static byte Plugin_091_ostate[4]; -byte Plugin_091_commandstate = 0; // 0:no,1:inprogress,2:finished +static uint8_t Plugin_091_switchstate[4]; +static uint8_t Plugin_091_ostate[4]; +uint8_t Plugin_091_commandstate = 0; // 0:no,1:inprogress,2:finished Sensor_VType Plugin_091_type = Sensor_VType::SENSOR_TYPE_NONE; -byte Plugin_091_numrelay = 1; -byte Plugin_091_ownindex; -byte Plugin_091_globalpar0; -byte Plugin_091_globalpar1; -byte Plugin_091_cmddbl = false; -byte Plugin_091_ipd = false; +uint8_t Plugin_091_numrelay = 1; +uint8_t Plugin_091_ownindex; +uint8_t Plugin_091_globalpar0; +uint8_t Plugin_091_globalpar1; +uint8_t Plugin_091_cmddbl = false; +uint8_t Plugin_091_ipd = false; boolean Plugin_091_init = false; -boolean Plugin_091(byte function, struct EventStruct *event, String& string) +boolean Plugin_091(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -120,7 +120,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); const __FlashStringHelper * options[4]; options[0] = F("Yewelink/TUYA"); options[1] = F("Sonoff Dual"); @@ -132,7 +132,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) if (PCONFIG(0) == SER_SWITCH_YEWE) { - byte choice = PCONFIG(1); + uint8_t choice = PCONFIG(1); const __FlashStringHelper * buttonOptions[4]; buttonOptions[0] = F("1"); buttonOptions[1] = F("2/Dimmer#2"); @@ -144,7 +144,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) if (PCONFIG(0) == SER_SWITCH_SONOFFDUAL) { - byte choice = PCONFIG(1); + uint8_t choice = PCONFIG(1); const __FlashStringHelper * modeoptions[3]; modeoptions[0] = F("Normal"); modeoptions[1] = F("Exclude/Blinds mode"); @@ -156,7 +156,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) if (PCONFIG(0) == SER_SWITCH_LCTECH) { { - byte choice = PCONFIG(1); + uint8_t choice = PCONFIG(1); const __FlashStringHelper * buttonOptions[4]; buttonOptions[0] = F("1"); buttonOptions[1] = F("2"); @@ -167,7 +167,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) } { - byte choice = PCONFIG(2); + uint8_t choice = PCONFIG(2); const __FlashStringHelper * speedOptions[8]; speedOptions[0] = F("9600"); speedOptions[1] = F("19200"); @@ -323,7 +323,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) case PLUGIN_SERIAL_IN: { int bytes_read = 0; - byte serial_buf[BUFFER_SIZE]; + uint8_t serial_buf[BUFFER_SIZE]; String log; if (Plugin_091_init) @@ -338,14 +338,14 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) Plugin_091_commandstate = 0; switch (PCONFIG(0)) { - case SER_SWITCH_YEWE: //decode first byte of package + case SER_SWITCH_YEWE: //decode first uint8_t of package { if (serial_buf[bytes_read] == 0x55) { Plugin_091_commandstate = 1; } break; } - case SER_SWITCH_SONOFFDUAL: //decode first byte of package + case SER_SWITCH_SONOFFDUAL: //decode first uint8_t of package { if (serial_buf[bytes_read] == 0xA0) { Plugin_091_commandstate = 1; @@ -452,7 +452,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) } if (bytes_read == 10) { if (serial_buf[5] == 5) { - byte btnnum = (serial_buf[6] - 1); + uint8_t btnnum = (serial_buf[6] - 1); Plugin_091_ostate[btnnum] = Plugin_091_switchstate[btnnum]; Plugin_091_switchstate[btnnum] = serial_buf[10]; Plugin_091_commandstate = 2; bytes_read = 0; @@ -498,11 +498,11 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) sendData(event); } } - } //10th byte end (Tuya switch) + } //10th uint8_t end (Tuya switch) if (bytes_read == 13) { if (serial_buf[5] == 8) { - byte btnnum = (serial_buf[6] - 1); + uint8_t btnnum = (serial_buf[6] - 1); Plugin_091_ostate[btnnum] = Plugin_091_switchstate[btnnum]; Plugin_091_switchstate[btnnum] = serial_buf[13]; Plugin_091_commandstate = 2; bytes_read = 0; @@ -532,7 +532,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) sendData(event); } } - } //13th byte end (Tuya dimmer) + } //13th uint8_t end (Tuya dimmer) } // yewe decode end } // Plugin_091_commandstate 1 end @@ -576,9 +576,9 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) { String log; String command = parseString(string, 1); - byte rnum = 0; - byte rcmd = 0; - byte par3 = 0; + uint8_t rnum = 0; + uint8_t rcmd = 0; + uint8_t par3 = 0; if (Plugin_091_init) { @@ -767,7 +767,7 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) case PLUGIN_TIMER_IN: { - byte par3 = 0; + uint8_t par3 = 0; LoadTaskSettings(Plugin_091_ownindex); // get our own task values please event->setTaskIndex(Plugin_091_ownindex); @@ -776,8 +776,8 @@ boolean Plugin_091(byte function, struct EventStruct *event, String& string) par3 = Plugin_091_globalpar1; } - byte rnum = event->Par1; - byte rcmd = event->Par2; + uint8_t rnum = event->Par1; + uint8_t rcmd = event->Par2; sendmcucommand(rnum, rcmd, Plugin_091_globalpar0, par3); // invert state if ( Plugin_091_globalpar0 > SER_SWITCH_YEWE) { // report state only if not Yewe @@ -826,9 +826,9 @@ void getmcustate() { Serial.flush(); } -void sendmcucommand(byte btnnum, byte state, byte swtype, byte btnum_mode) // btnnum=0,1,2, state=0/1 +void sendmcucommand(uint8_t btnnum, uint8_t state, uint8_t swtype, uint8_t btnum_mode) // btnnum=0,1,2, state=0/1 { - byte sstate; + uint8_t sstate; switch (swtype) { @@ -871,12 +871,12 @@ void sendmcucommand(byte btnnum, byte state, byte swtype, byte btnum_mode) // bt } case SER_SWITCH_LCTECH: { - byte c_d = 1; + uint8_t c_d = 1; if (Plugin_091_cmddbl) { c_d = 2; } Plugin_091_switchstate[btnnum] = state; - for (byte x = 0; x < c_d; x++) // try twice to be sure + for (uint8_t x = 0; x < c_d; x++) // try twice to be sure { if (x > 0) { delay(1); @@ -936,7 +936,7 @@ void sendmcucommand(byte btnnum, byte state, byte swtype, byte btnum_mode) // bt } } -void sendmcudim(byte dimvalue, byte swtype) +void sendmcudim(uint8_t dimvalue, uint8_t swtype) { switch (swtype) { @@ -956,7 +956,7 @@ void sendmcudim(byte dimvalue, byte swtype) Serial.write(0x00); // ? Serial.write(0x00); // ? Serial.write( dimvalue ); // dim value (0-255) - Serial.write( byte(19 + Plugin_091_numrelay + dimvalue) ); // checksum:sum of all bytes in packet mod 256 + Serial.write( uint8_t(19 + Plugin_091_numrelay + dimvalue) ); // checksum:sum of all bytes in packet mod 256 Serial.flush(); break; } diff --git a/src/_P093_MitsubishiHP.ino b/src/_P093_MitsubishiHP.ino index 5af80c7f8..ea4d8d172 100644 --- a/src/_P093_MitsubishiHP.ino +++ b/src/_P093_MitsubishiHP.ino @@ -492,7 +492,7 @@ private: uint8_t value = _serial->read(); if (_readPos == 0) { - // Wait for start byte. + // Wait for start uint8_t. if (value == 0xfc) { addByteToReadBuffer(value); } else { @@ -502,7 +502,7 @@ private: // Read header + data part - data length is at index 4. addByteToReadBuffer(value); } else { - // Done, last byte is checksum. + // Done, last uint8_t is checksum. uint8_t length = _readPos; _readPos = 0; return processIncomingPacket(_readBuffer, length, value); @@ -691,7 +691,7 @@ private: const Mappings _mappings; }; -boolean Plugin_093(byte function, struct EventStruct *event, String& string) { +boolean Plugin_093(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { diff --git a/src/_P094_CULReader.ino b/src/_P094_CULReader.ino index f263d56db..2cffc8feb 100644 --- a/src/_P094_CULReader.ino +++ b/src/_P094_CULReader.ino @@ -56,7 +56,7 @@ // Timeout between sentences. -boolean Plugin_094(byte function, struct EventStruct *event, String& string) { +boolean Plugin_094(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -82,10 +82,10 @@ boolean Plugin_094(byte function, struct EventStruct *event, String& string) { } case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P094_NR_OUTPUT_VALUES) { - const byte pconfigIndex = i + P094_QUERY1_CONFIG_POS; - byte choice = PCONFIG(pconfigIndex); + const uint8_t pconfigIndex = i + P094_QUERY1_CONFIG_POS; + uint8_t choice = PCONFIG(pconfigIndex); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], Plugin_094_valuename(choice, false), @@ -110,7 +110,7 @@ boolean Plugin_094(byte function, struct EventStruct *event, String& string) { if ((nullptr != P094_data) && P094_data->isInitialized()) { uint32_t success, error, length_last; P094_data->getSentencesReceived(success, error, length_last); - byte varNr = VARS_PER_TASK; + uint8_t varNr = VARS_PER_TASK; pluginWebformShowValue(event->TaskIndex, varNr++, F("Success"), String(success)); pluginWebformShowValue(event->TaskIndex, varNr++, F("Error"), String(error)); pluginWebformShowValue(event->TaskIndex, varNr++, F("Length Last"), String(length_last), true); @@ -167,7 +167,7 @@ boolean Plugin_094(byte function, struct EventStruct *event, String& string) { static_cast(getPluginTaskData(event->TaskIndex)); if (nullptr != P094_data) { - for (byte varNr = 0; varNr < P94_Nlines; varNr++) + for (uint8_t varNr = 0; varNr < P94_Nlines; varNr++) { P094_data->setLine(varNr, webArg(getPluginCustomArgName(varNr))); } @@ -236,7 +236,7 @@ boolean Plugin_094(byte function, struct EventStruct *event, String& string) { } // Filter length options: // - 22 char, for hash-value then we filter the exact meter including serial and meter type, (that will also prevent very quit sending meters, which normaly is a fault) - // - 38 char, The exact message, because we have 2 byte from the value payload + // - 38 char, The exact message, because we have 2 uint8_t from the value payload //sendData_checkDuplicates(event, event->String2.substring(0, 22)); sendData(event); } @@ -323,7 +323,7 @@ bool Plugin_094_match_all(taskIndex_t taskIndex, const String& received) return res; } -String Plugin_094_valuename(byte value_nr, bool displayString) { +String Plugin_094_valuename(uint8_t value_nr, bool displayString) { switch (value_nr) { case P094_QUERY_VALUE: return displayString ? F("Value") : F("v"); } @@ -363,18 +363,18 @@ void P094_html_show_matchForms(struct EventStruct *event) { } - byte filterSet = 0; + uint8_t filterSet = 0; uint32_t optional = 0; P094_Filter_Value_Type capture = P094_Filter_Value_Type::P094_packet_length; P094_Filter_Comp comparator = P094_Filter_Comp::P094_Equal_OR; String filter; - for (byte filterLine = 0; filterLine < P094_NR_FILTERS; ++filterLine) + for (uint8_t filterLine = 0; filterLine < P094_NR_FILTERS; ++filterLine) { // Filter parameter number on a filter line. bool newLine = (filterLine % P094_AND_FILTER_BLOCK) == 0; - for (byte filterLinePar = 0; filterLinePar < P094_ITEMS_PER_FILTER; ++filterLinePar) + for (uint8_t filterLinePar = 0; filterLinePar < P094_ITEMS_PER_FILTER; ++filterLinePar) { String id = getPluginCustomArgName(P094_data_struct::P094_Get_filter_base_index(filterLine) + filterLinePar); diff --git a/src/_P095_ILI9341.ino b/src/_P095_ILI9341.ino index bf6a4b359..de35e94ac 100644 --- a/src/_P095_ILI9341.ino +++ b/src/_P095_ILI9341.ino @@ -151,16 +151,16 @@ struct Plugin_095_TFT_SettingStruct { } - byte address_tft_cs; - byte address_tft_dc; - byte address_tft_rst; - byte rotation; + uint8_t address_tft_cs; + uint8_t address_tft_dc; + uint8_t address_tft_rst; + uint8_t rotation; } TFT_Settings; //The display pointer Adafruit_ILI9341 *tft = NULL; -boolean Plugin_095(byte function, struct EventStruct *event, String& string) +boolean Plugin_095(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -207,7 +207,7 @@ boolean Plugin_095(byte function, struct EventStruct *event, String& string) case PLUGIN_SET_DEFAULTS: { - byte init = PCONFIG(0); + uint8_t init = PCONFIG(0); //if already configured take it from settings, else use default values (only for pin values) if(init != 1) @@ -226,7 +226,7 @@ boolean Plugin_095(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte init = PCONFIG(0); + uint8_t init = PCONFIG(0); //if already configured take it from settings, else use default values (only for pin values) if(init == 1) @@ -236,7 +236,7 @@ boolean Plugin_095(byte function, struct EventStruct *event, String& string) TFT_Settings.address_tft_rst = PIN(2); } - byte choice2 = PCONFIG(1); + uint8_t choice2 = PCONFIG(1); const __FlashStringHelper * options2[4] = { F("Normal"), F("+90°"), F("+180°"), F("+270°") }; int optionValues2[4] = { 0, 1, 2, 3 }; addFormSelector(F("Rotation"), F("p095_rotate"), 4, options2, optionValues2, choice2); diff --git a/src/_P096_eInk.ino b/src/_P096_eInk.ino index bb55c2f9d..9985449a9 100644 --- a/src/_P096_eInk.ino +++ b/src/_P096_eInk.ino @@ -129,20 +129,20 @@ struct Plugin_096_EPD_SettingStruct { } - byte address_epd_cs; - byte address_epd_dc; - byte address_epd_rst; - byte address_epd_busy; - byte rotation; + uint8_t address_epd_cs; + uint8_t address_epd_dc; + uint8_t address_epd_rst; + uint8_t address_epd_busy; + uint8_t rotation; int width; int height; } EPD_Settings; //The display pointer LOLIN_IL3897 *eInkScreen = NULL; -byte plugin_096_sequence_in_progress = false; +uint8_t plugin_096_sequence_in_progress = false; -boolean Plugin_096(byte function, struct EventStruct *event, String& string) +boolean Plugin_096(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -189,7 +189,7 @@ boolean Plugin_096(byte function, struct EventStruct *event, String& string) case PLUGIN_SET_DEFAULTS: { - byte init = PCONFIG(0); + uint8_t init = PCONFIG(0); //if already configured take it from settings, else use default values (only for pin values) if(init != 1) @@ -209,7 +209,7 @@ boolean Plugin_096(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte init = PCONFIG(0); + uint8_t init = PCONFIG(0); //if already configured take it from settings, else use default values (only for pin values) if(init == 1) @@ -223,7 +223,7 @@ boolean Plugin_096(byte function, struct EventStruct *event, String& string) addFormPinSelect(formatGpioName_output(F("EPD BUSY")), F("p096_epd_busy"), EPD_Settings.address_epd_busy); { - byte choice2 = PCONFIG(1); + uint8_t choice2 = PCONFIG(1); const __FlashStringHelper * options2[4] = { F("Normal"), F("+90°"), F("+180°"), F("+270°") }; int optionValues2[4] = { 0, 1, 2, 3 }; addFormSelector(F("Rotation"), F("p096_rotate"), 4, options2, optionValues2, choice2); @@ -257,7 +257,7 @@ boolean Plugin_096(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { - byte init = PCONFIG(0); + uint8_t init = PCONFIG(0); //if already configured take it from settings, else use default values (only for pin values) if(init != 1) diff --git a/src/_P097_Esp32Touch.ino b/src/_P097_Esp32Touch.ino index 85c9e1468..c4fe5796f 100644 --- a/src/_P097_Esp32Touch.ino +++ b/src/_P097_Esp32Touch.ino @@ -34,7 +34,7 @@ DRAM_ATTR uint32_t p097_pinTouchedPrev = 0; DRAM_ATTR uint32_t p097_timestamp[10] = { 0 }; -boolean Plugin_097(byte function, struct EventStruct *event, String& string) +boolean Plugin_097(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P099_XPT2046Touch.ino b/src/_P099_XPT2046Touch.ino index 40b0724ac..5a0441bdf 100644 --- a/src/_P099_XPT2046Touch.ino +++ b/src/_P099_XPT2046Touch.ino @@ -78,7 +78,7 @@ #define P099_TOUCH_Z_INVALID 255 -boolean Plugin_099(byte function, struct EventStruct *event, String& string) +boolean Plugin_099(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -163,7 +163,7 @@ boolean Plugin_099(byte function, struct EventStruct *event, String& string) addFormNumericBox(F("Screen Height (px) (y)"), F("p099_height"), height_, 1, 65535); { - byte choice2 = P099_CONFIG_ROTATION; + uint8_t choice2 = P099_CONFIG_ROTATION; const __FlashStringHelper * options2[4] = { F("Normal"), F("+90°"), F("+180°"), F("+270°") }; // Avoid unicode int optionValues2[4] = { 0, 1, 2, 3 }; // Rotation similar to the TFT ILI9341 rotation addFormSelector(F("Rotation"), F("p099_rotate"), 4, options2, optionValues2, choice2); @@ -175,11 +175,11 @@ boolean Plugin_099(byte function, struct EventStruct *event, String& string) addFormSubHeader(F("Touch configuration")); - byte treshold = P099_CONFIG_TRESHOLD; + uint8_t treshold = P099_CONFIG_TRESHOLD; addFormNumericBox(F("Touch minimum pressure"), F("p099_treshold"), treshold, 0, 255); # define P099_EVENTS_OPTIONS 6 - byte choice3 = 0; + uint8_t choice3 = 0; bitWrite(choice3, P099_FLAGS_SEND_XY, bitRead(P099_CONFIG_FLAGS, P099_FLAGS_SEND_XY)); bitWrite(choice3, P099_FLAGS_SEND_Z, bitRead(P099_CONFIG_FLAGS, P099_FLAGS_SEND_Z)); bitWrite(choice3, P099_FLAGS_SEND_OBJECTNAME, bitRead(P099_CONFIG_FLAGS, P099_FLAGS_SEND_OBJECTNAME)); @@ -243,7 +243,7 @@ boolean Plugin_099(byte function, struct EventStruct *event, String& string) { if (P099_CONFIG_OBJECTCOUNT > P099_MaxObjectCount) P099_CONFIG_OBJECTCOUNT = P099_MaxObjectCount; - byte choice5 = P099_CONFIG_OBJECTCOUNT; + uint8_t choice5 = P099_CONFIG_OBJECTCOUNT; if (choice5 == 0) { // Uninitialized, so use default choice5 = P099_CONFIG_OBJECTCOUNT = P099_INIT_OBJECTCOUNT; } @@ -292,7 +292,7 @@ boolean Plugin_099(byte function, struct EventStruct *event, String& string) html_end_table(); addFormNote(F("Start objectname with '_' to ignore/disable the object (temporarily).")); - byte debounce = P099_CONFIG_DEBOUNCE_MS; + uint8_t debounce = P099_CONFIG_DEBOUNCE_MS; addFormNumericBox(F("Debounce delay for On/Off buttons"), F("p099_debounce"), debounce, 0, 255); addUnit(F("0-255 msec.")); } diff --git a/src/_P100_DS2423_counter.ino b/src/_P100_DS2423_counter.ino index 0fdeba3fd..549a40c33 100644 --- a/src/_P100_DS2423_counter.ino +++ b/src/_P100_DS2423_counter.ino @@ -14,7 +14,7 @@ # define PLUGIN_NAME_100 "Pulse Counter - DS2423 [TESTING]" # define PLUGIN_VALUENAME1_100 "CountDelta" -boolean Plugin_100(byte function, struct EventStruct *event, String& string) +boolean Plugin_100(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P101_WakeOnLan.ino b/src/_P101_WakeOnLan.ino index e056b3111..a1875530f 100644 --- a/src/_P101_WakeOnLan.ino +++ b/src/_P101_WakeOnLan.ino @@ -105,7 +105,7 @@ bool validatePort(const String& portStr); // ************************************************************************************************ -boolean Plugin_101(byte function, struct EventStruct *event, String& string) +boolean Plugin_101(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -262,7 +262,7 @@ boolean Plugin_101(byte function, struct EventStruct *event, String& string) } // Save all the Task parameters. - SaveCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemplate, sizeof(deviceTemplate)); + SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemplate, sizeof(deviceTemplate)); UDP_PORT_P101 = getFormItemInt(F(FORM_PORT_P101)); success = true; break; @@ -282,7 +282,7 @@ boolean Plugin_101(byte function, struct EventStruct *event, String& string) char ipString[IP_BUFF_SIZE_P101] = ""; char macString[MAC_BUFF_SIZE_P101] = ""; bool taskEnable = false; - byte parse_error = false; + uint8_t parse_error = false; String msgStr; String strings[2]; String tmpString = string; diff --git a/src/_P102_PZEM004Tv3.ino b/src/_P102_PZEM004Tv3.ino index 9954bbf80..cf6e9e9a2 100644 --- a/src/_P102_PZEM004Tv3.ino +++ b/src/_P102_PZEM004Tv3.ino @@ -47,12 +47,12 @@ uint8_t P102_PZEM_ADDR_SET = 0; // Flag for status of programmation/Energy reset // energy done // Forward declaration helper function -const __FlashStringHelper * p102_getQueryString(byte query); +const __FlashStringHelper * p102_getQueryString(uint8_t query); -boolean Plugin_102(byte function, struct EventStruct *event, String& string) +boolean Plugin_102(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -83,9 +83,9 @@ boolean Plugin_102(byte function, struct EventStruct *event, String& string) case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P102_NR_OUTPUT_VALUES) { - byte choice = PCONFIG(i + P102_QUERY1_CONFIG_POS); + uint8_t choice = PCONFIG(i + P102_QUERY1_CONFIG_POS); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], p102_getQueryString(choice), @@ -191,8 +191,8 @@ boolean Plugin_102(byte function, struct EventStruct *event, String& string) options[i] = p102_getQueryString(i); } - for (byte i = 0; i < P102_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P102_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P102_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P102_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P102_NR_OUTPUT_OPTIONS, options); } @@ -204,9 +204,9 @@ boolean Plugin_102(byte function, struct EventStruct *event, String& string) serialHelper_webformSave(event); // Save output selector parameters. - for (byte i = 0; i < P102_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P102_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < P102_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P102_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, p102_getQueryString(choice)); } P102_PZEM_mode = getFormItemInt(F("P102_PZEM_mode")); @@ -285,7 +285,7 @@ boolean Plugin_102(byte function, struct EventStruct *event, String& string) PZEM[4] = P102_PZEM_sensor->pf(); PZEM[5] = P102_PZEM_sensor->frequency(); - for (byte i = 0; i < 6; i++) // Check each PZEM field + for (uint8_t i = 0; i < 6; i++) // Check each PZEM field { if (PZEM[i] != PZEM[i]) // Check if NAN { @@ -364,7 +364,7 @@ boolean Plugin_102(byte function, struct EventStruct *event, String& string) return success; } -const __FlashStringHelper * p102_getQueryString(byte query) { +const __FlashStringHelper * p102_getQueryString(uint8_t query) { switch (query) { case 0: return F("Voltage_V"); diff --git a/src/_P103_Atlas_EZO_pH_ORP_EC.ino b/src/_P103_Atlas_EZO_pH_ORP_EC.ino index 77634701e..a01515876 100644 --- a/src/_P103_Atlas_EZO_pH_ORP_EC.ino +++ b/src/_P103_Atlas_EZO_pH_ORP_EC.ino @@ -27,12 +27,12 @@ #define FIXED_TEMP_VALUE 20 // Temperature correction for pH and EC sensor if no temperature is given from calculation -boolean Plugin_103(byte function, struct EventStruct *event, String &string) +boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string) { boolean success = false; - byte board_type = UNKNOWN; - byte I2Cchoice; + uint8_t board_type = UNKNOWN; + uint8_t I2Cchoice; switch (function) { @@ -266,7 +266,7 @@ boolean Plugin_103(byte function, struct EventStruct *event, String &string) addFormSubHeader(F("Temperature compensation")); char deviceTemperatureTemplate[40] = {0}; - LoadCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate)); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate)); ZERO_TERMINATE(deviceTemperatureTemplate); addFormTextBox(F("Temperature "), F("Plugin_103_temperature_template"), deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate)); addFormNote(F("You can use a formulae and idealy refer to a temp sensor (directly, via ESPEasyP2P or MQTT import) ,e.g. '[Pool#Temperature]'. If you don't have a sensor, you could type a fixed value like '25' for '25.5'.")); @@ -374,7 +374,7 @@ boolean Plugin_103(byte function, struct EventStruct *event, String &string) safe_strncpy(deviceTemperatureTemplate, tmpString.c_str(), sizeof(deviceTemperatureTemplate) - 1); ZERO_TERMINATE(deviceTemperatureTemplate); // be sure that our string ends with a \0 - addHtmlError(SaveCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate))); + addHtmlError(SaveCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate))); } success = true; @@ -397,7 +397,7 @@ boolean Plugin_103(byte function, struct EventStruct *event, String &string) { // first set the temperature of reading char deviceTemperatureTemplate[40] = {0}; - LoadCustomTaskSettings(event->TaskIndex, (byte *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate)); + LoadCustomTaskSettings(event->TaskIndex, (uint8_t *)&deviceTemperatureTemplate, sizeof(deviceTemperatureTemplate)); ZERO_TERMINATE(deviceTemperatureTemplate); String deviceTemperatureTemplateString(deviceTemperatureTemplate); @@ -453,9 +453,9 @@ bool _P103_send_I2C_command(uint8_t I2Caddress, const String &cmd, char *sensord uint16_t sensor_bytes_received = 0; - byte error; - byte i2c_response_code = 0; - byte in_char = 0; + uint8_t error; + uint8_t i2c_response_code = 0; + uint8_t in_char = 0; String log = F("> cmd = "); log += cmd; @@ -506,7 +506,7 @@ bool _P103_send_I2C_command(uint8_t I2Caddress, const String &cmd, char *sensord addLog(LOG_LEVEL_ERROR, F("< result array to short!")); return false; } - sensordata[sensor_bytes_received] = in_char; // load this byte into our array. + sensordata[sensor_bytes_received] = in_char; // load this uint8_t into our array. sensor_bytes_received++; } } @@ -578,7 +578,7 @@ void addCreateDryCalibration() addFormNote(F("Calibration for pH-Probe could be 1 (single) or 2 point (low, high).")); } -int addCreateSinglePointCalibration(byte board_type, struct EventStruct *event, byte I2Cchoice, String unit, float min, float max, byte nrDecimals, float stepsize) +int addCreateSinglePointCalibration(uint8_t board_type, struct EventStruct *event, uint8_t I2Cchoice, String unit, float min, float max, uint8_t nrDecimals, float stepsize) { int nb_calibration_points = getCalibrationPoints(I2Cchoice); @@ -614,7 +614,7 @@ int addCreateSinglePointCalibration(byte board_type, struct EventStruct *event, return nb_calibration_points; } -int addCreate3PointCalibration(byte board_type, struct EventStruct *event, byte I2Cchoice, String unit, float min, float max, byte nrDecimals, float stepsize) +int addCreate3PointCalibration(uint8_t board_type, struct EventStruct *event, uint8_t I2Cchoice, String unit, float min, float max, uint8_t nrDecimals, float stepsize) { int nb_calibration_points = addCreateSinglePointCalibration(board_type, event, I2Cchoice, unit, min, max, nrDecimals, stepsize); diff --git a/src/_P106_BME680.ino b/src/_P106_BME680.ino index 0d75d406f..86785b58d 100644 --- a/src/_P106_BME680.ino +++ b/src/_P106_BME680.ino @@ -27,7 +27,7 @@ # define PLUGIN_VALUENAME4_106 "Gas" -boolean Plugin_106(byte function, struct EventStruct *event, String& string) +boolean Plugin_106(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -66,7 +66,7 @@ boolean Plugin_106(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); /* String options[2]; diff --git a/src/_P107_SI1145.ino b/src/_P107_SI1145.ino index 8f572d42e..d56190300 100644 --- a/src/_P107_SI1145.ino +++ b/src/_P107_SI1145.ino @@ -14,7 +14,7 @@ # define PLUGIN_VALUENAME2_107 "Infra" # define PLUGIN_VALUENAME3_107 "UV" -boolean Plugin_107(byte function, struct EventStruct *event, String& string) +boolean Plugin_107(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P108_DDS238.ino b/src/_P108_DDS238.ino index de522a3c2..36e770699 100644 --- a/src/_P108_DDS238.ino +++ b/src/_P108_DDS238.ino @@ -73,7 +73,7 @@ DF - Below doesn't look right; needs a RS485 to TTL(3.3v) level converter (see h #include "src/DataStructs/ESPEasy_packed_raw_data.h" // Forward declaration of functions -const __FlashStringHelper * Plugin_108_valuename(byte value_nr, bool displayString); +const __FlashStringHelper * Plugin_108_valuename(uint8_t value_nr, bool displayString); struct P108_data_struct : public PluginTaskData_base { P108_data_struct() {} @@ -100,7 +100,7 @@ struct P108_data_struct : public PluginTaskData_base { unsigned int _plugin_108_last_measurement = 0; -boolean Plugin_108(byte function, struct EventStruct *event, String& string) { +boolean Plugin_108(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; switch (function) { @@ -125,10 +125,10 @@ boolean Plugin_108(byte function, struct EventStruct *event, String& string) { } case PLUGIN_GET_DEVICEVALUENAMES: { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < P108_NR_OUTPUT_VALUES) { - const byte pconfigIndex = i + P108_QUERY1_CONFIG_POS; - byte choice = PCONFIG(pconfigIndex); + const uint8_t pconfigIndex = i + P108_QUERY1_CONFIG_POS; + uint8_t choice = PCONFIG(pconfigIndex); safe_strncpy( ExtraTaskSettings.TaskDeviceValueNames[i], Plugin_108_valuename(choice, false), @@ -232,8 +232,8 @@ boolean Plugin_108(byte function, struct EventStruct *event, String& string) { options[i] = Plugin_108_valuename(i, true); } - for (byte i = 0; i < P108_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P108_QUERY1_CONFIG_POS; + for (uint8_t i = 0; i < P108_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P108_QUERY1_CONFIG_POS; sensorTypeHelper_loadOutputSelector(event, pconfigIndex, i, P108_NR_OUTPUT_OPTIONS, options); } } @@ -250,9 +250,9 @@ boolean Plugin_108(byte function, struct EventStruct *event, String& string) { } // Save output selector parameters. - for (byte i = 0; i < P108_NR_OUTPUT_VALUES; ++i) { - const byte pconfigIndex = i + P108_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < P108_NR_OUTPUT_VALUES; ++i) { + const uint8_t pconfigIndex = i + P108_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); sensorTypeHelper_saveOutputSelector(event, pconfigIndex, i, Plugin_108_valuename(choice, false)); } // Can't clear totals, maybe because of modbus library can't write DWORD? @@ -333,9 +333,9 @@ boolean Plugin_108(byte function, struct EventStruct *event, String& string) { // Matching JS code: // return decode(bytes, [header, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4, uint8, int32_1e4], // ['header', 'unit1', 'val_1', 'unit2', 'val_2', 'unit3', 'val_3', 'unit4', 'val_4']); - for (byte i = 0; i < VARS_PER_TASK; ++i) { - const byte pconfigIndex = i + P108_QUERY1_CONFIG_POS; - const byte choice = PCONFIG(pconfigIndex); + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { + const uint8_t pconfigIndex = i + P108_QUERY1_CONFIG_POS; + const uint8_t choice = PCONFIG(pconfigIndex); string += LoRa_addInt(choice, PackedData_uint8); string += LoRa_addFloat(UserVar[event->BaseVarIndex + i], PackedData_int32_1e4); } @@ -351,7 +351,7 @@ boolean Plugin_108(byte function, struct EventStruct *event, String& string) { return success; } -const __FlashStringHelper * Plugin_108_valuename(byte value_nr, bool displayString) { +const __FlashStringHelper * Plugin_108_valuename(uint8_t value_nr, bool displayString) { switch (value_nr) { case P108_QUERY_V: return displayString ? F("Voltage (V)") : F("V"); case P108_QUERY_A: return displayString ? F("Current (A)") : F("A"); @@ -366,7 +366,7 @@ const __FlashStringHelper * Plugin_108_valuename(byte value_nr, bool displayStri return F(""); } -int p108_storageValueToBaudrate(byte baudrate_setting) { +int p108_storageValueToBaudrate(uint8_t baudrate_setting) { switch (baudrate_setting) { case 0: return 1200; @@ -380,8 +380,8 @@ int p108_storageValueToBaudrate(byte baudrate_setting) { return 9600; } -float p108_readValue(byte query, struct EventStruct *event) { - byte errorcode = -1; // DF - not present in P085 +float p108_readValue(uint8_t query, struct EventStruct *event) { + uint8_t errorcode = -1; // DF - not present in P085 float value = 0; // DF - not present in P085 P108_data_struct *P108_data = static_cast(getPluginTaskData(event->TaskIndex)); @@ -421,7 +421,7 @@ float p108_readValue(byte query, struct EventStruct *event) { return 0.0f; } -void p108_showValueLoadPage(byte query, struct EventStruct *event) { +void p108_showValueLoadPage(uint8_t query, struct EventStruct *event) { addRowLabel(Plugin_108_valuename(query, true)); addHtml(String(p108_readValue(query, event))); } diff --git a/src/_P110_VL53L0X.ino b/src/_P110_VL53L0X.ino index 3bb01e422..41e66370e 100644 --- a/src/_P110_VL53L0X.ino +++ b/src/_P110_VL53L0X.ino @@ -26,7 +26,7 @@ boolean Plugin_110_init[3] = {false, false, false}; -boolean Plugin_110(byte function, struct EventStruct *event, String& string) +boolean Plugin_110(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -61,7 +61,7 @@ boolean Plugin_110(byte function, struct EventStruct *event, String& string) } case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); int optionValues[2] = { 0x29, 0x30 }; addFormSelectorI2C(F("plugin_110_vl53l0x_i2c"), 2, optionValues, choice); addFormNote(F("SDO Low=0x29, High=0x30")); diff --git a/src/_P111_RC522_RFID.ino b/src/_P111_RC522_RFID.ino index 8dc496ff8..149beb6cd 100644 --- a/src/_P111_RC522_RFID.ino +++ b/src/_P111_RC522_RFID.ino @@ -26,7 +26,7 @@ // #define P111_USE_REMOVAL // Enable (real) Tag Removal detection options -boolean Plugin_111(byte function, struct EventStruct *event, String& string) +boolean Plugin_111(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -167,7 +167,7 @@ boolean Plugin_111(byte function, struct EventStruct *event, String& string) unsigned long key = P111_NO_KEY; bool removedTag = false; - byte error = P111_data->readCardStatus(&key, &removedTag); + uint8_t error = P111_data->readCardStatus(&key, &removedTag); if (error == 0) { unsigned long old_key = UserVar.getSensorTypeLong(event->TaskIndex); diff --git a/src/_P112_AS7265x.ino b/src/_P112_AS7265x.ino index 9de8926aa..aee017bd1 100644 --- a/src/_P112_AS7265x.ino +++ b/src/_P112_AS7265x.ino @@ -23,7 +23,7 @@ #define PLUGIN_VALUENAME3_112 "State" #define AS7265X_ADDR 0x49 -boolean Plugin_112(byte function, struct EventStruct *event, String& string) +boolean Plugin_112(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -86,7 +86,7 @@ boolean Plugin_112(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_LOAD: { - byte choiceMode = PCONFIG_LONG(0); + uint8_t choiceMode = PCONFIG_LONG(0); { // sensor.setGain(AS7265X_GAIN_1X); //Default // sensor.setGain(AS7265X_GAIN_37X); //This is 3.7x @@ -104,7 +104,7 @@ boolean Plugin_112(byte function, struct EventStruct *event, String& string) optionValuesMode[3] = AS7265X_GAIN_64X; addFormSelector(F("Gain"), F("p112_Gain"), 4, optionsMode, optionValuesMode, choiceMode); } - byte choiceMode2 = PCONFIG_LONG(1); + uint8_t choiceMode2 = PCONFIG_LONG(1); { // Integration cycles from 0 (2.78ms) to 255 (711ms) // sensor.setIntegrationCycles(49); //Default: 50*2.8ms = 140ms per reading @@ -130,7 +130,7 @@ boolean Plugin_112(byte function, struct EventStruct *event, String& string) addFormSubHeader(F("LED settings")); addFormCheckBox(F("Blue"), F("p112_BlueStatusLED"), PCONFIG(0)); addHtml(F(" Status LED On")); - byte choiceMode3 = PCONFIG(1); + uint8_t choiceMode3 = PCONFIG(1); { // sensor.setIndicatorCurrent(AS7265X_INDICATOR_CURRENT_LIMIT_1MA); // sensor.setIndicatorCurrent(AS7265X_INDICATOR_CURRENT_LIMIT_2MA); @@ -151,7 +151,7 @@ boolean Plugin_112(byte function, struct EventStruct *event, String& string) addHtml(F(" Current Limit")); addFormNote(F("Activate Status LEDs only for debugging purpose.")); - byte choiceMode4 = PCONFIG(2); + uint8_t choiceMode4 = PCONFIG(2); { // White LED has max forward current of 120mA // sensor.setBulbCurrent(AS7265X_LED_CURRENT_LIMIT_12_5MA, AS7265x_LED_WHITE); //Default @@ -172,7 +172,7 @@ boolean Plugin_112(byte function, struct EventStruct *event, String& string) } addHtml(F(" Current Limit")); - byte choiceMode5 = PCONFIG(3); + uint8_t choiceMode5 = PCONFIG(3); { // IR LED has max forward current of 65mA // sensor.setBulbCurrent(AS7265X_LED_CURRENT_LIMIT_12_5MA, AS7265x_LED_IR); //Default @@ -190,7 +190,7 @@ boolean Plugin_112(byte function, struct EventStruct *event, String& string) addFormSelector(F("IR"), F("p112_IRLEDCurrentLimit"), 3, optionsMode5, optionValuesMode5, choiceMode5); } - byte choiceMode6 = PCONFIG(4); + uint8_t choiceMode6 = PCONFIG(4); { // UV LED has max forward current of 30mA so do not set the drive current higher // sensor.setBulbCurrent(AS7265X_LED_CURRENT_LIMIT_12_5MA, AS7265x_LED_UV); //Default diff --git a/src/_P113_VL53L1X.ino b/src/_P113_VL53L1X.ino index a096d951d..0bd13b370 100644 --- a/src/_P113_VL53L1X.ino +++ b/src/_P113_VL53L1X.ino @@ -20,7 +20,7 @@ # define PLUGIN_VALUENAME2_113 "Ambient" -boolean Plugin_113(byte function, struct EventStruct *event, String& string) +boolean Plugin_113(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -57,7 +57,7 @@ boolean Plugin_113(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { - byte choice = PCONFIG(0); + uint8_t choice = PCONFIG(0); int optionValues[2] = { 0x29, 0x30 }; addFormSelectorI2C(F("plugin_113_vl53l1x_i2c"), 2, optionValues, choice); diff --git a/src/_P114_VEML6075.ino b/src/_P114_VEML6075.ino index 3933ecc9c..066e4cae0 100644 --- a/src/_P114_VEML6075.ino +++ b/src/_P114_VEML6075.ino @@ -19,7 +19,7 @@ # include "./src/PluginStructs/P114_data_struct.h" -boolean Plugin_114(byte function, struct EventStruct *event, String& string) +boolean Plugin_114(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; diff --git a/src/_P115_MAX1704x_v2.ino b/src/_P115_MAX1704x_v2.ino index 13d1a20ee..e6b2acef1 100644 --- a/src/_P115_MAX1704x_v2.ino +++ b/src/_P115_MAX1704x_v2.ino @@ -29,7 +29,7 @@ # define P115_ALERTEVENT PCONFIG(2) # define P115_DEVICESELECTOR PCONFIG(3) -boolean Plugin_115(byte function, struct EventStruct *event, String& string) +boolean Plugin_115(uint8_t function, struct EventStruct *event, String& string) { boolean success = false; @@ -85,7 +85,7 @@ boolean Plugin_115(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { /* - byte choice = P115_I2CADDR; + uint8_t choice = P115_I2CADDR; int optionValues[1] = { 0x36 }; addFormSelectorI2C(F("plugin_115_i2c"), 1, optionValues, choice); */ diff --git a/src/_Plugin_Helper.cpp b/src/_Plugin_Helper.cpp index 6435e06f6..51532d04c 100644 --- a/src/_Plugin_Helper.cpp +++ b/src/_Plugin_Helper.cpp @@ -90,12 +90,12 @@ int getFormItemIntCustomArgName(int varNr) { // if the regular values should also be displayed. // The call to PLUGIN_WEBFORM_SHOW_VALUES should only return success = true when no regular values should be displayed // Note that the varNr of the custom values should not conflict with the existing variable numbers (e.g. start at VARS_PER_TASK) -void pluginWebformShowValue(taskIndex_t taskIndex, byte varNr, const __FlashStringHelper * label, const String& value, bool addTrailingBreak) { +void pluginWebformShowValue(taskIndex_t taskIndex, uint8_t varNr, const __FlashStringHelper * label, const String& value, bool addTrailingBreak) { pluginWebformShowValue(taskIndex, varNr, String(label), value, addTrailingBreak); } void pluginWebformShowValue(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, const String& label, const String& value, bool addTrailingBreak) { @@ -127,7 +127,7 @@ void pluginWebformShowValue(const String& valName, const String& valName_id, con } } -bool pluginOptionalTaskIndexArgumentMatch(taskIndex_t taskIndex, const String& string, byte paramNr) { +bool pluginOptionalTaskIndexArgumentMatch(taskIndex_t taskIndex, const String& string, uint8_t paramNr) { if (!validTaskIndex(taskIndex)) { return false; } diff --git a/src/_Plugin_Helper.h b/src/_Plugin_Helper.h index 4e6f804c3..c0bc4da9a 100644 --- a/src/_Plugin_Helper.h +++ b/src/_Plugin_Helper.h @@ -116,13 +116,13 @@ int getFormItemIntCustomArgName(int varNr); // The call to PLUGIN_WEBFORM_SHOW_VALUES should only return success = true when no regular values should be displayed // Note that the varNr of the custom values should not conflict with the existing variable numbers (e.g. start at VARS_PER_TASK) void pluginWebformShowValue(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, const __FlashStringHelper * label, const String& value, bool addTrailingBreak = false); void pluginWebformShowValue(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, const String& label, const String& value, bool addTrailingBreak = false); @@ -143,7 +143,7 @@ void pluginWebformShowValue(const String& valName, // Return if parameter at given paramNr matches given taskIndex. bool pluginOptionalTaskIndexArgumentMatch(taskIndex_t taskIndex, const String& string, - byte paramNr); + uint8_t paramNr); bool pluginWebformShowGPIOdescription(taskIndex_t taskIndex, const String& newline); diff --git a/src/_Pxxx_PluginTemplate.ino b/src/_Pxxx_PluginTemplate.ino index 3a5c4a268..7a70fa393 100644 --- a/src/_Pxxx_PluginTemplate.ino +++ b/src/_Pxxx_PluginTemplate.ino @@ -85,7 +85,7 @@ // A plugin has to implement the following function -boolean Plugin_xxx(byte function, struct EventStruct *event, String& string) +boolean Plugin_xxx(uint8_t function, struct EventStruct *event, String& string) { // function: reason the plugin was called // event: ??add description here?? @@ -136,11 +136,11 @@ boolean Plugin_xxx(byte function, struct EventStruct *event, String& string) case PLUGIN_WEBFORM_SHOW_I2C_PARAMS: { // Called to show the I2C parameters in the web interface (only called for I2C devices) - byte choice = Pxxx_I2C_ADDR; // define to get the stored I2C address (e.g. PCONFIG(1)) + uint8_t choice = Pxxx_I2C_ADDR; // define to get the stored I2C address (e.g. PCONFIG(1)) int optionValues[16]; - for (byte x = 0; x < 16; x++) + for (uint8_t x = 0; x < 16; x++) { if (x < 8) { optionValues[x] = 0x20 + x; diff --git a/src/__CPlugin.ino b/src/__CPlugin.ino index a3c60a534..c9d369e65 100644 --- a/src/__CPlugin.ino +++ b/src/__CPlugin.ino @@ -25,7 +25,7 @@ void CPluginInit(void) { ProtocolIndex_to_CPlugin_id[CPLUGIN_MAX] = INVALID_C_PLUGIN_ID; - byte x; + uint8_t x; // Clear pointer table for all plugins for (x = 0; x < CPLUGIN_MAX; x++) diff --git a/src/__NPlugin.ino b/src/__NPlugin.ino index 8c8e73214..b90dde7ba 100644 --- a/src/__NPlugin.ino +++ b/src/__NPlugin.ino @@ -31,7 +31,7 @@ static const char ADDNPLUGIN_ERROR[] PROGMEM = "System: Error - Too many N-Plugi void NPluginInit(void) { - byte x; + uint8_t x; // Clear pointer table for all plugins for (x = 0; x < NPLUGIN_MAX; x++) @@ -145,7 +145,7 @@ void NPluginInit(void) NPluginCall(NPlugin::Function::NPLUGIN_PROTOCOL_ADD, 0); } -byte NPluginCall(NPlugin::Function Function, struct EventStruct *event) +uint8_t NPluginCall(NPlugin::Function Function, struct EventStruct *event) { int x; struct EventStruct TempEvent; diff --git a/src/src/Commands/Blynk.cpp b/src/src/Commands/Blynk.cpp index e1c41c94b..952c0b430 100644 --- a/src/src/Commands/Blynk.cpp +++ b/src/src/Commands/Blynk.cpp @@ -143,7 +143,7 @@ bool Blynk_get(const String& command, controllerIndex_t controllerIndex, float * if (data && line.startsWith("[")) { String strValue = line; - byte pos = strValue.indexOf('"', 2); + uint8_t pos = strValue.indexOf('"', 2); strValue = strValue.substring(2, pos); strValue.trim(); *data = 0.0f; diff --git a/src/src/Commands/Common.cpp b/src/src/Commands/Common.cpp index 32965c020..2316e6038 100644 --- a/src/src/Commands/Common.cpp +++ b/src/src/Commands/Common.cpp @@ -62,7 +62,7 @@ const __FlashStringHelper * return_see_serial(struct EventStruct *event) String Command_GetORSetIP(struct EventStruct *event, const String & targetDescription, const char *Line, - byte *IP, + uint8_t *IP, const IPAddress & dhcpIP, int arg) { diff --git a/src/src/Commands/Common.h b/src/src/Commands/Common.h index 4b5775f7f..aadf799f8 100644 --- a/src/src/Commands/Common.h +++ b/src/src/Commands/Common.h @@ -22,7 +22,7 @@ bool IsNumeric(const char *source); String Command_GetORSetIP(struct EventStruct *event, const String & targetDescription, const char *Line, - byte *IP, + uint8_t *IP, const IPAddress& dhcpIP, int arg); diff --git a/src/src/Commands/Diagnostic.cpp b/src/src/Commands/Diagnostic.cpp index b76bfe426..f20afbee9 100644 --- a/src/src/Commands/Diagnostic.cpp +++ b/src/src/Commands/Diagnostic.cpp @@ -159,7 +159,7 @@ const __FlashStringHelper * Command_Debug(struct EventStruct *event, const char const __FlashStringHelper * Command_logentry(struct EventStruct *event, const char *Line) { - byte level = LOG_LEVEL_INFO; + uint8_t level = LOG_LEVEL_INFO; // An extra optional parameter to set log level. if (event->Par2 > LOG_LEVEL_NONE && event->Par2 <= LOG_LEVEL_DEBUG_MORE) { level = event->Par2; } addLog(level, tolerantParseStringKeepCase(Line, 2)); diff --git a/src/src/Commands/GPIO.cpp b/src/src/Commands/GPIO.cpp index f2712b4ab..dbfc2ff80 100644 --- a/src/src/Commands/GPIO.cpp +++ b/src/src/Commands/GPIO.cpp @@ -21,7 +21,7 @@ // Forward declarations of functions used in this module // Normally those would be declared in the .h file as private members // But since these are not part of a class, forward declare them in the .cpp -//void createAndSetPortStatus_Mode_State(uint32_t key, byte newMode, int8_t newState); +//void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t newState); bool getPluginIDAndPrefix(char selection, pluginID_t &pluginID, String &logPrefix); void logErrorGpioOffline(const String& prefix, int port); void logErrorGpioOutOfRange(const String& prefix, int port, const char* Line = nullptr); @@ -31,13 +31,13 @@ bool gpio_monitor_helper(int port, struct EventStruct *event, const char* Line); bool gpio_unmonitor_helper(int port, struct EventStruct *event, const char* Line); bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char* Line, bool isWritePattern); bool pcfgpio_range_pattern_helper(struct EventStruct *event, const char* Line, bool isWritePattern); -bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, const char* Line); -byte getPcfAddress(uint8_t pin); -bool setGPIOMode(byte pin, byte mode); -bool setPCFMode(byte pin, byte mode); -bool setMCPMode(byte pin, byte mode); -bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t &result); -bool pcfgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t &result); +bool gpio_mode_range_helper(uint8_t pin, uint8_t pinMode, struct EventStruct *event, const char* Line); +uint8_t getPcfAddress(uint8_t pin); +bool setGPIOMode(uint8_t pin, uint8_t mode); +bool setPCFMode(uint8_t pin, uint8_t mode); +bool setMCPMode(uint8_t pin, uint8_t mode); +bool mcpgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t &result); +bool pcfgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t &result); /*************************************************************************/ @@ -56,7 +56,7 @@ const __FlashStringHelper * Command_GPIO_MonitorRange(struct EventStruct *event, { bool success = true; - for (byte i = event->Par2; i <= event->Par3; i++) { + for (uint8_t i = event->Par2; i <= event->Par3; i++) { success &= gpio_monitor_helper(i, event, Line); } return success ? return_command_success() : return_command_failed(); @@ -115,7 +115,7 @@ const __FlashStringHelper * Command_GPIO_UnMonitorRange(struct EventStruct *even { bool success = true; - for (byte i = event->Par2; i <= event->Par3; i++) { + for (uint8_t i = event->Par2; i <= event->Par3; i++) { success &= gpio_unmonitor_helper(i, event, Line); } return success ? return_command_success() : return_command_failed(); @@ -193,7 +193,7 @@ const __FlashStringHelper * Command_GPIO_Status(struct EventStruct *event, const { bool success = true; bool sendStatusFlag; - byte pluginID = 0; + uint8_t pluginID = 0; switch (tolower(parseString(Line, 2).charAt(0))) { @@ -278,7 +278,7 @@ const __FlashStringHelper * Command_GPIO_Tone(struct EventStruct *event, const c if (tone_espEasy(event->Par1, event->Par2, duration)) { if (mustScheduleToneOff) { // For now, we only support the internal GPIO pins. - byte pluginID = PLUGIN_GPIO; + uint8_t pluginID = PLUGIN_GPIO; Scheduler.setGPIOTimer(event->Par3, pluginID, event->Par1, 0); } return return_command_success(); @@ -318,7 +318,7 @@ const __FlashStringHelper * Command_GPIO_Pulse(struct EventStruct *event, const { const __FlashStringHelper * logPrefix = F(""); bool success = false; - byte pluginID = INVALID_PLUGIN_ID; + uint8_t pluginID = INVALID_PLUGIN_ID; switch (tolower(Line[0])) { @@ -383,7 +383,7 @@ const __FlashStringHelper * Command_GPIO_Toggle(struct EventStruct *event, const // WARNING: operator [] creates an entry in the map if key does not exist // So the next command should be part of each command: - byte mode; + uint8_t mode; int8_t state; auto it = globalMapPortStatus.find(key); @@ -438,7 +438,7 @@ const __FlashStringHelper * Command_GPIO(struct EventStruct *event, const char * if (success && checkValidPortRange(pluginID, event->Par1)) { int8_t state = 0; - byte mode; + uint8_t mode; if (event->Par2 == 2) { // INPUT mode = PIN_MODE_INPUT_PULLUP; @@ -529,7 +529,7 @@ void logErrorGpioNotOutput(const String& prefix, int port) logErrorGpio(prefix, port, F(" is not an output port")); } -void createAndSetPortStatus_Mode_State(uint32_t key, byte newMode, int8_t newState) +void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t newState) { // WARNING: operator [] creates an entry in the map if key does not exist @@ -594,20 +594,20 @@ struct range_pattern_helper_data { uint32_t write = 0; uint32_t mask = 0; - byte firstPin = 0; - byte lastPin = 0; - byte numBytes = 0; - byte deltaStart = 0; - byte numBits = 0; - byte firstAddress = 0; - byte firstBank = 0; - byte initVal = 0; + uint8_t firstPin = 0; + uint8_t lastPin = 0; + uint8_t numBytes = 0; + uint8_t deltaStart = 0; + uint8_t numBits = 0; + uint8_t firstAddress = 0; + uint8_t firstBank = 0; + uint8_t initVal = 0; bool isMask = false; bool valid = false; }; -range_pattern_helper_data range_helper_shared(pluginID_t plugin, byte pin1, byte pin2) +range_pattern_helper_data range_helper_shared(pluginID_t plugin, uint8_t pin1, uint8_t pin2) { range_pattern_helper_data data; @@ -774,20 +774,20 @@ bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b bool onLine = false; String log; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue; - byte currentVal = data.initVal + i; - byte currentAddress = static_cast(currentVal / 2); - byte currentMask = (data.mask >> (8 * i)) & 0xFF; - byte currentInvertedMask = 0xFF - currentMask; - byte currentWrite = (data.write >> (8 * i)) & 0xFF; - byte currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; - byte currentIOModeRegister = ((currentVal % 2) == 0) ? MCP23017_IODIRA : MCP23017_IODIRB; - byte writeGPIOValue = 0; + uint8_t currentVal = data.initVal + i; + uint8_t currentAddress = static_cast(currentVal / 2); + uint8_t currentMask = (data.mask >> (8 * i)) & 0xFF; + uint8_t currentInvertedMask = 0xFF - currentMask; + uint8_t currentWrite = (data.write >> (8 * i)) & 0xFF; + uint8_t currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; + uint8_t currentIOModeRegister = ((currentVal % 2) == 0) ? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t writeGPIOValue = 0; if (GPIO_MCP_ReadRegister(currentAddress, currentIOModeRegister, &readValue)) { // set type to output only for the pins of the mask - byte writeModeValue = (readValue & currentInvertedMask); + uint8_t writeModeValue = (readValue & currentInvertedMask); GPIO_MCP_WriteRegister(currentAddress, currentIOModeRegister, writeModeValue); GPIO_MCP_ReadRegister(currentAddress, currentGPIORegister, &readValue); @@ -800,16 +800,16 @@ bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b onLine = false; } - byte mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; + uint8_t mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; int8_t state; - for (byte j = 0; j < 8; j++) { - // if ((currentMask & (byte(pow(2,j)))) >> j) { //only for the pins in the mask + for (uint8_t j = 0; j < 8; j++) { + // if ((currentMask & (uint8_t(pow(2,j)))) >> j) { //only for the pins in the mask if ((currentMask & (1 << j)) >> j) { // only for the pins in the mask - byte currentPin = data.firstPin + j + 8 * i; + uint8_t currentPin = data.firstPin + j + 8 * i; const uint32_t key = createKey(PLUGIN_MCP, currentPin); - // state = onLine ? ((writeGPIOValue & byte(pow(2,j))) >> j) : -1; + // state = onLine ? ((writeGPIOValue & uint8_t(pow(2,j))) >> j) : -1; state = onLine ? ((writeGPIOValue & (1 << j)) >> j) : -1; createAndSetPortStatus_Mode_State(key, mode, state); @@ -822,9 +822,9 @@ bool mcpgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b return onLine; } -byte getPcfAddress(uint8_t pin) +uint8_t getPcfAddress(uint8_t pin) { - byte retValue = static_cast((pin - 1) / 8) + 0x20; + uint8_t retValue = static_cast((pin - 1) / 8) + 0x20; if (retValue > 0x27) { retValue += 0x10; } return retValue; @@ -841,24 +841,24 @@ bool pcfgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b bool onLine = false; String log; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue; - byte currentAddress = getPcfAddress(event->Par1 + 8 * i); + uint8_t currentAddress = getPcfAddress(event->Par1 + 8 * i); - byte currentMask = (data.mask >> (8 * i)) & 0xFF; - byte currentInvertedMask = 0xFF - currentMask; - byte currentWrite = (data.write >> (8 * i)) & 0xFF; - byte writeGPIOValue = 255; + uint8_t currentMask = (data.mask >> (8 * i)) & 0xFF; + uint8_t currentInvertedMask = 0xFF - currentMask; + uint8_t currentWrite = (data.write >> (8 * i)) & 0xFF; + uint8_t writeGPIOValue = 255; onLine = GPIO_PCF_ReadAllPins(currentAddress, &readValue); if (onLine) { writeGPIOValue = (readValue & currentInvertedMask) | (currentWrite & data.mask); } - byte mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; + uint8_t mode = (onLine) ? PIN_MODE_OUTPUT : PIN_MODE_OFFLINE; int8_t state; - for (byte j = 0; j < 8; j++) { - byte currentPin = data.firstPin + j + 8 * i; + for (uint8_t j = 0; j < 8; j++) { + uint8_t currentPin = data.firstPin + j + 8 * i; const uint32_t key = createKey(PLUGIN_PCF, currentPin); if ((currentMask & (1 << j)) >> j) { // only for the pins in the mask @@ -888,7 +888,7 @@ bool pcfgpio_range_pattern_helper(struct EventStruct *event, const char *Line, b return onLine; } -bool setGPIOMode(byte pin, byte mode) +bool setGPIOMode(uint8_t pin, uint8_t mode) { if (checkValidPortRange(PLUGIN_GPIO, pin)) { switch (mode) { @@ -908,7 +908,7 @@ bool setGPIOMode(byte pin, byte mode) } } -bool setMCPMode(byte pin, byte mode) +bool setMCPMode(uint8_t pin, uint8_t mode) { if (checkValidPortRange(PLUGIN_MCP, pin)) { switch (mode) { @@ -928,7 +928,7 @@ bool setMCPMode(byte pin, byte mode) } } -bool setPCFMode(byte pin, byte mode) +bool setPCFMode(uint8_t pin, uint8_t mode) { if (checkValidPortRange(PLUGIN_PCF, pin)) { switch (mode) { @@ -967,13 +967,13 @@ const __FlashStringHelper * Command_GPIO_ModeRange(struct EventStruct *event, co { bool success = true; - for (byte i = event->Par1; i <= event->Par2; i++) { + for (uint8_t i = event->Par1; i <= event->Par2; i++) { success &= gpio_mode_range_helper(i, event->Par3, event, Line); } return success ? return_command_success() : return_command_failed(); } -bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, const char *Line) +bool gpio_mode_range_helper(uint8_t pin, uint8_t pinMode, struct EventStruct *event, const char *Line) { String logPrefix; // = new char; String logPostfix; // = new char; @@ -985,7 +985,7 @@ bool gpio_mode_range_helper(byte pin, byte pinMode, struct EventStruct *event, c if (success && checkValidPortRange(pluginID, pin)) { // int8_t state=0; - byte mode = 255; + uint8_t mode = 255; // bool setSuccess=false; @@ -1158,7 +1158,7 @@ bool getGPIOPinStateValues(String& str) { return success; } -bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) +bool mcpgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t& result) { const range_pattern_helper_data data = range_helper_shared(PLUGIN_MCP, pin1, pin2); @@ -1172,11 +1172,11 @@ bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) bool success = false; uint32_t tempResult = 0; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue = 0; - const byte currentVal = data.initVal + i; - const byte currentAddress = static_cast(currentVal / 2); - const byte currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; + const uint8_t currentVal = data.initVal + i; + const uint8_t currentAddress = static_cast(currentVal / 2); + const uint8_t currentGPIORegister = ((currentVal % 2) == 0) ? MCP23017_GPIOA : MCP23017_GPIOB; const bool onLine = GPIO_MCP_ReadRegister(currentAddress, currentGPIORegister, &readValue); @@ -1193,7 +1193,7 @@ bool mcpgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) return success; } -bool pcfgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) +bool pcfgpio_plugin_range_helper(uint8_t pin1, uint8_t pin2, uint16_t& result) { const range_pattern_helper_data data = range_helper_shared(PLUGIN_PCF, pin1, pin2); @@ -1208,9 +1208,9 @@ bool pcfgpio_plugin_range_helper(byte pin1, byte pin2, uint16_t& result) bool success = false; uint32_t tempResult = 0; - for (byte i = 0; i < data.numBytes; i++) { + for (uint8_t i = 0; i < data.numBytes; i++) { uint8_t readValue = 0; - const byte currentAddress = getPcfAddress(pin1 + 8 * i); + const uint8_t currentAddress = getPcfAddress(pin1 + 8 * i); const bool onLine = GPIO_PCF_ReadAllPins(currentAddress, &readValue); diff --git a/src/src/Commands/GPIO.h b/src/src/Commands/GPIO.h index a1be38fbe..155513c3c 100644 --- a/src/src/Commands/GPIO.h +++ b/src/src/Commands/GPIO.h @@ -15,7 +15,7 @@ // FIXME TD-er: This fwd declaration should not be in .h file. // Only needed till GPIO can be set from ESPEasy core. -void createAndSetPortStatus_Mode_State(uint32_t key, byte newMode, int8_t newState); +void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t newState); const __FlashStringHelper * Command_GPIO(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/Tasks.cpp b/src/src/Commands/Tasks.cpp index aa5d25f07..3e5a80462 100644 --- a/src/src/Commands/Tasks.cpp +++ b/src/src/Commands/Tasks.cpp @@ -58,7 +58,7 @@ bool validateAndParseTaskValueArguments(struct EventStruct * event, const char * String valueName; if ((event->Par2 <= 0 || event->Par2 >= VARS_PER_TASK) && event->Par1 - 1 != INVALID_TASK_INDEX && GetArgv(Line, valueName, 3)) { - byte tmpVarNr = findDeviceValueIndexByName(valueName, event->Par1 - 1); + uint8_t tmpVarNr = findDeviceValueIndexByName(valueName, event->Par1 - 1); if (tmpVarNr != VARS_PER_TASK) { event->Par2 = tmpVarNr + 1; } diff --git a/src/src/Commands/UDP.cpp b/src/src/Commands/UDP.cpp index 280b944b0..b1799b1db 100644 --- a/src/src/Commands/UDP.cpp +++ b/src/src/Commands/UDP.cpp @@ -15,7 +15,7 @@ const __FlashStringHelper * Command_UDP_Test(struct EventStruct *event, const char *Line) { - for (byte x = 0; x < event->Par2; x++) + for (uint8_t x = 0; x < event->Par2; x++) { String eventName = "Test "; eventName += x; diff --git a/src/src/Commands/i2c.cpp b/src/src/Commands/i2c.cpp index bab7bdc96..eb64ce74c 100644 --- a/src/src/Commands/i2c.cpp +++ b/src/src/Commands/i2c.cpp @@ -9,7 +9,7 @@ const __FlashStringHelper * Command_i2c_Scanner(struct EventStruct *event, const char* Line) { - byte error, address; + uint8_t error, address; for (address = 1; address <= 127; address++) { Wire.beginTransmission(address); error = Wire.endTransmission(); diff --git a/src/src/Commands/wd.cpp b/src/src/Commands/wd.cpp index 8f775b984..165eb4286 100644 --- a/src/src/Commands/wd.cpp +++ b/src/src/Commands/wd.cpp @@ -28,7 +28,7 @@ String Command_WD_Read(EventStruct *event, const char* Line) Wire.endTransmission(); if ( Wire.requestFrom(static_cast(event->Par1), static_cast(1)) == 1 ) { - byte value = Wire.read(); + uint8_t value = Wire.read(); serialPrintln(); String result = F("I2C Read address "); result += formatToHex(event->Par1); diff --git a/src/src/ControllerQueue/C015_queue_element.cpp b/src/src/ControllerQueue/C015_queue_element.cpp index 0b72317e5..9ea5e72c2 100644 --- a/src/src/ControllerQueue/C015_queue_element.cpp +++ b/src/src/ControllerQueue/C015_queue_element.cpp @@ -9,13 +9,13 @@ C015_queue_element::C015_queue_element(C015_queue_element&& other) , controller_idx(other.controller_idx), valuesSent(other.valuesSent) , valueCount(other.valueCount) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { txt[i] = std::move(other.txt[i]); vPin[i] = other.vPin[i]; } } -C015_queue_element::C015_queue_element(const struct EventStruct *event, byte value_count) : +C015_queue_element::C015_queue_element(const struct EventStruct *event, uint8_t value_count) : idx(event->idx), TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex), @@ -44,7 +44,7 @@ bool C015_queue_element::isDuplicate(const C015_queue_element& other) const { return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.txt[i] != txt[i]) { return false; } diff --git a/src/src/ControllerQueue/C015_queue_element.h b/src/src/ControllerQueue/C015_queue_element.h index cee9083ec..c30d353dc 100644 --- a/src/src/ControllerQueue/C015_queue_element.h +++ b/src/src/ControllerQueue/C015_queue_element.h @@ -25,7 +25,7 @@ public: C015_queue_element(C015_queue_element&& other); - C015_queue_element(const struct EventStruct *event, byte value_count); + C015_queue_element(const struct EventStruct *event, uint8_t value_count); bool checkDone(bool succesfull) const; @@ -41,8 +41,8 @@ public: unsigned long _timestamp = millis(); taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; - mutable byte valuesSent = 0; // Value must be set by const function checkDone() - byte valueCount = 0; + mutable uint8_t valuesSent = 0; // Value must be set by const function checkDone() + uint8_t valueCount = 0; }; #endif //USES_C015 diff --git a/src/src/ControllerQueue/C016_queue_element.cpp b/src/src/ControllerQueue/C016_queue_element.cpp index 6721f5a68..6321a762a 100644 --- a/src/src/ControllerQueue/C016_queue_element.cpp +++ b/src/src/ControllerQueue/C016_queue_element.cpp @@ -16,19 +16,19 @@ C016_queue_element::C016_queue_element(C016_queue_element&& other) , sensorType(other.sensorType) , valueCount(other.valueCount) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { values[i] = other.values[i]; } } -C016_queue_element::C016_queue_element(const struct EventStruct *event, byte value_count, unsigned long unixTime) : +C016_queue_element::C016_queue_element(const struct EventStruct *event, uint8_t value_count, unsigned long unixTime) : _timestamp(unixTime), TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex), sensorType(event->sensorType), valueCount(value_count) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (i < value_count) { values[i] = UserVar[event->BaseVarIndex + i]; } else { @@ -43,7 +43,7 @@ C016_queue_element& C016_queue_element::operator=(C016_queue_element&& other) { controller_idx = other.controller_idx; sensorType = other.sensorType; valueCount = other.valueCount; - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { values[i] = other.values[i]; } return *this; @@ -61,7 +61,7 @@ bool C016_queue_element::isDuplicate(const C016_queue_element& other) const { return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.values[i] != values[i]) { return false; } diff --git a/src/src/ControllerQueue/C016_queue_element.h b/src/src/ControllerQueue/C016_queue_element.h index cae74dbe6..72f2b66d3 100644 --- a/src/src/ControllerQueue/C016_queue_element.h +++ b/src/src/ControllerQueue/C016_queue_element.h @@ -16,7 +16,7 @@ struct EventStruct; * C016_queue_element for queueing requests for C016: Cached HTTP. \*********************************************************************************************/ -// TD-er: This one has a fixed byte order and is stored. +// TD-er: This one has a fixed uint8_t order and is stored. // This also means the order of members should not be changed! class C016_queue_element { public: @@ -26,7 +26,7 @@ public: C016_queue_element(C016_queue_element&& other); C016_queue_element(const struct EventStruct *event, - byte value_count, + uint8_t value_count, unsigned long unixTime); C016_queue_element& operator=(C016_queue_element&& other); @@ -43,7 +43,7 @@ public: taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; Sensor_VType sensorType = Sensor_VType::SENSOR_TYPE_NONE; - byte valueCount = 0; + uint8_t valueCount = 0; }; #endif //USES_C016 diff --git a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h index adb3fe347..629bc868f 100644 --- a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h +++ b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h @@ -244,9 +244,9 @@ struct ControllerDelayHandlerStruct { unsigned long lastSend; unsigned int minTimeBetweenMessages; unsigned long expire_timeout = 0; - byte max_queue_depth; - byte attempt; - byte max_retries; + uint8_t max_queue_depth; + uint8_t attempt; + uint8_t max_retries; bool delete_oldest; bool must_check_reply; bool deduplicate; diff --git a/src/src/ControllerQueue/queue_element_formatted_uservar.cpp b/src/src/ControllerQueue/queue_element_formatted_uservar.cpp index cf247f927..19a9b1127 100644 --- a/src/src/ControllerQueue/queue_element_formatted_uservar.cpp +++ b/src/src/ControllerQueue/queue_element_formatted_uservar.cpp @@ -27,7 +27,7 @@ queue_element_formatted_uservar::queue_element_formatted_uservar(EventStruct *ev { valueCount = getValueCountForTask(TaskIndex); - for (byte i = 0; i < valueCount; ++i) { + for (uint8_t i = 0; i < valueCount; ++i) { txt[i] = formatUserVarNoCheck(event, i); } } @@ -67,7 +67,7 @@ bool queue_element_formatted_uservar::isDuplicate(const queue_element_formatted_ return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.txt[i] != txt[i]) { return false; } diff --git a/src/src/ControllerQueue/queue_element_formatted_uservar.h b/src/src/ControllerQueue/queue_element_formatted_uservar.h index 97daf3983..fed79983b 100644 --- a/src/src/ControllerQueue/queue_element_formatted_uservar.h +++ b/src/src/ControllerQueue/queue_element_formatted_uservar.h @@ -38,7 +38,7 @@ public: taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; Sensor_VType sensorType = Sensor_VType::SENSOR_TYPE_NONE; - byte valueCount = 0; + uint8_t valueCount = 0; }; #endif // CONTROLLERQUEUE_QUEUE_ELEMENT_FORMATTED_USERVAR_H diff --git a/src/src/ControllerQueue/queue_element_single_value_base.cpp b/src/src/ControllerQueue/queue_element_single_value_base.cpp index f5760df2f..a22e30342 100644 --- a/src/src/ControllerQueue/queue_element_single_value_base.cpp +++ b/src/src/ControllerQueue/queue_element_single_value_base.cpp @@ -2,7 +2,7 @@ #include "../DataStructs/ESPEasy_EventStruct.h" -queue_element_single_value_base::queue_element_single_value_base(const struct EventStruct *event, byte value_count) : +queue_element_single_value_base::queue_element_single_value_base(const struct EventStruct *event, uint8_t value_count) : idx(event->idx), TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex), @@ -14,7 +14,7 @@ queue_element_single_value_base::queue_element_single_value_base(queue_element_s controller_idx(rval.controller_idx), valuesSent(rval.valuesSent), valueCount(rval.valueCount) { - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { txt[i] = std::move(rval.txt[i]); } } @@ -30,7 +30,7 @@ queue_element_single_value_base& queue_element_single_value_base::operator=(queu HeapSelectIram ephemeral; #endif // ifdef USE_SECOND_HEAP - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { txt[i] = std::move(rval.txt[i]); } return *this; @@ -58,7 +58,7 @@ bool queue_element_single_value_base::isDuplicate(const queue_element_single_val return false; } - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (other.txt[i] != txt[i]) { return false; } diff --git a/src/src/ControllerQueue/queue_element_single_value_base.h b/src/src/ControllerQueue/queue_element_single_value_base.h index b5fc5d3ed..67990184b 100644 --- a/src/src/ControllerQueue/queue_element_single_value_base.h +++ b/src/src/ControllerQueue/queue_element_single_value_base.h @@ -20,7 +20,7 @@ public: queue_element_single_value_base() = default; queue_element_single_value_base(const struct EventStruct *event, - byte value_count); + uint8_t value_count); queue_element_single_value_base(const queue_element_single_value_base& rval) = delete; @@ -44,8 +44,8 @@ public: unsigned long _timestamp = millis(); taskIndex_t TaskIndex = INVALID_TASK_INDEX; controllerIndex_t controller_idx = INVALID_CONTROLLER_INDEX; - mutable byte valuesSent = 0; // Value must be set by const function checkDone() - byte valueCount = 0; + mutable uint8_t valuesSent = 0; // Value must be set by const function checkDone() + uint8_t valueCount = 0; }; diff --git a/src/src/DataStructs/C013_p2p_dataStructs.h b/src/src/DataStructs/C013_p2p_dataStructs.h index 12b324d01..e8b11fe36 100644 --- a/src/src/DataStructs/C013_p2p_dataStructs.h +++ b/src/src/DataStructs/C013_p2p_dataStructs.h @@ -15,10 +15,10 @@ struct C013_SensorInfoStruct bool isValid() const; - byte header = 255; - byte ID = 3; - byte sourceUnit = 0; - byte destUnit = 0; + uint8_t header = 255; + uint8_t ID = 3; + uint8_t sourceUnit = 0; + uint8_t destUnit = 0; taskIndex_t sourceTaskIndex = INVALID_TASK_INDEX; taskIndex_t destTaskIndex = INVALID_TASK_INDEX; pluginID_t deviceNumber = INVALID_PLUGIN_ID; @@ -32,10 +32,10 @@ struct C013_SensorDataStruct bool isValid() const; - byte header = 255; - byte ID = 5; - byte sourceUnit = 0; - byte destUnit = 0; + uint8_t header = 255; + uint8_t ID = 5; + uint8_t sourceUnit = 0; + uint8_t destUnit = 0; taskIndex_t sourceTaskIndex = INVALID_TASK_INDEX; taskIndex_t destTaskIndex = INVALID_TASK_INDEX; float Values[VARS_PER_TASK]; diff --git a/src/src/DataStructs/Caches.h b/src/src/DataStructs/Caches.h index f75d18153..4960c0436 100644 --- a/src/src/DataStructs/Caches.h +++ b/src/src/DataStructs/Caches.h @@ -6,7 +6,7 @@ #include "../Globals/Plugins.h" typedef std::mapTaskIndexNameMap; -typedef std::map TaskIndexValueNameMap; +typedef std::map TaskIndexValueNameMap; typedef std::map FilePresenceMap; struct Caches { diff --git a/src/src/DataStructs/ControllerSettingsStruct.cpp b/src/src/DataStructs/ControllerSettingsStruct.cpp index ebb4b21cd..1f54f11ce 100644 --- a/src/src/DataStructs/ControllerSettingsStruct.cpp +++ b/src/src/DataStructs/ControllerSettingsStruct.cpp @@ -31,7 +31,7 @@ void ControllerSettingsStruct::reset() { SampleSetInitiator = INVALID_TASK_INDEX; VariousFlags = 0; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { IP[i] = 0; } ZERO_FILL(HostName); @@ -119,7 +119,7 @@ bool ControllerSettingsStruct::connectToHost(WiFiClient& client) { if (!checkHostReachable(true)) { return false; // Host not reachable } - byte retry = 2; + uint8_t retry = 2; bool connected = false; while (retry > 0 && !connected) { @@ -139,7 +139,7 @@ bool ControllerSettingsStruct::beginPacket(WiFiUDP& client) { if (!checkHostReachable(true)) { return false; // Host not reachable } - byte retry = 2; + uint8_t retry = 2; while (retry > 0) { --retry; FeedSW_watchdog(); @@ -164,7 +164,7 @@ String ControllerSettingsStruct::getHostPortString() const { } bool ControllerSettingsStruct::ipSet() const { - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (IP[i] != 0) { return true; } } return false; @@ -179,7 +179,7 @@ bool ControllerSettingsStruct::updateIPcache() { IPAddress tmpIP; if (resolveHostByName(HostName, tmpIP, ClientTimeout)) { - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { IP[x] = tmpIP[x]; } return true; diff --git a/src/src/DataStructs/ControllerSettingsStruct.h b/src/src/DataStructs/ControllerSettingsStruct.h index 25c1d64e5..694acd020 100644 --- a/src/src/DataStructs/ControllerSettingsStruct.h +++ b/src/src/DataStructs/ControllerSettingsStruct.h @@ -143,7 +143,7 @@ struct ControllerSettingsStruct void deduplicate(bool value); boolean UseDNS; - byte IP[4]; + uint8_t IP[4]; unsigned int Port; char HostName[65]; char Publish[129]; diff --git a/src/src/DataStructs/DeviceStruct.h b/src/src/DataStructs/DeviceStruct.h index b26a6af4a..4daaa2566 100644 --- a/src/src/DataStructs/DeviceStruct.h +++ b/src/src/DataStructs/DeviceStruct.h @@ -32,7 +32,7 @@ #define I2C_FLAGS_MUX_MULTICHANNEL 1 // Allow multiple multiplexer channels when set -enum class Sensor_VType : byte { +enum class Sensor_VType : uint8_t { SENSOR_TYPE_NONE = 0, SENSOR_TYPE_SINGLE = 1, SENSOR_TYPE_TEMP_HUM = 2, @@ -51,7 +51,7 @@ enum class Sensor_VType : byte { SENSOR_TYPE_NOT_SET = 255 }; -enum class Output_Data_type_t : byte { +enum class Output_Data_type_t : uint8_t { Default = 0, Simple, // SENSOR_TYPE_SINGLE, _DUAL, _TRIPLE, _QUAD All @@ -71,11 +71,11 @@ struct DeviceStruct bool configurableDecimals() const; - byte Number; // Plugin ID number. (PLUGIN_ID_xxx) - byte Type; // How the device is connected. e.g. DEVICE_TYPE_SINGLE => connected through 1 datapin + uint8_t Number; // Plugin ID number. (PLUGIN_ID_xxx) + uint8_t Type; // How the device is connected. e.g. DEVICE_TYPE_SINGLE => connected through 1 datapin Sensor_VType VType; // Type of value the plugin will return. e.g. SENSOR_TYPE_STRING - byte Ports; // Port to use when device has multiple I/O pins (N.B. not used much) - byte ValueCount; // The number of output values of a plugin. The value should match the number of keys PLUGIN_VALUENAME1_xxx + uint8_t Ports; // Port to use when device has multiple I/O pins (N.B. not used much) + uint8_t ValueCount; // The number of output values of a plugin. The value should match the number of keys PLUGIN_VALUENAME1_xxx Output_Data_type_t OutputDataType; // Subset of selectable output data types (Default = no selection) bool PullUpOption : 1; // Allow to set internal pull-up resistors. diff --git a/src/src/DataStructs/ESPEasy_EventStruct.h b/src/src/DataStructs/ESPEasy_EventStruct.h index 48965b859..8f602a8df 100644 --- a/src/src/DataStructs/ESPEasy_EventStruct.h +++ b/src/src/DataStructs/ESPEasy_EventStruct.h @@ -50,7 +50,7 @@ public: String String3; String String4; String String5; - byte *Data = nullptr; + uint8_t *Data = nullptr; int idx = 0; int Par1 = 0; int Par2 = 0; @@ -63,9 +63,9 @@ public: taskIndex_t TaskIndex = INVALID_TASK_INDEX; // index position in TaskSettings array, 0-11 controllerIndex_t ControllerIndex = INVALID_CONTROLLER_INDEX; // index position in Settings.Controller, 0-3 notifierIndex_t NotificationIndex = INVALID_NOTIFIER_INDEX; // index position in Settings.Notification, 0-3 - byte BaseVarIndex = 0; + uint8_t BaseVarIndex = 0; Sensor_VType sensorType = Sensor_VType::SENSOR_TYPE_NOT_SET; - byte OriginTaskIndex = 0; + uint8_t OriginTaskIndex = 0; }; #endif // ESPEASY_EVENTSTRUCT_H diff --git a/src/src/DataStructs/ESPEasy_packed_raw_data.cpp b/src/src/DataStructs/ESPEasy_packed_raw_data.cpp index 335147b6d..317c995a2 100644 --- a/src/src/DataStructs/ESPEasy_packed_raw_data.cpp +++ b/src/src/DataStructs/ESPEasy_packed_raw_data.cpp @@ -34,21 +34,21 @@ uint8_t getPackedDataTypeSize(PackedData_enum dtype, float& factor, float& offse return 0; } -void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, byte *data, uint8_t& cursor) { +void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor) { // Clip values to upper limit const uint64_t upperlimit = (1ull << (8*byteSize)) - 1; if (value > upperlimit) { value = upperlimit; } for (uint8_t x = 0; x < byteSize; x++) { - byte next = 0; + uint8_t next = 0; if (sizeof(value) > x) { - next = static_cast((value >> (x * 8)) & 0xFF); + next = static_cast((value >> (x * 8)) & 0xFF); } data[cursor] = next; ++cursor; } } -void LoRa_intToBytes(int64_t value, uint8_t byteSize, byte *data, uint8_t& cursor) { +void LoRa_intToBytes(int64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor) { // Clip values to lower limit const int64_t lowerlimit = (1ull << ((8*byteSize) - 1)) * -1; if (value < lowerlimit) { value = lowerlimit; } @@ -58,7 +58,7 @@ void LoRa_intToBytes(int64_t value, uint8_t byteSize, byte *data, uint8_t& curso LoRa_uintToBytes(value, byteSize, data, cursor); } -String LoRa_base16Encode(byte *data, size_t size) { +String LoRa_base16Encode(uint8_t *data, size_t size) { String output; output.reserve(size * 2); char buffer[3]; @@ -74,7 +74,7 @@ String LoRa_base16Encode(byte *data, size_t size) { String LoRa_addInt(uint64_t value, PackedData_enum datatype) { float factor, offset; uint8_t byteSize = getPackedDataTypeSize(datatype, factor, offset); - byte data[4] = {0}; + uint8_t data[4] = {0}; uint8_t cursor = 0; LoRa_uintToBytes((value + offset) * factor, byteSize, &data[0], cursor); return LoRa_base16Encode(data, cursor); @@ -84,7 +84,7 @@ String LoRa_addInt(uint64_t value, PackedData_enum datatype) { String LoRa_addFloat(float value, PackedData_enum datatype) { float factor, offset; uint8_t byteSize = getPackedDataTypeSize(datatype, factor, offset); - byte data[4] = {0}; + uint8_t data[4] = {0}; uint8_t cursor = 0; LoRa_intToBytes((value + offset) * factor, byteSize, &data[0], cursor); return LoRa_base16Encode(data, cursor); diff --git a/src/src/DataStructs/ESPEasy_packed_raw_data.h b/src/src/DataStructs/ESPEasy_packed_raw_data.h index 1764d4be2..2512c11e8 100644 --- a/src/src/DataStructs/ESPEasy_packed_raw_data.h +++ b/src/src/DataStructs/ESPEasy_packed_raw_data.h @@ -69,11 +69,11 @@ typedef uint32_t PackedData_enum; uint8_t getPackedDataTypeSize(PackedData_enum dtype, float& factor, float& offset); -void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, byte *data, uint8_t& cursor); +void LoRa_uintToBytes(uint64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor); -void LoRa_intToBytes(int64_t value, uint8_t byteSize, byte *data, uint8_t& cursor); +void LoRa_intToBytes(int64_t value, uint8_t byteSize, uint8_t *data, uint8_t& cursor); -String LoRa_base16Encode(byte *data, size_t size); +String LoRa_base16Encode(uint8_t *data, size_t size); String LoRa_addInt(uint64_t value, PackedData_enum datatype); diff --git a/src/src/DataStructs/ExtraTaskSettingsStruct.cpp b/src/src/DataStructs/ExtraTaskSettingsStruct.cpp index 6f28976e1..eb5b18494 100644 --- a/src/src/DataStructs/ExtraTaskSettingsStruct.cpp +++ b/src/src/DataStructs/ExtraTaskSettingsStruct.cpp @@ -10,13 +10,13 @@ void ExtraTaskSettingsStruct::clear() { TaskIndex = INVALID_TASK_INDEX; ZERO_FILL(TaskDeviceName); - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { TaskDeviceValueDecimals[i] = 2; ZERO_FILL(TaskDeviceFormula[i]); ZERO_FILL(TaskDeviceValueNames[i]); } - for (byte i = 0; i < PLUGIN_EXTRACONFIGVAR_MAX; ++i) { + for (uint8_t i = 0; i < PLUGIN_EXTRACONFIGVAR_MAX; ++i) { TaskDevicePluginConfigLong[i] = 0; TaskDevicePluginConfig[i] = 0; } @@ -25,7 +25,7 @@ void ExtraTaskSettingsStruct::clear() { void ExtraTaskSettingsStruct::validate() { ZERO_TERMINATE(TaskDeviceName); - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { ZERO_TERMINATE(TaskDeviceFormula[i]); ZERO_TERMINATE(TaskDeviceValueNames[i]); } @@ -44,8 +44,8 @@ bool ExtraTaskSettingsStruct::checkUniqueValueNames() const { return true; } -void ExtraTaskSettingsStruct::clearUnusedValueNames(byte usedVars) { - for (byte i = usedVars; i < VARS_PER_TASK; ++i) { +void ExtraTaskSettingsStruct::clearUnusedValueNames(uint8_t usedVars) { + for (uint8_t i = usedVars; i < VARS_PER_TASK; ++i) { TaskDeviceValueDecimals[i] = 2; ZERO_FILL(TaskDeviceFormula[i]); ZERO_FILL(TaskDeviceValueNames[i]); diff --git a/src/src/DataStructs/ExtraTaskSettingsStruct.h b/src/src/DataStructs/ExtraTaskSettingsStruct.h index 550d9fbb7..7da577043 100644 --- a/src/src/DataStructs/ExtraTaskSettingsStruct.h +++ b/src/src/DataStructs/ExtraTaskSettingsStruct.h @@ -24,7 +24,7 @@ struct ExtraTaskSettingsStruct bool checkUniqueValueNames() const; - void clearUnusedValueNames(byte usedVars); + void clearUnusedValueNames(uint8_t usedVars); bool checkInvalidCharInNames(const char* name) const; @@ -35,7 +35,7 @@ struct ExtraTaskSettingsStruct char TaskDeviceFormula[VARS_PER_TASK][NAME_FORMULA_LENGTH_MAX + 1]; char TaskDeviceValueNames[VARS_PER_TASK][NAME_FORMULA_LENGTH_MAX + 1]; long TaskDevicePluginConfigLong[PLUGIN_EXTRACONFIGVAR_MAX]; - byte TaskDeviceValueDecimals[VARS_PER_TASK]; + uint8_t TaskDeviceValueDecimals[VARS_PER_TASK]; int16_t TaskDevicePluginConfig[PLUGIN_EXTRACONFIGVAR_MAX]; }; diff --git a/src/src/DataStructs/LogStruct.cpp b/src/src/DataStructs/LogStruct.cpp index c48e38fb3..98eca1554 100644 --- a/src/src/DataStructs/LogStruct.cpp +++ b/src/src/DataStructs/LogStruct.cpp @@ -5,7 +5,7 @@ -void LogStruct::add(const byte loglevel, const char *line) { +void LogStruct::add(const uint8_t loglevel, const char *line) { write_idx = (write_idx + 1) % LOG_STRUCT_MESSAGE_LINES; if (write_idx == read_idx) { @@ -44,7 +44,7 @@ bool LogStruct::get(String& output, const String& lineEnd) { return !isEmpty(); } -bool LogStruct::getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, byte& loglevel) { +bool LogStruct::getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, uint8_t& loglevel) { lastReadTimeStamp = millis(); logLinesAvailable = false; diff --git a/src/src/DataStructs/LogStruct.h b/src/src/DataStructs/LogStruct.h index 3112bd4ab..2e626194c 100644 --- a/src/src/DataStructs/LogStruct.h +++ b/src/src/DataStructs/LogStruct.h @@ -23,13 +23,13 @@ struct LogStruct { - void add(const byte loglevel, const char *line); + void add(const uint8_t loglevel, const char *line); // Read the next item and append it to the given string. // Returns whether new lines are available. bool get(String& output, const String& lineEnd); - bool getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, byte& loglevel); + bool getNext(bool& logLinesAvailable, unsigned long& timestamp, String& message, uint8_t& loglevel); bool isEmpty(); @@ -45,7 +45,7 @@ struct LogStruct { int write_idx = 0; int read_idx = 0; unsigned long lastReadTimeStamp = 0; - byte log_level[LOG_STRUCT_MESSAGE_LINES] = {0}; + uint8_t log_level[LOG_STRUCT_MESSAGE_LINES] = {0}; }; diff --git a/src/src/DataStructs/NodeStruct.cpp b/src/src/DataStructs/NodeStruct.cpp index 871a38109..31f15a1c7 100644 --- a/src/src/DataStructs/NodeStruct.cpp +++ b/src/src/DataStructs/NodeStruct.cpp @@ -1,6 +1,6 @@ #include "NodeStruct.h" -const __FlashStringHelper * getNodeTypeDisplayString(byte nodeType) { +const __FlashStringHelper * getNodeTypeDisplayString(uint8_t nodeType) { switch (nodeType) { case NODE_TYPE_ID_ESP_EASY_STD: return F("ESP Easy"); @@ -16,5 +16,5 @@ const __FlashStringHelper * getNodeTypeDisplayString(byte nodeType) { NodeStruct::NodeStruct() : build(0), age(0), nodeType(0), webgui_portnumber(0) { - for (byte i = 0; i < 4; ++i) { ip[i] = 0; } + for (uint8_t i = 0; i < 4; ++i) { ip[i] = 0; } } diff --git a/src/src/DataStructs/NodeStruct.h b/src/src/DataStructs/NodeStruct.h index 2f8d43413..86bd888b5 100644 --- a/src/src/DataStructs/NodeStruct.h +++ b/src/src/DataStructs/NodeStruct.h @@ -13,7 +13,7 @@ #define NODE_TYPE_ID_ARDUINO_EASY_STD 65 #define NODE_TYPE_ID_NANO_EASY_STD 81 -const __FlashStringHelper * getNodeTypeDisplayString(byte nodeType); +const __FlashStringHelper * getNodeTypeDisplayString(uint8_t nodeType); /*********************************************************************************************\ * NodeStruct @@ -25,11 +25,11 @@ struct NodeStruct String nodeName; IPAddress ip; uint16_t build; - byte age; - byte nodeType; + uint8_t age; + uint8_t nodeType; uint16_t webgui_portnumber; }; -typedef std::map NodesMap; +typedef std::map NodesMap; #endif // DATASTRUCTS_NODESTRUCT_H diff --git a/src/src/DataStructs/NotificationSettingsStruct.h b/src/src/DataStructs/NotificationSettingsStruct.h index cfccda1ba..b418bb758 100644 --- a/src/src/DataStructs/NotificationSettingsStruct.h +++ b/src/src/DataStructs/NotificationSettingsStruct.h @@ -20,8 +20,8 @@ struct NotificationSettingsStruct char Receiver[65]; char Subject[129]; char Body[513]; - byte Pin1; - byte Pin2; + uint8_t Pin1; + uint8_t Pin2; char User[49]; char Pass[33]; //its safe to extend this struct, up to 4096 bytes, default values in config are 0 diff --git a/src/src/DataStructs/NotificationStruct.h b/src/src/DataStructs/NotificationStruct.h index 182c4a45d..0f9ad48f7 100644 --- a/src/src/DataStructs/NotificationStruct.h +++ b/src/src/DataStructs/NotificationStruct.h @@ -10,8 +10,8 @@ struct NotificationStruct NotificationStruct() : Number(0), usesGPIO(0), usesMessaging(false) {} - byte Number; - byte usesGPIO; + uint8_t Number; + uint8_t usesGPIO; bool usesMessaging; }; diff --git a/src/src/DataStructs/ProtocolStruct.h b/src/src/DataStructs/ProtocolStruct.h index 40785bd86..5f97dd845 100644 --- a/src/src/DataStructs/ProtocolStruct.h +++ b/src/src/DataStructs/ProtocolStruct.h @@ -16,7 +16,7 @@ struct ProtocolStruct bool useExtendedCredentials() const; uint16_t defaultPort; - byte Number; + uint8_t Number; bool usesMQTT : 1; bool usesAccount : 1; bool usesPassword : 1; diff --git a/src/src/DataStructs/RTCStruct.cpp b/src/src/DataStructs/RTCStruct.cpp index b35f77c22..0d5bd67b3 100644 --- a/src/src/DataStructs/RTCStruct.cpp +++ b/src/src/DataStructs/RTCStruct.cpp @@ -18,7 +18,7 @@ } void RTCStruct::clearLastWiFi() { - for (byte i = 0; i < 6; ++i) { + for (uint8_t i = 0; i < 6; ++i) { lastBSSID[i] = 0; } lastWiFiChannel = 0; diff --git a/src/src/DataStructs/RTCStruct.h b/src/src/DataStructs/RTCStruct.h index 69f8dddf7..541f704fe 100644 --- a/src/src/DataStructs/RTCStruct.h +++ b/src/src/DataStructs/RTCStruct.h @@ -38,20 +38,20 @@ struct RTCStruct bool lastWiFi_set() const; - byte ID1 = 0; - byte ID2 = 0; - byte lastWiFiChannel = 0; - byte factoryResetCounter = 0; - byte deepSleepState = 0; - byte bootFailedCount = 0; - byte flashDayCounter = 0; - byte lastWiFiSettingsIndex = 0; + uint8_t ID1 = 0; + uint8_t ID2 = 0; + uint8_t lastWiFiChannel = 0; + uint8_t factoryResetCounter = 0; + uint8_t deepSleepState = 0; + uint8_t bootFailedCount = 0; + uint8_t flashDayCounter = 0; + uint8_t lastWiFiSettingsIndex = 0; unsigned long flashCounter = 0; unsigned long bootCounter = 0; unsigned long lastMixedSchedulerId = 0; uint8_t lastBSSID[6] = { 0 }; - byte unused1 = 0; // Force alignment to 4 bytes - byte unused2 = 0; + uint8_t unused1 = 0; // Force alignment to 4 bytes + uint8_t unused2 = 0; unsigned long lastSysTime = 0; }; diff --git a/src/src/DataStructs/RTC_cache_handler_struct.cpp b/src/src/DataStructs/RTC_cache_handler_struct.cpp index 6d26ffbbe..e07bc9b16 100644 --- a/src/src/DataStructs/RTC_cache_handler_struct.cpp +++ b/src/src/DataStructs/RTC_cache_handler_struct.cpp @@ -249,12 +249,12 @@ bool RTC_cache_handler_struct::loadMetaData() // No need to load on ESP32, as the data is already allocated to the RTC memory by the compiler #ifdef ESP8266 - if (!system_rtc_mem_read(RTC_BASE_CACHE, (byte *)&RTC_cache, sizeof(RTC_cache))) { + if (!system_rtc_mem_read(RTC_BASE_CACHE, (uint8_t *)&RTC_cache, sizeof(RTC_cache))) { return false; } #endif - return RTC_cache.checksumMetadata == calc_CRC32((byte *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); + return RTC_cache.checksumMetadata == calc_CRC32((uint8_t *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); } bool RTC_cache_handler_struct::loadData() @@ -263,7 +263,7 @@ bool RTC_cache_handler_struct::loadData() // No need to load on ESP32, as the data is already allocated to the RTC memory by the compiler #ifdef ESP8266 - if (!system_rtc_mem_read(RTC_BASE_CACHE + (sizeof(RTC_cache) / 4), (byte *)&RTC_cache_data[0], RTC_CACHE_DATA_SIZE)) { + if (!system_rtc_mem_read(RTC_BASE_CACHE + (sizeof(RTC_cache) / 4), (uint8_t *)&RTC_cache_data[0], RTC_CACHE_DATA_SIZE)) { return false; } #endif @@ -284,13 +284,13 @@ bool RTC_cache_handler_struct::saveRTCcache() { bool RTC_cache_handler_struct::saveRTCcache(unsigned int startOffset, size_t nrBytes) { RTC_cache.checksumData = getDataChecksum(); - RTC_cache.checksumMetadata = calc_CRC32((byte *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); + RTC_cache.checksumMetadata = calc_CRC32((uint8_t *)&RTC_cache, sizeof(RTC_cache) - sizeof(uint32_t)); #ifdef ESP32 return true; #endif #ifdef ESP8266 - if (!system_rtc_mem_write(RTC_BASE_CACHE, (byte *)&RTC_cache, sizeof(RTC_cache)) || !loadMetaData()) + if (!system_rtc_mem_write(RTC_BASE_CACHE, (uint8_t *)&RTC_cache, sizeof(RTC_cache)) || !loadMetaData()) { # ifdef RTC_STRUCT_DEBUG addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing cache metadata to RTC")); @@ -302,7 +302,7 @@ bool RTC_cache_handler_struct::saveRTCcache(unsigned int startOffset, size_t nrB if (nrBytes > 0) { // Check needed? const size_t address = RTC_BASE_CACHE + ((sizeof(RTC_cache) + startOffset) / 4); - if (!system_rtc_mem_write(address, (byte *)&RTC_cache_data[startOffset], nrBytes)) + if (!system_rtc_mem_write(address, (uint8_t *)&RTC_cache_data[startOffset], nrBytes)) { # ifdef RTC_STRUCT_DEBUG addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing cache data to RTC")); @@ -329,7 +329,7 @@ uint32_t RTC_cache_handler_struct::getDataChecksum() { */ // Only compute the checksum over the number of samples stored. - return calc_CRC32((byte *)&RTC_cache_data[0], /*dataLength*/ RTC_CACHE_DATA_SIZE); + return calc_CRC32((uint8_t *)&RTC_cache_data[0], /*dataLength*/ RTC_CACHE_DATA_SIZE); } void RTC_cache_handler_struct::initRTCcache_data() { diff --git a/src/src/DataStructs/RTC_cache_handler_struct.h b/src/src/DataStructs/RTC_cache_handler_struct.h index 18d93a24b..42b68f531 100644 --- a/src/src/DataStructs/RTC_cache_handler_struct.h +++ b/src/src/DataStructs/RTC_cache_handler_struct.h @@ -91,7 +91,7 @@ private: size_t peekfilenr = 0; size_t peekreadpos = 0; - byte storageLocation = CACHE_STORAGE_SPIFFS; + uint8_t storageLocation = CACHE_STORAGE_SPIFFS; bool writeerror = false; }; diff --git a/src/src/DataStructs/SecurityStruct.h b/src/src/DataStructs/SecurityStruct.h index e4a347f0a..a279556b9 100644 --- a/src/src/DataStructs/SecurityStruct.h +++ b/src/src/DataStructs/SecurityStruct.h @@ -35,9 +35,9 @@ struct SecurityStruct char ControllerUser[CONTROLLER_MAX][26]; char ControllerPassword[CONTROLLER_MAX][64]; char Password[26]; - byte AllowedIPrangeLow[4] = {0}; // TD-er: Use these - byte AllowedIPrangeHigh[4] = {0}; - byte IPblockLevel = 0; + uint8_t AllowedIPrangeLow[4] = {0}; // TD-er: Use these + uint8_t AllowedIPrangeHigh[4] = {0}; + uint8_t IPblockLevel = 0; //its safe to extend this struct, up to 4096 bytes, default values in config are 0. Make sure crc is last uint8_t ProgmemMd5[16] = {0}; // crc of the binary that last saved the struct to file. diff --git a/src/src/DataStructs/SettingsStruct.cpp b/src/src/DataStructs/SettingsStruct.cpp index 2d54538d4..93e8710ac 100644 --- a/src/src/DataStructs/SettingsStruct.cpp +++ b/src/src/DataStructs/SettingsStruct.cpp @@ -261,7 +261,7 @@ bool SettingsStruct_tmpl::networkSettingsEmpty() const { template void SettingsStruct_tmpl::clearNetworkSettings() { - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { IP[i] = 0; Gateway[i] = 0; Subnet[i] = 0; @@ -287,7 +287,7 @@ void SettingsStruct_tmpl::clearTimeSettings() { template void SettingsStruct_tmpl::clearNotifications() { - for (byte i = 0; i < NOTIFICATION_MAX; ++i) { + for (uint8_t i = 0; i < NOTIFICATION_MAX; ++i) { Notification[i] = 0; NotificationEnabled[i] = false; } @@ -316,7 +316,7 @@ void SettingsStruct_tmpl::clearLogSettings() { SDLogLevel = 0; SyslogFacility = DEFAULT_SYSLOG_FACILITY; - for (byte i = 0; i < 4; ++i) { Syslog_IP[i] = 0; } + for (uint8_t i = 0; i < 4; ++i) { Syslog_IP[i] = 0; } } template @@ -357,13 +357,13 @@ void SettingsStruct_tmpl::clearMisc() { // Here we initialize all data to 0, so this is the ONLY reason why PinBootStates // can now be directly accessed. // In all other use cases, use the get and set functions for it. - constexpr byte maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); - for (byte i = 0; i < maxStates; ++i) { + constexpr uint8_t maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); + for (uint8_t i = 0; i < maxStates; ++i) { PinBootStates[i] = 0; } #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); - for (byte i = 0; i < maxStatesesp32; ++i) { + constexpr uint8_t maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); + for (uint8_t i = 0; i < maxStatesesp32; ++i) { PinBootStates_ESP32[i] = 0; } #endif @@ -433,16 +433,16 @@ void SettingsStruct_tmpl::clearTask(taskIndex_t task) { TaskDevicePort[task] = 0; TaskDevicePin1PullUp[task] = false; - for (byte cv = 0; cv < PLUGIN_CONFIGVAR_MAX; ++cv) { + for (uint8_t cv = 0; cv < PLUGIN_CONFIGVAR_MAX; ++cv) { TaskDevicePluginConfig[task][cv] = 0; } TaskDevicePin1Inversed[task] = false; - for (byte cv = 0; cv < PLUGIN_CONFIGFLOATVAR_MAX; ++cv) { + for (uint8_t cv = 0; cv < PLUGIN_CONFIGFLOATVAR_MAX; ++cv) { TaskDevicePluginConfigFloat[task][cv] = 0.0f; } - for (byte cv = 0; cv < PLUGIN_CONFIGLONGVAR_MAX; ++cv) { + for (uint8_t cv = 0; cv < PLUGIN_CONFIGLONGVAR_MAX; ++cv) { TaskDevicePluginConfigLong[task][cv] = 0; } TaskDeviceSendDataFlags[task] = 0; @@ -472,12 +472,12 @@ String SettingsStruct_tmpl::getHostname(bool appendUnit) const { template PinBootState SettingsStruct_tmpl::getPinBootState(uint8_t gpio_pin) const { - constexpr byte maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); + constexpr uint8_t maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); if (gpio_pin < maxStates) { return static_cast(PinBootStates[gpio_pin]); } #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); + constexpr uint8_t maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); const uint8_t addr = gpio_pin - maxStates; if (addr < maxStatesesp32) { return static_cast(PinBootStates_ESP32[addr]); @@ -488,12 +488,12 @@ PinBootState SettingsStruct_tmpl::getPinBootState(uint8_t gpio_pin) con template void SettingsStruct_tmpl::setPinBootState(uint8_t gpio_pin, PinBootState state) { - constexpr byte maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); + constexpr uint8_t maxStates = sizeof(PinBootStates) / sizeof(PinBootStates[0]); if (gpio_pin < maxStates) { PinBootStates[gpio_pin] = static_cast(state); } #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); + constexpr uint8_t maxStatesesp32 = sizeof(PinBootStates_ESP32) / sizeof(PinBootStates_ESP32[0]); const uint8_t addr = gpio_pin - maxStates; if (addr < maxStatesesp32) { PinBootStates_ESP32[addr] = static_cast(state); @@ -538,7 +538,7 @@ bool SettingsStruct_tmpl::isSPI_pin(int8_t pin) const { if (pin < 0) return false; int8_t spi_gpios[3]; if (getSPI_pins(spi_gpios)) { - for (byte i = 0; i < 3; ++i) { + for (uint8_t i = 0; i < 3; ++i) { if (spi_gpios[i] == pin) return true; } } @@ -582,7 +582,7 @@ bool SettingsStruct_tmpl::isEthernetPinOptional(int8_t pin) const { } template -int8_t SettingsStruct_tmpl::getTaskDevicePin(taskIndex_t taskIndex, byte pinnr) const { +int8_t SettingsStruct_tmpl::getTaskDevicePin(taskIndex_t taskIndex, uint8_t pinnr) const { if (validTaskIndex(taskIndex)) { switch(pinnr) { case 1: return TaskDevicePin1[taskIndex]; diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index 174052292..3b971c9c8 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -177,7 +177,7 @@ class SettingsStruct_tmpl // Access to TaskDevicePin1 ... TaskDevicePin3 // @param pinnr 1 = TaskDevicePin1, ..., 3 = TaskDevicePin3 - int8_t getTaskDevicePin(taskIndex_t taskIndex, byte pinnr) const; + int8_t getTaskDevicePin(taskIndex_t taskIndex, uint8_t pinnr) const; float getWiFi_TX_power() const; void setWiFi_TX_power(float dBm); @@ -186,12 +186,12 @@ class SettingsStruct_tmpl unsigned long PID; int Version; int16_t Build; - byte IP[4]; - byte Gateway[4]; - byte Subnet[4]; - byte DNS[4]; - byte IP_Octet; - byte Unit; + uint8_t IP[4]; + uint8_t Gateway[4]; + uint8_t Subnet[4]; + uint8_t DNS[4]; + uint8_t IP_Octet; + uint8_t Unit; char Name[26]; char NTPHost[64]; // FIXME TD-er: Issue #2690 @@ -201,18 +201,18 @@ class SettingsStruct_tmpl int8_t Pin_status_led; int8_t Pin_sd_cs; int8_t PinBootStates[17]; // Only use getPinBootState and setPinBootState as multiple pins are packed for ESP32 - byte Syslog_IP[4]; + uint8_t Syslog_IP[4]; unsigned int UDPPort; - byte SyslogLevel; - byte SerialLogLevel; - byte WebLogLevel; - byte SDLogLevel; + uint8_t SyslogLevel; + uint8_t SerialLogLevel; + uint8_t WebLogLevel; + uint8_t SDLogLevel; unsigned long BaudRate; unsigned long MessageDelay_unused; // MQTT settings now moved to the controller settings. - byte deepSleep_wakeTime; // 0 = Sleep Disabled, else time awake from sleep in seconds + uint8_t deepSleep_wakeTime; // 0 = Sleep Disabled, else time awake from sleep in seconds boolean CustomCSS; boolean DST; - byte WDI2CAddress; + uint8_t WDI2CAddress; boolean UseRules; boolean UseSerial; boolean UseSSDP; @@ -222,19 +222,19 @@ class SettingsStruct_tmpl unsigned long ConnectionFailuresThreshold; int16_t TimeZone; boolean MQTTRetainFlag_unused; - byte InitSPI; //0 = disabled, 1= enabled but for ESP32 there is option 2= SPI2 + uint8_t InitSPI; //0 = disabled, 1= enabled but for ESP32 there is option 2= SPI2 // FIXME TD-er: Must change to cpluginID_t, but then also another check must be added since changing the pluginID_t will also render settings incompatible - byte Protocol[CONTROLLER_MAX]; - byte Notification[NOTIFICATION_MAX]; //notifications, point to a NPLUGIN id + uint8_t Protocol[CONTROLLER_MAX]; + uint8_t Notification[NOTIFICATION_MAX]; //notifications, point to a NPLUGIN id // FIXME TD-er: Must change to pluginID_t, but then also another check must be added since changing the pluginID_t will also render settings incompatible - byte TaskDeviceNumber[N_TASKS]; // The "plugin number" set at as task (e.g. 4 for P004_dallas) + uint8_t TaskDeviceNumber[N_TASKS]; // The "plugin number" set at as task (e.g. 4 for P004_dallas) unsigned int OLD_TaskDeviceID[N_TASKS]; //UNUSED: this can be removed union { struct { int8_t TaskDevicePin1[N_TASKS]; int8_t TaskDevicePin2[N_TASKS]; int8_t TaskDevicePin3[N_TASKS]; - byte TaskDevicePort[N_TASKS]; + uint8_t TaskDevicePort[N_TASKS]; }; int8_t TaskDevicePin[4][N_TASKS]; }; @@ -243,9 +243,9 @@ class SettingsStruct_tmpl boolean TaskDevicePin1Inversed[N_TASKS]; float TaskDevicePluginConfigFloat[N_TASKS][PLUGIN_CONFIGFLOATVAR_MAX]; long TaskDevicePluginConfigLong[N_TASKS][PLUGIN_CONFIGLONGVAR_MAX]; - byte TaskDeviceSendDataFlags[N_TASKS]; - byte OLD_TaskDeviceGlobalSync[N_TASKS]; - byte TaskDeviceDataFeed[N_TASKS]; // When set to 0, only read local connected sensorsfeeds + uint8_t TaskDeviceSendDataFlags[N_TASKS]; + uint8_t OLD_TaskDeviceGlobalSync[N_TASKS]; + uint8_t TaskDeviceDataFeed[N_TASKS]; // When set to 0, only read local connected sensorsfeeds unsigned long TaskDeviceTimer[N_TASKS]; boolean TaskDeviceEnabled[N_TASKS]; boolean ControllerEnabled[CONTROLLER_MAX]; @@ -260,7 +260,7 @@ class SettingsStruct_tmpl uint16_t DST_End; boolean UseRTOSMultitasking; int8_t Pin_Reset; - byte SyslogFacility; + uint8_t SyslogFacility; uint32_t StructSize; // Forced to be 32 bit, to make sure alignment is clear. boolean MQTTUseUnitNameAsClientId_unused; @@ -277,7 +277,7 @@ class SettingsStruct_tmpl // FIXME @TD-er: As discussed in #1292, the CRC for the settings is now disabled. // make sure crc is the last value in the struct - // Try to extend settings to make the checksum 4-byte aligned. + // Try to extend settings to make the checksum 4-uint8_t aligned. // uint8_t ProgmemMd5[16]; // crc of the binary that last saved the struct to file. // uint8_t md5[16]; uint8_t ETH_Phy_Addr; @@ -286,10 +286,10 @@ class SettingsStruct_tmpl int8_t ETH_Pin_power; EthPhyType_t ETH_Phy_Type; EthClockMode_t ETH_Clock_Mode; - byte ETH_IP[4]; - byte ETH_Gateway[4]; - byte ETH_Subnet[4]; - byte ETH_DNS[4]; + uint8_t ETH_IP[4]; + uint8_t ETH_Gateway[4]; + uint8_t ETH_Subnet[4]; + uint8_t ETH_DNS[4]; NetworkMedium_t NetworkMedium; int8_t I2C_Multiplexer_Type; int8_t I2C_Multiplexer_Addr; diff --git a/src/src/DataStructs/UnitMessageCount.h b/src/src/DataStructs/UnitMessageCount.h index 734d6cbe3..de2550510 100644 --- a/src/src/DataStructs/UnitMessageCount.h +++ b/src/src/DataStructs/UnitMessageCount.h @@ -11,10 +11,10 @@ struct UnitMessageCount_t { UnitMessageCount_t() {} - UnitMessageCount_t(byte unitnr, byte messageCount) : unit(unitnr), count(messageCount) {} + UnitMessageCount_t(uint8_t unitnr, uint8_t messageCount) : unit(unitnr), count(messageCount) {} - byte unit = 0; // Initialize to "not set" - byte count = 0; + uint8_t unit = 0; // Initialize to "not set" + uint8_t count = 0; }; struct UnitLastMessageCount_map { @@ -24,7 +24,7 @@ struct UnitLastMessageCount_map { private: - std::map_map; + std::map_map; }; #endif // ifndef DATASTRUCTS_UNITMESSAGECOUNT_H diff --git a/src/src/DataStructs/UserVarStruct.cpp b/src/src/DataStructs/UserVarStruct.cpp index c7d014d39..00bb3651d 100644 --- a/src/src/DataStructs/UserVarStruct.cpp +++ b/src/src/DataStructs/UserVarStruct.cpp @@ -55,7 +55,7 @@ void UserVarStruct::setSensorTypeLong(taskIndex_t taskIndex, unsigned long value _data[baseVarIndex + 1] = (value >> 16) & 0xFFFF; } -uint32_t UserVarStruct::getUint32(taskIndex_t taskIndex, byte varNr) const +uint32_t UserVarStruct::getUint32(taskIndex_t taskIndex, uint8_t varNr) const { if (!validTaskIndex(taskIndex) || (varNr >= VARS_PER_TASK)) { addLog(LOG_LEVEL_ERROR, F("UserVar index out of range")); @@ -67,7 +67,7 @@ uint32_t UserVarStruct::getUint32(taskIndex_t taskIndex, byte varNr) const return res; } -void UserVarStruct::setUint32(taskIndex_t taskIndex, byte varNr, uint32_t value) +void UserVarStruct::setUint32(taskIndex_t taskIndex, uint8_t varNr, uint32_t value) { if (!validTaskIndex(taskIndex) || (varNr >= VARS_PER_TASK)) { addLog(LOG_LEVEL_ERROR, F("UserVar index out of range")); @@ -87,7 +87,7 @@ size_t UserVarStruct::getNrElements() const return _data.size(); } -byte * UserVarStruct::get() +uint8_t * UserVarStruct::get() { - return (byte *)(&_data[0]); + return (uint8_t *)(&_data[0]); } diff --git a/src/src/DataStructs/UserVarStruct.h b/src/src/DataStructs/UserVarStruct.h index 52272d39d..e97cf5dc2 100644 --- a/src/src/DataStructs/UserVarStruct.h +++ b/src/src/DataStructs/UserVarStruct.h @@ -18,15 +18,15 @@ struct UserVarStruct { // 32 bit unsigned int stored at the memory location of the float uint32_t getUint32(taskIndex_t taskIndex, - byte varNr) const; + uint8_t varNr) const; void setUint32(taskIndex_t taskIndex, - byte varNr, + uint8_t varNr, uint32_t value); size_t getNrElements() const; - byte * get(); + uint8_t * get(); private: diff --git a/src/src/DataStructs/WiFiEventData.cpp b/src/src/DataStructs/WiFiEventData.cpp index 6182afd41..0aafaf489 100644 --- a/src/src/DataStructs/WiFiEventData.cpp +++ b/src/src/DataStructs/WiFiEventData.cpp @@ -164,7 +164,7 @@ void WiFiEventData_t::markDisconnect(WiFiDisconnectReason reason) { wifiConnectInProgress = false; } -void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], byte channel) { +void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], uint8_t channel) { usedChannel = channel; lastConnectMoment.setNow(); processedConnect = false; @@ -174,7 +174,7 @@ void WiFiEventData_t::markConnected(const String& ssid, const uint8_t bssid[6], auth_mode = WiFi_AP_Candidates.getCurrent().enc_type; RTC.lastWiFiChannel = channel; - for (byte i = 0; i < 6; ++i) { + for (uint8_t i = 0; i < 6; ++i) { if (RTC.lastBSSID[i] != bssid[i]) { bssid_changed = true; RTC.lastBSSID[i] = bssid[i]; diff --git a/src/src/DataStructs/WiFiEventData.h b/src/src/DataStructs/WiFiEventData.h index deb735f5c..322a1bb04 100644 --- a/src/src/DataStructs/WiFiEventData.h +++ b/src/src/DataStructs/WiFiEventData.h @@ -49,7 +49,7 @@ struct WiFiEventData_t { void markDisconnect(WiFiDisconnectReason reason); void markConnected(const String& ssid, const uint8_t bssid[6], - byte channel); + uint8_t channel); void markConnectedAPmode(const uint8_t mac[6]); void markDisconnectedAPmode(const uint8_t mac[6]); diff --git a/src/src/DataStructs/WiFi_AP_Candidate.cpp b/src/src/DataStructs/WiFi_AP_Candidate.cpp index 3c7f6bf18..25cec631a 100644 --- a/src/src/DataStructs/WiFi_AP_Candidate.cpp +++ b/src/src/DataStructs/WiFi_AP_Candidate.cpp @@ -15,7 +15,7 @@ #define WIFI_AP_CANDIDATE_MAX_AGE 300000 // 5 minutes in msec -WiFi_AP_Candidate::WiFi_AP_Candidate(byte index_c, const String& ssid_c, const String& pass) : +WiFi_AP_Candidate::WiFi_AP_Candidate(uint8_t index_c, const String& ssid_c, const String& pass) : rssi(0), channel(0), index(index_c), isHidden(false) { const size_t ssid_length = ssid_c.length(); diff --git a/src/src/DataStructs/WiFi_AP_Candidate.h b/src/src/DataStructs/WiFi_AP_Candidate.h index b11bf962d..ad5543726 100644 --- a/src/src/DataStructs/WiFi_AP_Candidate.h +++ b/src/src/DataStructs/WiFi_AP_Candidate.h @@ -9,7 +9,7 @@ struct WiFi_AP_Candidate { // @param index The index of the stored credentials // @param ssid_c SSID of the credentials // @param pass Password/key of the credentials - WiFi_AP_Candidate(byte index, + WiFi_AP_Candidate(uint8_t index, const String& ssid_c, const String& pass); @@ -60,8 +60,8 @@ struct WiFi_AP_Candidate { int32_t rssi = 0; int32_t channel = 0; MAC_address bssid; - byte index = 0; // Index of the matching credentials - byte enc_type = 0; // Encryption used (e.g. WPA2) + uint8_t index = 0; // Index of the matching credentials + uint8_t enc_type = 0; // Encryption used (e.g. WPA2) bool isHidden = false; // Hidden SSID bool lowPriority = false; // Try as last attempt bool isEmergencyFallback = false; diff --git a/src/src/DataTypes/ControllerIndex.h b/src/src/DataTypes/ControllerIndex.h index 2b10bd114..75f7db59b 100644 --- a/src/src/DataTypes/ControllerIndex.h +++ b/src/src/DataTypes/ControllerIndex.h @@ -3,7 +3,7 @@ #include -typedef byte controllerIndex_t; +typedef uint8_t controllerIndex_t; extern controllerIndex_t INVALID_CONTROLLER_INDEX; diff --git a/src/src/DataTypes/EventValueSource.h b/src/src/DataTypes/EventValueSource.h index d8d147b01..394ae60b7 100644 --- a/src/src/DataTypes/EventValueSource.h +++ b/src/src/DataTypes/EventValueSource.h @@ -4,7 +4,7 @@ #include struct EventValueSourceGroup { - enum class Enum : byte { + enum class Enum : uint8_t { RESTRICTED, ALL }; @@ -13,7 +13,7 @@ struct EventValueSourceGroup { struct EventValueSource { // Keep the values as they can be used by other/older builds to communicate with ESPEasy - enum class Enum : byte { + enum class Enum : uint8_t { VALUE_SOURCE_NOT_SET = 0, VALUE_SOURCE_SYSTEM = 1, VALUE_SOURCE_SERIAL = 2, diff --git a/src/src/DataTypes/ProtocolIndex.h b/src/src/DataTypes/ProtocolIndex.h index 48e2feb92..9167f3546 100644 --- a/src/src/DataTypes/ProtocolIndex.h +++ b/src/src/DataTypes/ProtocolIndex.h @@ -3,7 +3,7 @@ #include -typedef byte protocolIndex_t; +typedef uint8_t protocolIndex_t; extern protocolIndex_t INVALID_PROTOCOL_INDEX; diff --git a/src/src/DataTypes/TaskIndex.h b/src/src/DataTypes/TaskIndex.h index e0f6283cb..610e94c6b 100644 --- a/src/src/DataTypes/TaskIndex.h +++ b/src/src/DataTypes/TaskIndex.h @@ -7,7 +7,7 @@ #define USERVAR_MAX_INDEX (VARS_PER_TASK * TASKS_MAX) -typedef byte taskIndex_t; +typedef uint8_t taskIndex_t; typedef uint16_t userVarIndex_t; typedef uint16_t taskVarIndex_t; diff --git a/src/src/ESPEasyCore/Controller.cpp b/src/src/ESPEasyCore/Controller.cpp index bc7c77e89..9066e8f70 100644 --- a/src/src/ESPEasyCore/Controller.cpp +++ b/src/src/ESPEasyCore/Controller.cpp @@ -97,7 +97,7 @@ bool validUserVar(struct EventStruct *event) { default: break; } - byte valueCount = getValueCountForTask(event->TaskIndex); + uint8_t valueCount = getValueCountForTask(event->TaskIndex); for (int i = 0; i < valueCount; ++i) { const float f(UserVar[event->BaseVarIndex + i]); @@ -114,7 +114,7 @@ bool validUserVar(struct EventStruct *event) { \*********************************************************************************************/ // handle MQTT messages -void incoming_mqtt_callback(char *c_topic, byte *b_payload, unsigned int length) { +void incoming_mqtt_callback(char *c_topic, uint8_t *b_payload, unsigned int length) { statusLED(true); controllerIndex_t enabledMqttController = firstEnabledMQTT_ControllerIndex(); @@ -236,7 +236,7 @@ bool MQTTConnect(controllerIndex_t controller_idx) delay(0); - byte controller_number = Settings.Protocol[controller_idx]; + uint8_t controller_number = Settings.Protocol[controller_idx]; count_connection_results(MQTTresult, F("MQTT : Broker "), controller_number); @@ -607,7 +607,7 @@ void SensorSendTask(taskIndex_t TaskIndex) float preValue[VARS_PER_TASK]; // store values before change, in case we need it in the formula - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) { + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { preValue[varNr] = UserVar[TempEvent.BaseVarIndex + varNr]; } @@ -625,7 +625,7 @@ void SensorSendTask(taskIndex_t TaskIndex) if (Device[DeviceIndex].FormulaOption) { START_TIMER; - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { if (ExtraTaskSettings.TaskDeviceFormula[varNr][0] != 0) { diff --git a/src/src/ESPEasyCore/Controller.h b/src/src/ESPEasyCore/Controller.h index 54ac0cb3e..0a69b48a4 100644 --- a/src/src/ESPEasyCore/Controller.h +++ b/src/src/ESPEasyCore/Controller.h @@ -19,7 +19,7 @@ bool validUserVar(struct EventStruct *event); \*********************************************************************************************/ // handle MQTT messages -void incoming_mqtt_callback(char *c_topic, byte *b_payload, unsigned int length); +void incoming_mqtt_callback(char *c_topic, uint8_t *b_payload, unsigned int length); /*********************************************************************************************\ * Disconnect from MQTT message broker diff --git a/src/src/ESPEasyCore/ESPEasyGPIO.cpp b/src/src/ESPEasyCore/ESPEasyGPIO.cpp index fa34672cd..0801f9454 100644 --- a/src/src/ESPEasyCore/ESPEasyGPIO.cpp +++ b/src/src/ESPEasyCore/ESPEasyGPIO.cpp @@ -17,7 +17,7 @@ //******************************************************************************** // Internal GPIO write //******************************************************************************** -void GPIO_Internal_Write(int pin, byte value) +void GPIO_Internal_Write(int pin, uint8_t value) { if (checkValidPortRange(PLUGIN_GPIO, pin)) { const uint32_t key = createKey(PLUGIN_GPIO, pin); @@ -59,7 +59,7 @@ bool GPIO_Read_Switch_State(struct EventStruct *event) { return false; } -bool GPIO_Read_Switch_State(int pin, byte pinMode) { +bool GPIO_Read_Switch_State(int pin, uint8_t pinMode) { bool canRead = false; if (checkValidPortRange(PLUGIN_GPIO, pin)) { switch (pinMode) @@ -95,13 +95,13 @@ int8_t GPIO_MCP_Read(int Par1) { int8_t pinState = -1; if (checkValidPortRange(PLUGIN_MCP, Par1)) { - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) - 1; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) - 1; uint8_t address = 0x20 + unit; - byte IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; + uint8_t IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; port = port % 8; - byte retValue; + uint8_t retValue; if (GPIO_MCP_ReadRegister(address,IOBankValueReg,&retValue)) { retValue = (retValue & (1 << port)) >> port; pinState = (retValue==0)?0:1; @@ -126,7 +126,7 @@ int8_t GPIO_MCP_Read(int Par1) // MCP23017 read register //******************************************************************************** -bool GPIO_MCP_ReadRegister(byte mcpAddr, uint8_t regAddr, uint8_t *retValue) { +bool GPIO_MCP_ReadRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t *retValue) { bool success = false; // Read the register Wire.beginTransmission(mcpAddr); @@ -145,7 +145,7 @@ bool GPIO_MCP_ReadRegister(byte mcpAddr, uint8_t regAddr, uint8_t *retValue) { // MCP23017 write register //******************************************************************************** -void GPIO_MCP_WriteRegister(byte mcpAddr, uint8_t regAddr, uint8_t regValue) { +void GPIO_MCP_WriteRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t regValue) { // Write the register Wire.beginTransmission(mcpAddr); Wire.write(regAddr); @@ -157,20 +157,20 @@ void GPIO_MCP_WriteRegister(byte mcpAddr, uint8_t regAddr, uint8_t regValue) { //******************************************************************************** // MCP23017 write pin //******************************************************************************** -bool GPIO_MCP_Write(int Par1, byte Par2) +bool GPIO_MCP_Write(int Par1, uint8_t Par2) { if (!checkValidPortRange(PLUGIN_MCP, Par1)) { return false; } bool success = false; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) - 1; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) - 1; uint8_t address = int((Par1-1) / 16) + 0x20; - byte IOBankConfigReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; - byte IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; + uint8_t IOBankConfigReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t IOBankValueReg = (port<8)? MCP23017_GPIOA : MCP23017_GPIOB; port = port % 8; - byte retValue; + uint8_t retValue; // turn this port into output, first read current config if (GPIO_MCP_ReadRegister(address,IOBankConfigReg,&retValue)) { @@ -190,7 +190,7 @@ bool GPIO_MCP_Write(int Par1, byte Par2) return(success); /* - byte portvalue = 0; + uint8_t portvalue = 0; // turn this port into output, first read current config Wire.beginTransmission(address); Wire.write(IOBankConfigReg); // IO config register @@ -243,14 +243,14 @@ bool setMCPInputAndPullupMode(uint8_t Par1, bool enablePullUp) } bool success = false; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) -1; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) -1; uint8_t address = 0x20 + unit; - byte IOBankPullUpReg = (port<8)? MCP23017_GPPUA : MCP23017_GPPUB; - byte IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t IOBankPullUpReg = (port<8)? MCP23017_GPPUA : MCP23017_GPPUB; + uint8_t IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; port = port % 8; - byte retValue; + uint8_t retValue; // set this port mode to INPUT (bit=1) if (GPIO_MCP_ReadRegister(address, IOBankIODirReg, &retValue)) { retValue |= (1 << port); @@ -274,11 +274,11 @@ bool setMCPOutputMode(uint8_t Par1) } bool success = false; - byte retValue; - byte unit = (Par1 - 1) / 16; - byte port = Par1 - (unit * 16) - 1; + uint8_t retValue; + uint8_t unit = (Par1 - 1) / 16; + uint8_t port = Par1 - (unit * 16) - 1; uint8_t address = 0x20 + unit; - byte IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; + uint8_t IOBankIODirReg = (port<8)? MCP23017_IODIRA : MCP23017_IODIRB; port = port % 8; // set this port mode to OUTPUT (bit=0) @@ -298,8 +298,8 @@ int8_t GPIO_PCF_Read(int Par1) { int8_t state = -1; if (checkValidPortRange(PLUGIN_PCF, Par1)) { - byte unit = (Par1 - 1) / 8; - byte port = Par1 - (unit * 8) - 1; + uint8_t unit = (Par1 - 1) / 8; + uint8_t port = Par1 - (unit * 8) - 1; uint8_t address = 0x20 + unit; if (unit > 7) address += 0x10; @@ -337,7 +337,7 @@ void GPIO_PCF_WriteAllPins(uint8_t address, uint8_t value) Wire.endTransmission(); } -bool GPIO_PCF_Write(int Par1, byte Par2) +bool GPIO_PCF_Write(int Par1, uint8_t Par2) { if (!checkValidPortRange(PLUGIN_PCF, Par1)) { return false; @@ -513,7 +513,7 @@ void setInternalGPIOPullupMode(uint8_t port) } } -bool GPIO_Write(pluginID_t pluginID, int port, byte value, byte pinMode) +bool GPIO_Write(pluginID_t pluginID, int port, uint8_t value, uint8_t pinMode) { bool success=true; switch (pluginID) diff --git a/src/src/ESPEasyCore/ESPEasyGPIO.h b/src/src/ESPEasyCore/ESPEasyGPIO.h index 0a40bf7ea..540f89264 100644 --- a/src/src/ESPEasyCore/ESPEasyGPIO.h +++ b/src/src/ESPEasyCore/ESPEasyGPIO.h @@ -17,26 +17,26 @@ //******************************************************************************** // Internal GPIO write //******************************************************************************** -void GPIO_Internal_Write(int pin, byte value); +void GPIO_Internal_Write(int pin, uint8_t value); //******************************************************************************** // Internal GPIO read //******************************************************************************** bool GPIO_Internal_Read(int pin); bool GPIO_Read_Switch_State(struct EventStruct *event); -bool GPIO_Read_Switch_State(int pinNumber, byte pinMode); +bool GPIO_Read_Switch_State(int pinNumber, uint8_t pinMode); //******************************************************************************** // MCP23017 read //******************************************************************************** int8_t GPIO_MCP_Read(int Par1); -bool GPIO_MCP_ReadRegister(byte mcpAddr, uint8_t regAddr, uint8_t *retValue); +bool GPIO_MCP_ReadRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t *retValue); //******************************************************************************** // MCP23017 write //******************************************************************************** -bool GPIO_MCP_Write(int Par1, byte Par2); -void GPIO_MCP_WriteRegister(byte mcpAddr, uint8_t regAddr, uint8_t regValue); +bool GPIO_MCP_Write(int Par1, uint8_t Par2); +void GPIO_MCP_WriteRegister(uint8_t mcpAddr, uint8_t regAddr, uint8_t regValue); //******************************************************************************** // MCP23017 pullUP @@ -52,7 +52,7 @@ bool GPIO_PCF_ReadAllPins(uint8_t address, uint8_t *retValue); //******************************************************************************** // PCF8574 write //******************************************************************************** -bool GPIO_PCF_Write(int Par1, byte Par2); +bool GPIO_PCF_Write(int Par1, uint8_t Par2); void GPIO_PCF_WriteAllPins(uint8_t Par1, uint8_t Par2); //********************************************************* @@ -70,14 +70,14 @@ void GPIO_Monitor10xSec(); void sendMonitorEvent(const char* prefix, int port, int8_t state); bool checkValidPortRange(pluginID_t pluginID, int port); -bool checkValidPortAddress(pluginID_t pluginID, byte address); +bool checkValidPortAddress(pluginID_t pluginID, uint8_t address); void setInternalGPIOPullupMode(uint8_t port); bool setMCPInputAndPullupMode(uint8_t Par1, bool enablePullUp); bool setMCPOutputMode(uint8_t Par1); bool setPCFInputMode(uint8_t pin); -bool GPIO_Write(pluginID_t pluginID, int port, byte value, byte pinMode=PIN_MODE_OUTPUT); +bool GPIO_Write(pluginID_t pluginID, int port, uint8_t value, uint8_t pinMode=PIN_MODE_OUTPUT); bool GPIO_Read(pluginID_t pluginID, int port, int8_t &value); #endif \ No newline at end of file diff --git a/src/src/ESPEasyCore/ESPEasyRules.cpp b/src/src/ESPEasyCore/ESPEasyRules.cpp index 7246d4960..f88f464a1 100644 --- a/src/src/ESPEasyCore/ESPEasyRules.cpp +++ b/src/src/ESPEasyCore/ESPEasyRules.cpp @@ -59,7 +59,7 @@ String FileNameToEvent(const String& fileName) { } void checkRuleSets() { - for (byte x = 0; x < RULESETS_MAX; x++) { + for (uint8_t x = 0; x < RULESETS_MAX; x++) { #if defined(ESP8266) String fileName = F("rules"); #endif // if defined(ESP8266) @@ -128,7 +128,7 @@ void rulesProcessing(const String& event) { } if (Settings.OldRulesEngine()) { - for (byte x = 0; x < RULESETS_MAX; x++) { + for (uint8_t x = 0; x < RULESETS_MAX; x++) { if (activeRuleSets[x]) { rulesProcessingFile(getRulesFileName(x), event); } @@ -185,7 +185,7 @@ String rulesProcessingFile(const String& fileName, const String& event) { } #endif // ifndef BUILD_NO_DEBUG - static byte nestingLevel = 0; + static uint8_t nestingLevel = 0; nestingLevel++; @@ -207,10 +207,10 @@ String rulesProcessingFile(const String& fileName, const String& event) { bool isCommand = false; bool condition[RULES_IF_MAX_NESTING_LEVEL]; bool ifBranche[RULES_IF_MAX_NESTING_LEVEL]; - byte ifBlock = 0; - byte fakeIfBlock = 0; + uint8_t ifBlock = 0; + uint8_t fakeIfBlock = 0; - std::vector buf; + std::vector buf; buf.resize(RULES_BUFFER_SIZE); bool firstNonSpaceRead = false; @@ -589,7 +589,7 @@ void parse_string_commands(String& line) { } else if (cmd_s_lower.equals(F("div100ths"))) { // division and giving the 100ths as integer // 5 / 100 would yield 5 - // useful for fractions that use a full byte gaining a + // useful for fractions that use a full uint8_t gaining a // precision/granularity of 1/256 instead of only 1/100 // Syntax like XXX{div100ths:24:256}XXX if (validUInt64FromString(arg1, iarg1) @@ -698,7 +698,7 @@ void parseCompleteNonCommentLine(String& line, const String& event, String& action, bool& match, bool& codeBlock, bool& isCommand, bool condition[], bool ifBranche[], - byte& ifBlock, byte& fakeIfBlock) { + uint8_t& ifBlock, uint8_t& fakeIfBlock) { const bool lineStartsWith_on = line.substring(0, 3).equalsIgnoreCase(F("on ")); if (!codeBlock && !match) { @@ -804,7 +804,7 @@ void parseCompleteNonCommentLine(String& line, const String& event, void processMatchedRule(String& action, const String& event, bool& match, bool& codeBlock, bool& isCommand, bool condition[], bool ifBranche[], - byte& ifBlock, byte& fakeIfBlock) { + uint8_t& ifBlock, uint8_t& fakeIfBlock) { String lcAction = action; lcAction.toLowerCase(); @@ -1242,7 +1242,7 @@ bool timeStringToSeconds(const String& tBuf, int& time_seconds, String& timeStri // Should only try to match "7:07", not "7:07 and 10:11:12" // Or else it will find "7:07:11" bool done = false; - for (byte pos = 0; !done && timeString.length() < 8 && pos < tBuf.length(); ++pos) { + for (uint8_t pos = 0; !done && timeString.length() < 8 && pos < tBuf.length(); ++pos) { char c = tBuf[pos]; if (isdigit(c) || c == ':') { timeString += c; @@ -1429,7 +1429,7 @@ void createRuleEvents(struct EventStruct *event) { LoadTaskSettings(event->TaskIndex); - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); // Small optimization as sensor type string may result in large strings // These also only yield a single value, so no need to check for combining task values. @@ -1467,7 +1467,7 @@ void createRuleEvents(struct EventStruct *event) { eventString = getTaskDeviceName(event->TaskIndex); eventString += F("#All="); - for (byte varNr = 0; varNr < valueCount; varNr++) { + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { if (varNr != 0) { eventString += ','; } @@ -1475,7 +1475,7 @@ void createRuleEvents(struct EventStruct *event) { } eventQueue.addMove(std::move(eventString)); } else { - for (byte varNr = 0; varNr < valueCount; varNr++) { + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { String eventString; eventString.reserve(64); // Enough for most use cases, prevent lots of memory allocations. eventString = getTaskDeviceName(event->TaskIndex); diff --git a/src/src/ESPEasyCore/ESPEasyRules.h b/src/src/ESPEasyCore/ESPEasyRules.h index 8c562f48d..da7695098 100644 --- a/src/src/ESPEasyCore/ESPEasyRules.h +++ b/src/src/ESPEasyCore/ESPEasyRules.h @@ -100,8 +100,8 @@ void parseCompleteNonCommentLine(String& line, bool & isCommand, bool condition[], bool ifBranche[], - byte & ifBlock, - byte & fakeIfBlock); + uint8_t & ifBlock, + uint8_t & fakeIfBlock); void processMatchedRule(String& action, const String& event, @@ -110,8 +110,8 @@ void processMatchedRule(String& action, bool & isCommand, bool condition[], bool ifBranche[], - byte & ifBlock, - byte & fakeIfBlock); + uint8_t & ifBlock, + uint8_t & fakeIfBlock); /********************************************************************************************\ Check if an event matches to a given rule diff --git a/src/src/ESPEasyCore/ESPEasy_Log.cpp b/src/src/ESPEasyCore/ESPEasy_Log.cpp index eaa3d0372..b41261b97 100644 --- a/src/src/ESPEasyCore/ESPEasy_Log.cpp +++ b/src/src/ESPEasyCore/ESPEasy_Log.cpp @@ -47,7 +47,7 @@ const __FlashStringHelper * getLogLevelDisplayString(int logLevel) { return F(""); } -const __FlashStringHelper * getLogLevelDisplayStringFromIndex(byte index, int& logLevel) { +const __FlashStringHelper * getLogLevelDisplayStringFromIndex(uint8_t index, int& logLevel) { switch (index) { case 0: logLevel = LOG_LEVEL_ERROR; break; case 1: logLevel = LOG_LEVEL_INFO; break; @@ -65,7 +65,7 @@ void disableSerialLog() { setLogLevelFor(LOG_TO_SERIAL, 0); } -void setLogLevelFor(byte destination, byte logLevel) { +void setLogLevelFor(uint8_t destination, uint8_t logLevel) { switch (destination) { case LOG_TO_SERIAL: if (!log_to_serial_disabled || logLevel == 0) { @@ -82,7 +82,7 @@ void setLogLevelFor(byte destination, byte logLevel) { } void updateLogLevelCache() { - byte max_lvl = 0; + uint8_t max_lvl = 0; const bool useSerial = Settings.UseSerial && !activeTaskUseSerial0(); if (log_to_serial_disabled) { if (useSerial) { @@ -106,11 +106,11 @@ void updateLogLevelCache() { highest_active_log_level = max_lvl; } -bool loglevelActiveFor(byte logLevel) { +bool loglevelActiveFor(uint8_t logLevel) { return loglevelActive(logLevel, highest_active_log_level); } -byte getSerialLogLevel() { +uint8_t getSerialLogLevel() { if (log_to_serial_disabled || !Settings.UseSerial || activeTaskUseSerial0()) return 0; if (!(WiFiEventData.WiFiServicesInitialized())){ if (Settings.SerialLogLevel < LOG_LEVEL_INFO) { @@ -120,8 +120,8 @@ byte getSerialLogLevel() { return Settings.SerialLogLevel; } -byte getWebLogLevel() { - byte logLevelSettings = 0; +uint8_t getWebLogLevel() { + uint8_t logLevelSettings = 0; if (Logging.logActiveRead()) { logLevelSettings = Settings.WebLogLevel; } else { @@ -132,8 +132,8 @@ byte getWebLogLevel() { return logLevelSettings; } -bool loglevelActiveFor(byte destination, byte logLevel) { - byte logLevelSettings = 0; +bool loglevelActiveFor(uint8_t destination, uint8_t logLevel) { + uint8_t logLevelSettings = 0; switch (destination) { case LOG_TO_SERIAL: { logLevelSettings = getSerialLogLevel(); @@ -160,29 +160,29 @@ bool loglevelActiveFor(byte destination, byte logLevel) { } -bool loglevelActive(byte logLevel, byte logLevelSettings) { +bool loglevelActive(uint8_t logLevel, uint8_t logLevelSettings) { return (logLevel <= logLevelSettings); } //#ifdef LIMIT_BUILD_SIZE -void addLog(byte loglevel, const __FlashStringHelper *str) +void addLog(uint8_t loglevel, const __FlashStringHelper *str) { addToLog(loglevel, str); } -void addLog(byte logLevel, const char *line) +void addLog(uint8_t logLevel, const char *line) { addToLog(logLevel, line); } -void addLog(byte loglevel, const String& string) +void addLog(uint8_t loglevel, const String& string) { addToLog(loglevel, string); } //#endif -void addToLog(byte loglevel, const __FlashStringHelper *str) +void addToLog(uint8_t loglevel, const __FlashStringHelper *str) { if (loglevelActiveFor(loglevel)) { String copy; @@ -193,14 +193,14 @@ void addToLog(byte loglevel, const __FlashStringHelper *str) } } -void addToLog(byte loglevel, const String& string) +void addToLog(uint8_t loglevel, const String& string) { if (loglevelActiveFor(loglevel)) { addToLog(loglevel, string.c_str()); } } -void addToLog(byte logLevel, const char *line) +void addToLog(uint8_t logLevel, const char *line) { // Please note all functions called from here handling line must be PROGMEM aware. if (loglevelActiveFor(LOG_TO_SERIAL, logLevel)) { diff --git a/src/src/ESPEasyCore/ESPEasy_Log.h b/src/src/ESPEasyCore/ESPEasy_Log.h index b4f1dd100..601f9758c 100644 --- a/src/src/ESPEasyCore/ESPEasy_Log.h +++ b/src/src/ESPEasyCore/ESPEasy_Log.h @@ -25,40 +25,40 @@ void initLog(); const __FlashStringHelper * getLogLevelDisplayString(int logLevel); -const __FlashStringHelper * getLogLevelDisplayStringFromIndex(byte index, int& logLevel); +const __FlashStringHelper * getLogLevelDisplayStringFromIndex(uint8_t index, int& logLevel); void disableSerialLog(); -void setLogLevelFor(byte destination, byte logLevel); +void setLogLevelFor(uint8_t destination, uint8_t logLevel); void updateLogLevelCache(); -bool loglevelActiveFor(byte logLevel); +bool loglevelActiveFor(uint8_t logLevel); -byte getSerialLogLevel(); +uint8_t getSerialLogLevel(); -byte getWebLogLevel(); +uint8_t getWebLogLevel(); -bool loglevelActiveFor(byte destination, byte logLevel); +bool loglevelActiveFor(uint8_t destination, uint8_t logLevel); -bool loglevelActive(byte logLevel, byte logLevelSettings); +bool loglevelActive(uint8_t logLevel, uint8_t logLevelSettings); //#ifdef LIMIT_BUILD_SIZE // Macro does add to the build size, but does take more resources as the string may need resources to create -void addLog(byte loglevel, const __FlashStringHelper *str); -void addLog(byte logLevel, const char *line); -void addLog(byte loglevel, const String& string); +void addLog(uint8_t loglevel, const __FlashStringHelper *str); +void addLog(uint8_t logLevel, const char *line); +void addLog(uint8_t loglevel, const String& string); //#else // Do this in a template to prevent casting to String when not needed. //#define addLog(L,S) if (loglevelActiveFor(L)) { addToLog(L,S); } //#endif -void addToLog(byte loglevel, const __FlashStringHelper *str); +void addToLog(uint8_t loglevel, const __FlashStringHelper *str); -void addToLog(byte loglevel, const String& string); +void addToLog(uint8_t loglevel, const String& string); -void addToLog(byte logLevel, const char *line); +void addToLog(uint8_t logLevel, const char *line); #endif \ No newline at end of file diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index 058f562d9..77fd0564f 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -223,7 +223,7 @@ void ESPEasy_setup() Settings.UseRTOSMultitasking = false; // For now, disable it, we experience heap corruption. if ((RTC.bootFailedCount > 10) && (RTC.bootCounter > 10)) { - byte toDisable = RTC.bootFailedCount - 10; + uint8_t toDisable = RTC.bootFailedCount - 10; toDisable = disablePlugin(toDisable); if (toDisable != 0) { diff --git a/src/src/ESPEasyCore/Serial.cpp b/src/src/ESPEasyCore/Serial.cpp index 552760a66..911a3001b 100644 --- a/src/src/ESPEasyCore/Serial.cpp +++ b/src/src/ESPEasyCore/Serial.cpp @@ -14,7 +14,7 @@ * Get data from Serial Interface \*********************************************************************************************/ -byte SerialInByte; +uint8_t SerialInByte; int SerialInByteCounter = 0; char InputBuffer_Serial[INPUT_BUFFER_SIZE + 2]; diff --git a/src/src/ESPEasyCore/Serial.h b/src/src/ESPEasyCore/Serial.h index ea9abab1d..56f97c2eb 100644 --- a/src/src/ESPEasyCore/Serial.h +++ b/src/src/ESPEasyCore/Serial.h @@ -5,7 +5,7 @@ #define INPUT_BUFFER_SIZE 128 -extern byte SerialInByte; +extern uint8_t SerialInByte; extern int SerialInByteCounter; extern char InputBuffer_Serial[INPUT_BUFFER_SIZE + 2]; diff --git a/src/src/Globals/C016_ControllerCache.cpp b/src/src/Globals/C016_ControllerCache.cpp index 381210584..f28750b30 100644 --- a/src/src/Globals/C016_ControllerCache.cpp +++ b/src/src/Globals/C016_ControllerCache.cpp @@ -22,10 +22,10 @@ bool C016_deleteOldestCacheBlock() { bool C016_getCSVline( unsigned long& timestamp, - byte& controller_idx, - byte& TaskIndex, + uint8_t& controller_idx, + uint8_t& TaskIndex, Sensor_VType& sensorType, - byte& valueCount, + uint8_t& valueCount, float& val1, float& val2, float& val3, diff --git a/src/src/Globals/C016_ControllerCache.h b/src/src/Globals/C016_ControllerCache.h index 08c13446a..edcd613ed 100644 --- a/src/src/Globals/C016_ControllerCache.h +++ b/src/src/Globals/C016_ControllerCache.h @@ -22,10 +22,10 @@ bool C016_deleteOldestCacheBlock(); bool C016_getCSVline( unsigned long& timestamp, - byte& controller_idx, - byte& TaskIndex, + uint8_t& controller_idx, + uint8_t& TaskIndex, Sensor_VType& sensorType, - byte& valueCount, + uint8_t& valueCount, float& val1, float& val2, float& val3, diff --git a/src/src/Globals/MainLoopCommand.cpp b/src/src/Globals/MainLoopCommand.cpp index 9a5bb2e1a..8f5fc427d 100644 --- a/src/src/Globals/MainLoopCommand.cpp +++ b/src/src/Globals/MainLoopCommand.cpp @@ -1,3 +1,3 @@ #include "MainLoopCommand.h" -byte cmd_within_mainloop = 0; \ No newline at end of file +uint8_t cmd_within_mainloop = 0; \ No newline at end of file diff --git a/src/src/Globals/MainLoopCommand.h b/src/src/Globals/MainLoopCommand.h index 055446114..1d2caa715 100644 --- a/src/src/Globals/MainLoopCommand.h +++ b/src/src/Globals/MainLoopCommand.h @@ -3,7 +3,7 @@ #include -extern byte cmd_within_mainloop; +extern uint8_t cmd_within_mainloop; // ******************************************************************************** // DO NOT CHANGE ANYTHING BELOW THIS LINE diff --git a/src/src/Globals/NPlugins.cpp b/src/src/Globals/NPlugins.cpp index f9fbe5b6c..975091bcb 100644 --- a/src/src/Globals/NPlugins.cpp +++ b/src/src/Globals/NPlugins.cpp @@ -52,7 +52,7 @@ String getNPluginNameFromNotifierIndex(notifierIndex_t NotifierIndex) { \*********************************************************************************************/ nprotocolIndex_t getNProtocolIndex(npluginID_t Number) { - for (byte x = 0; x <= notificationCount; x++) { + for (uint8_t x = 0; x <= notificationCount; x++) { if (Notification[x].Number == Number) { return x; } diff --git a/src/src/Globals/NPlugins.h b/src/src/Globals/NPlugins.h index 2875a8679..38f4e659e 100644 --- a/src/src/Globals/NPlugins.h +++ b/src/src/Globals/NPlugins.h @@ -9,8 +9,8 @@ #include "../DataTypes/ESPEasy_plugin_functions.h" -typedef byte nprotocolIndex_t; -typedef byte notifierIndex_t; +typedef uint8_t nprotocolIndex_t; +typedef uint8_t notifierIndex_t; typedef uint8_t npluginID_t; extern nprotocolIndex_t INVALID_NPROTOCOL_INDEX; @@ -28,7 +28,7 @@ extern NotificationStruct Notification[NPLUGIN_MAX]; extern int notificationCount; -byte NPluginCall(NPlugin::Function Function, +uint8_t NPluginCall(NPlugin::Function Function, struct EventStruct *event); bool validNProtocolIndex(nprotocolIndex_t index); diff --git a/src/src/Globals/NetworkState.cpp b/src/src/Globals/NetworkState.cpp index 4d8582b12..3f42e91b4 100644 --- a/src/src/Globals/NetworkState.cpp +++ b/src/src/Globals/NetworkState.cpp @@ -16,7 +16,7 @@ bool statusNTPInitialized = false; // Setup DNS, only used if the ESP has no valid WiFi config -const byte DNS_PORT = 53; +const uint8_t DNS_PORT = 53; IPAddress apIP(DEFAULT_AP_IP); diff --git a/src/src/Globals/NetworkState.h b/src/src/Globals/NetworkState.h index f229ec2ff..ec8aa2174 100644 --- a/src/src/Globals/NetworkState.h +++ b/src/src/Globals/NetworkState.h @@ -22,7 +22,7 @@ extern bool statusNTPInitialized; // Setup DNS, only used if the ESP has no valid WiFi config -extern const byte DNS_PORT; +extern const uint8_t DNS_PORT; extern IPAddress apIP; // udp protocol stuff (syslog, global sync, node info list, ntp time) diff --git a/src/src/Globals/Plugins.cpp b/src/src/Globals/Plugins.cpp index bd4a15f29..62424cf59 100644 --- a/src/src/Globals/Plugins.cpp +++ b/src/src/Globals/Plugins.cpp @@ -32,7 +32,7 @@ int deviceCount = -1; -boolean (*Plugin_ptr[PLUGIN_MAX])(byte, +boolean (*Plugin_ptr[PLUGIN_MAX])(uint8_t, struct EventStruct *, String&); @@ -255,7 +255,7 @@ void queueTaskEvent(const String& eventName, taskIndex_t taskIndex, int value1) /** * Call the plugin of 1 task for 1 function, with standard EventStruct and optional command string */ -bool PluginCallForTask(taskIndex_t taskIndex, byte Function, EventStruct *TempEvent, String& command, EventStruct *event = nullptr) { +bool PluginCallForTask(taskIndex_t taskIndex, uint8_t Function, EventStruct *TempEvent, String& command, EventStruct *event = nullptr) { bool retval = false; if (Settings.TaskDeviceEnabled[taskIndex] && validPluginID_fullcheck(Settings.TaskDeviceNumber[taskIndex])) { @@ -308,7 +308,7 @@ bool PluginCallForTask(taskIndex_t taskIndex, byte Function, EventStruct *TempEv /*********************************************************************************************\ * Function call to all or specific plugins \*********************************************************************************************/ -bool PluginCall(byte Function, struct EventStruct *event, String& str) +bool PluginCall(uint8_t Function, struct EventStruct *event, String& str) { struct EventStruct TempEvent; diff --git a/src/src/Globals/Plugins.h b/src/src/Globals/Plugins.h index e190de0bb..dfedcc3e3 100644 --- a/src/src/Globals/Plugins.h +++ b/src/src/Globals/Plugins.h @@ -46,7 +46,7 @@ extern int deviceCount; // Array of function pointers to call plugins. -extern boolean (*Plugin_ptr[PLUGIN_MAX])(byte, +extern boolean (*Plugin_ptr[PLUGIN_MAX])(uint8_t, struct EventStruct *, String&); @@ -93,7 +93,7 @@ void post_I2C_by_taskIndex(taskIndex_t taskIndex, deviceIndex_t DeviceIndex); /*********************************************************************************************\ * Function call to all or specific plugins \*********************************************************************************************/ -bool PluginCall(byte Function, struct EventStruct *event, String& str); +bool PluginCall(uint8_t Function, struct EventStruct *event, String& str); /*********************************************************************************************\ diff --git a/src/src/Helpers/Audio.cpp b/src/src/Helpers/Audio.cpp index 1c769338b..c29fdc5fb 100644 --- a/src/src/Helpers/Audio.cpp +++ b/src/src/Helpers/Audio.cpp @@ -38,14 +38,14 @@ bool play_rtttl(uint8_t _pin, const char *p) }; - byte default_dur = 4; - byte default_oct = 6; + uint8_t default_dur = 4; + uint8_t default_oct = 6; int bpm = 63; int num; long wholenote; long duration; - byte note; - byte scale; + uint8_t note; + uint8_t scale; // format: d=N,o=N,b=NNN: // find the start (skip name, etc) diff --git a/src/src/Helpers/Convert.cpp b/src/src/Helpers/Convert.cpp index b8c00a669..b178371df 100644 --- a/src/src/Helpers/Convert.cpp +++ b/src/src/Helpers/Convert.cpp @@ -234,7 +234,7 @@ float ul2float(unsigned long ul) /*********************************************************************************************\ Workaround for removing trailing white space when String() converts a float with 0 decimals \*********************************************************************************************/ -String toString(const float& value, byte decimals) +String toString(const float& value, uint8_t decimals) { String sValue = String(value, decimals); diff --git a/src/src/Helpers/Convert.h b/src/src/Helpers/Convert.h index 669d5ed47..e5c1bf8a8 100644 --- a/src/src/Helpers/Convert.h +++ b/src/src/Helpers/Convert.h @@ -65,7 +65,7 @@ float ul2float(unsigned long ul); /*********************************************************************************************\ Workaround for removing trailing white space when String() converts a float with 0 decimals \*********************************************************************************************/ -String toString(const float& value, byte decimals); +String toString(const float& value, uint8_t decimals); String doubleToString(const double& value, int decimals = 2, bool trimTrailingZeros = false); diff --git a/src/src/Helpers/Dallas1WireHelper.cpp b/src/src/Helpers/Dallas1WireHelper.cpp index 48b20d048..d59fc2944 100644 --- a/src/src/Helpers/Dallas1WireHelper.cpp +++ b/src/src/Helpers/Dallas1WireHelper.cpp @@ -46,7 +46,7 @@ String Dallas_format_address(const uint8_t addr[]) { result.reserve(40); - for (byte j = 0; j < 8; j++) + for (uint8_t j = 0; j < 8; j++) { if (addr[j] < 0x10) { result += '0'; @@ -65,7 +65,7 @@ String Dallas_format_address(const uint8_t addr[]) { uint64_t Dallas_addr_to_uint64(const uint8_t addr[]) { uint64_t tmpAddr_64 = 0; - for (byte i = 0; i < 8; ++i) { + for (uint8_t i = 0; i < 8; ++i) { tmpAddr_64 *= 256; tmpAddr_64 += addr[i]; } @@ -160,7 +160,7 @@ void Dallas_addr_selector_webform_load(taskIndex_t TaskIndex, int8_t gpio_pin_rx // get currently saved address uint8_t savedAddress[8]; - for (byte index = 0; index < scan_res.size(); ++index) { + for (uint8_t index = 0; index < scan_res.size(); ++index) { Dallas_plugin_get_addr(savedAddress, TaskIndex, var_index); Dallas_uint64_to_addr(scan_res[index], tmpAddress); String option = Dallas_format_address(tmpAddress); @@ -248,7 +248,7 @@ void Dallas_plugin_get_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i // Load ROM address from tasksettings LoadTaskSettings(TaskIndex); - for (byte x = 0; x < 8; x++) { + for (uint8_t x = 0; x < 8; x++) { uint32_t value = (uint32_t)ExtraTaskSettings.TaskDevicePluginConfigLong[x]; addr[x] = static_cast((value >> (var_index * 8)) & 0xFF); } @@ -262,7 +262,7 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i LoadTaskSettings(TaskIndex); const uint32_t mask = ~(0xFF << (var_index * 8)); - for (byte x = 0; x < 8; x++) { + for (uint8_t x = 0; x < 8; x++) { uint32_t value = (uint32_t)ExtraTaskSettings.TaskDevicePluginConfigLong[x]; value &= mask; value += (static_cast(addr[x]) << (var_index * 8)); @@ -273,10 +273,10 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i /*********************************************************************************************\ Dallas Scan bus \*********************************************************************************************/ -byte Dallas_scan(byte getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpio_pin_tx) +uint8_t Dallas_scan(uint8_t getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpio_pin_tx) { - byte tmpaddr[8]; - byte devCount = 0; + uint8_t tmpaddr[8]; + uint8_t devCount = 0; Dallas_reset(gpio_pin_rx, gpio_pin_tx); @@ -285,7 +285,7 @@ byte Dallas_scan(byte getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpi while (Dallas_search(tmpaddr, gpio_pin_rx, gpio_pin_tx)) { if (getDeviceROM == devCount) { - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { ROM[i] = tmpaddr[i]; } } @@ -309,7 +309,7 @@ void Dallas_startConversion(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpi Dallas_reset(gpio_pin_rx, gpio_pin_tx); Dallas_write(0x55, gpio_pin_rx, gpio_pin_tx); // Choose ROM - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { Dallas_write(ROM[i], gpio_pin_rx, gpio_pin_tx); } Dallas_write(0x44, gpio_pin_rx, gpio_pin_tx); @@ -321,14 +321,14 @@ void Dallas_startConversion(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpi bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int8_t gpio_pin_tx) { int16_t DSTemp; - byte ScratchPad[12]; + uint8_t ScratchPad[12]; if (!Dallas_address_ROM(ROM, gpio_pin_rx, gpio_pin_tx)) { return false; } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - for (byte i = 0; i < 9; i++) { // read 9 bytes + for (uint8_t i = 0; i < 9; i++) { // read 9 bytes ScratchPad[i] = Dallas_read(gpio_pin_rx, gpio_pin_tx); } @@ -337,7 +337,7 @@ bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { String log = F("DS: SP: "); - for (byte x = 0; x < 9; x++) + for (uint8_t x = 0; x < 9; x++) { if (x != 0) { log += ','; @@ -389,25 +389,25 @@ bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int return true; } -bool Dallas_readiButton(const byte addr[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) +bool Dallas_readiButton(const uint8_t addr[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) { // maybe this is needed to trigger the reading - // byte ScratchPad[12]; + // uint8_t ScratchPad[12]; Dallas_reset(gpio_pin_rx, gpio_pin_tx); Dallas_write(0x55, gpio_pin_rx, gpio_pin_tx); // Choose ROM - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { Dallas_write(addr[i], gpio_pin_rx, gpio_pin_tx); } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - // for (byte i = 0; i < 9; i++) // read 9 bytes + // for (uint8_t i = 0; i < 9; i++) // read 9 bytes // ScratchPad[i] = Dallas_read(); // end maybe this is needed to trigger the reading - byte tmpaddr[8]; + uint8_t tmpaddr[8]; bool found = false; Dallas_reset(gpio_pin_rx, gpio_pin_tx); @@ -496,19 +496,19 @@ bool Dallas_readCounter(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, /*********************************************************************************************\ * Dallas Get Resolution \*********************************************************************************************/ -byte Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) +uint8_t Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx) { // DS1820 and DS18S20 have no resolution configuration register if (ROM[0] == 0x10) { return 12; } - byte ScratchPad[12]; + uint8_t ScratchPad[12]; if (!Dallas_address_ROM(ROM, gpio_pin_rx, gpio_pin_tx)) { return 0; } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - for (byte i = 0; i < 9; i++) { // read 9 bytes + for (uint8_t i = 0; i < 9; i++) { // read 9 bytes ScratchPad[i] = Dallas_read(gpio_pin_rx, gpio_pin_tx); } @@ -539,19 +539,19 @@ byte Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_ /*********************************************************************************************\ * Dallas Get Resolution \*********************************************************************************************/ -bool Dallas_setResolution(const uint8_t ROM[8], byte res, int8_t gpio_pin_rx, int8_t gpio_pin_tx) +bool Dallas_setResolution(const uint8_t ROM[8], uint8_t res, int8_t gpio_pin_rx, int8_t gpio_pin_tx) { // DS1820 and DS18S20 have no resolution configuration register if (ROM[0] == 0x10) { return true; } - byte ScratchPad[12]; + uint8_t ScratchPad[12]; if (!Dallas_address_ROM(ROM, gpio_pin_rx, gpio_pin_tx)) { return false; } Dallas_write(0xBE, gpio_pin_rx, gpio_pin_tx); // Read scratchpad - for (byte i = 0; i < 9; i++) { // read 9 bytes + for (uint8_t i = 0; i < 9; i++) { // read 9 bytes ScratchPad[i] = Dallas_read(gpio_pin_rx, gpio_pin_tx); } @@ -561,7 +561,7 @@ bool Dallas_setResolution(const uint8_t ROM[8], byte res, int8_t gpio_pin_rx, in } else { - byte old_configuration = ScratchPad[4]; + uint8_t old_configuration = ScratchPad[4]; switch (res) { @@ -706,7 +706,7 @@ void Dallas_reset_search() LastDeviceFlag = FALSE; LastFamilyDiscrepancy = 0; - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { ROM_NO[i] = 0; } } @@ -985,7 +985,7 @@ bool Dallas_address_ROM(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pi if (!Dallas_reset(gpio_pin_rx, gpio_pin_tx)) { return false; } Dallas_write(0x55, gpio_pin_rx, gpio_pin_tx); // Choose ROM - for (byte i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { Dallas_write(ROM[i], gpio_pin_rx, gpio_pin_tx); } return true; diff --git a/src/src/Helpers/Dallas1WireHelper.h b/src/src/Helpers/Dallas1WireHelper.h index 209e6cd12..5e64305e8 100644 --- a/src/src/Helpers/Dallas1WireHelper.h +++ b/src/src/Helpers/Dallas1WireHelper.h @@ -86,7 +86,7 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i /*********************************************************************************************\ Dallas Scan bus \*********************************************************************************************/ -byte Dallas_scan(byte getDeviceROM, +uint8_t Dallas_scan(uint8_t getDeviceROM, uint8_t *ROM, int8_t gpio_pin_rx, int8_t gpio_pin_tx); @@ -108,7 +108,7 @@ bool Dallas_readTemp(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx); -bool Dallas_readiButton(const byte addr[8], +bool Dallas_readiButton(const uint8_t addr[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx); @@ -121,7 +121,7 @@ bool Dallas_readCounter(const uint8_t ROM[8], /*********************************************************************************************\ * Dallas Get Resolution \*********************************************************************************************/ -byte Dallas_getResolution(const uint8_t ROM[8], +uint8_t Dallas_getResolution(const uint8_t ROM[8], int8_t gpio_pin_rx, int8_t gpio_pin_tx); @@ -129,7 +129,7 @@ byte Dallas_getResolution(const uint8_t ROM[8], * Dallas Set Resolution \*********************************************************************************************/ bool Dallas_setResolution(const uint8_t ROM[8], - byte res, + uint8_t res, int8_t gpio_pin_rx, int8_t gpio_pin_tx); diff --git a/src/src/Helpers/ESPEasyRTC.cpp b/src/src/Helpers/ESPEasyRTC.cpp index b4841fd32..1e93990c6 100644 --- a/src/src/Helpers/ESPEasyRTC.cpp +++ b/src/src/Helpers/ESPEasyRTC.cpp @@ -36,7 +36,7 @@ So, if we want to access some data at the beginning of user data area, address: 256/4 = 64 data : data pointer - size : data length, byte + size : data length, uint8_t Prototype: bool system_rtc_mem_read ( @@ -114,7 +114,7 @@ bool saveToRTC() #else // if defined(ESP32) START_TIMER - if (!system_rtc_mem_write(RTC_BASE_STRUCT, (byte *)&RTC, sizeof(RTC)) || !readFromRTC()) + if (!system_rtc_mem_write(RTC_BASE_STRUCT, (uint8_t *)&RTC, sizeof(RTC)) || !readFromRTC()) { # ifdef RTC_STRUCT_DEBUG addLog(LOG_LEVEL_ERROR, F("RTC : Error while writing to RTC")); @@ -154,7 +154,7 @@ bool readFromRTC() RTC = RTC_tmp; #endif #ifdef ESP8266 - if (!system_rtc_mem_read(RTC_BASE_STRUCT, (byte *)&RTC, sizeof(RTC))) { + if (!system_rtc_mem_read(RTC_BASE_STRUCT, (uint8_t *)&RTC, sizeof(RTC))) { return false; } #endif @@ -172,17 +172,17 @@ bool saveUserVarToRTC() for (size_t i = 0; i < UserVar_nrelements; ++i) { UserVar_RTC[i] = UserVar[i]; } - UserVar_checksum = calc_CRC32((byte *)(&UserVar[0]), UserVar_nrelements * sizeof(float)); + UserVar_checksum = calc_CRC32((uint8_t *)(&UserVar[0]), UserVar_nrelements * sizeof(float)); return true; #endif #ifdef ESP8266 // addLog(LOG_LEVEL_DEBUG, F("RTCMEM: saveUserVarToRTC")); - byte *buffer = UserVar.get(); + uint8_t *buffer = UserVar.get(); size_t size = UserVar.getNrElements() * sizeof(float); uint32_t sum = calc_CRC32(buffer, size); bool ret = system_rtc_mem_write(RTC_BASE_USERVAR, buffer, size); - ret &= system_rtc_mem_write(RTC_BASE_USERVAR + (size >> 2), (byte *)&sum, 4); + ret &= system_rtc_mem_write(RTC_BASE_USERVAR + (size >> 2), (uint8_t *)&sum, 4); return ret; #endif } @@ -195,7 +195,7 @@ bool readUserVarFromRTC() // ESP8266 has the RTC struct stored in memory which we must actively fetch // ESP32 Uses a temp structure which is mapped to the RTC address range. #if defined(ESP32) - if (calc_CRC32((byte *)(&UserVar_RTC[0]), UserVar_nrelements * sizeof(float)) == UserVar_checksum) { + if (calc_CRC32((uint8_t *)(&UserVar_RTC[0]), UserVar_nrelements * sizeof(float)) == UserVar_checksum) { for (size_t i = 0; i < UserVar_nrelements; ++i) { UserVar[i] = UserVar_RTC[i]; } @@ -206,12 +206,12 @@ bool readUserVarFromRTC() #ifdef ESP8266 // addLog(LOG_LEVEL_DEBUG, F("RTCMEM: readUserVarFromRTC")); - byte *buffer = UserVar.get(); + uint8_t *buffer = UserVar.get(); size_t size = UserVar.getNrElements() * sizeof(float); bool ret = system_rtc_mem_read(RTC_BASE_USERVAR, buffer, size); uint32_t sumRAM = calc_CRC32(buffer, size); uint32_t sumRTC = 0; - ret &= system_rtc_mem_read(RTC_BASE_USERVAR + (size >> 2), (byte *)&sumRTC, 4); + ret &= system_rtc_mem_read(RTC_BASE_USERVAR + (size >> 2), (uint8_t *)&sumRTC, 4); if (!ret || (sumRTC != sumRAM)) { diff --git a/src/src/Helpers/ESPEasyStatistics.cpp b/src/src/Helpers/ESPEasyStatistics.cpp index 8a09a68b5..2fd85f161 100644 --- a/src/src/Helpers/ESPEasyStatistics.cpp +++ b/src/src/Helpers/ESPEasyStatistics.cpp @@ -8,7 +8,7 @@ #include "../Globals/Protocol.h" /* - void logStatistics(byte loglevel, bool clearStats) { + void logStatistics(uint8_t loglevel, bool clearStats) { if (loglevelActiveFor(loglevel)) { String log; log.reserve(80); diff --git a/src/src/Helpers/ESPEasyStatistics.h b/src/src/Helpers/ESPEasyStatistics.h index e806afb92..20a3bdd6c 100644 --- a/src/src/Helpers/ESPEasyStatistics.h +++ b/src/src/Helpers/ESPEasyStatistics.h @@ -9,7 +9,7 @@ #include "../DataStructs/TimingStats.h" -//void logStatistics(byte loglevel, bool clearStats); +//void logStatistics(uint8_t loglevel, bool clearStats); void stream_json_timing_stats(const TimingStats& stats, long timeSinceLastReset); diff --git a/src/src/Helpers/ESPEasy_Storage.cpp b/src/src/Helpers/ESPEasy_Storage.cpp index d967f4354..27e523e89 100644 --- a/src/src/Helpers/ESPEasy_Storage.cpp +++ b/src/src/Helpers/ESPEasy_Storage.cpp @@ -266,8 +266,8 @@ String BuildFixes() } if (Settings.Build < 20111) { #ifdef ESP32 - constexpr byte maxStatesesp32 = sizeof(Settings.PinBootStates_ESP32) / sizeof(Settings.PinBootStates_ESP32[0]); - for (byte i = 0; i < maxStatesesp32; ++i) { + constexpr uint8_t maxStatesesp32 = sizeof(Settings.PinBootStates_ESP32) / sizeof(Settings.PinBootStates_ESP32[0]); + for (uint8_t i = 0; i < maxStatesesp32; ++i) { Settings.PinBootStates_ESP32[i] = 0; } #endif @@ -395,7 +395,7 @@ String SaveSettings() memcpy(Settings.md5, tmp_md5, 16); */ Settings.validate(); - err = SaveToFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (byte *)&Settings, sizeof(Settings)); + err = SaveToFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (uint8_t *)&Settings, sizeof(Settings)); } if (err.length()) { @@ -427,7 +427,7 @@ String SaveSecuritySettings() { if (memcmp(tmp_md5, SecuritySettings.md5, 16) != 0) { // Settings have changed, save to file. memcpy(SecuritySettings.md5, tmp_md5, 16); - err = SaveToFile((char *)FILE_SECURITY, 0, (byte *)&SecuritySettings, sizeof(SecuritySettings)); + err = SaveToFile((char *)FILE_SECURITY, 0, (uint8_t *)&SecuritySettings, sizeof(SecuritySettings)); if (WifiIsAP(WiFi.getMode())) { // Security settings are saved, may be update of WiFi settings or hostname. @@ -471,7 +471,7 @@ String LoadSettings() uint8_t calculatedMd5[16]; MD5Builder md5; - err = LoadFromFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (byte *)&Settings, sizeof(SettingsStruct)); + err = LoadFromFile(SettingsType::getSettingsFileName(SettingsType::Enum::BasicSettings_Type).c_str(), 0, (uint8_t *)&Settings, sizeof(SettingsStruct)); if (err.length()) { return err; @@ -497,7 +497,7 @@ String LoadSettings() } */ - err = LoadFromFile((char *)FILE_SECURITY, 0, (byte *)&SecuritySettings, sizeof(SecurityStruct)); + err = LoadFromFile((char *)FILE_SECURITY, 0, (uint8_t *)&SecuritySettings, sizeof(SecurityStruct)); md5.begin(); md5.add((uint8_t *)&SecuritySettings, sizeof(SecuritySettings) - 16); md5.calculate(); @@ -526,7 +526,7 @@ String LoadSettings() /********************************************************************************************\ Disable Plugin, based on bootFailedCount \*********************************************************************************************/ -byte disablePlugin(byte bootFailedCount) { +uint8_t disablePlugin(uint8_t bootFailedCount) { for (taskIndex_t i = 0; i < TASKS_MAX && bootFailedCount > 0; ++i) { if (Settings.TaskDeviceEnabled[i]) { --bootFailedCount; @@ -542,7 +542,7 @@ byte disablePlugin(byte bootFailedCount) { /********************************************************************************************\ Disable Controller, based on bootFailedCount \*********************************************************************************************/ -byte disableController(byte bootFailedCount) { +uint8_t disableController(uint8_t bootFailedCount) { for (controllerIndex_t i = 0; i < CONTROLLER_MAX && bootFailedCount > 0; ++i) { if (Settings.ControllerEnabled[i]) { --bootFailedCount; @@ -558,8 +558,8 @@ byte disableController(byte bootFailedCount) { /********************************************************************************************\ Disable Notification, based on bootFailedCount \*********************************************************************************************/ -byte disableNotification(byte bootFailedCount) { - for (byte i = 0; i < NOTIFICATION_MAX && bootFailedCount > 0; ++i) { +uint8_t disableNotification(uint8_t bootFailedCount) { + for (uint8_t i = 0; i < NOTIFICATION_MAX && bootFailedCount > 0; ++i) { if (Settings.NotificationEnabled[i]) { --bootFailedCount; @@ -676,7 +676,7 @@ String SaveStringArray(SettingsType::Enum settingsType, int index, const String const uint16_t bufferSize = 128; // FIXME TD-er: For now stack allocated, may need to be heap allocated? - byte buffer[bufferSize]; + uint8_t buffer[bufferSize]; String result; int writePos = 0; @@ -764,7 +764,7 @@ String SaveTaskSettings(taskIndex_t TaskIndex) } String err = SaveToFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, - (byte *)&ExtraTaskSettings, + (uint8_t *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); if (err.isEmpty()) { @@ -791,7 +791,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex) START_TIMER ExtraTaskSettings.clear(); - const String result = LoadFromFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, (byte *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); + const String result = LoadFromFile(SettingsType::Enum::TaskSettings_Type, TaskIndex, (uint8_t *)&ExtraTaskSettings, sizeof(struct ExtraTaskSettingsStruct)); // After loading, some settings may need patching. ExtraTaskSettings.TaskIndex = TaskIndex; // Needed when an empty task was requested @@ -800,7 +800,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex) if (validDeviceIndex(DeviceIndex)) { if (!Device[DeviceIndex].configurableDecimals()) { // Nr of decimals cannot be configured, so set them to 0 just to be sure. - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { ExtraTaskSettings.TaskDeviceValueDecimals[i] = 0; } } @@ -823,7 +823,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex) /********************************************************************************************\ Save Custom Task settings to file system \*********************************************************************************************/ -String SaveCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize) +String SaveCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("SaveCustomTaskSettings")); @@ -845,7 +845,7 @@ String SaveCustomTaskSettings(taskIndex_t TaskIndex, String strings[], uint16_t strings, nrStrings, maxStringLength); } -String getCustomTaskSettingsError(byte varNr) { +String getCustomTaskSettingsError(uint8_t varNr) { String error = F("Error: Text too long for line "); error += varNr + 1; @@ -865,7 +865,7 @@ String ClearCustomTaskSettings(taskIndex_t TaskIndex) /********************************************************************************************\ Load Custom Task settings from file system \*********************************************************************************************/ -String LoadCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize) +String LoadCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize) { START_TIMER; #ifndef BUILD_NO_RAM_TRACKER @@ -903,7 +903,7 @@ String SaveControllerSettings(controllerIndex_t ControllerIndex, ControllerSetti #endif controller_settings.validate(); // Make sure the saved controller settings have proper values. return SaveToFile(SettingsType::Enum::ControllerSettings_Type, ControllerIndex, - (byte *)&controller_settings, sizeof(controller_settings)); + (uint8_t *)&controller_settings, sizeof(controller_settings)); } /********************************************************************************************\ @@ -915,7 +915,7 @@ String LoadControllerSettings(controllerIndex_t ControllerIndex, ControllerSetti #endif String result = LoadFromFile(SettingsType::Enum::ControllerSettings_Type, ControllerIndex, - (byte *)&controller_settings, sizeof(controller_settings)); + (uint8_t *)&controller_settings, sizeof(controller_settings)); controller_settings.validate(); // Make sure the loaded controller settings have proper values. return result; } @@ -936,7 +936,7 @@ String ClearCustomControllerSettings(controllerIndex_t ControllerIndex) /********************************************************************************************\ Save Custom Controller settings to file system \*********************************************************************************************/ -String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize) +String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("SaveCustomControllerSettings")); @@ -947,7 +947,7 @@ String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, byte *mem /********************************************************************************************\ Load Custom Controller settings to file system \*********************************************************************************************/ -String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize) +String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("LoadCustomControllerSettings")); @@ -958,7 +958,7 @@ String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, byte *mem /********************************************************************************************\ Save Controller settings to file system \*********************************************************************************************/ -String SaveNotificationSettings(int NotificationIndex, byte *memAddress, int datasize) +String SaveNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("SaveNotificationSettings")); @@ -969,7 +969,7 @@ String SaveNotificationSettings(int NotificationIndex, byte *memAddress, int dat /********************************************************************************************\ Load Controller settings to file system \*********************************************************************************************/ -String LoadNotificationSettings(int NotificationIndex, byte *memAddress, int datasize) +String LoadNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("LoadNotificationSettings")); @@ -1017,13 +1017,13 @@ String InitFile(SettingsType::SettingsFileEnum file_type) /********************************************************************************************\ Save data into config file on file system \*********************************************************************************************/ -String SaveToFile(const char *fname, int index, const byte *memAddress, int datasize) +String SaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize) { return doSaveToFile(fname, index, memAddress, datasize, "r+"); } // See for mode description: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst -String doSaveToFile(const char *fname, int index, const byte *memAddress, int datasize, const char *mode) +String doSaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize, const char *mode) { #ifndef BUILD_NO_DEBUG #ifndef ESP32 @@ -1071,7 +1071,7 @@ String doSaveToFile(const char *fname, int index, const byte *memAddress, int da clearAllCaches(); SPIFFS_CHECK(f, fname); SPIFFS_CHECK(f.seek(index, fs::SeekSet), fname); - const byte *pointerToByteToSave = memAddress; + const uint8_t *pointerToByteToSave = memAddress; for (int x = 0; x < datasize; x++) { @@ -1184,7 +1184,7 @@ String ClearInFile(const char *fname, int index, int datasize) /********************************************************************************************\ Load data from config file on file system \*********************************************************************************************/ -String LoadFromFile(const char *fname, int offset, byte *memAddress, int datasize) +String LoadFromFile(const char *fname, int offset, uint8_t *memAddress, int datasize) { if (offset < 0) { #ifndef BUILD_NO_DEBUG @@ -1252,7 +1252,7 @@ String getSettingsFileDatasizeError(bool read, SettingsType::Enum settingsType, return error; } -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int offset_in_block) { +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int offset_in_block) { bool read = true; int offset, max_size; @@ -1267,15 +1267,15 @@ String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress return LoadFromFile(fname.c_str(), (offset + offset_in_block), memAddress, datasize); } -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize) { +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize) { return LoadFromFile(settingsType, index, memAddress, datasize, 0); } -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize) { +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize) { return SaveToFile(settingsType, index, memAddress, datasize, 0); } -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int posInBlock) { +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int posInBlock) { bool read = false; int offset, max_size; @@ -1499,7 +1499,7 @@ bool getCacheFileCounters(uint16_t& lowest, uint16_t& highest, size_t& filesizeH Get partition table information \*********************************************************************************************/ #ifdef ESP32 -String getPartitionType(byte pType, byte pSubType) { +String getPartitionType(uint8_t pType, uint8_t pSubType) { esp_partition_type_t partitionType = static_cast(pType); esp_partition_subtype_t partitionSubType = static_cast(pSubType); @@ -1552,7 +1552,7 @@ String getPartitionTableHeader(const String& itemSep, const String& lineEnd) { return result; } -String getPartitionTable(byte pType, const String& itemSep, const String& lineEnd) { +String getPartitionTable(uint8_t pType, const String& itemSep, const String& lineEnd) { esp_partition_type_t partitionType = static_cast(pType); String result; esp_partition_iterator_t _mypartiterator = esp_partition_find(partitionType, ESP_PARTITION_SUBTYPE_ANY, NULL); diff --git a/src/src/Helpers/ESPEasy_Storage.h b/src/src/Helpers/ESPEasy_Storage.h index c9d32af4b..c592aa92b 100644 --- a/src/src/Helpers/ESPEasy_Storage.h +++ b/src/src/Helpers/ESPEasy_Storage.h @@ -67,17 +67,17 @@ String LoadSettings(); /********************************************************************************************\ Disable Plugin, based on bootFailedCount \*********************************************************************************************/ -byte disablePlugin(byte bootFailedCount); +uint8_t disablePlugin(uint8_t bootFailedCount); /********************************************************************************************\ Disable Controller, based on bootFailedCount \*********************************************************************************************/ -byte disableController(byte bootFailedCount); +uint8_t disableController(uint8_t bootFailedCount); /********************************************************************************************\ Disable Notification, based on bootFailedCount \*********************************************************************************************/ -byte disableNotification(byte bootFailedCount); +uint8_t disableNotification(uint8_t bootFailedCount); bool getAndLogSettingsParameters(bool read, SettingsType::Enum settingsType, int index, int& offset, int& max_size); @@ -108,7 +108,7 @@ String LoadTaskSettings(taskIndex_t TaskIndex); /********************************************************************************************\ Save Custom Task settings to file system \*********************************************************************************************/ -String SaveCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize); +String SaveCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Save array of Strings to Custom Task settings @@ -116,7 +116,7 @@ String SaveCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datas \*********************************************************************************************/ String SaveCustomTaskSettings(taskIndex_t TaskIndex, String strings[], uint16_t nrStrings, uint16_t maxStringLength); -String getCustomTaskSettingsError(byte varNr); +String getCustomTaskSettingsError(uint8_t varNr); /********************************************************************************************\ Clear custom task settings @@ -126,7 +126,7 @@ String ClearCustomTaskSettings(taskIndex_t TaskIndex); /********************************************************************************************\ Load Custom Task settings from file system \*********************************************************************************************/ -String LoadCustomTaskSettings(taskIndex_t TaskIndex, byte *memAddress, int datasize); +String LoadCustomTaskSettings(taskIndex_t TaskIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Load array of Strings from Custom Task settings @@ -152,23 +152,23 @@ String ClearCustomControllerSettings(controllerIndex_t ControllerIndex); /********************************************************************************************\ Save Custom Controller settings to file system \*********************************************************************************************/ -String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize); +String SaveCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Load Custom Controller settings to file system \*********************************************************************************************/ -String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, byte *memAddress, int datasize); +String LoadCustomControllerSettings(controllerIndex_t ControllerIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Save Controller settings to file system \*********************************************************************************************/ -String SaveNotificationSettings(int NotificationIndex, byte *memAddress, int datasize); +String SaveNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ Load Controller settings to file system \*********************************************************************************************/ -String LoadNotificationSettings(int NotificationIndex, byte *memAddress, int datasize); +String LoadNotificationSettings(int NotificationIndex, uint8_t *memAddress, int datasize); /********************************************************************************************\ @@ -182,10 +182,10 @@ String InitFile(SettingsType::SettingsFileEnum file_type); /********************************************************************************************\ Save data into config file on file system \*********************************************************************************************/ -String SaveToFile(const char *fname, int index, const byte *memAddress, int datasize); +String SaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize); // See for mode description: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.rst -String doSaveToFile(const char *fname, int index, const byte *memAddress, int datasize, const char *mode); +String doSaveToFile(const char *fname, int index, const uint8_t *memAddress, int datasize, const char *mode); /********************************************************************************************\ @@ -196,7 +196,7 @@ String ClearInFile(const char *fname, int index, int datasize); /********************************************************************************************\ Load data from config file on file system \*********************************************************************************************/ -String LoadFromFile(const char *fname, int offset, byte *memAddress, int datasize); +String LoadFromFile(const char *fname, int offset, uint8_t *memAddress, int datasize); /********************************************************************************************\ Wrapper functions to handle errors in accessing settings @@ -205,13 +205,13 @@ String getSettingsFileIndexRangeError(bool read, SettingsType::Enum settingsType String getSettingsFileDatasizeError(bool read, SettingsType::Enum settingsType, int index, int datasize, int max_size); -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int offset_in_block); +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int offset_in_block); -String LoadFromFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize); +String LoadFromFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize); -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize); +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize); -String SaveToFile(SettingsType::Enum settingsType, int index, byte *memAddress, int datasize, int posInBlock); +String SaveToFile(SettingsType::Enum settingsType, int index, uint8_t *memAddress, int datasize, int posInBlock); String ClearInFile(SettingsType::Enum settingsType, int index); @@ -249,11 +249,11 @@ bool getCacheFileCounters(uint16_t& lowest, uint16_t& highest, size_t& filesizeH \*********************************************************************************************/ #ifdef ESP32 -String getPartitionType(byte pType, byte pSubType); +String getPartitionType(uint8_t pType, uint8_t pSubType); String getPartitionTableHeader(const String& itemSep, const String& lineEnd); -String getPartitionTable(byte pType, const String& itemSep, const String& lineEnd); +String getPartitionTable(uint8_t pType, const String& itemSep, const String& lineEnd); #endif // ifdef ESP32 diff --git a/src/src/Helpers/ESPEasy_time.cpp b/src/src/Helpers/ESPEasy_time.cpp index 415b326b8..8aa227ce9 100644 --- a/src/src/Helpers/ESPEasy_time.cpp +++ b/src/src/Helpers/ESPEasy_time.cpp @@ -74,7 +74,7 @@ void ESPEasy_time::breakTime(unsigned long timeInput, struct tm& tm) { } -void ESPEasy_time::restoreLastKnownUnixTime(unsigned long lastSysTime, byte deepSleepState) +void ESPEasy_time::restoreLastKnownUnixTime(unsigned long lastSysTime, uint8_t deepSleepState) { static bool firstCall = true; if (firstCall && lastSysTime != 0 && deepSleepState != 1) { @@ -252,7 +252,7 @@ bool ESPEasy_time::getNtpTime(double& unixTime_d) } const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message - byte packetBuffer[NTP_PACKET_SIZE]; // buffer to hold incoming & outgoing packets + uint8_t packetBuffer[NTP_PACKET_SIZE]; // buffer to hold incoming & outgoing packets log += F(" queried"); #ifndef BUILD_NO_DEBUG diff --git a/src/src/Helpers/ESPEasy_time.h b/src/src/Helpers/ESPEasy_time.h index 5b2d4972f..6d4c452ee 100644 --- a/src/src/Helpers/ESPEasy_time.h +++ b/src/src/Helpers/ESPEasy_time.h @@ -21,7 +21,7 @@ static void breakTime(unsigned long timeInput, struct tm& tm); // This way the unit can do things based on local time even when NTP servers may not respond. // Do not use this when booting from deep sleep. // Only call this once during boot. -void restoreLastKnownUnixTime(unsigned long lastSysTime, byte deepSleepState); +void restoreLastKnownUnixTime(unsigned long lastSysTime, uint8_t deepSleepState); void setExternalTimeSource(double time, timeSource_t source); @@ -98,31 +98,31 @@ int year() const } // Get current month -byte month() const +uint8_t month() const { return tm.tm_mon + 1; // tm_mon starts at 0 } // Get current day of the month -byte day() const +uint8_t day() const { return tm.tm_mday; } // Get current hour -byte hour() const +uint8_t hour() const { return tm.tm_hour; } // Get current minute -byte minute() const +uint8_t minute() const { return tm.tm_min; } // Get current second -byte second() const +uint8_t second() const { return tm.tm_sec; } @@ -184,7 +184,7 @@ struct tm sunRise; struct tm sunSet; timeSource_t timeSource = No_time_source; -byte PrevMinutes = 0; +uint8_t PrevMinutes = 0; diff --git a/src/src/Helpers/ESPEasy_time_calc.cpp b/src/src/Helpers/ESPEasy_time_calc.cpp index 3e6fe2e49..e5d0833c5 100644 --- a/src/src/Helpers/ESPEasy_time_calc.cpp +++ b/src/src/Helpers/ESPEasy_time_calc.cpp @@ -209,7 +209,7 @@ bool matchClockEvent(unsigned long clockEvent, unsigned long clockSet) { unsigned long Mask; - for (byte y = 0; y < 8; y++) + for (uint8_t y = 0; y < 8; y++) { if (((clockSet >> (y * 4)) & 0xf) == 0xf) // if nibble y has the wildcard value 0xf { diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index 240f9b045..44ca52af7 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -198,14 +198,14 @@ void initI2C() { delay(500); Wire.beginTransmission(Settings.WDI2CAddress); Wire.write(0x83); // command to set pointer - Wire.write(17); // pointer value to status byte + Wire.write(17); // pointer value to status uint8_t Wire.endTransmission(); Wire.requestFrom(Settings.WDI2CAddress, (uint8_t)1); if (Wire.available()) { - byte status = Wire.read(); + uint8_t status = Wire.read(); if (status & 0x1) { @@ -245,8 +245,8 @@ void I2CMultiplexerReset() { } // Shift the bit in the right position when selecting a single channel -byte I2CMultiplexerShiftBit(uint8_t i) { - byte toWrite = 0; +uint8_t I2CMultiplexerShiftBit(uint8_t i) { + uint8_t toWrite = 0; switch (Settings.I2C_Multiplexer_Type) { case I2C_MULTIPLEXER_TCA9543A: // TCA9543/6/8 addressing @@ -272,7 +272,7 @@ void I2CMultiplexerSelectByTaskIndex(taskIndex_t taskIndex) { if (!validTaskIndex(taskIndex)) { return; } if (!I2CMultiplexerPortSelectedForTask(taskIndex)) { return; } - byte toWrite = 0; + uint8_t toWrite = 0; if (!bitRead(Settings.I2C_Flags[taskIndex], I2C_FLAGS_MUX_MULTICHANNEL)) { uint8_t i = Settings.I2C_Multiplexer_Channel[taskIndex]; @@ -289,7 +289,7 @@ void I2CMultiplexerSelectByTaskIndex(taskIndex_t taskIndex) { void I2CMultiplexerSelect(uint8_t i) { if (i > 7) { return; } - byte toWrite = I2CMultiplexerShiftBit(i); + uint8_t toWrite = I2CMultiplexerShiftBit(i); SetI2CMultiplexer(toWrite); } @@ -297,7 +297,7 @@ void I2CMultiplexerOff() { SetI2CMultiplexer(0); // no channel selected } -void SetI2CMultiplexer(byte toWrite) { +void SetI2CMultiplexer(uint8_t toWrite) { if (isI2CMultiplexerEnabled()) { // FIXME TD-er: Must check to see if we can cache the value so only change it when needed. Wire.beginTransmission(Settings.I2C_Multiplexer_Addr); @@ -307,7 +307,7 @@ void SetI2CMultiplexer(byte toWrite) { } } -byte I2CMultiplexerMaxChannels() { +uint8_t I2CMultiplexerMaxChannels() { uint channels = 0; switch (Settings.I2C_Multiplexer_Type) { @@ -331,7 +331,7 @@ bool I2CMultiplexerPortSelectedForTask(taskIndex_t taskIndex) { #endif // ifdef FEATURE_I2CMULTIPLEXER void checkResetFactoryPin() { - static byte factoryResetCounter = 0; + static uint8_t factoryResetCounter = 0; if (Settings.Pin_Reset == -1) { return; @@ -780,7 +780,7 @@ void addPredefinedPlugins(const GpioFactorySettingsStruct& gpio_settings) { } } -void addButtonRelayRule(byte buttonNumber, int relay_gpio) { +void addButtonRelayRule(uint8_t buttonNumber, int relay_gpio) { Settings.UseRules = true; String fileName; @@ -1060,7 +1060,7 @@ int touchPinToGpio(int touch_pin) void initAnalogWrite() { #if defined(ESP32) - for(byte x = 0; x < 16; x++) { + for(uint8_t x = 0; x < 16; x++) { ledcSetup(x, 0, 10); // Clear the channel ledChannelPin[x] = -1; ledChannelFreq[x] = 0; @@ -1082,7 +1082,7 @@ int8_t attachLedChannel(int pin, uint32_t frequency) // find existing channel if this pin has been used before int8_t ledChannel = -1; bool mustSetup = false; - for (byte x = 0; x < 16; x++) { + for (uint8_t x = 0; x < 16; x++) { if (ledChannelPin[x] == pin) { ledChannel = x; } @@ -1090,7 +1090,7 @@ int8_t attachLedChannel(int pin, uint32_t frequency) if (ledChannel == -1) // no channel set for this pin { - for (byte x = 0; x < 16; x++) { // find free channel + for (uint8_t x = 0; x < 16; x++) { // find free channel if (ledChannelPin[x] == -1) { if (!ledcRead(x)) { @@ -1130,7 +1130,7 @@ void detachLedChannel(int pin) { int8_t ledChannel = -1; - for (byte x = 0; x < 16; x++) { + for (uint8_t x = 0; x < 16; x++) { if (ledChannelPin[x] == pin) { ledChannel = x; } @@ -1177,7 +1177,7 @@ bool set_Gpio_PWM(int gpio, uint32_t dutyCycle, uint32_t frequency) { bool set_Gpio_PWM(int gpio, uint32_t dutyCycle, uint32_t fadeDuration_ms, uint32_t& frequency, uint32_t& key) { // For now, we only support the internal GPIO pins. - byte pluginID = PLUGIN_GPIO; + uint8_t pluginID = PLUGIN_GPIO; if (!checkValidPortRange(pluginID, gpio)) { return false; } @@ -1203,7 +1203,7 @@ bool set_Gpio_PWM(int gpio, uint32_t dutyCycle, uint32_t fadeDuration_ms, uint32 if (fadeDuration_ms != 0) { const int32_t resolution_factor = (1 << 12); - const byte prev_mode = tempStatus.mode; + const uint8_t prev_mode = tempStatus.mode; int32_t prev_value = tempStatus.getDutyCycle(); // getPinState(pluginID, gpio, &prev_mode, &prev_value); diff --git a/src/src/Helpers/Hardware.h b/src/src/Helpers/Hardware.h index d5a688ff6..340aa5561 100644 --- a/src/src/Helpers/Hardware.h +++ b/src/src/Helpers/Hardware.h @@ -34,9 +34,9 @@ void I2CMultiplexerSelect(uint8_t i); void I2CMultiplexerOff(); -void SetI2CMultiplexer(byte toWrite); +void SetI2CMultiplexer(uint8_t toWrite); -byte I2CMultiplexerMaxChannels(); +uint8_t I2CMultiplexerMaxChannels(); void I2CMultiplexerReset(); @@ -101,7 +101,7 @@ void addSwitchPlugin(taskIndex_t taskIndex, int gpio, const String& name, bool a void addPredefinedPlugins(const GpioFactorySettingsStruct& gpio_settings); -void addButtonRelayRule(byte buttonNumber, int relay_gpio); +void addButtonRelayRule(uint8_t buttonNumber, int relay_gpio); void addPredefinedRules(const GpioFactorySettingsStruct& gpio_settings); diff --git a/src/src/Helpers/I2C_access.cpp b/src/src/Helpers/I2C_access.cpp index 890679a40..a6f2d128d 100644 --- a/src/src/Helpers/I2C_access.cpp +++ b/src/src/Helpers/I2C_access.cpp @@ -37,7 +37,7 @@ void I2C_wakeup(uint8_t i2caddr) { // **************************************************************************/ // Writes an 8 bit value over I2C // **************************************************************************/ -bool I2C_write8(uint8_t i2caddr, byte value) { +bool I2C_write8(uint8_t i2caddr, uint8_t value) { Wire.beginTransmission(i2caddr); Wire.write((uint8_t)value); return Wire.endTransmission() == 0; @@ -46,7 +46,7 @@ bool I2C_write8(uint8_t i2caddr, byte value) { // **************************************************************************/ // Writes an 8 bit value over I2C to a register // **************************************************************************/ -bool I2C_write8_reg(uint8_t i2caddr, byte reg, byte value) { +bool I2C_write8_reg(uint8_t i2caddr, uint8_t reg, uint8_t value) { Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.write((uint8_t)value); @@ -56,7 +56,7 @@ bool I2C_write8_reg(uint8_t i2caddr, byte reg, byte value) { // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ -bool I2C_write16_reg(uint8_t i2caddr, byte reg, uint16_t value) { +bool I2C_write16_reg(uint8_t i2caddr, uint8_t reg, uint16_t value) { Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.write((uint8_t)(value >> 8)); @@ -67,7 +67,7 @@ bool I2C_write16_reg(uint8_t i2caddr, byte reg, uint16_t value) { // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ -bool I2C_write16_LE_reg(uint8_t i2caddr, byte reg, uint16_t value) { +bool I2C_write16_LE_reg(uint8_t i2caddr, uint8_t reg, uint16_t value) { return I2C_write16_reg(i2caddr, reg, (value << 8) | (value >> 8)); } @@ -77,7 +77,7 @@ bool I2C_write16_LE_reg(uint8_t i2caddr, byte reg, uint16_t value) { uint8_t I2C_read8(uint8_t i2caddr, bool *is_ok) { uint8_t value; - byte count = Wire.requestFrom(i2caddr, (byte)1); + uint8_t count = Wire.requestFrom(i2caddr, (uint8_t)1); if (is_ok != NULL) { *is_ok = (count == 1); @@ -92,7 +92,7 @@ uint8_t I2C_read8(uint8_t i2caddr, bool *is_ok) { // **************************************************************************/ // Reads an 8 bit value from a register over I2C // **************************************************************************/ -uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool *is_ok) { +uint8_t I2C_read8_reg(uint8_t i2caddr, uint8_t reg, bool *is_ok) { uint8_t value; Wire.beginTransmission(i2caddr); @@ -111,7 +111,7 @@ uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool *is_ok) { *is_ok = false; } } - byte count = Wire.requestFrom(i2caddr, (byte)1); + uint8_t count = Wire.requestFrom(i2caddr, (uint8_t)1); if (is_ok != NULL) { *is_ok = (count == 1); @@ -124,13 +124,13 @@ uint8_t I2C_read8_reg(uint8_t i2caddr, byte reg, bool *is_ok) { // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ -uint16_t I2C_read16_reg(uint8_t i2caddr, byte reg) { +uint16_t I2C_read16_reg(uint8_t i2caddr, uint8_t reg) { uint16_t value(0); Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.endTransmission(END_TRANSMISSION_FLAG); - Wire.requestFrom(i2caddr, (byte)2); + Wire.requestFrom(i2caddr, (uint8_t)2); value = (Wire.read() << 8) | Wire.read(); return value; @@ -139,13 +139,13 @@ uint16_t I2C_read16_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a 24 bit value starting at a given register over I2C // **************************************************************************/ -int32_t I2C_read24_reg(uint8_t i2caddr, byte reg) { +int32_t I2C_read24_reg(uint8_t i2caddr, uint8_t reg) { int32_t value; Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.endTransmission(END_TRANSMISSION_FLAG); - Wire.requestFrom(i2caddr, (byte)3); + Wire.requestFrom(i2caddr, (uint8_t)3); value = (((int32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read(); return value; @@ -154,13 +154,13 @@ int32_t I2C_read24_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a 32 bit value starting at a given register over I2C // **************************************************************************/ -int32_t I2C_read32_reg(uint8_t i2caddr, byte reg) { +int32_t I2C_read32_reg(uint8_t i2caddr, uint8_t reg) { int32_t value; Wire.beginTransmission(i2caddr); Wire.write((uint8_t)reg); Wire.endTransmission(END_TRANSMISSION_FLAG); - Wire.requestFrom(i2caddr, (byte)4); + Wire.requestFrom(i2caddr, (uint8_t)4); value = (((int32_t)Wire.read()) << 24) | (((uint32_t)Wire.read()) << 16) | (Wire.read() << 8) | Wire.read(); return value; @@ -169,7 +169,7 @@ int32_t I2C_read32_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ -uint16_t I2C_read16_LE_reg(uint8_t i2caddr, byte reg) { +uint16_t I2C_read16_LE_reg(uint8_t i2caddr, uint8_t reg) { uint16_t temp = I2C_read16_reg(i2caddr, reg); return (temp >> 8) | (temp << 8); @@ -178,11 +178,11 @@ uint16_t I2C_read16_LE_reg(uint8_t i2caddr, byte reg) { // **************************************************************************/ // Reads a signed 16 bit value starting at a given register over I2C // **************************************************************************/ -int16_t I2C_readS16_reg(uint8_t i2caddr, byte reg) { +int16_t I2C_readS16_reg(uint8_t i2caddr, uint8_t reg) { return (int16_t)I2C_read16_reg(i2caddr, reg); } -int16_t I2C_readS16_LE_reg(uint8_t i2caddr, byte reg) { +int16_t I2C_readS16_LE_reg(uint8_t i2caddr, uint8_t reg) { return (int16_t)I2C_read16_LE_reg(i2caddr, reg); } diff --git a/src/src/Helpers/I2C_access.h b/src/src/Helpers/I2C_access.h index 85478043b..e1cf3b030 100644 --- a/src/src/Helpers/I2C_access.h +++ b/src/src/Helpers/I2C_access.h @@ -21,27 +21,27 @@ void I2C_wakeup(uint8_t i2caddr); // Writes an 8 bit value over I2C // **************************************************************************/ bool I2C_write8(uint8_t i2caddr, - byte value); + uint8_t value); // **************************************************************************/ // Writes an 8 bit value over I2C to a register // **************************************************************************/ bool I2C_write8_reg(uint8_t i2caddr, - byte reg, - byte value); + uint8_t reg, + uint8_t value); // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ bool I2C_write16_reg(uint8_t i2caddr, - byte reg, + uint8_t reg, uint16_t value); // **************************************************************************/ // Writes an 16 bit value over I2C to a register // **************************************************************************/ bool I2C_write16_LE_reg(uint8_t i2caddr, - byte reg, + uint8_t reg, uint16_t value); // **************************************************************************/ @@ -54,41 +54,41 @@ uint8_t I2C_read8(uint8_t i2caddr, // Reads an 8 bit value from a register over I2C // **************************************************************************/ uint8_t I2C_read8_reg(uint8_t i2caddr, - byte reg, + uint8_t reg, bool *is_ok = nullptr); // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ uint16_t I2C_read16_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a 24 bit value starting at a given register over I2C // **************************************************************************/ int32_t I2C_read24_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a 32 bit value starting at a given register over I2C // **************************************************************************/ int32_t I2C_read32_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a 16 bit value starting at a given register over I2C // **************************************************************************/ uint16_t I2C_read16_LE_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); // **************************************************************************/ // Reads a signed 16 bit value starting at a given register over I2C // **************************************************************************/ int16_t I2C_readS16_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); int16_t I2C_readS16_LE_reg(uint8_t i2caddr, - byte reg); + uint8_t reg); #endif // HELPERS_I2C_ACCESS_H diff --git a/src/src/Helpers/Misc.cpp b/src/src/Helpers/Misc.cpp index 1b3e04410..11bc348f1 100644 --- a/src/src/Helpers/Misc.cpp +++ b/src/src/Helpers/Misc.cpp @@ -292,9 +292,9 @@ void SendValueLogger(taskIndex_t TaskIndex) if (validDeviceIndex(DeviceIndex)) { LoadTaskSettings(TaskIndex); - const byte valueCount = getValueCountForTask(TaskIndex); + const uint8_t valueCount = getValueCountForTask(TaskIndex); - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { logger += node_time.getDateString('-'); logger += ' '; @@ -409,22 +409,22 @@ void HSV2RGBW(float H, float S, float I, int rgbw[4]) { // Simple bitwise get/set functions -uint8_t get8BitFromUL(uint32_t number, byte bitnr) { +uint8_t get8BitFromUL(uint32_t number, uint8_t bitnr) { return (number >> bitnr) & 0xFF; } -void set8BitToUL(uint32_t& number, byte bitnr, uint8_t value) { +void set8BitToUL(uint32_t& number, uint8_t bitnr, uint8_t value) { uint32_t mask = (0xFFUL << bitnr); uint32_t newvalue = ((value << bitnr) & mask); number = (number & ~mask) | newvalue; } -uint8_t get4BitFromUL(uint32_t number, byte bitnr) { +uint8_t get4BitFromUL(uint32_t number, uint8_t bitnr) { return (number >> bitnr) & 0x0F; } -void set4BitToUL(uint32_t& number, byte bitnr, uint8_t value) { +void set4BitToUL(uint32_t& number, uint8_t bitnr, uint8_t value) { uint32_t mask = (0x0FUL << bitnr); uint32_t newvalue = ((value << bitnr) & mask); diff --git a/src/src/Helpers/Misc.h b/src/src/Helpers/Misc.h index 6bbe96134..4dd8e7aab 100644 --- a/src/src/Helpers/Misc.h +++ b/src/src/Helpers/Misc.h @@ -157,17 +157,17 @@ void HSV2RGBW(float H, // Simple bitwise get/set functions uint8_t get8BitFromUL(uint32_t number, - byte bitnr); + uint8_t bitnr); void set8BitToUL(uint32_t& number, - byte bitnr, + uint8_t bitnr, uint8_t value); uint8_t get4BitFromUL(uint32_t number, - byte bitnr); + uint8_t bitnr); void set4BitToUL(uint32_t& number, - byte bitnr, + uint8_t bitnr, uint8_t value); diff --git a/src/src/Helpers/Modbus_RTU.cpp b/src/src/Helpers/Modbus_RTU.cpp index dbbdc72b0..a4bee6173 100644 --- a/src/src/Helpers/Modbus_RTU.cpp +++ b/src/src/Helpers/Modbus_RTU.cpp @@ -36,11 +36,11 @@ void ModbusRTU_struct::reset() { _reads_nodata = 0; } -bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, byte address) { +bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, uint8_t address) { return init(port, serial_rx, serial_tx, baudrate, address, -1); } -bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, byte address, int8_t dere_pin) { +bool ModbusRTU_struct::init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, uint8_t address, int8_t dere_pin) { if ((serial_rx < 0) || (serial_tx < 0)) { return false; } @@ -86,15 +86,15 @@ uint16_t ModbusRTU_struct::getModbusTimeout() const { return _modbus_timeout; } -String ModbusRTU_struct::getDevice_description(byte slaveAddress) { +String ModbusRTU_struct::getDevice_description(uint8_t slaveAddress) { bool more_follows = true; - byte next_object_id = 0; - byte conformity_level = 0; + uint8_t next_object_id = 0; + uint8_t conformity_level = 0; unsigned int object_value_int; String description; String obj_text; - for (byte object_id = 0; object_id < 0x84; ++object_id) { + for (uint8_t object_id = 0; object_id < 0x84; ++object_id) { if (object_id == 6) { object_id = 0x82; // Skip to the serialnr/sensor type } @@ -155,18 +155,18 @@ String ModbusRTU_struct::getDevice_description(byte slaveAddress) { } // Read from RAM or EEPROM -void ModbusRTU_struct::buildRead_RAM_EEPROM(byte slaveAddress, byte functionCode, - short startAddress, byte number_bytes) { +void ModbusRTU_struct::buildRead_RAM_EEPROM(uint8_t slaveAddress, uint8_t functionCode, + short startAddress, uint8_t number_bytes) { _sendframe[0] = slaveAddress; _sendframe[1] = functionCode; - _sendframe[2] = (byte)(startAddress >> 8); - _sendframe[3] = (byte)(startAddress & 0xFF); + _sendframe[2] = (uint8_t)(startAddress >> 8); + _sendframe[3] = (uint8_t)(startAddress & 0xFF); _sendframe[4] = number_bytes; _sendframe_used = 5; } // Write to the Special Control Register (SCR) -void ModbusRTU_struct::buildWriteCommandRegister(byte slaveAddress, byte value) { +void ModbusRTU_struct::buildWriteCommandRegister(uint8_t slaveAddress, uint8_t value) { _sendframe[0] = slaveAddress; _sendframe[1] = MODBUS_CMD_WRITE_RAM; _sendframe[2] = 0; // Address-Hi SCR (0x0060) @@ -176,32 +176,32 @@ void ModbusRTU_struct::buildWriteCommandRegister(byte slaveAddress, byte value) _sendframe_used = 6; } -void ModbusRTU_struct::buildWriteMult16bRegister(byte slaveAddress, uint16_t startAddress, uint16_t value) { +void ModbusRTU_struct::buildWriteMult16bRegister(uint8_t slaveAddress, uint16_t startAddress, uint16_t value) { _sendframe[0] = slaveAddress; _sendframe[1] = MODBUS_WRITE_MULTIPLE_REGISTERS; - _sendframe[2] = (byte)(startAddress >> 8); - _sendframe[3] = (byte)(startAddress & 0xFF); + _sendframe[2] = (uint8_t)(startAddress >> 8); + _sendframe[3] = (uint8_t)(startAddress & 0xFF); _sendframe[4] = 0; // nr reg hi _sendframe[5] = 1; // nr reg lo _sendframe[6] = 2; // nr bytes to follow (2 bytes per register) - _sendframe[7] = (byte)(value >> 8); - _sendframe[8] = (byte)(value & 0xFF); + _sendframe[7] = (uint8_t)(value >> 8); + _sendframe[8] = (uint8_t)(value & 0xFF); _sendframe_used = 9; } -void ModbusRTU_struct::buildFrame(byte slaveAddress, byte functionCode, +void ModbusRTU_struct::buildFrame(uint8_t slaveAddress, uint8_t functionCode, short startAddress, short parameter) { _sendframe[0] = slaveAddress; _sendframe[1] = functionCode; - _sendframe[2] = (byte)(startAddress >> 8); - _sendframe[3] = (byte)(startAddress & 0xFF); - _sendframe[4] = (byte)(parameter >> 8); - _sendframe[5] = (byte)(parameter & 0xFF); + _sendframe[2] = (uint8_t)(startAddress >> 8); + _sendframe[3] = (uint8_t)(startAddress & 0xFF); + _sendframe[4] = (uint8_t)(parameter >> 8); + _sendframe[5] = (uint8_t)(parameter & 0xFF); _sendframe_used = 6; } -void ModbusRTU_struct::build_modbus_MEI_frame(byte slaveAddress, byte device_id, - byte object_id) { +void ModbusRTU_struct::build_modbus_MEI_frame(uint8_t slaveAddress, uint8_t device_id, + uint8_t object_id) { _sendframe[0] = slaveAddress; _sendframe[1] = 0x2B; _sendframe[2] = 0x0E; @@ -216,7 +216,7 @@ void ModbusRTU_struct::build_modbus_MEI_frame(byte slaveAddress, byte device_id, _sendframe_used = 5; } -String ModbusRTU_struct::MEI_objectid_to_name(byte object_id) { +String ModbusRTU_struct::MEI_objectid_to_name(uint8_t object_id) { String result; switch (object_id) { @@ -239,9 +239,9 @@ String ModbusRTU_struct::MEI_objectid_to_name(byte object_id) { } String ModbusRTU_struct::parse_modbus_MEI_response(unsigned int& object_value_int, - byte & next_object_id, + uint8_t & next_object_id, bool & more_follows, - byte & conformity_level) { + uint8_t & conformity_level) { String result; if (_recv_buf_used < 8) { @@ -258,13 +258,13 @@ String ModbusRTU_struct::parse_modbus_MEI_response(unsigned int& object_value_in conformity_level = _recv_buf[pos++]; more_follows = _recv_buf[pos++] != 0; next_object_id = _recv_buf[pos++]; - const byte number_objects = _recv_buf[pos++]; - byte object_id = 0; + const uint8_t number_objects = _recv_buf[pos++]; + uint8_t object_id = 0; for (int i = 0; i < number_objects; ++i) { if ((pos + 3) < _recv_buf_used) { object_id = _recv_buf[pos++]; - const byte object_length = _recv_buf[pos++]; + const uint8_t object_length = _recv_buf[pos++]; if ((pos + object_length) < _recv_buf_used) { String object_value; @@ -299,7 +299,7 @@ String ModbusRTU_struct::parse_modbus_MEI_response(unsigned int& object_value_in return result; } -void ModbusRTU_struct::logModbusException(byte value) { +void ModbusRTU_struct::logModbusException(uint8_t value) { if (value == 0) { return; } @@ -397,7 +397,7 @@ void ModbusRTU_struct::logModbusException(byte value) { } /* - String log_buffer(byte *buffer, int length) { + String log_buffer(uint8_t *buffer, int length) { String log; log.reserve(3 * length + 5); for (int i = 0; i < length; ++i) { @@ -412,26 +412,26 @@ void ModbusRTU_struct::logModbusException(byte value) { return log; } */ -byte ModbusRTU_struct::processCommand() { +uint8_t ModbusRTU_struct::processCommand() { // CRC-calculation unsigned int crc = ModRTU_CRC(_sendframe, _sendframe_used); // Note, this number has low and high bytes swapped, so use it accordingly (or // swap bytes) - byte checksumHi = (byte)((crc >> 8) & 0xFF); - byte checksumLo = (byte)(crc & 0xFF); + uint8_t checksumHi = (uint8_t)((crc >> 8) & 0xFF); + uint8_t checksumLo = (uint8_t)(crc & 0xFF); _sendframe[_sendframe_used++] = checksumLo; _sendframe[_sendframe_used++] = checksumHi; int nrRetriesLeft = 2; - byte return_value = 0; + uint8_t return_value = 0; while (nrRetriesLeft > 0) { return_value = 0; - // Send the byte array + // Send the uint8_t array startWrite(); easySerial->write(_sendframe, _sendframe_used); @@ -484,7 +484,7 @@ byte ModbusRTU_struct::processCommand() { ++_reads_crc_failed; return_value = MODBUS_BADCRC; } else { - const byte received_functionCode = _recv_buf[1]; + const uint8_t received_functionCode = _recv_buf[1]; if ((received_functionCode & 0x80) != 0) { return_value = _recv_buf[2]; @@ -513,7 +513,7 @@ byte ModbusRTU_struct::processCommand() { uint32_t ModbusRTU_struct::read_32b_InputRegister(short address) { uint32_t result = 0; - byte errorcode; + uint8_t errorcode; int idHigh = readInputRegister(address, errorcode); if (errorcode != 0) { return result; } @@ -548,12 +548,12 @@ float ModbusRTU_struct::read_float_HoldingRegister(short address) { // return fval; } -int ModbusRTU_struct::readInputRegister(short address, byte& errorcode) { +int ModbusRTU_struct::readInputRegister(short address, uint8_t& errorcode) { // Only read 1 register return process_16b_register(_modbus_address, MODBUS_READ_INPUT_REGISTERS, address, 1, errorcode); } -int ModbusRTU_struct::readHoldingRegister(short address, byte& errorcode) { +int ModbusRTU_struct::readHoldingRegister(short address, uint8_t& errorcode) { // Only read 1 register return process_16b_register( _modbus_address, MODBUS_READ_HOLDING_REGISTERS, address, 1, errorcode); @@ -562,12 +562,12 @@ int ModbusRTU_struct::readHoldingRegister(short address, byte& errorcode) { // Write to holding register. int ModbusRTU_struct::writeSingleRegister(short address, short value) { // No check for the specific error code. - byte errorcode = 0; + uint8_t errorcode = 0; return writeSingleRegister(address, value, errorcode); } -int ModbusRTU_struct::writeSingleRegister(short address, short value, byte& errorcode) { +int ModbusRTU_struct::writeSingleRegister(short address, short value, uint8_t& errorcode) { // GN: Untested, will probably not work return process_16b_register( _modbus_address, MODBUS_WRITE_SINGLE_REGISTER, address, value, errorcode); @@ -579,13 +579,13 @@ int ModbusRTU_struct::writeMultipleRegisters(short address, short value) { _modbus_address, address, value); } -byte ModbusRTU_struct::modbus_get_MEI(byte slaveAddress, byte object_id, +uint8_t ModbusRTU_struct::modbus_get_MEI(uint8_t slaveAddress, uint8_t object_id, String& result, unsigned int& object_value_int, - byte& next_object_id, bool& more_follows, - byte& conformity_level) { + uint8_t& next_object_id, bool& more_follows, + uint8_t& conformity_level) { // Force device_id to 4 = individual access (reading one ID object per call) build_modbus_MEI_frame(slaveAddress, 4, object_id); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { result = parse_modbus_MEI_response(object_value_int, @@ -597,19 +597,19 @@ byte ModbusRTU_struct::modbus_get_MEI(byte slaveAddress, byte object_id, return process_result; } -void ModbusRTU_struct::modbus_log_MEI(byte slaveAddress) { +void ModbusRTU_struct::modbus_log_MEI(uint8_t slaveAddress) { // Iterate over all Device identification items, using // Modbus command (0x2B / 0x0E) Read Device Identification // And add to log. bool more_follows = true; - byte conformity_level = 0; - byte object_id = 0; - byte next_object_id = 0; + uint8_t conformity_level = 0; + uint8_t object_id = 0; + uint8_t next_object_id = 0; while (more_follows) { String result; unsigned int object_value_int; - const byte process_result = modbus_get_MEI( + const uint8_t process_result = modbus_get_MEI( slaveAddress, object_id, result, object_value_int, next_object_id, more_follows, conformity_level); @@ -650,9 +650,9 @@ void ModbusRTU_struct::modbus_log_MEI(byte slaveAddress) { } } -int ModbusRTU_struct::process_16b_register(byte slaveAddress, byte functionCode, +int ModbusRTU_struct::process_16b_register(uint8_t slaveAddress, uint8_t functionCode, short startAddress, short parameter, - byte& errorcode) { + uint8_t& errorcode) { buildFrame(slaveAddress, functionCode, startAddress, parameter); errorcode = processCommand(); @@ -664,9 +664,9 @@ int ModbusRTU_struct::process_16b_register(byte slaveAddress, byte functionCode, } // Still writing single register, but calling it using "Preset Multiple Registers" function (FC=16) -int ModbusRTU_struct::preset_mult16b_register(byte slaveAddress, uint16_t startAddress, uint16_t value) { +int ModbusRTU_struct::preset_mult16b_register(uint8_t slaveAddress, uint16_t startAddress, uint16_t value) { buildWriteMult16bRegister(slaveAddress, startAddress, value); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { return (_recv_buf[4] << 8) | (_recv_buf[5]); @@ -675,15 +675,15 @@ int ModbusRTU_struct::preset_mult16b_register(byte slaveAddress, uint16_t startA return -1 * process_result; } -bool ModbusRTU_struct::process_32b_register(byte slaveAddress, byte functionCode, +bool ModbusRTU_struct::process_32b_register(uint8_t slaveAddress, uint8_t functionCode, short startAddress, uint32_t& result) { buildFrame(slaveAddress, functionCode, startAddress, 2); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { result = 0; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { result = result << 8; result += _recv_buf[i + 3]; } @@ -693,9 +693,9 @@ bool ModbusRTU_struct::process_32b_register(byte slaveAddress, byte functionCode return false; } -int ModbusRTU_struct::writeSpecialCommandRegister(byte command) { +int ModbusRTU_struct::writeSpecialCommandRegister(uint8_t command) { buildWriteCommandRegister(_modbus_address, command); - const byte process_result = processCommand(); + const uint8_t process_result = processCommand(); if (process_result == 0) { return 0; @@ -704,9 +704,9 @@ int ModbusRTU_struct::writeSpecialCommandRegister(byte command) { return -1 * process_result; } -unsigned int ModbusRTU_struct::read_RAM_EEPROM(byte command, byte startAddress, - byte nrBytes, - byte& errorcode) { +unsigned int ModbusRTU_struct::read_RAM_EEPROM(uint8_t command, uint8_t startAddress, + uint8_t nrBytes, + uint8_t& errorcode) { buildRead_RAM_EEPROM(_modbus_address, command, startAddress, nrBytes); errorcode = processCommand(); @@ -715,7 +715,7 @@ unsigned int ModbusRTU_struct::read_RAM_EEPROM(byte command, byte startAddress, unsigned int result = 0; for (int i = 0; i < _recv_buf[2]; ++i) { - // Most significant byte at lower address + // Most significant uint8_t at lower address result = (result << 8) | _recv_buf[i + 3]; } return result; @@ -725,11 +725,11 @@ unsigned int ModbusRTU_struct::read_RAM_EEPROM(byte command, byte startAddress, } // Compute the MODBUS RTU CRC -unsigned int ModbusRTU_struct::ModRTU_CRC(byte *buf, int len) { +unsigned int ModbusRTU_struct::ModRTU_CRC(uint8_t *buf, int len) { unsigned int crc = 0xFFFF; for (int pos = 0; pos < len; pos++) { - crc ^= (unsigned int)buf[pos]; // XOR byte into least sig. byte of crc + crc ^= (unsigned int)buf[pos]; // XOR uint8_t into least sig. uint8_t of crc for (int i = 8; i != 0; i--) { // Loop over each bit if ((crc & 0x0001) != 0) { // If the LSB is set diff --git a/src/src/Helpers/Modbus_RTU.h b/src/src/Helpers/Modbus_RTU.h index ab04cc10f..da135e917 100644 --- a/src/src/Helpers/Modbus_RTU.h +++ b/src/src/Helpers/Modbus_RTU.h @@ -54,13 +54,13 @@ struct ModbusRTU_struct { const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, - byte address); + uint8_t address); bool init(const ESPEasySerialPort port, const int16_t serial_rx, const int16_t serial_tx, int16_t baudrate, - byte address, + uint8_t address, int8_t dere_pin); bool isInitialized() const; @@ -73,42 +73,42 @@ struct ModbusRTU_struct { uint16_t getModbusTimeout() const; - String getDevice_description(byte slaveAddress); + String getDevice_description(uint8_t slaveAddress); // Read from RAM or EEPROM - void buildRead_RAM_EEPROM(byte slaveAddress, - byte functionCode, + void buildRead_RAM_EEPROM(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, - byte number_bytes); + uint8_t number_bytes); // Write to the Special Control Register (SCR) - void buildWriteCommandRegister(byte slaveAddress, - byte value); + void buildWriteCommandRegister(uint8_t slaveAddress, + uint8_t value); - void buildWriteMult16bRegister(byte slaveAddress, + void buildWriteMult16bRegister(uint8_t slaveAddress, uint16_t startAddress, uint16_t value); - void buildFrame(byte slaveAddress, - byte functionCode, + void buildFrame(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, short parameter); - void build_modbus_MEI_frame(byte slaveAddress, - byte device_id, - byte object_id); + void build_modbus_MEI_frame(uint8_t slaveAddress, + uint8_t device_id, + uint8_t object_id); - String MEI_objectid_to_name(byte object_id); + String MEI_objectid_to_name(uint8_t object_id); String parse_modbus_MEI_response(unsigned int& object_value_int, - byte & next_object_id, + uint8_t & next_object_id, bool & more_follows, - byte & conformity_level); + uint8_t & conformity_level); - void logModbusException(byte value); + void logModbusException(uint8_t value); /* - String log_buffer(byte *buffer, int length) { + String log_buffer(uint8_t *buffer, int length) { String log; log.reserve(3 * length + 5); for (int i = 0; i < length; ++i) { @@ -123,7 +123,7 @@ struct ModbusRTU_struct { return log; } */ - byte processCommand(); + uint8_t processCommand(); uint32_t read_32b_InputRegister(short address); @@ -132,10 +132,10 @@ struct ModbusRTU_struct { float read_float_HoldingRegister(short address); int readInputRegister(short address, - byte& errorcode); + uint8_t& errorcode); int readHoldingRegister(short address, - byte& errorcode); + uint8_t& errorcode); // Write to holding register. int writeSingleRegister(short address, @@ -143,47 +143,47 @@ struct ModbusRTU_struct { int writeSingleRegister(short address, short value, - byte& errorcode); + uint8_t& errorcode); // Function 16 (0x10) "Write Multiple Registers" to write to a single holding register int writeMultipleRegisters(short address, short value); - byte modbus_get_MEI(byte slaveAddress, - byte object_id, + uint8_t modbus_get_MEI(uint8_t slaveAddress, + uint8_t object_id, String & result, unsigned int& object_value_int, - byte & next_object_id, + uint8_t & next_object_id, bool & more_follows, - byte & conformity_level); + uint8_t & conformity_level); - void modbus_log_MEI(byte slaveAddress); + void modbus_log_MEI(uint8_t slaveAddress); - int process_16b_register(byte slaveAddress, - byte functionCode, + int process_16b_register(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, short parameter, - byte& errorcode); + uint8_t& errorcode); // Still writing single register, but calling it using "Preset Multiple Registers" function (FC=16) - int preset_mult16b_register(byte slaveAddress, + int preset_mult16b_register(uint8_t slaveAddress, uint16_t startAddress, uint16_t value); - bool process_32b_register(byte slaveAddress, - byte functionCode, + bool process_32b_register(uint8_t slaveAddress, + uint8_t functionCode, short startAddress, uint32_t& result); - int writeSpecialCommandRegister(byte command); + int writeSpecialCommandRegister(uint8_t command); - unsigned int read_RAM_EEPROM(byte command, - byte startAddress, - byte nrBytes, - byte& errorcode); + unsigned int read_RAM_EEPROM(uint8_t command, + uint8_t startAddress, + uint8_t nrBytes, + uint8_t& errorcode); // Compute the MODBUS RTU CRC - static unsigned int ModRTU_CRC(byte *buf, + static unsigned int ModRTU_CRC(uint8_t *buf, int len); uint32_t readTypeId(); @@ -202,11 +202,11 @@ private: void startRead(); - byte _sendframe[12] = { 0 }; - byte _sendframe_used = 0; - byte _recv_buf[MODBUS_RECEIVE_BUFFER] = { 0 }; - byte _recv_buf_used = 0; - byte _modbus_address = MODBUS_BROADCAST_ADDRESS; + uint8_t _sendframe[12] = { 0 }; + uint8_t _sendframe_used = 0; + uint8_t _recv_buf[MODBUS_RECEIVE_BUFFER] = { 0 }; + uint8_t _recv_buf_used = 0; + uint8_t _modbus_address = MODBUS_BROADCAST_ADDRESS; int8_t _dere_pin = -1; uint32_t _reads_pass = 0; uint32_t _reads_crc_failed = 0; diff --git a/src/src/Helpers/Networking.cpp b/src/src/Helpers/Networking.cpp index 33779955d..f353f5188 100644 --- a/src/src/Helpers/Networking.cpp +++ b/src/src/Helpers/Networking.cpp @@ -68,7 +68,7 @@ void etharp_gratuitous_r(struct netif *netif) { /*********************************************************************************************\ Syslog client \*********************************************************************************************/ -void syslog(byte logLevel, const char *message) +void syslog(uint8_t logLevel, const char *message) { if ((Settings.Syslog_IP[0] != 0) && NetworkConnected()) { @@ -79,7 +79,7 @@ void syslog(byte logLevel, const char *message) // problem resolving the hostname or port return; } - byte prio = Settings.SyslogFacility * 8; + uint8_t prio = Settings.SyslogFacility * 8; if (logLevel == LOG_LEVEL_ERROR) { prio += 3; // syslog error @@ -237,16 +237,16 @@ void checkUDP() if (len < 13) { break; } - byte unit = packetBuffer[12]; + uint8_t unit = packetBuffer[12]; #ifndef BUILD_NO_DEBUG MAC_address mac; - byte ip[4]; + uint8_t ip[4]; - for (byte x = 0; x < 6; x++) { + for (uint8_t x = 0; x < 6; x++) { mac.mac[x] = packetBuffer[x + 2]; } - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { ip[x] = packetBuffer[x + 8]; } #endif // ifndef BUILD_NO_DEBUG @@ -254,7 +254,7 @@ void checkUDP() NodesMap::iterator it = Nodes.find(unit); if (it != Nodes.end()) { - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { it->second.ip[x] = packetBuffer[x + 8]; } it->second.age = 0; // reset 'age counter' @@ -263,7 +263,7 @@ void checkUDP() { it->second.build = makeWord(packetBuffer[14], packetBuffer[13]); char tmpNodeName[26] = { 0 }; - memcpy(&tmpNodeName[0], reinterpret_cast(&packetBuffer[15]), 25); + memcpy(&tmpNodeName[0], reinterpret_cast(&packetBuffer[15]), 25); tmpNodeName[25] = 0; it->second.nodeName = tmpNodeName; it->second.nodeName.trim(); @@ -295,7 +295,7 @@ void checkUDP() default: { struct EventStruct TempEvent; - TempEvent.Data = reinterpret_cast(&packetBuffer[0]); + TempEvent.Data = reinterpret_cast(&packetBuffer[0]); TempEvent.Par1 = remoteIP[3]; TempEvent.Par2 = len; String dummy; @@ -321,7 +321,7 @@ void checkUDP() /*********************************************************************************************\ Send event using UDP message \*********************************************************************************************/ -void SendUDPCommand(byte destUnit, const char *data, byte dataLength) +void SendUDPCommand(uint8_t destUnit, const char *data, uint8_t dataLength) { if (!NetworkConnected(10)) { return; @@ -329,12 +329,12 @@ void SendUDPCommand(byte destUnit, const char *data, byte dataLength) if (destUnit != 0) { - sendUDP(destUnit, (const byte *)data, dataLength); + sendUDP(destUnit, (const uint8_t *)data, dataLength); delay(10); } else { for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { if (it->first != Settings.Unit) { - sendUDP(it->first, (const byte *)data, dataLength); + sendUDP(it->first, (const uint8_t *)data, dataLength); delay(10); } } @@ -346,7 +346,7 @@ void SendUDPCommand(byte destUnit, const char *data, byte dataLength) Get formatted IP address for unit formatcodes: 0 = default toString(), 1 = empty string when invalid, 2 = 0 when invalid \*********************************************************************************************/ -String formatUnitToIPAddress(byte unit, byte formatCode) { +String formatUnitToIPAddress(uint8_t unit, uint8_t formatCode) { IPAddress unitIPAddress = getIPAddressForUnit(unit); if (unitIPAddress[0] == 0) { // Invalid? @@ -367,7 +367,7 @@ String formatUnitToIPAddress(byte unit, byte formatCode) { /*********************************************************************************************\ Get IP address for unit \*********************************************************************************************/ -IPAddress getIPAddressForUnit(byte unit) { +IPAddress getIPAddressForUnit(uint8_t unit) { IPAddress remoteNodeIP; if (unit == 255) { @@ -391,7 +391,7 @@ IPAddress getIPAddressForUnit(byte unit) { /*********************************************************************************************\ Send UDP message (unit 255=broadcast) \*********************************************************************************************/ -void sendUDP(byte unit, const byte *data, byte size) +void sendUDP(uint8_t unit, const uint8_t *data, uint8_t size) { if (!NetworkConnected(10)) { return; @@ -457,50 +457,50 @@ void refreshNodeList() /*********************************************************************************************\ Broadcast system info to other nodes. (to update node lists) \*********************************************************************************************/ -void sendSysInfoUDP(byte repeats) +void sendSysInfoUDP(uint8_t repeats) { if ((Settings.UDPPort == 0) || !NetworkConnected(10)) { return; } // TODO: make a nice struct of it and clean up - // 1 byte 'binary token 255' - // 1 byte id '1' - // 6 byte mac - // 4 byte ip - // 1 byte unit - // 2 byte build + // 1 uint8_t 'binary token 255' + // 1 uint8_t id '1' + // 6 uint8_t mac + // 4 uint8_t ip + // 1 uint8_t unit + // 2 uint8_t build // 25 char name - // 1 byte node type id + // 1 uint8_t node type id // send my info to the world... #ifndef BUILD_NO_DEBUG addLog(LOG_LEVEL_DEBUG_MORE, F("UDP : Send Sysinfo message")); #endif // ifndef BUILD_NO_DEBUG - for (byte counter = 0; counter < repeats; counter++) + for (uint8_t counter = 0; counter < repeats; counter++) { - byte data[80] = { 0 }; + uint8_t data[80] = { 0 }; data[0] = 255; data[1] = 1; { const MAC_address macread = NetworkMacAddress(); - for (byte x = 0; x < 6; x++) { + for (uint8_t x = 0; x < 6; x++) { data[x + 2] = macread.mac[x]; } } { const IPAddress ip = NetworkLocalIP(); - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { data[x + 8] = ip[x]; } } data[12] = Settings.Unit; data[13] = lowByte(Settings.Build); data[14] = highByte(Settings.Build); - memcpy((byte *)data + 15, Settings.Name, 25); + memcpy((uint8_t *)data + 15, Settings.Name, 25); data[40] = NODE_TYPE_ID; data[41] = lowByte(Settings.WebserverPort); data[42] = highByte(Settings.WebserverPort); @@ -526,7 +526,7 @@ void sendSysInfoUDP(byte repeats) { IPAddress ip = NetworkLocalIP(); - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { it->second.ip[x] = ip[x]; } it->second.age = 0; @@ -684,7 +684,7 @@ bool SSDP_begin() { /********************************************************************************************\ Send SSDP messages (notify & responses) \*********************************************************************************************/ -void SSDP_send(byte method) { +void SSDP_send(uint8_t method) { uint32_t ip = NetworkLocalIP(); // FIXME TD-er: Why create String objects of these flashstrings? @@ -904,7 +904,7 @@ bool getSubnetRange(IPAddress& low, IPAddress& high) high = ip; // Compute subnet range. - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (subnet[i] != 255) { low[i] = low[i] & subnet[i]; high[i] = high[i] | ~subnet[i]; @@ -973,7 +973,7 @@ bool hostReachable(const IPAddress& ip) { /* // Only do 1 ping at a time to return early - byte retry = 3; + uint8_t retry = 3; while (retry > 0) { #if defined(ESP8266) if (Ping.ping(ip, 1)) return true; @@ -1246,7 +1246,7 @@ bool downloadFile(const String& url, String file_save, const String& user, const // read all data from server while (http.connected() && (len > 0 || len == -1)) { - // read up to 128 byte + // read up to 128 uint8_t size_t c = stream->readBytes(buff, std::min((size_t)len, sizeof(buff))); if (c > 0) { diff --git a/src/src/Helpers/Networking.h b/src/src/Helpers/Networking.h index 69de5c3be..1bd629147 100644 --- a/src/src/Helpers/Networking.h +++ b/src/src/Helpers/Networking.h @@ -10,7 +10,7 @@ /*********************************************************************************************\ Syslog client \*********************************************************************************************/ -void syslog(byte logLevel, const char *message); +void syslog(uint8_t logLevel, const char *message); /*********************************************************************************************\ @@ -28,23 +28,23 @@ void checkUDP(); /*********************************************************************************************\ Send event using UDP message \*********************************************************************************************/ -void SendUDPCommand(byte destUnit, const char *data, byte dataLength); +void SendUDPCommand(uint8_t destUnit, const char *data, uint8_t dataLength); /*********************************************************************************************\ Get formatted IP address for unit formatcodes: 0 = default toString(), 1 = empty string when invalid, 2 = 0 when invalid \*********************************************************************************************/ -String formatUnitToIPAddress(byte unit, byte formatCode); +String formatUnitToIPAddress(uint8_t unit, uint8_t formatCode); /*********************************************************************************************\ Get IP address for unit \*********************************************************************************************/ -IPAddress getIPAddressForUnit(byte unit); +IPAddress getIPAddressForUnit(uint8_t unit); /*********************************************************************************************\ Send UDP message (unit 255=broadcast) \*********************************************************************************************/ -void sendUDP(byte unit, const byte *data, byte size); +void sendUDP(uint8_t unit, const uint8_t *data, uint8_t size); /*********************************************************************************************\ Refresh aging for remote units, drop if too old... @@ -54,7 +54,7 @@ void refreshNodeList(); /*********************************************************************************************\ Broadcast system info to other nodes. (to update node lists) \*********************************************************************************************/ -void sendSysInfoUDP(byte repeats); +void sendSysInfoUDP(uint8_t repeats); #if defined(ESP8266) @@ -101,7 +101,7 @@ bool SSDP_begin(); /********************************************************************************************\ Send SSDP messages (notify & responses) \*********************************************************************************************/ -void SSDP_send(byte method); +void SSDP_send(uint8_t method); /********************************************************************************************\ SSDP message processing diff --git a/src/src/Helpers/PeriodicalActions.cpp b/src/src/Helpers/PeriodicalActions.cpp index c92f52cab..892169bc1 100644 --- a/src/src/Helpers/PeriodicalActions.cpp +++ b/src/src/Helpers/PeriodicalActions.cpp @@ -404,7 +404,7 @@ controllerIndex_t firstEnabledMQTT_ControllerIndex() { void logTimerStatistics() { - byte loglevel = LOG_LEVEL_DEBUG; + uint8_t loglevel = LOG_LEVEL_DEBUG; updateLoopStats_30sec(loglevel); #ifndef BUILD_NO_DEBUG // logStatistics(loglevel, true); @@ -416,7 +416,7 @@ void logTimerStatistics() { #endif } -void updateLoopStats_30sec(byte loglevel) { +void updateLoopStats_30sec(uint8_t loglevel) { loopCounterLast = loopCounter; loopCounter = 0; if (loopCounterLast > loopCounterMax) diff --git a/src/src/Helpers/PeriodicalActions.h b/src/src/Helpers/PeriodicalActions.h index 90188d8d4..27aa51598 100644 --- a/src/src/Helpers/PeriodicalActions.h +++ b/src/src/Helpers/PeriodicalActions.h @@ -48,7 +48,7 @@ controllerIndex_t firstEnabledMQTT_ControllerIndex(); void logTimerStatistics(); -void updateLoopStats_30sec(byte loglevel); +void updateLoopStats_30sec(uint8_t loglevel); /********************************************************************************************\ Clean up all before going to sleep or reboot. diff --git a/src/src/Helpers/PortStatus.cpp b/src/src/Helpers/PortStatus.cpp index a5fd8110a..7c8d46a80 100644 --- a/src/src/Helpers/PortStatus.cpp +++ b/src/src/Helpers/PortStatus.cpp @@ -118,12 +118,12 @@ uint16_t getPortFromKey(uint32_t key) { set pin mode & state (info table) \*********************************************************************************************/ /* - void setPinState(byte plugin, byte index, byte mode, uint16_t value) + void setPinState(uint8_t plugin, uint8_t index, uint8_t mode, uint16_t value) { // plugin number and index form a unique key // first check if this pin is already known bool reUse = false; - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index)) { pinStates[x].mode = mode; @@ -134,7 +134,7 @@ uint16_t getPortFromKey(uint32_t key) { if (!reUse) { - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if (pinStates[x].plugin == 0) { pinStates[x].plugin = plugin; @@ -152,9 +152,9 @@ uint16_t getPortFromKey(uint32_t key) { \*********************************************************************************************/ /* - bool getPinState(byte plugin, byte index, byte *mode, uint16_t *value) + bool getPinState(uint8_t plugin, uint8_t index, uint8_t *mode, uint16_t *value) { - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index)) { * mode = pinStates[x].mode; @@ -169,9 +169,9 @@ uint16_t getPortFromKey(uint32_t key) { check if pin mode & state is known (info table) \*********************************************************************************************/ /* - bool hasPinState(byte plugin, byte index) + bool hasPinState(uint8_t plugin, uint8_t index) { - for (byte x = 0; x < PINSTATE_TABLE_MAX; x++) + for (uint8_t x = 0; x < PINSTATE_TABLE_MAX; x++) if ((pinStates[x].plugin == plugin) && (pinStates[x].index == index)) { return true; @@ -191,7 +191,7 @@ String getPinStateJSON(bool search, uint32_t key, const String& log, int16_t noS checkRAM(F("getPinStateJSON")); #endif printToWebJSON = true; - byte mode = PIN_MODE_INPUT; + uint8_t mode = PIN_MODE_INPUT; int16_t value = noSearchValue; bool found = false; @@ -233,7 +233,7 @@ String getPinStateJSON(bool search, uint32_t key, const String& log, int16_t noS return ""; } -const __FlashStringHelper * getPinModeString(byte mode) { +const __FlashStringHelper * getPinModeString(uint8_t mode) { switch (mode) { case PIN_MODE_UNDEFINED: return F("undefined"); diff --git a/src/src/Helpers/PortStatus.h b/src/src/Helpers/PortStatus.h index 7b3ff2b9c..eeba29743 100644 --- a/src/src/Helpers/PortStatus.h +++ b/src/src/Helpers/PortStatus.h @@ -39,7 +39,7 @@ uint16_t getPortFromKey(uint32_t key); set pin mode & state (info table) \*********************************************************************************************/ /* - void setPinState(byte plugin, byte index, byte mode, uint16_t value); + void setPinState(uint8_t plugin, uint8_t index, uint8_t mode, uint16_t value); */ /*********************************************************************************************\ @@ -47,14 +47,14 @@ uint16_t getPortFromKey(uint32_t key); \*********************************************************************************************/ /* - bool getPinState(byte plugin, byte index, byte *mode, uint16_t *value); + bool getPinState(uint8_t plugin, uint8_t index, uint8_t *mode, uint16_t *value); */ /*********************************************************************************************\ check if pin mode & state is known (info table) \*********************************************************************************************/ /* - bool hasPinState(byte plugin, byte index); + bool hasPinState(uint8_t plugin, uint8_t index); */ @@ -67,6 +67,6 @@ String getPinStateJSON(bool search, const String& log, int16_t noSearchValue); -const __FlashStringHelper * getPinModeString(byte mode); +const __FlashStringHelper * getPinModeString(uint8_t mode); #endif \ No newline at end of file diff --git a/src/src/Helpers/Scheduler.cpp b/src/src/Helpers/Scheduler.cpp index c853db5a9..d29a83228 100644 --- a/src/src/Helpers/Scheduler.cpp +++ b/src/src/Helpers/Scheduler.cpp @@ -167,9 +167,9 @@ String ESPEasy_Scheduler::decodeSchedulerId(unsigned long mixed_id) { case GPIO_TIMER: { result = F("GPIO: "); - byte GPIOType = static_cast((id) & 0xFF); - byte pinNumber = static_cast((id >> 8) & 0xFF); - byte pinStateValue = static_cast((id >> 16) & 0xFF); + uint8_t GPIOType = static_cast((id) & 0xFF); + uint8_t pinNumber = static_cast((id >> 8) & 0xFF); + uint8_t pinStateValue = static_cast((id >> 16) & 0xFF); switch (GPIOType) { @@ -835,7 +835,7 @@ void ESPEasy_Scheduler::process_plugin_timer(unsigned long id) { * GPIO Timer * Special timer to handle timed GPIO actions \*********************************************************************************************/ -unsigned long ESPEasy_Scheduler::createGPIOTimerId(byte GPIOType, byte pinNumber, int Par1) { +unsigned long ESPEasy_Scheduler::createGPIOTimerId(uint8_t GPIOType, uint8_t pinNumber, int Par1) { const unsigned long mask = (1 << TIMER_ID_SHIFT) - 1; // const unsigned long mixed = (Par1 << 8) + pinNumber; @@ -846,7 +846,7 @@ unsigned long ESPEasy_Scheduler::createGPIOTimerId(byte GPIOType, byte pinNumber void ESPEasy_Scheduler::setGPIOTimer(unsigned long msecFromNow, pluginID_t pluginID, int Par1, int Par2, int Par3, int Par4, int Par5) { - byte GPIOType = GPIO_TYPE_INVALID; + uint8_t GPIOType = GPIO_TYPE_INVALID; switch (pluginID) { case PLUGIN_GPIO: @@ -869,13 +869,13 @@ void ESPEasy_Scheduler::setGPIOTimer(unsigned long msecFromNow, pluginID_t plugi void ESPEasy_Scheduler::process_gpio_timer(unsigned long id) { - byte GPIOType = static_cast((id) & 0xFF); - byte pinNumber = static_cast((id >> 8) & 0xFF); - byte pinStateValue = static_cast((id >> 16) & 0xFF); + uint8_t GPIOType = static_cast((id) & 0xFF); + uint8_t pinNumber = static_cast((id >> 8) & 0xFF); + uint8_t pinStateValue = static_cast((id >> 16) & 0xFF); bool success = true; - byte pluginID; + uint8_t pluginID; switch (GPIOType) { @@ -998,7 +998,7 @@ void ESPEasy_Scheduler::process_task_device_timer(unsigned long task_index, unsi * Thus only use these when the result is not needed immediately. * Proper use case is calling from a callback function, since those cannot use yield() or delay() \*********************************************************************************************/ -void ESPEasy_Scheduler::schedule_plugin_task_event_timer(deviceIndex_t DeviceIndex, byte Function, struct EventStruct &&event) { +void ESPEasy_Scheduler::schedule_plugin_task_event_timer(deviceIndex_t DeviceIndex, uint8_t Function, struct EventStruct &&event) { if (validDeviceIndex(DeviceIndex)) { schedule_event_timer(PluginPtrType::TaskPlugin, DeviceIndex, Function, std::move(event)); } @@ -1006,12 +1006,12 @@ void ESPEasy_Scheduler::schedule_plugin_task_event_timer(deviceIndex_t DeviceInd void ESPEasy_Scheduler::schedule_mqtt_plugin_import_event_timer(deviceIndex_t DeviceIndex, taskIndex_t TaskIndex, - byte Function, + uint8_t Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length) { if (validDeviceIndex(DeviceIndex)) { - const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::TaskPlugin, DeviceIndex, static_cast(Function)); + const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::TaskPlugin, DeviceIndex, static_cast(Function)); EventStruct event(TaskIndex); const size_t topic_length = strlen_P(c_topic); if (!(event.String1.reserve(topic_length) && event.String2.reserve(length))) { @@ -1031,7 +1031,7 @@ void ESPEasy_Scheduler::schedule_mqtt_plugin_import_event_timer(deviceIndex_t } } -void ESPEasy_Scheduler::schedule_controller_event_timer(protocolIndex_t ProtocolIndex, byte Function, struct EventStruct &&event) { +void ESPEasy_Scheduler::schedule_controller_event_timer(protocolIndex_t ProtocolIndex, uint8_t Function, struct EventStruct &&event) { if (validProtocolIndex(ProtocolIndex)) { schedule_event_timer(PluginPtrType::ControllerPlugin, ProtocolIndex, Function, std::move(event)); } @@ -1044,7 +1044,7 @@ unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type return getMixedId(SYSTEM_EVENT_QUEUE, subId); } -unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type, byte Index, byte Function) { +unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type, uint8_t Index, uint8_t Function) { unsigned long subId = static_cast(ptr_type); subId = (subId << 8) + Index; @@ -1055,12 +1055,12 @@ unsigned long ESPEasy_Scheduler::createSystemEventMixedId(PluginPtrType ptr_type void ESPEasy_Scheduler::schedule_mqtt_controller_event_timer(protocolIndex_t ProtocolIndex, CPlugin::Function Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length) { if (validProtocolIndex(ProtocolIndex)) { // Emplace empty event in the queue first and the fill it. // This makes sure the relatively large event will not be in memory twice. - const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::ControllerPlugin, ProtocolIndex, static_cast(Function)); + const unsigned long mixedId = createSystemEventMixedId(PluginPtrType::ControllerPlugin, ProtocolIndex, static_cast(Function)); ScheduledEventQueue.emplace_back(mixedId, EventStruct()); ScheduledEventQueue.back().event.String1 = c_topic; @@ -1076,11 +1076,11 @@ void ESPEasy_Scheduler::schedule_mqtt_controller_event_timer(protocolIndex_t Pro } } -void ESPEasy_Scheduler::schedule_notification_event_timer(byte NotificationProtocolIndex, NPlugin::Function Function, struct EventStruct &&event) { - schedule_event_timer(PluginPtrType::NotificationPlugin, NotificationProtocolIndex, static_cast(Function), std::move(event)); +void ESPEasy_Scheduler::schedule_notification_event_timer(uint8_t NotificationProtocolIndex, NPlugin::Function Function, struct EventStruct &&event) { + schedule_event_timer(PluginPtrType::NotificationPlugin, NotificationProtocolIndex, static_cast(Function), std::move(event)); } -void ESPEasy_Scheduler::schedule_event_timer(PluginPtrType ptr_type, byte Index, byte Function, struct EventStruct &&event) { +void ESPEasy_Scheduler::schedule_event_timer(PluginPtrType ptr_type, uint8_t Index, uint8_t Function, struct EventStruct &&event) { const unsigned long mixedId = createSystemEventMixedId(ptr_type, Index, Function); // EventStructCommandWrapper eventWrapper(mixedId, *event); @@ -1091,8 +1091,8 @@ void ESPEasy_Scheduler::schedule_event_timer(PluginPtrType ptr_type, byte Index, void ESPEasy_Scheduler::process_system_event_queue() { if (ScheduledEventQueue.size() == 0) { return; } unsigned long id = ScheduledEventQueue.front().id; - byte Function = id & 0xFF; - byte Index = (id >> 8) & 0xFF; + uint8_t Function = id & 0xFF; + uint8_t Index = (id >> 8) & 0xFF; PluginPtrType ptr_type = static_cast((id >> 16) & 0xFF); // At this moment, the String is not being used in the plugin calls, so just supply a dummy String. diff --git a/src/src/Helpers/Scheduler.h b/src/src/Helpers/Scheduler.h index f28b624d3..e070113bf 100644 --- a/src/src/Helpers/Scheduler.h +++ b/src/src/Helpers/Scheduler.h @@ -186,8 +186,8 @@ public: * GPIO Timer * Special timer to handle timed GPIO actions \*********************************************************************************************/ - static unsigned long createGPIOTimerId(byte GPIOType, - byte pinNumber, + static unsigned long createGPIOTimerId(uint8_t GPIOType, + uint8_t pinNumber, int Par1); @@ -233,30 +233,30 @@ public: // Note: event will be moved void schedule_plugin_task_event_timer(deviceIndex_t DeviceIndex, - byte Function, + uint8_t Function, struct EventStruct &&event); void schedule_mqtt_plugin_import_event_timer(deviceIndex_t DeviceIndex, taskIndex_t TaskIndex, - byte Function, + uint8_t Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length); // Note: the event will be moved void schedule_controller_event_timer(protocolIndex_t ProtocolIndex, - byte Function, + uint8_t Function, struct EventStruct &&event); void schedule_mqtt_controller_event_timer(protocolIndex_t ProtocolIndex, CPlugin::Function Function, char *c_topic, - byte *b_payload, + uint8_t *b_payload, unsigned int length); // Note: The event will be moved - void schedule_notification_event_timer(byte NotificationProtocolIndex, + void schedule_notification_event_timer(uint8_t NotificationProtocolIndex, NPlugin::Function Function, struct EventStruct &&event); @@ -265,13 +265,13 @@ public: uint16_t crc16); static unsigned long createSystemEventMixedId(PluginPtrType ptr_type, - byte Index, - byte Function); + uint8_t Index, + uint8_t Function); // Note, the event will be moved void schedule_event_timer(PluginPtrType ptr_type, - byte Index, - byte Function, + uint8_t Index, + uint8_t Function, struct EventStruct &&event); void process_system_event_queue(); diff --git a/src/src/Helpers/StringConverter.cpp b/src/src/Helpers/StringConverter.cpp index 8264cae22..4ec15bcd8 100644 --- a/src/src/Helpers/StringConverter.cpp +++ b/src/src/Helpers/StringConverter.cpp @@ -76,24 +76,24 @@ bool string2float(const String& string, float& floatvalue) { } /********************************************************************************************\ - Convert a char string to IP byte array + Convert a char string to IP uint8_t array \*********************************************************************************************/ bool isIP(const String& string) { IPAddress tmpip; return (tmpip.fromString(string)); } -bool str2ip(const String& string, byte *IP) { +bool str2ip(const String& string, uint8_t *IP) { return str2ip(string.c_str(), IP); } -bool str2ip(const char *string, byte *IP) +bool str2ip(const char *string, uint8_t *IP) { IPAddress tmpip; // Default constructor => set to 0.0.0.0 if ((*string == 0) || tmpip.fromString(string)) { // Eiher empty string or a valid IP addres, so copy value. - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { IP[i] = tmpip[i]; } return true; @@ -162,7 +162,7 @@ String formatHumanReadable(unsigned long value, unsigned long factor) { String formatHumanReadable(unsigned long value, unsigned long factor, int NrDecimals) { float floatValue(value); - byte steps = 0; + uint8_t steps = 0; while (value >= factor) { value /= factor; @@ -225,7 +225,7 @@ void addNewLine(String& line) { /*********************************************************************************************\ Format a value to the set number of decimals \*********************************************************************************************/ -String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck, bool& isvalid) { +String doFormatUserVar(struct EventStruct *event, uint8_t rel_index, bool mustCheck, bool& isvalid) { if (event == nullptr) return EMPTY_STRING; isvalid = true; @@ -249,7 +249,7 @@ String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck } - const byte valueCount = getValueCountForTask(event->TaskIndex); + const uint8_t valueCount = getValueCountForTask(event->TaskIndex); Sensor_VType sensorType = event->getSensorType(); if (valueCount <= rel_index) { @@ -298,7 +298,7 @@ String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck } LoadTaskSettings(event->TaskIndex); - byte nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[rel_index]; + uint8_t nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[rel_index]; if (!Device[DeviceIndex].configurableDecimals()) { nrDecimals = 0; @@ -309,7 +309,7 @@ String doFormatUserVar(struct EventStruct *event, byte rel_index, bool mustCheck return result; } -String formatUserVarNoCheck(taskIndex_t TaskIndex, byte rel_index) { +String formatUserVarNoCheck(taskIndex_t TaskIndex, uint8_t rel_index) { bool isvalid; // FIXME TD-er: calls to this function cannot handle Sensor_VType::SENSOR_TYPE_STRING @@ -318,21 +318,21 @@ String formatUserVarNoCheck(taskIndex_t TaskIndex, byte rel_index) { return doFormatUserVar(&TempEvent, rel_index, false, isvalid); } -String formatUserVar(taskIndex_t TaskIndex, byte rel_index, bool& isvalid) { +String formatUserVar(taskIndex_t TaskIndex, uint8_t rel_index, bool& isvalid) { // FIXME TD-er: calls to this function cannot handle Sensor_VType::SENSOR_TYPE_STRING struct EventStruct TempEvent(TaskIndex); return doFormatUserVar(&TempEvent, rel_index, true, isvalid); } -String formatUserVarNoCheck(struct EventStruct *event, byte rel_index) +String formatUserVarNoCheck(struct EventStruct *event, uint8_t rel_index) { bool isvalid; return doFormatUserVar(event, rel_index, false, isvalid); } -String formatUserVar(struct EventStruct *event, byte rel_index, bool& isvalid) +String formatUserVar(struct EventStruct *event, uint8_t rel_index, bool& isvalid) { return doFormatUserVar(event, rel_index, true, isvalid); } @@ -514,14 +514,14 @@ String to_internal_string(const String& input, char replaceSpace) { IndexFind = 1 => command. // FIXME TD-er: parseString* should use index starting at 0. \*********************************************************************************************/ -String parseString(const String& string, byte indexFind, char separator) { +String parseString(const String& string, uint8_t indexFind, char separator) { String result = parseStringKeepCase(string, indexFind, separator); result.toLowerCase(); return result; } -String parseStringKeepCase(const String& string, byte indexFind, char separator) { +String parseStringKeepCase(const String& string, uint8_t indexFind, char separator) { String result; if (!GetArgv(string.c_str(), result, indexFind, separator)) { @@ -531,19 +531,19 @@ String parseStringKeepCase(const String& string, byte indexFind, char separator) return stripQuotes(result); } -String parseStringToEnd(const String& string, byte indexFind, char separator) { +String parseStringToEnd(const String& string, uint8_t indexFind, char separator) { String result = parseStringToEndKeepCase(string, indexFind, separator); result.toLowerCase(); return result; } -String parseStringToEndKeepCase(const String& string, byte indexFind, char separator) { +String parseStringToEndKeepCase(const String& string, uint8_t indexFind, char separator) { // Loop over the arguments to find the first and last pos of the arguments. int pos_begin = string.length(); int pos_end = pos_begin; int tmppos_begin, tmppos_end = -1; - byte nextArgument = indexFind; + uint8_t nextArgument = indexFind; bool hasArgument = false; while (GetArgvBeginEnd(string.c_str(), nextArgument, tmppos_begin, tmppos_end, separator)) @@ -569,7 +569,7 @@ String parseStringToEndKeepCase(const String& string, byte indexFind, char separ return stripQuotes(result); } -String tolerantParseStringKeepCase(const String& string, byte indexFind, char separator) +String tolerantParseStringKeepCase(const String& string, uint8_t indexFind, char separator) { if (Settings.TolerantLastArgParse()) { return parseStringToEndKeepCase(string, indexFind, separator); @@ -787,7 +787,7 @@ void parseControllerVariables(String& s, struct EventStruct *event, bool useURLe void parseSingleControllerVariable(String & s, struct EventStruct *event, - byte taskValueIndex, + uint8_t taskValueIndex, bool useURLencode) { if (validTaskIndex(event->TaskIndex)) { LoadTaskSettings(event->TaskIndex); @@ -819,7 +819,7 @@ void parseEventVariables(String& s, struct EventStruct *event, bool useURLencode if (event->getSensorType() == Sensor_VType::SENSOR_TYPE_LONG) { SMART_REPL(F("%val1%"), String(UserVar.getSensorTypeLong(event->TaskIndex))) } else { - for (byte i = 0; i < getValueCountForTask(event->TaskIndex); ++i) { + for (uint8_t i = 0; i < getValueCountForTask(event->TaskIndex); ++i) { String valstr = F("%val"); valstr += (i + 1); valstr += '%'; @@ -840,7 +840,7 @@ void parseEventVariables(String& s, struct EventStruct *event, bool useURLencode const bool vname_found = s.indexOf(F("%vname")) != -1; if (vname_found) { - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { String vname = F("%vname"); vname += (i + 1); vname += '%'; diff --git a/src/src/Helpers/StringConverter.h b/src/src/Helpers/StringConverter.h index 013849120..eb40a935b 100644 --- a/src/src/Helpers/StringConverter.h +++ b/src/src/Helpers/StringConverter.h @@ -30,15 +30,15 @@ bool string2float(const String& string, /********************************************************************************************\ - Convert a char string to IP byte array + Convert a char string to IP uint8_t array \*********************************************************************************************/ bool isIP(const String& string); bool str2ip(const String& string, - byte *IP); + uint8_t *IP); bool str2ip(const char *string, - byte *IP); + uint8_t *IP); String formatIP(const IPAddress& ip); @@ -87,22 +87,22 @@ void addNewLine(String& line); Format a value to the set number of decimals \*********************************************************************************************/ String doFormatUserVar(struct EventStruct *event, - byte rel_index, + uint8_t rel_index, bool mustCheck, bool & isvalid); String formatUserVarNoCheck(taskIndex_t TaskIndex, - byte rel_index); + uint8_t rel_index); String formatUserVar(taskIndex_t TaskIndex, - byte rel_index, + uint8_t rel_index, bool & isvalid); String formatUserVarNoCheck(struct EventStruct *event, - byte rel_index); + uint8_t rel_index); String formatUserVar(struct EventStruct *event, - byte rel_index, + uint8_t rel_index, bool & isvalid); @@ -171,23 +171,23 @@ String to_internal_string(const String& input, // FIXME TD-er: parseString* should use index starting at 0. \*********************************************************************************************/ String parseString(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String parseStringKeepCase(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String parseStringToEnd(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String parseStringToEndKeepCase(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); String tolerantParseStringKeepCase(const String& string, - byte indexFind, + uint8_t indexFind, char separator = ','); // escapes special characters in strings for use in html-forms @@ -232,7 +232,7 @@ void parseControllerVariables(String & s, void parseSingleControllerVariable(String & s, struct EventStruct *event, - byte taskValueIndex, + uint8_t taskValueIndex, bool useURLencode); void parseSystemVariables(String& s, diff --git a/src/src/Helpers/StringGenerator_System.cpp b/src/src/Helpers/StringGenerator_System.cpp index 9d75c8b5d..ce4e18a88 100644 --- a/src/src/Helpers/StringGenerator_System.cpp +++ b/src/src/Helpers/StringGenerator_System.cpp @@ -56,7 +56,7 @@ const __FlashStringHelper * getLastBootCauseString() { #include // See https://github.com/espressif/esp-idf/blob/master/components/esp32/include/rom/rtc.h -String getResetReasonString(byte icore) { +String getResetReasonString(uint8_t icore) { bool isDEEPSLEEP_RESET(false); switch (rtc_get_reset_reason((RESET_REASON)icore)) { diff --git a/src/src/Helpers/StringGenerator_System.h b/src/src/Helpers/StringGenerator_System.h index 4d7baa4ee..e4a5e7763 100644 --- a/src/src/Helpers/StringGenerator_System.h +++ b/src/src/Helpers/StringGenerator_System.h @@ -23,7 +23,7 @@ const __FlashStringHelper * getLastBootCauseString(); #ifdef ESP32 // See https://github.com/espressif/esp-idf/blob/master/components/esp32/include/rom/rtc.h -String getResetReasonString(byte icore); +String getResetReasonString(uint8_t icore); #endif // ifdef ESP32 String getResetReasonString(); diff --git a/src/src/Helpers/StringGenerator_WiFi.cpp b/src/src/Helpers/StringGenerator_WiFi.cpp index e158282c9..f90d855b6 100644 --- a/src/src/Helpers/StringGenerator_WiFi.cpp +++ b/src/src/Helpers/StringGenerator_WiFi.cpp @@ -2,7 +2,7 @@ #include "../Globals/ESPEasyWiFiEvent.h" -const __FlashStringHelper * WiFi_encryptionType(byte encryptionType) { +const __FlashStringHelper * WiFi_encryptionType(uint8_t encryptionType) { switch (encryptionType) { #ifdef ESP32 case WIFI_AUTH_OPEN: return F("open"); diff --git a/src/src/Helpers/StringGenerator_WiFi.h b/src/src/Helpers/StringGenerator_WiFi.h index 9d74f964a..d08e57b98 100644 --- a/src/src/Helpers/StringGenerator_WiFi.h +++ b/src/src/Helpers/StringGenerator_WiFi.h @@ -3,7 +3,7 @@ #include "../../ESPEasy_common.h" -const __FlashStringHelper * WiFi_encryptionType(byte encryptionType); +const __FlashStringHelper * WiFi_encryptionType(uint8_t encryptionType); #ifdef ESP8266 #ifdef LIMIT_BUILD_SIZE diff --git a/src/src/Helpers/StringParser.cpp b/src/src/Helpers/StringParser.cpp index b442a8dd8..b4fc80011 100644 --- a/src/src/Helpers/StringParser.cpp +++ b/src/src/Helpers/StringParser.cpp @@ -36,12 +36,12 @@ String parseTemplate(String& tmpString, bool useURLencode) return parseTemplate_padded(tmpString, 0, useURLencode); } -String parseTemplate_padded(String& tmpString, byte minimal_lineSize) +String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize) { return parseTemplate_padded(tmpString, minimal_lineSize, false); } -String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useURLencode) +String parseTemplate_padded(String& tmpString, uint8_t minimal_lineSize, bool useURLencode) { #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("parseTemplate_padded")); @@ -49,7 +49,7 @@ String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useUR START_TIMER; // Keep current loaded taskSettings to restore at the end. - byte currentTaskIndex = ExtraTaskSettings.TaskIndex; + uint8_t currentTaskIndex = ExtraTaskSettings.TaskIndex; String newString; newString.reserve(minimal_lineSize); // Our best guess of the new size. @@ -126,7 +126,7 @@ String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useUR taskIndex_t taskIndex = findTaskIndexByName(deviceName); if (validTaskIndex(taskIndex) && Settings.TaskDeviceEnabled[taskIndex]) { - byte valueNr = findDeviceValueIndexByName(valueName, taskIndex); + uint8_t valueNr = findDeviceValueIndexByName(valueName, taskIndex); if (valueNr != VARS_PER_TASK) { // here we know the task and value, so find the uservar @@ -197,7 +197,7 @@ String parseTemplate_padded(String& tmpString, byte minimal_lineSize, bool useUR // valueFormat="transformation#justification" void transformValue( String & newString, - byte lineSize, + uint8_t lineSize, String value, String & valueFormat, const String& tmpString) @@ -377,7 +377,7 @@ void transformValue( indexDot = value.length(); } - for (byte f = 0; f < (x - indexDot); f++) { + for (uint8_t f = 0; f < (x - indexDot); f++) { value = (tempValueFormat[0] == 'd' ? ' ' : '0') + value; } break; @@ -410,7 +410,7 @@ void transformValue( { int filler = valueJust[1] - value.length() - '0'; // char '0' = 48; char '9' = 58 - for (byte f = 0; f < filler; f++) { + for (uint8_t f = 0; f < filler; f++) { newString += ' '; } } @@ -424,7 +424,7 @@ void transformValue( { int filler = valueJust[1] - value.length() - '0'; // 48 - for (byte f = 0; f < filler; f++) { + for (uint8_t f = 0; f < filler; f++) { value += ' '; } } @@ -496,7 +496,7 @@ void transformValue( { int filler = lineSize - newString.length() - value.length() - tmpString.length(); - for (byte f = 0; f < filler; f++) { + for (uint8_t f = 0; f < filler; f++) { newString += ' '; } } @@ -566,7 +566,7 @@ taskIndex_t findTaskIndexByName(const String& deviceName) // Find the first device value index of a taskIndex. // Return VARS_PER_TASK if none found. -byte findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex) +uint8_t findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex) { const deviceIndex_t deviceIndex = getDeviceIndex_from_TaskIndex(taskIndex); @@ -590,9 +590,9 @@ byte findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex) } LoadTaskSettings(taskIndex); // Probably already loaded, but just to be sure - const byte valCount = getValueCountForTask(taskIndex); + const uint8_t valCount = getValueCountForTask(taskIndex); - for (byte valueNr = 0; valueNr < valCount; valueNr++) + for (uint8_t valueNr = 0; valueNr < valCount; valueNr++) { // Check case insensitive, since the user entered value name can have any case. if (valueName.equalsIgnoreCase(ExtraTaskSettings.TaskDeviceValueNames[valueNr])) diff --git a/src/src/Helpers/StringParser.h b/src/src/Helpers/StringParser.h index 075f40cd8..9dd7a6bbd 100644 --- a/src/src/Helpers/StringParser.h +++ b/src/src/Helpers/StringParser.h @@ -14,10 +14,10 @@ String parseTemplate(String& tmpString, bool useURLencode); String parseTemplate_padded(String& tmpString, - byte minimal_lineSize); + uint8_t minimal_lineSize); String parseTemplate_padded(String& tmpString, - byte minimal_lineSize, + uint8_t minimal_lineSize, bool useURLencode); @@ -29,7 +29,7 @@ String parseTemplate_padded(String& tmpString, // valueFormat="transformation#justification" void transformValue( String & newString, - byte lineSize, + uint8_t lineSize, String value, String & valueFormat, const String& tmpString); @@ -42,7 +42,7 @@ taskIndex_t findTaskIndexByName(const String& deviceName); // Find the first device value index of a taskIndex. // Return VARS_PER_TASK if none found. -byte findDeviceValueIndexByName(const String& valueName, +uint8_t findDeviceValueIndexByName(const String& valueName, taskIndex_t taskIndex); // Find positions of [...#...] in the given string. diff --git a/src/src/Helpers/WiFi_AP_CandidatesList.cpp b/src/src/Helpers/WiFi_AP_CandidatesList.cpp index 0cd7441fa..209f876d2 100644 --- a/src/src/Helpers/WiFi_AP_CandidatesList.cpp +++ b/src/src/Helpers/WiFi_AP_CandidatesList.cpp @@ -29,7 +29,7 @@ void WiFi_AP_CandidatesList::load_knownCredentials() { { // Add the known SSIDs String ssid, key; - byte index = 1; // Index 0 is the "unset" value + uint8_t index = 1; // Index 0 is the "unset" value bool done = false; @@ -413,7 +413,7 @@ void WiFi_AP_CandidatesList::purge_unusable() { candidates.unique(); } -bool WiFi_AP_CandidatesList::get_SSID_key(byte index, String& ssid, String& key) const { +bool WiFi_AP_CandidatesList::get_SSID_key(uint8_t index, String& ssid, String& key) const { switch (index) { case 1: ssid = SecuritySettings.WifiSSID; diff --git a/src/src/Helpers/WiFi_AP_CandidatesList.h b/src/src/Helpers/WiFi_AP_CandidatesList.h index a12431ec5..93e2c1b02 100644 --- a/src/src/Helpers/WiFi_AP_CandidatesList.h +++ b/src/src/Helpers/WiFi_AP_CandidatesList.h @@ -68,7 +68,7 @@ private: void purge_unusable(); // Load SSID and pass/key from the settings. - bool get_SSID_key(byte index, + bool get_SSID_key(uint8_t index, String& ssid, String& key) const; diff --git a/src/src/Helpers/_CPlugin_DomoticzHelper.cpp b/src/src/Helpers/_CPlugin_DomoticzHelper.cpp index 075a417f8..bcc7a01c3 100644 --- a/src/src/Helpers/_CPlugin_DomoticzHelper.cpp +++ b/src/src/Helpers/_CPlugin_DomoticzHelper.cpp @@ -25,7 +25,7 @@ // 1=Comfortable // 2=Dry // 3=Wet -String humStatDomoticz(struct EventStruct *event, byte rel_index) { +String humStatDomoticz(struct EventStruct *event, uint8_t rel_index) { userVarIndex_t userVarIndex = event->BaseVarIndex + rel_index; if (validTaskVarIndex(rel_index) && validUserVarIndex(userVarIndex)) { @@ -62,7 +62,7 @@ int mapVccToDomoticz() { } // Format including trailing semi colon -String formatUserVarDomoticz(struct EventStruct *event, byte rel_index) { +String formatUserVarDomoticz(struct EventStruct *event, uint8_t rel_index) { String text = formatUserVarNoCheck(event, rel_index); text += ';'; @@ -169,7 +169,7 @@ String formatDomoticzSensorType(struct EventStruct *event) { if (loglevelActiveFor(LOG_LEVEL_ERROR)) { String log = F("Domoticz Controller: Not yet implemented sensor type: "); - log += static_cast(event->sensorType); + log += static_cast(event->sensorType); log += F(" idx: "); log += event->idx; addLog(LOG_LEVEL_ERROR, log); @@ -191,7 +191,7 @@ String formatDomoticzSensorType(struct EventStruct *event) { if (loglevelActiveFor(LOG_LEVEL_INFO)) { String log = F(" Domoticz: Sensortype: "); - log += static_cast(event->sensorType); + log += static_cast(event->sensorType); log += F(" idx: "); log += event->idx; log += F(" values: "); diff --git a/src/src/Helpers/_CPlugin_DomoticzHelper.h b/src/src/Helpers/_CPlugin_DomoticzHelper.h index 5dd91e22f..a3b4adc8a 100644 --- a/src/src/Helpers/_CPlugin_DomoticzHelper.h +++ b/src/src/Helpers/_CPlugin_DomoticzHelper.h @@ -14,7 +14,7 @@ // 2=Dry // 3=Wet String humStatDomoticz(struct EventStruct *event, - byte rel_index); + uint8_t rel_index); int mapRSSItoDomoticz(); @@ -22,7 +22,7 @@ int mapVccToDomoticz(); // Format including trailing semi colon String formatUserVarDomoticz(struct EventStruct *event, - byte rel_index); + uint8_t rel_index); String formatUserVarDomoticz(int value); diff --git a/src/src/Helpers/_CPlugin_Helper.cpp b/src/src/Helpers/_CPlugin_Helper.cpp index 4ff8c5daf..903ae9954 100644 --- a/src/src/Helpers/_CPlugin_Helper.cpp +++ b/src/src/Helpers/_CPlugin_Helper.cpp @@ -336,7 +336,7 @@ bool send_via_http(const String& logIdentifier, WiFiClient& client, const String bool success = !must_check_reply; // This will send the request to the server - byte written = client.print(postStr); + uint8_t written = client.print(postStr); // as of 2018/11/01 the print function only returns one byte (upd to 256 chars sent). However if the string sent can be longer than this // therefore we calculate modulo 256. @@ -552,7 +552,7 @@ String send_via_http(const String& logIdentifier, if (httpCode > 0) { response = http.getString(); - byte loglevel = LOG_LEVEL_ERROR; + uint8_t loglevel = LOG_LEVEL_ERROR; // HTTP codes: // 1xx Informational response // 2xx Success diff --git a/src/src/Helpers/_CPlugin_Helper_webform.cpp b/src/src/Helpers/_CPlugin_Helper_webform.cpp index bfef0ed48..617c328f7 100644 --- a/src/src/Helpers/_CPlugin_Helper_webform.cpp +++ b/src/src/Helpers/_CPlugin_Helper_webform.cpp @@ -129,7 +129,7 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin switch (varType) { case ControllerSettingsStruct::CONTROLLER_USE_DNS: { - byte choice = ControllerSettings.UseDNS; + uint8_t choice = ControllerSettings.UseDNS; const __FlashStringHelper * options[2]; options[0] = F("Use IP address"); options[1] = F("Use Hostname"); @@ -286,7 +286,7 @@ void saveControllerParameterForm(ControllerSettingsStruct & ControllerSet IPAddress IP; resolveHostByName(ControllerSettings.HostName, IP, ControllerSettings.ClientTimeout); - for (byte x = 0; x < 4; x++) { + for (uint8_t x = 0; x < 4; x++) { ControllerSettings.IP[x] = IP[x]; } } diff --git a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp index d7ea9709f..034955aad 100644 --- a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp +++ b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp @@ -15,7 +15,7 @@ String getPackedFromPlugin(struct EventStruct *event, uint8_t sampleSetCount) { - byte value_count = getValueCountForTask(event->TaskIndex); + uint8_t value_count = getValueCountForTask(event->TaskIndex); String raw_packed; if (PluginCall(PLUGIN_GET_PACKED_RAW_DATA, event, raw_packed)) { @@ -51,7 +51,7 @@ String getPackedFromPlugin(struct EventStruct *event, uint8_t sampleSetCount) default: - for (byte i = 0; i < value_count && i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < value_count && i < VARS_PER_TASK; ++i) { // For now, just store the floats as an int32 by multiplying the value with 10000. packed += LoRa_addFloat(UserVar[event->BaseVarIndex + i], PackedData_int32_1e4); } diff --git a/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp b/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp index ce6f3072a..7afd532ef 100644 --- a/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp +++ b/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp @@ -408,7 +408,7 @@ void Internal_GPIO_pulseHelper::updateStatisticalCounters(int par1) { pulseModeData.Step3OKcounter -= ISRdata.pulseTotalCounter - par1; } -void Internal_GPIO_pulseHelper::setStatsLogLevel(byte logLevel) { +void Internal_GPIO_pulseHelper::setStatsLogLevel(uint8_t logLevel) { pulseModeData.StatsLogLevel = logLevel; } @@ -430,7 +430,7 @@ void Internal_GPIO_pulseHelper::resetStatsErrorVars() { /*********************************************************************************************\ * write statistic counters to logfile \*********************************************************************************************/ -void Internal_GPIO_pulseHelper::doStatisticLogging(byte logLevel) +void Internal_GPIO_pulseHelper::doStatisticLogging(uint8_t logLevel) { if (loglevelActiveFor(logLevel)) { // Statistic to logfile. E.g: ... [123/1|111|100/5|80/3/4|40] [12243|3244] @@ -455,7 +455,7 @@ void Internal_GPIO_pulseHelper::doStatisticLogging(byte logLevel) /*********************************************************************************************\ * write collected timing values to logfile \*********************************************************************************************/ -void Internal_GPIO_pulseHelper::doTimingLogging(byte logLevel) +void Internal_GPIO_pulseHelper::doTimingLogging(uint8_t logLevel) { if (loglevelActiveFor(logLevel)) { // Timer to logfile. E.g: ... [4|12000|13444|12243|3244] diff --git a/src/src/Helpers/_Internal_GPIO_pulseHelper.h b/src/src/Helpers/_Internal_GPIO_pulseHelper.h index 075598c78..de5b5f690 100644 --- a/src/src/Helpers/_Internal_GPIO_pulseHelper.h +++ b/src/src/Helpers/_Internal_GPIO_pulseHelper.h @@ -74,7 +74,7 @@ struct pulseModeData_t { unsigned int Step3IGNcounter = 0; // counts how often step 3 detected the wrong pin state (2nd verification failed) unsigned int Step0ODcounter = 0; // counts how often the debounce time timed out before step 0 was reached long StepOverdueMax[P003_PSTEP_MAX + 1] = { 0 }; // longest recognised overdue time per step in ms - byte StatsLogLevel = PULSE_STATS_ADHOC_LOG_LEVEL; // log level for regular statistics logging + uint8_t StatsLogLevel = PULSE_STATS_ADHOC_LOG_LEVEL; // log level for regular statistics logging #endif }; @@ -109,8 +109,8 @@ struct Internal_GPIO_pulseHelper { uint64_t debounceTime_micros = 0; // 64 bit version of debounceTime in micoseconds uint16_t debounceTime = 0; taskIndex_t taskIndex = INVALID_TASK_INDEX; - byte gpio = -1; - byte pullupPinMode = INPUT_PULLUP; + uint8_t gpio = -1; + uint8_t pullupPinMode = INPUT_PULLUP; GPIOtriggerMode interruptPinMode = GPIOtriggerMode::Change; }; @@ -167,7 +167,7 @@ public: // adjust the statistical step counters relative to TotalCounter, in order to keep statistic correct void updateStatisticalCounters(int par1); - void setStatsLogLevel(byte logLevel); + void setStatsLogLevel(uint8_t logLevel); /*********************************************************************************************\ * reset statistical error cunters and overview variables @@ -177,12 +177,12 @@ public: /*********************************************************************************************\ * write statistic counters to logfile \*********************************************************************************************/ - void doStatisticLogging(byte logLevel); + void doStatisticLogging(uint8_t logLevel); /*********************************************************************************************\ * write collected timing values to logfile \*********************************************************************************************/ - void doTimingLogging(byte logLevel); + void doTimingLogging(uint8_t logLevel); #endif // ifdef PULSE_STATISTIC }; diff --git a/src/src/Helpers/_Plugin_Helper_serial.cpp b/src/src/Helpers/_Plugin_Helper_serial.cpp index c72f0f0c5..7af28d57a 100644 --- a/src/src/Helpers/_Plugin_Helper_serial.cpp +++ b/src/src/Helpers/_Plugin_Helper_serial.cpp @@ -251,7 +251,7 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef #endif } -void serialHelper_webformSave(byte& port, int8_t& rxPin, int8_t& txPin) { +void serialHelper_webformSave(uint8_t& port, int8_t& rxPin, int8_t& txPin) { int serialPortSelected = getFormItemInt(F("serPort"), -1); if (serialPortSelected < 0) { return; } @@ -295,14 +295,14 @@ void serialHelper_webformSave(struct EventStruct *event) { serialHelper_webformSave(CONFIG_PORT, CONFIG_PIN1, CONFIG_PIN2); } -bool serialHelper_isValid_serialconfig(byte serialconfig) { +bool serialHelper_isValid_serialconfig(uint8_t serialconfig) { if ((serialconfig >= 0x10) && (serialconfig <= 0x3f)) { return true; } return false; } -void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte currentSelection) { +void serialHelper_serialconfig_webformLoad(struct EventStruct *event, uint8_t currentSelection) { // nrOptions = 4 * 3 * 2 = 24 (bits 5..8 , parity N/E/O , stopbits 1/2) String id = F("serConf"); @@ -310,13 +310,13 @@ void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte curre do_addSelector_Head(id, EMPTY_STRING, EMPTY_STRING, false); if (currentSelection == 0) { - // Must truncate it to 1 byte, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. - currentSelection = static_cast(SERIAL_8N1 & 0xFF); // Some default + // Must truncate it to 1 uint8_t, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. + currentSelection = static_cast(SERIAL_8N1 & 0xFF); // Some default } - for (byte parity = 0; parity < 3; ++parity) { - for (byte stopBits = 1; stopBits <= 2; ++stopBits) { - for (byte bits = 5; bits <= 8; ++bits) { + for (uint8_t parity = 0; parity < 3; ++parity) { + for (uint8_t stopBits = 1; stopBits <= 2; ++stopBits) { + for (uint8_t bits = 5; bits <= 8; ++bits) { String label; label.reserve(36); label = String(bits); @@ -343,23 +343,23 @@ void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte curre addSelector_Foot(); } -byte serialHelper_serialconfig_webformSave() { +uint8_t serialHelper_serialconfig_webformSave() { int serialConfSelected = getFormItemInt(F("serConf"), 0); if (serialHelper_isValid_serialconfig(serialConfSelected)) { return serialConfSelected; } - // Must truncate it to 1 byte, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. - return static_cast(SERIAL_8N1 & 0xFF); // Some default + // Must truncate it to 1 uint8_t, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. + return static_cast(SERIAL_8N1 & 0xFF); // Some default } // Used by some plugins, which used several TaskDevicePluginConfigLong -byte serialHelper_convertOldSerialConfig(byte newLocationConfig) { +uint8_t serialHelper_convertOldSerialConfig(uint8_t newLocationConfig) { if (serialHelper_isValid_serialconfig(newLocationConfig)) { return newLocationConfig; } - byte serialconfig = 0x10; // Default stopbits = 1 + uint8_t serialconfig = 0x10; // Default stopbits = 1 serialconfig += ExtraTaskSettings.TaskDevicePluginConfigLong[3]; // Parity serialconfig += (ExtraTaskSettings.TaskDevicePluginConfigLong[2] - 5) << 2; // databits @@ -372,6 +372,6 @@ byte serialHelper_convertOldSerialConfig(byte newLocationConfig) { return serialconfig; } - // Must truncate it to 1 byte, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. - return static_cast(SERIAL_8N1 & 0xFF); // Some default + // Must truncate it to 1 uint8_t, since ESP32 uses a 32-bit value. We add these high bits later for ESP32. + return static_cast(SERIAL_8N1 & 0xFF); // Some default } diff --git a/src/src/Helpers/_Plugin_Helper_serial.h b/src/src/Helpers/_Plugin_Helper_serial.h index 9401b9707..3151aef89 100644 --- a/src/src/Helpers/_Plugin_Helper_serial.h +++ b/src/src/Helpers/_Plugin_Helper_serial.h @@ -37,18 +37,18 @@ void serialHelper_webformLoad(struct EventStruct *event, bool allowSoftwareSeria void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef, bool allowSoftwareSerial); -void serialHelper_webformSave(byte& port, int8_t &rxPin, int8_t &txPin); +void serialHelper_webformSave(uint8_t& port, int8_t &rxPin, int8_t &txPin); void serialHelper_webformSave(struct EventStruct *event); -bool serialHelper_isValid_serialconfig(byte serialconfig); +bool serialHelper_isValid_serialconfig(uint8_t serialconfig); -void serialHelper_serialconfig_webformLoad(struct EventStruct *event, byte currentSelection); +void serialHelper_serialconfig_webformLoad(struct EventStruct *event, uint8_t currentSelection); -byte serialHelper_serialconfig_webformSave(); +uint8_t serialHelper_serialconfig_webformSave(); // Used by some plugins, which used several TaskDevicePluginConfigLong -byte serialHelper_convertOldSerialConfig(byte newLocationConfig); +uint8_t serialHelper_convertOldSerialConfig(uint8_t newLocationConfig); diff --git a/src/src/Helpers/_Plugin_SensorTypeHelper.cpp b/src/src/Helpers/_Plugin_SensorTypeHelper.cpp index eebae55bc..637101367 100644 --- a/src/src/Helpers/_Plugin_SensorTypeHelper.cpp +++ b/src/src/Helpers/_Plugin_SensorTypeHelper.cpp @@ -14,7 +14,7 @@ Only use this function to determine nr of output values when changing output type of a task To get the actual output values for a task, use getValueCountForTask \*********************************************************************************************/ -byte getValueCountFromSensorType(Sensor_VType sensorType) +uint8_t getValueCountFromSensorType(Sensor_VType sensorType) { switch (sensorType) { @@ -66,22 +66,22 @@ const __FlashStringHelper * getSensorTypeLabel(Sensor_VType sensorType) { return F(""); } -void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, byte pconfigIndex) +void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, uint8_t pconfigIndex) { - byte optionValues[12]; + uint8_t optionValues[12]; - optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); - optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM); - optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_BARO); - optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM_BARO); - optionValues[4] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); - optionValues[5] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); - optionValues[6] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); - optionValues[7] = static_cast(Sensor_VType::SENSOR_TYPE_SWITCH); - optionValues[8] = static_cast(Sensor_VType::SENSOR_TYPE_DIMMER); - optionValues[9] = static_cast(Sensor_VType::SENSOR_TYPE_LONG); - optionValues[10] = static_cast(Sensor_VType::SENSOR_TYPE_WIND); - optionValues[11] = static_cast(Sensor_VType::SENSOR_TYPE_STRING); + optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); + optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM); + optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_BARO); + optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_TEMP_HUM_BARO); + optionValues[4] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); + optionValues[5] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); + optionValues[6] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); + optionValues[7] = static_cast(Sensor_VType::SENSOR_TYPE_SWITCH); + optionValues[8] = static_cast(Sensor_VType::SENSOR_TYPE_DIMMER); + optionValues[9] = static_cast(Sensor_VType::SENSOR_TYPE_LONG); + optionValues[10] = static_cast(Sensor_VType::SENSOR_TYPE_WIND); + optionValues[11] = static_cast(Sensor_VType::SENSOR_TYPE_STRING); sensorTypeHelper_webformLoad(event, pconfigIndex, 11, optionValues); } @@ -90,19 +90,19 @@ void sensorTypeHelper_webformLoad_header() addFormSubHeader(F("Output Configuration")); } -void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, byte pconfigIndex) +void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, uint8_t pconfigIndex) { sensorTypeHelper_webformLoad_header(); - byte optionValues[4]; - optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); - optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); - optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); - optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); + uint8_t optionValues[4]; + optionValues[0] = static_cast(Sensor_VType::SENSOR_TYPE_SINGLE); + optionValues[1] = static_cast(Sensor_VType::SENSOR_TYPE_DUAL); + optionValues[2] = static_cast(Sensor_VType::SENSOR_TYPE_TRIPLE); + optionValues[3] = static_cast(Sensor_VType::SENSOR_TYPE_QUAD); sensorTypeHelper_webformLoad(event, pconfigIndex, 4, optionValues); } -void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, int optionCount, const byte options[]) +void sensorTypeHelper_webformLoad(struct EventStruct *event, uint8_t pconfigIndex, int optionCount, const uint8_t options[]) { if (pconfigIndex >= PLUGIN_CONFIGVAR_MAX) { return; @@ -111,12 +111,12 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(event->TaskIndex); if (!validDeviceIndex(DeviceIndex)) { choice = Sensor_VType::SENSOR_TYPE_NONE; - PCONFIG(pconfigIndex) = static_cast(choice); + PCONFIG(pconfigIndex) = static_cast(choice); } else if (getValueCountFromSensorType(choice) != getValueCountForTask(event->TaskIndex)) { // Invalid value checkDeviceVTypeForTask(event); choice = event->sensorType; - PCONFIG(pconfigIndex) = static_cast(choice); + PCONFIG(pconfigIndex) = static_cast(choice); } String outputTypeLabel = F("Output Data Type"); if (Device[DeviceIndex].OutputDataType == Output_Data_type_t::Simple) { @@ -130,7 +130,7 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, default: { choice = Device[DeviceIndex].VType; - PCONFIG(pconfigIndex) = static_cast(choice); + PCONFIG(pconfigIndex) = static_cast(choice); break; } } @@ -139,7 +139,7 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, addRowLabel(outputTypeLabel); addSelector_Head(PCONFIG_LABEL(pconfigIndex)); - for (byte x = 0; x < optionCount; x++) + for (uint8_t x = 0; x < optionCount; x++) { String name = getSensorTypeLabel(static_cast(options[x])); addSelector_Item(name, @@ -156,7 +156,7 @@ void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, } } -void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, byte pconfigIndex, byte valueIndex, const String& defaultValueName) +void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, uint8_t pconfigIndex, uint8_t valueIndex, const String& defaultValueName) { if (defaultValueName.equals(ExtraTaskSettings.TaskDeviceValueNames[valueIndex])) { ZERO_FILL(ExtraTaskSettings.TaskDeviceValueNames[valueIndex]); @@ -164,16 +164,16 @@ void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, byte pconfig pconfig_webformSave(event, pconfigIndex); } -void pconfig_webformSave(struct EventStruct *event, byte pconfigIndex) +void pconfig_webformSave(struct EventStruct *event, uint8_t pconfigIndex) { PCONFIG(pconfigIndex) = getFormItemInt(PCONFIG_LABEL(pconfigIndex), 0); } void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const __FlashStringHelper * options[], const int indices[]) { - byte choice = PCONFIG(pconfigIndex); + uint8_t choice = PCONFIG(pconfigIndex); String label = F("Value "); label += (valuenr + 1); @@ -182,10 +182,10 @@ void sensorTypeHelper_loadOutputSelector( void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const String options[], const int indices[]) { - byte choice = PCONFIG(pconfigIndex); + uint8_t choice = PCONFIG(pconfigIndex); String label = F("Value "); label += (valuenr + 1); diff --git a/src/src/Helpers/_Plugin_SensorTypeHelper.h b/src/src/Helpers/_Plugin_SensorTypeHelper.h index d9e3c1ebd..83d2a3ee9 100644 --- a/src/src/Helpers/_Plugin_SensorTypeHelper.h +++ b/src/src/Helpers/_Plugin_SensorTypeHelper.h @@ -11,28 +11,28 @@ Only use this function to determine nr of output values when changing output type of a task To get the actual output values for a task, use getValueCountForTask \*********************************************************************************************/ -byte getValueCountFromSensorType(Sensor_VType sensorType); +uint8_t getValueCountFromSensorType(Sensor_VType sensorType); const __FlashStringHelper * getSensorTypeLabel(Sensor_VType sensorType); -void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, byte pconfigIndex); +void sensorTypeHelper_webformLoad_allTypes(struct EventStruct *event, uint8_t pconfigIndex); void sensorTypeHelper_webformLoad_header(); -void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, byte pconfigIndex); +void sensorTypeHelper_webformLoad_simple(struct EventStruct *event, uint8_t pconfigIndex); -void sensorTypeHelper_webformLoad(struct EventStruct *event, byte pconfigIndex, int optionCount, const byte options[]); +void sensorTypeHelper_webformLoad(struct EventStruct *event, uint8_t pconfigIndex, int optionCount, const uint8_t options[]); -void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, byte pconfigIndex, byte valueIndex, const String& defaultValueName); +void sensorTypeHelper_saveOutputSelector(struct EventStruct *event, uint8_t pconfigIndex, uint8_t valueIndex, const String& defaultValueName); -void pconfig_webformSave(struct EventStruct *event, byte pconfigIndex); +void pconfig_webformSave(struct EventStruct *event, uint8_t pconfigIndex); void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const __FlashStringHelper * options[], const int indices[] = NULL); void sensorTypeHelper_loadOutputSelector( - struct EventStruct *event, byte pconfigIndex, byte valuenr, + struct EventStruct *event, uint8_t pconfigIndex, uint8_t valuenr, int optionCount, const String options[], const int indices[] = NULL); diff --git a/src/src/PluginStructs/P004_data_struct.cpp b/src/src/PluginStructs/P004_data_struct.cpp index ea84c1a28..a847acab7 100644 --- a/src/src/PluginStructs/P004_data_struct.cpp +++ b/src/src/PluginStructs/P004_data_struct.cpp @@ -30,7 +30,7 @@ void P004_data_struct::add_addr(const uint8_t addr[], uint8_t index) { bool P004_data_struct::initiate_read() { _measurementStart = millis(); - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (_sensors[i].initiate_read(_gpio_rx, _gpio_tx, _res)) { if (!measurement_active()) { // Set the timer right after initiating the first sensor @@ -58,7 +58,7 @@ bool P004_data_struct::initiate_read() { bool P004_data_struct::collect_values() { bool success = false; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { if (_sensors[i].collect_value(_gpio_rx, _gpio_tx)) { success = true; } diff --git a/src/src/PluginStructs/P012_data_struct.cpp b/src/src/PluginStructs/P012_data_struct.cpp index 804c9b086..d5e7db1ab 100644 --- a/src/src/PluginStructs/P012_data_struct.cpp +++ b/src/src/PluginStructs/P012_data_struct.cpp @@ -9,7 +9,7 @@ P012_data_struct::P012_data_struct(uint8_t addr, uint8_t lcd_size, uint8_t mode, - byte timer) : + uint8_t timer) : lcd(addr, 20, 4), Plugin_012_mode(mode), displayTimer(timer) { @@ -38,7 +38,7 @@ P012_data_struct::P012_data_struct(uint8_t addr, createCustomChars(); } -void P012_data_struct::setBacklightTimer(byte timer) { +void P012_data_struct::setBacklightTimer(uint8_t timer) { displayTimer = timer; lcd.backlight(); } @@ -54,12 +54,12 @@ void P012_data_struct::checkTimer() { } } -void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { +void P012_data_struct::lcdWrite(const String& text, uint8_t col, uint8_t row) { // clear line before writing new string if (Plugin_012_mode == 2) { lcd.setCursor(col, row); - for (byte i = col; i < Plugin_012_cols; i++) { + for (uint8_t i = col; i < Plugin_012_cols; i++) { lcd.print(" "); } } @@ -69,7 +69,7 @@ void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { if ((Plugin_012_mode == 1) || (Plugin_012_mode == 2)) { lcd.setCursor(col, row); - for (byte i = 0; i < Plugin_012_cols - col; i++) { + for (uint8_t i = 0; i < Plugin_012_cols - col; i++) { if (text[i]) { lcd.print(text[i]); } @@ -80,7 +80,7 @@ void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { else { // Fix Weird (native) lcd display behaviour that split long string into row 1,3,2,4, instead of 1,2,3,4 bool stillProcessing = 1; - byte charCount = 1; + uint8_t charCount = 1; while (stillProcessing) { if (++col > Plugin_012_cols) { // have we printed 20 characters yet (+1 for the logic) @@ -107,7 +107,7 @@ void P012_data_struct::lcdWrite(const String& text, byte col, byte row) { // Perform some specific changes for LCD display // https://www.letscontrolit.com/forum/viewtopic.php?t=2368 -String P012_data_struct::P012_parseTemplate(String& tmpString, byte lineSize) { +String P012_data_struct::P012_parseTemplate(String& tmpString, uint8_t lineSize) { String result = parseTemplate_padded(tmpString, lineSize); const char degree[3] = { 0xc2, 0xb0, 0 }; // Unicode degree symbol const char degree_lcd[2] = { 0xdf, 0 }; // P012_LCD degree symbol diff --git a/src/src/PluginStructs/P012_data_struct.h b/src/src/PluginStructs/P012_data_struct.h index 95fb5d6c1..658e46df2 100644 --- a/src/src/PluginStructs/P012_data_struct.h +++ b/src/src/PluginStructs/P012_data_struct.h @@ -11,17 +11,17 @@ struct P012_data_struct : public PluginTaskData_base { P012_data_struct(uint8_t addr, uint8_t lcd_size, uint8_t mode, - byte timer); + uint8_t timer); - void setBacklightTimer(byte timer); + void setBacklightTimer(uint8_t timer); void checkTimer(); void lcdWrite(const String& text, - byte col, - byte row); + uint8_t col, + uint8_t row); - String P012_parseTemplate(String& tmpString, byte lineSize); + String P012_parseTemplate(String& tmpString, uint8_t lineSize); void createCustomChars(); @@ -30,7 +30,7 @@ struct P012_data_struct : public PluginTaskData_base { int Plugin_012_cols = 16; int Plugin_012_rows = 2; int Plugin_012_mode = 1; - byte displayTimer = 0; + uint8_t displayTimer = 0; }; #endif // ifdef USES_P012 diff --git a/src/src/PluginStructs/P015_data_struct.cpp b/src/src/PluginStructs/P015_data_struct.cpp index 461f23cd2..dc3d4c0bd 100644 --- a/src/src/PluginStructs/P015_data_struct.cpp +++ b/src/src/PluginStructs/P015_data_struct.cpp @@ -12,7 +12,7 @@ # define TSL2561_REG_DATA_1 0x0E -P015_data_struct::P015_data_struct(byte i2caddr, unsigned int gain, byte integration) : +P015_data_struct::P015_data_struct(uint8_t i2caddr, unsigned int gain, uint8_t integration) : _gain(gain), _i2cAddr(i2caddr), _integration(integration) @@ -138,7 +138,7 @@ bool P015_data_struct::readByte(unsigned char address, unsigned char& value) // Read requested byte if (_error == 0) { - Wire.requestFrom(_i2cAddr, (byte)1); + Wire.requestFrom(_i2cAddr, (uint8_t)1); if (Wire.available() == 1) { @@ -188,7 +188,7 @@ bool P015_data_struct::readUInt(unsigned char address, unsigned int& value) // Read two bytes (low and high) if (_error == 0) { - Wire.requestFrom(_i2cAddr, (byte)2); + Wire.requestFrom(_i2cAddr, (uint8_t)2); if (Wire.available() == 2) { diff --git a/src/src/PluginStructs/P015_data_struct.h b/src/src/PluginStructs/P015_data_struct.h index 5c31836cf..9c1b1493e 100644 --- a/src/src/PluginStructs/P015_data_struct.h +++ b/src/src/PluginStructs/P015_data_struct.h @@ -16,9 +16,9 @@ # define P015_EXT_AUTO_GAIN 3 struct P015_data_struct : public PluginTaskData_base { - P015_data_struct(byte i2caddr, + P015_data_struct(uint8_t i2caddr, unsigned int gain, - byte integration); + uint8_t integration); bool begin(); @@ -125,9 +125,9 @@ struct P015_data_struct : public PluginTaskData_base { unsigned int _gain; // Gain setting, 0 = X1, 1 = X16, 2 = auto, 3 = extended auto; - byte _i2cAddr = 0; - byte _integration = 0; - byte _error = 0; + uint8_t _i2cAddr = 0; + uint8_t _integration = 0; + uint8_t _error = 0; bool _gain16xActive = false; }; diff --git a/src/src/PluginStructs/P020_data_struct.cpp b/src/src/PluginStructs/P020_data_struct.cpp index b8fada952..e88481dc2 100644 --- a/src/src/PluginStructs/P020_data_struct.cpp +++ b/src/src/PluginStructs/P020_data_struct.cpp @@ -111,7 +111,7 @@ void P020_Task::clearBuffer() { serial_buffer.reserve(P020_DATAGRAM_MAX_SIZE); } -void P020_Task::serialBegin(const ESPEasySerialPort port, int16_t rxPin, int16_t txPin, unsigned long baud, byte config) { +void P020_Task::serialBegin(const ESPEasySerialPort port, int16_t rxPin, int16_t txPin, unsigned long baud, uint8_t config) { serialEnd(); if (rxPin >= 0) { diff --git a/src/src/PluginStructs/P020_data_struct.h b/src/src/PluginStructs/P020_data_struct.h index f687ae284..3b9bcd716 100644 --- a/src/src/PluginStructs/P020_data_struct.h +++ b/src/src/PluginStructs/P020_data_struct.h @@ -36,7 +36,7 @@ struct P020_Task : public PluginTaskData_base { int16_t rxPin, int16_t txPin, unsigned long baud, - byte config); + uint8_t config); void serialEnd(); @@ -58,7 +58,7 @@ struct P020_Task : public PluginTaskData_base { String net_buffer; int checkI = 0; ESPeasySerial *ser2netSerial = nullptr; - byte serial_processing = 0; + uint8_t serial_processing = 0; taskIndex_t _taskIndex = INVALID_TASK_INDEX; }; diff --git a/src/src/PluginStructs/P022_data_struct.cpp b/src/src/PluginStructs/P022_data_struct.cpp index b36636457..3e59d26b3 100644 --- a/src/src/PluginStructs/P022_data_struct.cpp +++ b/src/src/PluginStructs/P022_data_struct.cpp @@ -41,7 +41,7 @@ bool P022_data_struct::p022_clear_init(uint8_t address) { // ******************************************************************************** // PCA9685 config // ******************************************************************************** -void P022_data_struct::Plugin_022_writeRegister(int i2cAddress, int regAddress, byte data) { +void P022_data_struct::Plugin_022_writeRegister(int i2cAddress, int regAddress, uint8_t data) { Wire.beginTransmission(i2cAddress); Wire.write(regAddress); Wire.write(data); @@ -96,7 +96,7 @@ void P022_data_struct::Plugin_022_Frequency(int address, uint16_t freq) { int i2cAddress = address; - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)0x0); + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)0x0); freq *= 0.9; // prescale = 25000000 / 4096; @@ -107,11 +107,11 @@ void P022_data_struct::Plugin_022_Frequency(int address, uint16_t freq) uint8_t oldmode = Plugin_022_readRegister(i2cAddress, 0); uint8_t newmode = (oldmode & 0x7f) | 0x10; - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)newmode); - Plugin_022_writeRegister(i2cAddress, 0xfe, (byte)prescale); // prescale register - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)oldmode); + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)newmode); + Plugin_022_writeRegister(i2cAddress, 0xfe, (uint8_t)prescale); // prescale register + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)oldmode); delayMicroseconds(5000); - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)oldmode | 0xa1); + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)oldmode | 0xa1); } void P022_data_struct::Plugin_022_initialize(int address) @@ -119,10 +119,10 @@ void P022_data_struct::Plugin_022_initialize(int address) int i2cAddress = address; // default mode is open drain output, drive leds connected to VCC - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)0x01); // reset the device + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)0x01); // reset the device delay(1); - Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (byte)B10100000); // set up for auto increment - // Plugin_022_writeRegister(i2cAddress, PCA9685_MODE2, (byte)0x10); // set to output + Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)B10100000); // set up for auto increment + // Plugin_022_writeRegister(i2cAddress, PCA9685_MODE2, (uint8_t)0x10); // set to output p022_set_init(address); } diff --git a/src/src/PluginStructs/P022_data_struct.h b/src/src/PluginStructs/P022_data_struct.h index e76c8476c..3778d124a 100644 --- a/src/src/PluginStructs/P022_data_struct.h +++ b/src/src/PluginStructs/P022_data_struct.h @@ -16,7 +16,7 @@ # define PCA9685_MAX_PWM 4095 # define PCA9685_MIN_FREQUENCY 23.0 // Min possible PWM cycle frequency # define PCA9685_MAX_FREQUENCY 1500.0 // Max possible PWM cycle frequency -# define PCA9685_ALLLED_REG (byte)0xFA +# define PCA9685_ALLLED_REG (uint8_t)0xFA // FIXME TD-er: This still uses a bitmask to keep track of what address was initialized. // That's no longer needed as it is now a data struct object per task instead of per address. @@ -31,7 +31,7 @@ struct P022_data_struct : public PluginTaskData_base { void Plugin_022_writeRegister(int i2cAddress, int regAddress, - byte data); + uint8_t data); uint8_t Plugin_022_readRegister(int i2cAddress, int regAddress); diff --git a/src/src/PluginStructs/P023_data_struct.cpp b/src/src/PluginStructs/P023_data_struct.cpp index 596628743..6dd95e99b 100644 --- a/src/src/PluginStructs/P023_data_struct.cpp +++ b/src/src/PluginStructs/P023_data_struct.cpp @@ -205,11 +205,11 @@ const char Plugin_023_myFont[][8] PROGMEM = { }; -P023_data_struct::P023_data_struct(byte _address, byte _type, P023_data_struct::Spacing _font_spacing, byte _displayTimer,byte _use_sh1106) +P023_data_struct::P023_data_struct(uint8_t _address, uint8_t _type, P023_data_struct::Spacing _font_spacing, uint8_t _displayTimer,uint8_t _use_sh1106) : address(_address), type(_type), font_spacing(_font_spacing), displayTimer(_displayTimer), use_sh1106(_use_sh1106) {} -void P023_data_struct::setDisplayTimer(byte _displayTimer) { +void P023_data_struct::setDisplayTimer(uint8_t _displayTimer) { displayOn(); displayTimer = _displayTimer; } @@ -226,7 +226,7 @@ void P023_data_struct::checkDisplayTimer() { } // Perform some specific changes for OLED display -String P023_data_struct::parseTemplate(String& tmpString, byte lineSize) { +String P023_data_struct::parseTemplate(String& tmpString, uint8_t lineSize) { String result = parseTemplate_padded(tmpString, lineSize); const char degree[3] = { 0xc2, 0xb0, 0 }; // Unicode degree symbol const char degree_oled[2] = { 0x7F, 0 }; // P023_OLED degree symbol diff --git a/src/src/PluginStructs/P023_data_struct.h b/src/src/PluginStructs/P023_data_struct.h index 5d1b50678..e05eef006 100644 --- a/src/src/PluginStructs/P023_data_struct.h +++ b/src/src/PluginStructs/P023_data_struct.h @@ -23,17 +23,17 @@ struct P023_data_struct : public PluginTaskData_base { optimized = 0x02 }; - P023_data_struct(byte _address, - byte _type, + P023_data_struct(uint8_t _address, + uint8_t _type, Spacing _font_spacing, - byte _displayTimer, - byte _use_sh1106); + uint8_t _displayTimer, + uint8_t _use_sh1106); - void setDisplayTimer(byte _displayTimer); + void setDisplayTimer(uint8_t _displayTimer); void checkDisplayTimer(); String parseTemplate(String& tmpString, - byte lineSize); + uint8_t lineSize); void resetDisplay(); @@ -72,11 +72,11 @@ struct P023_data_struct : public PluginTaskData_base { void init_OLED(); - byte address = 0; - byte type = 0; + uint8_t address = 0; + uint8_t type = 0; Spacing font_spacing = Spacing::normal; - byte displayTimer = 0; - byte use_sh1106 = 0; + uint8_t displayTimer = 0; + uint8_t use_sh1106 = 0; }; diff --git a/src/src/PluginStructs/P028_data_struct.cpp b/src/src/PluginStructs/P028_data_struct.cpp index d59dc9aa5..f564fa5ee 100644 --- a/src/src/PluginStructs/P028_data_struct.cpp +++ b/src/src/PluginStructs/P028_data_struct.cpp @@ -16,7 +16,7 @@ P028_data_struct::P028_data_struct(uint8_t addr) : state(BMx_Uninitialized) {} -byte P028_data_struct::get_config_settings() const { +uint8_t P028_data_struct::get_config_settings() const { switch (sensorID) { case BMP280_DEVICE_SAMPLE1: case BMP280_DEVICE_SAMPLE2: @@ -26,7 +26,7 @@ byte P028_data_struct::get_config_settings() const { } } -byte P028_data_struct::get_control_settings() const { +uint8_t P028_data_struct::get_control_settings() const { switch (sensorID) { case BMP280_DEVICE_SAMPLE1: case BMP280_DEVICE_SAMPLE2: diff --git a/src/src/PluginStructs/P028_data_struct.h b/src/src/PluginStructs/P028_data_struct.h index c1c275a78..bed32b746 100644 --- a/src/src/PluginStructs/P028_data_struct.h +++ b/src/src/PluginStructs/P028_data_struct.h @@ -106,9 +106,9 @@ enum BMx_state { struct P028_data_struct : public PluginTaskData_base { P028_data_struct(uint8_t addr); - byte get_config_settings() const; + uint8_t get_config_settings() const; - byte get_control_settings() const; + uint8_t get_control_settings() const; String getFullDeviceName() const; diff --git a/src/src/PluginStructs/P044_data_struct.cpp b/src/src/PluginStructs/P044_data_struct.cpp index 1e9d6d130..b16fe7b59 100644 --- a/src/src/PluginStructs/P044_data_struct.cpp +++ b/src/src/PluginStructs/P044_data_struct.cpp @@ -214,7 +214,7 @@ bool P044_Task::validP1char(char ch) { } void P044_Task::serialBegin(const ESPEasySerialPort port, int16_t rxPin, int16_t txPin, - unsigned long baud, byte config) { + unsigned long baud, uint8_t config) { serialEnd(); if (rxPin >= 0) { diff --git a/src/src/PluginStructs/P044_data_struct.h b/src/src/PluginStructs/P044_data_struct.h index 009d2dec2..62469d5c8 100644 --- a/src/src/PluginStructs/P044_data_struct.h +++ b/src/src/PluginStructs/P044_data_struct.h @@ -17,7 +17,7 @@ struct P044_Task : public PluginTaskData_base { - enum class ParserState : byte { + enum class ParserState : uint8_t { WAITING, READING, CHECKSUM @@ -73,7 +73,7 @@ struct P044_Task : public PluginTaskData_base { int16_t rxPin, int16_t txPin, unsigned long baud, - byte config); + uint8_t config); void serialEnd(); diff --git a/src/src/PluginStructs/P062_data_struct.cpp b/src/src/PluginStructs/P062_data_struct.cpp index 407c9c67c..52b47f3e0 100644 --- a/src/src/PluginStructs/P062_data_struct.cpp +++ b/src/src/PluginStructs/P062_data_struct.cpp @@ -58,7 +58,7 @@ bool P062_data_struct::readKey(uint16_t& key) { { uint16_t colMask = 0x01; - for (byte col = 1; col <= 12; col++) + for (uint8_t col = 1; col <= 12; col++) { if (key & colMask) // this key pressed? { diff --git a/src/src/PluginStructs/P079_data_struct.cpp b/src/src/PluginStructs/P079_data_struct.cpp index 3aa89e897..3cfb84efd 100644 --- a/src/src/PluginStructs/P079_data_struct.cpp +++ b/src/src/PluginStructs/P079_data_struct.cpp @@ -49,10 +49,10 @@ WemosMotor::WemosMotor(uint8_t address, uint8_t motor, uint32_t freq, uint8_t ST void WemosMotor::setfreq(uint32_t freq) { Wire.beginTransmission(_address); - Wire.write(((byte)(freq >> 24)) & (byte)0x0f); - Wire.write((byte)(freq >> 16)); - Wire.write((byte)(freq >> 8)); - Wire.write((byte)freq); + Wire.write(((uint8_t)(freq >> 24)) & (uint8_t)0x0f); + Wire.write((uint8_t)(freq >> 16)); + Wire.write((uint8_t)(freq >> 8)); + Wire.write((uint8_t)freq); Wire.endTransmission(); // stop transmitting delay(0); } @@ -92,7 +92,7 @@ void WemosMotor::setmotor(uint8_t dir, float pwm_val) } Wire.beginTransmission(_address); - Wire.write(_motor | (byte)0x10); // CMD either 0x10 or 0x11 + Wire.write(_motor | (uint8_t)0x10); // CMD either 0x10 or 0x11 Wire.write(dir); // PWM in % @@ -102,8 +102,8 @@ void WemosMotor::setmotor(uint8_t dir, float pwm_val) _pwm_val = 10000; } - Wire.write((byte)(_pwm_val >> 8)); - Wire.write((byte)_pwm_val); + Wire.write((uint8_t)(_pwm_val >> 8)); + Wire.write((uint8_t)_pwm_val); Wire.endTransmission(); // stop transmitting delay(0); diff --git a/src/src/PluginStructs/P082_data_struct.h b/src/src/PluginStructs/P082_data_struct.h index 44945a576..7c814f3bc 100644 --- a/src/src/PluginStructs/P082_data_struct.h +++ b/src/src/PluginStructs/P082_data_struct.h @@ -15,7 +15,7 @@ # define P082_DEFAULT_FIX_TIMEOUT 2500 // TTL of fix status in ms since last update -enum class P082_query : byte { +enum class P082_query : uint8_t { P082_QUERY_LONG = 0, P082_QUERY_LAT = 1, P082_QUERY_ALT = 2, @@ -83,7 +83,7 @@ struct P082_data_struct : public PluginTaskData_base { String _currentSentence; # endif // ifdef P082_SEND_GPS_TO_LOG - float _cache[static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)] = { 0 }; + float _cache[static_cast(P082_query::P082_NR_OUTPUT_OPTIONS)] = { 0 }; }; #endif // ifdef USES_P082 diff --git a/src/src/PluginStructs/P087_data_struct.cpp b/src/src/PluginStructs/P087_data_struct.cpp index d68301a02..7ca2fb353 100644 --- a/src/src/PluginStructs/P087_data_struct.cpp +++ b/src/src/PluginStructs/P087_data_struct.cpp @@ -160,7 +160,7 @@ void P087_data_struct::setMaxLength(uint16_t maxlenght) { max_length = maxlenght; } -void P087_data_struct::setLine(byte varNr, const String& line) { +void P087_data_struct::setLine(uint8_t varNr, const String& line) { if (varNr < P87_Nlines) { _lines[varNr] = line; } @@ -247,7 +247,7 @@ static std::vector capture_vector; // called for each match void P087_data_struct::match_callback(const char *match, const unsigned int length, const MatchState& ms) { - for (byte i = 0; i < ms.level; i++) + for (uint8_t i = 0; i < ms.level; i++) { capture_tuple tuple; tuple.first = i; diff --git a/src/src/PluginStructs/P087_data_struct.h b/src/src/PluginStructs/P087_data_struct.h index d450d8f52..e069da493 100644 --- a/src/src/PluginStructs/P087_data_struct.h +++ b/src/src/PluginStructs/P087_data_struct.h @@ -71,7 +71,7 @@ public: void setMaxLength(uint16_t maxlenght); - void setLine(byte varNr, + void setLine(uint8_t varNr, const String& line); String getRegEx() const; diff --git a/src/src/PluginStructs/P090_data_struct.cpp b/src/src/PluginStructs/P090_data_struct.cpp index ab70a7a55..90d704557 100644 --- a/src/src/PluginStructs/P090_data_struct.cpp +++ b/src/src/PluginStructs/P090_data_struct.cpp @@ -153,7 +153,7 @@ CCS811Core::status CCS811Core::multiWriteRegister(uint8_t offset, uint8_t *input while (i < length) // send data bytes { - Wire.write(*inputPointer); // receive a byte as character + Wire.write(*inputPointer); // receive a uint8_t as character inputPointer++; i++; } @@ -416,7 +416,7 @@ CCS811Core::status CCS811::setEnvironmentalData(float relativeHumidity, float te uint32_t rH = relativeHumidity * 1000; // 42.348 becomes 42348 uint32_t temp = temperature * 1000; // 23.2 becomes 23200 - byte envData[4]; + uint8_t envData[4]; //Split value into 7-bit integer and 9-bit fractional diff --git a/src/src/PluginStructs/P094_data_struct.cpp b/src/src/PluginStructs/P094_data_struct.cpp index c37378104..80e8c0e44 100644 --- a/src/src/PluginStructs/P094_data_struct.cpp +++ b/src/src/PluginStructs/P094_data_struct.cpp @@ -172,7 +172,7 @@ void P094_data_struct::setMaxLength(uint16_t maxlenght) { max_length = maxlenght; } -void P094_data_struct::setLine(byte varNr, const String& line) { +void P094_data_struct::setLine(uint8_t varNr, const String& line) { if (varNr < P94_Nlines) { _lines[varNr] = line; } diff --git a/src/src/PluginStructs/P094_data_struct.h b/src/src/PluginStructs/P094_data_struct.h index c3ea2de3e..d5d22fc69 100644 --- a/src/src/PluginStructs/P094_data_struct.h +++ b/src/src/PluginStructs/P094_data_struct.h @@ -85,7 +85,7 @@ public: void setMaxLength(uint16_t maxlenght); - void setLine(byte varNr, + void setLine(uint8_t varNr, const String& line); diff --git a/src/src/PluginStructs/P099_data_struct.h b/src/src/PluginStructs/P099_data_struct.h index e8aa4c21b..769432f73 100644 --- a/src/src/PluginStructs/P099_data_struct.h +++ b/src/src/PluginStructs/P099_data_struct.h @@ -82,7 +82,7 @@ struct P099_data_struct : public PluginTaskData_base struct tP099_Touchobjects { char objectname[P099_MaxObjectNameLength] = { 0 }; - byte flags = 0; + uint8_t flags = 0; tP099_Point top_left; tP099_Point bottom_right; }; diff --git a/src/src/PluginStructs/P111_data_struct.cpp b/src/src/PluginStructs/P111_data_struct.cpp index d214535bf..913f4a77f 100644 --- a/src/src/PluginStructs/P111_data_struct.cpp +++ b/src/src/PluginStructs/P111_data_struct.cpp @@ -8,7 +8,7 @@ #include -P111_data_struct::P111_data_struct(byte csPin, byte rstPin) : mfrc522(nullptr), _csPin(csPin), _rstPin(rstPin) +P111_data_struct::P111_data_struct(uint8_t csPin, uint8_t rstPin) : mfrc522(nullptr), _csPin(csPin), _rstPin(rstPin) {} void P111_data_struct::init() { @@ -21,9 +21,9 @@ void P111_data_struct::init() { /** * read status and tag */ -byte P111_data_struct::readCardStatus(unsigned long *key, bool *removedTag) { +uint8_t P111_data_struct::readCardStatus(unsigned long *key, bool *removedTag) { - byte error = 0; + uint8_t error = 0; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; uint8_t uidLength; @@ -103,7 +103,7 @@ bool P111_data_struct::reset(int8_t csPin, int8_t resetPin) { if (result) { //String log = F("RC522: Found"); // Get the MFRC522 software version - byte v = mfrc522->PCD_ReadRegister(mfrc522->VersionReg); + uint8_t v = mfrc522->PCD_ReadRegister(mfrc522->VersionReg); // When 0x00 or 0xFF is returned, communication probably failed if ((v == 0x00) || (v == 0xFF)) { @@ -129,7 +129,7 @@ bool P111_data_struct::reset(int8_t csPin, int8_t resetPin) { /*********************************************************************************************\ * RC522 read tag ID \*********************************************************************************************/ -byte P111_data_struct::readPassiveTargetID(uint8_t *uid, uint8_t *uidLength) { //needed ? see above (not PN532) +uint8_t P111_data_struct::readPassiveTargetID(uint8_t *uid, uint8_t *uidLength) { //needed ? see above (not PN532) // Getting ready for Reading PICCs if ( ! mfrc522->PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue return 2; @@ -139,9 +139,9 @@ byte P111_data_struct::readPassiveTargetID(uint8_t *uid, uint8_t *uidLength) { / return 1; } - // There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC - // I think we should assume every PICC as they have 4 byte UID - // Until we support 7 byte PICCs + // There are Mifare PICCs which have 4 uint8_t or 7 uint8_t UID care if you use 7 uint8_t PICC + // I think we should assume every PICC as they have 4 uint8_t UID + // Until we support 7 uint8_t PICCs addLog(LOG_LEVEL_INFO, F("MFRC522: Scanned PICC's UID")); for (uint8_t i = 0; i < 4; i++) { // uid[i] = mfrc522->uid.uidByte[i]; diff --git a/src/src/PluginStructs/P111_data_struct.h b/src/src/PluginStructs/P111_data_struct.h index 1f3387a68..45f6ed66a 100644 --- a/src/src/PluginStructs/P111_data_struct.h +++ b/src/src/PluginStructs/P111_data_struct.h @@ -8,23 +8,23 @@ struct P111_data_struct : public PluginTaskData_base { - P111_data_struct(byte csPin, byte rstPin); + P111_data_struct(uint8_t csPin, uint8_t rstPin); void init(); - byte readCardStatus(unsigned long *key, bool *removedTag); + uint8_t readCardStatus(unsigned long *key, bool *removedTag); String getCardName(); MFRC522 *mfrc522; - byte counter = 0; + uint8_t counter = 0; private: bool reset(int8_t csPin, int8_t resetPin); - byte readPassiveTargetID(uint8_t *uid, uint8_t *uidLength); + uint8_t readPassiveTargetID(uint8_t *uid, uint8_t *uidLength); - byte _csPin; - byte _rstPin; + uint8_t _csPin; + uint8_t _rstPin; - byte errorCount = 0; + uint8_t errorCount = 0; bool removedState = true; // On startup, there will usually not be a tag nearby }; diff --git a/src/src/PluginStructs/P112_data_struct.h b/src/src/PluginStructs/P112_data_struct.h index f98c2d8a8..e1a71a606 100644 --- a/src/src/PluginStructs/P112_data_struct.h +++ b/src/src/PluginStructs/P112_data_struct.h @@ -26,7 +26,7 @@ struct P112_data_struct : public PluginTaskData_base { // MeasurementStatus: // 0 : Not running // 1 - 18 : Running - byte MeasurementStatus = 0; + uint8_t MeasurementStatus = 0; }; #endif // ifdef USES_P112 diff --git a/src/src/WebServer/AdvancedConfigPage.cpp b/src/src/WebServer/AdvancedConfigPage.cpp index 1d4a19c7b..db21c0772 100644 --- a/src/src/WebServer/AdvancedConfigPage.cpp +++ b/src/src/WebServer/AdvancedConfigPage.cpp @@ -18,7 +18,7 @@ #ifdef WEBSERVER_ADVANCED -void setLogLevelFor(byte destination, LabelType::Enum label) { +void setLogLevelFor(uint8_t destination, LabelType::Enum label) { setLogLevelFor(destination, getFormItemInt(getInternalLabel(label))); } diff --git a/src/src/WebServer/CacheControllerPages.cpp b/src/src/WebServer/CacheControllerPages.cpp index d4e123612..cbf4a200f 100644 --- a/src/src/WebServer/CacheControllerPages.cpp +++ b/src/src/WebServer/CacheControllerPages.cpp @@ -24,10 +24,10 @@ void handle_dumpcache() { C016_startCSVdump(); unsigned long timestamp; - byte controller_idx; - byte TaskIndex; + uint8_t controller_idx; + uint8_t TaskIndex; Sensor_VType sensorType; - byte valueCount; + uint8_t valueCount; float val1; float val2; float val3; @@ -62,7 +62,7 @@ void handle_dumpcache() { html += ';'; html += controller_idx; html += ';'; - html += static_cast(sensorType); + html += static_cast(sensorType); html += ';'; html += TaskIndex; html += ';'; diff --git a/src/src/WebServer/ConfigPage.cpp b/src/src/WebServer/ConfigPage.cpp index c05da53cd..fbce37616 100644 --- a/src/src/WebServer/ConfigPage.cpp +++ b/src/src/WebServer/ConfigPage.cpp @@ -95,7 +95,7 @@ void handle_config() { IPAddress low, high; getSubnetRange(low, high); - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { SecuritySettings.AllowedIPrangeLow[i] = low[i]; SecuritySettings.AllowedIPrangeHigh[i] = high[i]; } @@ -164,10 +164,10 @@ void handle_config() { { IPAddress low, high; getIPallowedRange(low, high); - byte iplow[4]; - byte iphigh[4]; + uint8_t iplow[4]; + uint8_t iphigh[4]; - for (byte i = 0; i < 4; ++i) { + for (uint8_t i = 0; i < 4; ++i) { iplow[i] = low[i]; iphigh[i] = high[i]; } diff --git a/src/src/WebServer/ControllerPage.cpp b/src/src/WebServer/ControllerPage.cpp index e24342cf9..5d5a4ef5f 100644 --- a/src/src/WebServer/ControllerPage.cpp +++ b/src/src/WebServer/ControllerPage.cpp @@ -37,7 +37,7 @@ void handle_controllers() { TXBuffer.startStream(); sendHeadandTail_stdtemplate(_HEAD); - byte controllerindex = getFormItemInt(F("index"), 0); + uint8_t controllerindex = getFormItemInt(F("index"), 0); boolean controllerNotSet = controllerindex == 0; --controllerindex; // Index in URL is starting from 1, but starting from 0 in the array. @@ -123,7 +123,7 @@ void handle_controllers() { // Selected controller has changed. // Clear all Controller settings and load some defaults // ******************************************************************************** -void handle_controllers_clearLoadDefaults(byte controllerindex, ControllerSettingsStruct& ControllerSettings) +void handle_controllers_clearLoadDefaults(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings) { // Protocol has changed and it was not an empty one. // reset (some) default-settings @@ -162,7 +162,7 @@ void handle_controllers_clearLoadDefaults(byte controllerindex, ControllerSettin // ******************************************************************************** // Collect all submitted form data and store in the ControllerSettings // ******************************************************************************** -void handle_controllers_CopySubmittedSettings(byte controllerindex, ControllerSettingsStruct& ControllerSettings) +void handle_controllers_CopySubmittedSettings(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings) { // copy all settings to controller settings struct for (int parameterIdx = 0; parameterIdx <= ControllerSettingsStruct::CONTROLLER_ENABLED; ++parameterIdx) { @@ -171,7 +171,7 @@ void handle_controllers_CopySubmittedSettings(byte controllerindex, ControllerSe } } -void handle_controllers_CopySubmittedSettings_CPluginCall(byte controllerindex) { +void handle_controllers_CopySubmittedSettings_CPluginCall(uint8_t controllerindex) { protocolIndex_t ProtocolIndex = getProtocolIndex_from_ControllerIndex(controllerindex); if (validProtocolIndex(ProtocolIndex)) { @@ -275,11 +275,11 @@ void handle_controllers_ControllerSettingsPage(controllerIndex_t controllerindex html_table_class_normal(); addFormHeader(F("Controller Settings")); addRowLabel(F("Protocol")); - byte choice = Settings.Protocol[controllerindex]; + uint8_t choice = Settings.Protocol[controllerindex]; addSelector_Head_reloadOnChange(F("protocol")); addSelector_Item(F("- Standalone -"), 0, false, false, EMPTY_STRING); - for (byte x = 0; x <= protocolCount; x++) + for (uint8_t x = 0; x <= protocolCount; x++) { boolean disabled = false; // !((controllerindex == 0) || !Protocol[x].usesMQTT); addSelector_Item(getCPluginNameFromProtocolIndex(x), diff --git a/src/src/WebServer/ControllerPage.h b/src/src/WebServer/ControllerPage.h index c9834ac9f..7c9e495b0 100644 --- a/src/src/WebServer/ControllerPage.h +++ b/src/src/WebServer/ControllerPage.h @@ -20,14 +20,14 @@ void handle_controllers(); // Selected controller has changed. // Clear all Controller settings and load some defaults // ******************************************************************************** -void handle_controllers_clearLoadDefaults(byte controllerindex, ControllerSettingsStruct& ControllerSettings); +void handle_controllers_clearLoadDefaults(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings); // ******************************************************************************** // Collect all submitted form data and store in the ControllerSettings // ******************************************************************************** -void handle_controllers_CopySubmittedSettings(byte controllerindex, ControllerSettingsStruct& ControllerSettings); +void handle_controllers_CopySubmittedSettings(uint8_t controllerindex, ControllerSettingsStruct& ControllerSettings); -void handle_controllers_CopySubmittedSettings_CPluginCall(byte controllerindex); +void handle_controllers_CopySubmittedSettings_CPluginCall(uint8_t controllerindex); // ******************************************************************************** // Show table with all selected controllers diff --git a/src/src/WebServer/CustomPage.cpp b/src/src/WebServer/CustomPage.cpp index 50b4bc33a..b7d7518a3 100644 --- a/src/src/WebServer/CustomPage.cpp +++ b/src/src/WebServer/CustomPage.cpp @@ -54,8 +54,8 @@ boolean handle_custom(String path) { if (dashboardPage) // for the dashboard page, create a default unit dropdown selector { // handle page redirects to other unit's as requested by the unit dropdown selector - byte unit = getFormItemInt(F("unit")); - byte btnunit = getFormItemInt(F("btnunit")); + uint8_t unit = getFormItemInt(F("unit")); + uint8_t btnunit = getFormItemInt(F("btnunit")); if (!unit) { unit = btnunit; // unit element prevails, if not used then set to btnunit } @@ -83,7 +83,7 @@ boolean handle_custom(String path) { // create unit selector dropdown addSelector_Head_reloadOnChange(F("unit")); - byte choice = Settings.Unit; + uint8_t choice = Settings.Unit; for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { @@ -103,11 +103,11 @@ boolean handle_custom(String path) { addSelector_Foot(); // create <> navigation buttons - byte prev = Settings.Unit; - byte next = Settings.Unit; + uint8_t prev = Settings.Unit; + uint8_t next = Settings.Unit; NodesMap::iterator it; - for (byte x = Settings.Unit - 1; x > 0; x--) { + for (uint8_t x = Settings.Unit - 1; x > 0; x--) { it = Nodes.find(x); if (it != Nodes.end()) { @@ -115,7 +115,7 @@ boolean handle_custom(String path) { } } - for (byte x = Settings.Unit + 1; x < UNIT_NUMBER_MAX; x++) { + for (uint8_t x = Settings.Unit + 1; x < UNIT_NUMBER_MAX; x++) { it = Nodes.find(x); if (it != Nodes.end()) { @@ -179,9 +179,9 @@ boolean handle_custom(String path) { html_TR_TD(); addHtml(ExtraTaskSettings.TaskDeviceName); - const byte valueCount = getValueCountForTask(x); + const uint8_t valueCount = getValueCountForTask(x); - for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) { if ((varNr < valueCount) && (ExtraTaskSettings.TaskDeviceValueNames[varNr][0] != 0)) diff --git a/src/src/WebServer/DevicesPage.cpp b/src/src/WebServer/DevicesPage.cpp index f33d70072..226340c16 100644 --- a/src/src/WebServer/DevicesPage.cpp +++ b/src/src/WebServer/DevicesPage.cpp @@ -71,7 +71,7 @@ void handle_devices() { // String taskdeviceglobalsync = webArg(F("TDGS")); // String taskdeviceenabled = webArg(F("TDE")); - // for (byte varNr = 0; varNr < VARS_PER_TASK; varNr++) + // for (uint8_t varNr = 0; varNr < VARS_PER_TASK; varNr++) // { // char argc[25]; // String arg = F("TDF"); @@ -104,12 +104,12 @@ void handle_devices() { // taskdevicesenddata[controllerNr] = webArg(argc); // } - byte page = getFormItemInt(F("page"), 0); + uint8_t page = getFormItemInt(F("page"), 0); if (page == 0) { page = 1; } - byte setpage = getFormItemInt(F("setpage"), 0); + uint8_t setpage = getFormItemInt(F("setpage"), 0); if (setpage > 0) { @@ -201,7 +201,7 @@ void addDeviceSelect(const __FlashStringHelper * name, int choice) addSelector_Head_reloadOnChange(name); addSelector_Item(F("- None -"), 0, false); - for (byte x = 0; x <= deviceCount; x++) + for (uint8_t x = 0; x <= deviceCount; x++) { const deviceIndex_t deviceIndex = DeviceIndex_sorted[x]; @@ -302,9 +302,9 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task // nr output values has changed, generate new variable names String oldNames[VARS_PER_TASK]; - byte oldNrDec[VARS_PER_TASK]; + uint8_t oldNrDec[VARS_PER_TASK]; - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { oldNames[i] = ExtraTaskSettings.TaskDeviceValueNames[i]; oldNrDec[i] = ExtraTaskSettings.TaskDeviceValueDecimals[i]; } @@ -313,7 +313,7 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task PluginCall(PLUGIN_GET_DEVICEVALUENAMES, &TempEvent, dummy); // Restore the settings that were already set by the user - for (byte i = 0; i < VARS_PER_TASK; ++i) { + for (uint8_t i = 0; i < VARS_PER_TASK; ++i) { if (!oldNames[i].isEmpty()) { safe_strncpy(ExtraTaskSettings.TaskDeviceValueNames[i], oldNames[i], sizeof(ExtraTaskSettings.TaskDeviceValueNames[i])); ExtraTaskSettings.TaskDeviceValueDecimals[i] = oldNrDec[i]; @@ -361,9 +361,9 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task # endif // ifdef PLUGIN_USES_SERIAL } - const byte valueCount = getValueCountForTask(taskIndex); + const uint8_t valueCount = getValueCountForTask(taskIndex); - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { strncpy_webserver_arg(ExtraTaskSettings.TaskDeviceFormula[varNr], String(F("TDF")) + (varNr + 1)); update_whenset_FormItemInt(String(F("TDVD")) + (varNr + 1), ExtraTaskSettings.TaskDeviceValueDecimals[varNr]); @@ -413,7 +413,7 @@ void Label_Gpio_toHtml(const __FlashStringHelper * label, const String& gpio_pin // ******************************************************************************** // Show table with all selected Tasks/Devices // ******************************************************************************** -void handle_devicess_ShowAllTasksTable(byte page) +void handle_devicess_ShowAllTasksTable(uint8_t page) { serve_JS(JSfiles_e::UpdateSensorValuesDevicePage); html_table_class_multirow(); @@ -521,7 +521,7 @@ void handle_devicess_ShowAllTasksTable(byte page) if (validDeviceIndex(DeviceIndex)) { if (Settings.TaskDeviceDataFeed[x] != 0) { // Show originating node number - const byte remoteUnit = Settings.TaskDeviceDataFeed[x]; + const uint8_t remoteUnit = Settings.TaskDeviceDataFeed[x]; format_originating_node(remoteUnit); } else { String portDescr; @@ -715,9 +715,9 @@ void handle_devicess_ShowAllTasksTable(byte page) if (!customValues) { - const byte valueCount = getValueCountForTask(x); + const uint8_t valueCount = getValueCountForTask(x); - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { if (validPluginID_fullcheck(Settings.TaskDeviceNumber[x])) { @@ -735,7 +735,7 @@ void handle_devicess_ShowAllTasksTable(byte page) html_end_form(); } -void format_originating_node(byte remoteUnit) { +void format_originating_node(uint8_t remoteUnit) { addHtml(F("Unit ")); addHtmlInt(remoteUnit); @@ -831,7 +831,7 @@ void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x) // ******************************************************************************** // Show the task settings page // ******************************************************************************** -void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, byte page) +void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page) { if (!validTaskIndex(taskIndex)) { return; } const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(taskIndex); @@ -932,7 +932,7 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, byte page) else { // Show remote feed information. addFormSubHeader(F("Data Source")); - byte remoteUnit = Settings.TaskDeviceDataFeed[taskIndex]; + uint8_t remoteUnit = Settings.TaskDeviceDataFeed[taskIndex]; addFormNumericBox(F("Remote Unit"), F("RemoteUnit"), remoteUnit, 0, 255); if (remoteUnit != 255) { @@ -1224,7 +1224,7 @@ void devicePage_show_interval_config(taskIndex_t taskIndex, deviceIndex_t Device void devicePage_show_task_values(taskIndex_t taskIndex, deviceIndex_t DeviceIndex) { // section: Values - const byte valueCount = getValueCountForTask(taskIndex); + const uint8_t valueCount = getValueCountForTask(taskIndex); if (!Device[DeviceIndex].Custom && (valueCount > 0)) { @@ -1247,7 +1247,7 @@ void devicePage_show_task_values(taskIndex_t taskIndex, deviceIndex_t DeviceInde } // table body - for (byte varNr = 0; varNr < valueCount; varNr++) + for (uint8_t varNr = 0; varNr < valueCount; varNr++) { html_TR_TD(); addHtmlInt(varNr + 1); diff --git a/src/src/WebServer/DevicesPage.h b/src/src/WebServer/DevicesPage.h index 1a67d02e8..79c96b503 100644 --- a/src/src/WebServer/DevicesPage.h +++ b/src/src/WebServer/DevicesPage.h @@ -34,9 +34,9 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task // ******************************************************************************** // Show table with all selected Tasks/Devices // ******************************************************************************** -void handle_devicess_ShowAllTasksTable(byte page); +void handle_devicess_ShowAllTasksTable(uint8_t page); -void format_originating_node(byte remoteUnit); +void format_originating_node(uint8_t remoteUnit); void format_I2C_port_description(taskIndex_t x); @@ -51,7 +51,7 @@ void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x); // ******************************************************************************** // Show the task settings page // ******************************************************************************** -void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, byte page); +void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page); void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex); diff --git a/src/src/WebServer/I2C_Scanner.cpp b/src/src/WebServer/I2C_Scanner.cpp index 0ffb27cbc..b6aa9f6b5 100644 --- a/src/src/WebServer/I2C_Scanner.cpp +++ b/src/src/WebServer/I2C_Scanner.cpp @@ -26,7 +26,7 @@ int scanI2CbusForDevices_json( // Utility function for scanning the I2C bus for , i2c_addresses_t &excludeDevices #endif ) { - byte error, address; + uint8_t error, address; for (address = 1; address <= 127; address++) { @@ -143,7 +143,7 @@ void handle_i2cscanner_json() { #endif // WEBSERVER_NEW_UI -String getKnownI2Cdevice(byte address) { +String getKnownI2Cdevice(uint8_t address) { String result; #ifndef LIMIT_BUILD_SIZE @@ -266,7 +266,7 @@ int scanI2CbusForDevices( // Utility function for scanning the I2C bus for valid , i2c_addresses_t &excludeDevices #endif ) { - byte error, address; + uint8_t error, address; for (address = 1; address <= 127; address++) { diff --git a/src/src/WebServer/I2C_Scanner.h b/src/src/WebServer/I2C_Scanner.h index 4819bb198..fff7e273e 100644 --- a/src/src/WebServer/I2C_Scanner.h +++ b/src/src/WebServer/I2C_Scanner.h @@ -30,7 +30,7 @@ void handle_i2cscanner_json(); #endif // WEBSERVER_NEW_UI -String getKnownI2Cdevice(byte address); +String getKnownI2Cdevice(uint8_t address); int scanI2CbusForDevices( // Utility function for scanning the I2C bus for valid devices, with HTML table output int8_t muxAddr diff --git a/src/src/WebServer/JSON.cpp b/src/src/WebServer/JSON.cpp index 7c0a165a7..8723f872f 100644 --- a/src/src/WebServer/JSON.cpp +++ b/src/src/WebServer/JSON.cpp @@ -59,13 +59,13 @@ void handle_csvval() if (validDeviceIndex(DeviceIndex)) { LoadTaskSettings(taskNr); - const byte taskValCount = getValueCountForTask(taskNr); + const uint8_t taskValCount = getValueCountForTask(taskNr); uint16_t stringReserveSize = (valNr == INVALID_VALUE_NUM ? 1 : taskValCount) * 24; htmlData.reserve(stringReserveSize); if (printHeader) { - for (byte x = 0; x < taskValCount; x++) + for (uint8_t x = 0; x < taskValCount; x++) { if (valNr == INVALID_VALUE_NUM || valNr == x) { @@ -81,7 +81,7 @@ void handle_csvval() htmlData = ""; } - for (byte x = 0; x < taskValCount; x++) + for (uint8_t x = 0; x < taskValCount; x++) { if ((valNr == INVALID_VALUE_NUM) || (valNr == x)) { @@ -336,7 +336,7 @@ void handle_json() unsigned long ttl_json = 60; // Default value // For simplicity, do the optional values first. - const byte valueCount = getValueCountForTask(TaskIndex); + const uint8_t valueCount = getValueCountForTask(TaskIndex); if (valueCount != 0) { if ((taskInterval > 0) && Settings.TaskDeviceEnabled[TaskIndex]) { @@ -348,11 +348,11 @@ void handle_json() } addHtml(F("\"TaskValues\": [\n")); - for (byte x = 0; x < valueCount; x++) + for (uint8_t x = 0; x < valueCount; x++) { addHtml('{'); const String value = formatUserVarNoCheck(TaskIndex, x); - byte nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[x]; + uint8_t nrDecimals = ExtraTaskSettings.TaskDeviceValueDecimals[x]; if (mustConsiderAsString(value)) { // Flag as not to treat as a float @@ -527,7 +527,7 @@ void handle_buildinfo() { { json_open(true, F("notifications")); - for (byte x = 0; x < NPLUGIN_MAX; x++) { + for (uint8_t x = 0; x < NPLUGIN_MAX; x++) { if (validNPluginID(NPlugin_id[x])) { json_open(); json_number(F("id"), String(x + 1)); diff --git a/src/src/WebServer/Log.cpp b/src/src/WebServer/Log.cpp index ae0973841..52115c080 100644 --- a/src/src/WebServer/Log.cpp +++ b/src/src/WebServer/Log.cpp @@ -55,7 +55,7 @@ void handle_log_JSON() { if (webrequest == F("legend")) { addHtml(F("\"Legend\": [")); - for (byte i = 0; i < LOG_LEVEL_NRELEMENTS; ++i) { + for (uint8_t i = 0; i < LOG_LEVEL_NRELEMENTS; ++i) { if (i != 0) { addHtml(','); } @@ -74,7 +74,7 @@ void handle_log_JSON() { while (logLinesAvailable) { String message; - byte loglevel; + uint8_t loglevel; if (Logging.getNext(logLinesAvailable, lastTimeStamp, message, loglevel)) { addHtml('{'); stream_next_json_object_value(F("timestamp"), String(lastTimeStamp)); diff --git a/src/src/WebServer/Markup.cpp b/src/src/WebServer/Markup.cpp index 459b85297..16c0a6e7e 100644 --- a/src/src/WebServer/Markup.cpp +++ b/src/src/WebServer/Markup.cpp @@ -103,7 +103,7 @@ void addSelector_options(int optionCount, const __FlashStringHelper *options[], { int index; - for (byte x = 0; x < optionCount; x++) + for (uint8_t x = 0; x < optionCount; x++) { if (indices) { index = indices[x]; @@ -125,7 +125,7 @@ void addSelector_options(int optionCount, const String options[], const int indi { int index; - for (byte x = 0; x < optionCount; x++) + for (uint8_t x = 0; x < optionCount; x++) { if (indices) { index = indices[x]; @@ -549,7 +549,7 @@ void addNumericBox(const String& id, int value, int min, int max) addHtml('>'); } -void addFloatNumberBox(const String& id, float value, float min, float max, byte nrDecimals, float stepsize) +void addFloatNumberBox(const String& id, float value, float min, float max, uint8_t nrDecimals, float stepsize) { String html; @@ -567,7 +567,7 @@ void addFloatNumberBox(const String& id, float value, float min, float max, byte if (stepsize <= 0.0f) { html += F("0."); - for (byte i = 1; i < nrDecimals; ++i) { + for (uint8_t i = 1; i < nrDecimals; ++i) { html += '0'; } html += '1'; diff --git a/src/src/WebServer/Markup.h b/src/src/WebServer/Markup.h index 07eab7906..f5aab4860 100644 --- a/src/src/WebServer/Markup.h +++ b/src/src/WebServer/Markup.h @@ -131,7 +131,7 @@ void addCheckBox(const String& id, boolean checked, bool disabled = false); void addNumericBox(const __FlashStringHelper * id, int value, int min, int max); void addNumericBox(const String& id, int value, int min, int max); -void addFloatNumberBox(const String& id, float value, float min, float max, byte nrDecimals = 6, float stepsize = 0.0f); +void addFloatNumberBox(const String& id, float value, float min, float max, uint8_t nrDecimals = 6, float stepsize = 0.0f); // ******************************************************************************** // Add Textbox diff --git a/src/src/WebServer/Markup_Forms.cpp b/src/src/WebServer/Markup_Forms.cpp index 17d899b50..855ea5141 100644 --- a/src/src/WebServer/Markup_Forms.cpp +++ b/src/src/WebServer/Markup_Forms.cpp @@ -104,11 +104,11 @@ void addFormNumericBox(const String& label, const String& id, int value, int min addNumericBox(id, value, min, max); } -void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, byte nrDecimals, float stepsize) { +void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, uint8_t nrDecimals, float stepsize) { addFormFloatNumberBox(getLabel(label), getInternalLabel(label), value, min, max, nrDecimals, stepsize); } -void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, byte nrDecimals, float stepsize) +void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, uint8_t nrDecimals, float stepsize) { addRowLabel_tr_id(label, id); addFloatNumberBox(id, value, min, max, nrDecimals, stepsize); @@ -190,7 +190,7 @@ bool getFormPassword(const String& id, String& password) // Add a IP Box form // ******************************************************************************** -void addFormIPBox(const String& label, const String& id, const byte ip[4]) +void addFormIPBox(const String& label, const String& id, const uint8_t ip[4]) { bool empty_IP = (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0); @@ -240,7 +240,7 @@ void addFormSelectorI2C(const String& id, int addressCount, const int addresses[ addRowLabel_tr_id(F("I2C Address"), id); do_addSelector_Head(id, EMPTY_STRING, EMPTY_STRING, false); - for (byte x = 0; x < addressCount; x++) + for (uint8_t x = 0; x < addressCount; x++) { String option = formatToHex_decimal(addresses[x]); @@ -442,7 +442,7 @@ bool update_whenset_FormItemInt(const String& key, int& value) { return false; } -bool update_whenset_FormItemInt(const String& key, byte& value) { +bool update_whenset_FormItemInt(const String& key, uint8_t& value) { int tmpVal; if (getCheckWebserverArg_int(key, tmpVal)) { diff --git a/src/src/WebServer/Markup_Forms.h b/src/src/WebServer/Markup_Forms.h index becd65d73..c2ec65599 100644 --- a/src/src/WebServer/Markup_Forms.h +++ b/src/src/WebServer/Markup_Forms.h @@ -41,8 +41,8 @@ void addFormNumericBox(LabelType::Enum label, int value, int min = INT_MIN, int void addFormNumericBox(const __FlashStringHelper * label, const __FlashStringHelper * id, int value, int min = INT_MIN, int max = INT_MAX); void addFormNumericBox(const String& label, const String& id, int value, int min = INT_MIN, int max = INT_MAX); -void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, byte nrDecimals = 6, float stepsize = 0.0f); -void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, byte nrDecimals = 6, float stepsize = 0.0f); +void addFormFloatNumberBox(LabelType::Enum label, float value, float min, float max, uint8_t nrDecimals = 6, float stepsize = 0.0f); +void addFormFloatNumberBox(const String& label, const String& id, float value, float min, float max, uint8_t nrDecimals = 6, float stepsize = 0.0f); // ******************************************************************************** // Add a task selector form @@ -90,7 +90,7 @@ bool getFormPassword(const String& id, String& password); // Add a IP Box form // ******************************************************************************** -void addFormIPBox(const String& label, const String& id, const byte ip[4]); +void addFormIPBox(const String& label, const String& id, const uint8_t ip[4]); // ******************************************************************************** // Add a IP Access Control select dropdown list @@ -184,7 +184,7 @@ bool getCheckWebserverArg_int(const String& key, int& value); bool update_whenset_FormItemInt(const String& key, int& value); -bool update_whenset_FormItemInt(const String& key, byte& value); +bool update_whenset_FormItemInt(const String& key, uint8_t& value); // Note: Checkbox values will not appear in POST Form data if unchecked. // So if webserver does not have an argument for a checkbox form, it means it should be considered unchecked. diff --git a/src/src/WebServer/NotificationPage.cpp b/src/src/WebServer/NotificationPage.cpp index 84067875c..fef28387f 100644 --- a/src/src/WebServer/NotificationPage.cpp +++ b/src/src/WebServer/NotificationPage.cpp @@ -41,7 +41,7 @@ void handle_notifications() { // char tmpString[64]; - byte notificationindex = getFormItemInt(F("index"), 0); + uint8_t notificationindex = getFormItemInt(F("index"), 0); boolean notificationindexNotSet = notificationindex == 0; --notificationindex; @@ -81,7 +81,7 @@ void handle_notifications() { } // Save the settings. - addHtmlError(SaveNotificationSettings(notificationindex, (byte *)&NotificationSettings, sizeof(NotificationSettingsStruct))); + addHtmlError(SaveNotificationSettings(notificationindex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct))); addHtmlError(SaveSettings()); if (web_server.hasArg(F("test"))) { @@ -112,9 +112,9 @@ void handle_notifications() { MakeNotificationSettings(NotificationSettings); - for (byte x = 0; x < NOTIFICATION_MAX; x++) + for (uint8_t x = 0; x < NOTIFICATION_MAX; x++) { - LoadNotificationSettings(x, (byte *)&NotificationSettings, sizeof(NotificationSettingsStruct)); + LoadNotificationSettings(x, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct)); NotificationSettings.validate(); html_TR_TD(); html_add_button_prefix(); @@ -130,7 +130,7 @@ void handle_notifications() { addEnabled(Settings.NotificationEnabled[x]); html_TD(); - byte NotificationProtocolIndex = getNProtocolIndex(Settings.Notification[x]); + uint8_t NotificationProtocolIndex = getNProtocolIndex(Settings.Notification[x]); String NotificationName = F("(plugin not found?)"); if (validNProtocolIndex(NotificationProtocolIndex)) @@ -155,11 +155,11 @@ void handle_notifications() { html_table_class_normal(); addFormHeader(F("Notification Settings")); addRowLabel(F("Notification")); - byte choice = Settings.Notification[notificationindex]; + uint8_t choice = Settings.Notification[notificationindex]; addSelector_Head_reloadOnChange(F("notification")); addSelector_Item(F("- None -"), 0, false); - for (byte x = 0; x <= notificationCount; x++) + for (uint8_t x = 0; x <= notificationCount; x++) { String NotificationName; NPlugin_ptr[x](NPlugin::Function::NPLUGIN_GET_DEVICENAME, 0, NotificationName); @@ -174,7 +174,7 @@ void handle_notifications() { if (Settings.Notification[notificationindex]) { MakeNotificationSettings(NotificationSettings); - LoadNotificationSettings(notificationindex, (byte *)&NotificationSettings, sizeof(NotificationSettingsStruct)); + LoadNotificationSettings(notificationindex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct)); NotificationSettings.validate(); nprotocolIndex_t NotificationProtocolIndex = getNProtocolIndex_from_NotifierIndex(notificationindex); diff --git a/src/src/WebServer/Rules.cpp b/src/src/WebServer/Rules.cpp index 201bcfa3d..df38755da 100644 --- a/src/src/WebServer/Rules.cpp +++ b/src/src/WebServer/Rules.cpp @@ -31,7 +31,7 @@ void handle_rules() { if (!isLoggedIn() || !Settings.UseRules) { return; } navMenuIndex = MENU_INDEX_RULES; - const byte rulesSet = getFormItemInt(F("set"), 1); + const uint8_t rulesSet = getFormItemInt(F("set"), 1); # if defined(ESP8266) String fileName = F("rules"); @@ -69,11 +69,11 @@ void handle_rules() { addHtml(F("
")); { // Place combo box in its own scope to release these arrays as soon as possible - byte choice = rulesSet; + uint8_t choice = rulesSet; String options[RULESETS_MAX]; int optionValues[RULESETS_MAX]; - for (byte x = 0; x < RULESETS_MAX; x++) + for (uint8_t x = 0; x < RULESETS_MAX; x++) { options[x] = F("Rules Set "); options[x] += x + 1; diff --git a/src/src/WebServer/SetupPage.cpp b/src/src/WebServer/SetupPage.cpp index 585688e7b..7918f0b45 100644 --- a/src/src/WebServer/SetupPage.cpp +++ b/src/src/WebServer/SetupPage.cpp @@ -76,8 +76,8 @@ void handle_setup() { } else { // if (active_network_medium == NetworkMedium_t::WIFI) // { - static byte status = HANDLE_SETUP_SCAN_STAGE; - static byte refreshCount = 0; + static uint8_t status = HANDLE_SETUP_SCAN_STAGE; + static uint8_t refreshCount = 0; String ssid = webArg(F("ssid")); String other = webArg(F("other")); @@ -364,7 +364,7 @@ void handle_setup_scan_and_show(const String& ssid, const String& other, const S html_end_table(); } -bool handle_setup_connectingStage(byte refreshCount) { +bool handle_setup_connectingStage(uint8_t refreshCount) { if (refreshCount > 0) { // safe_strncpy(SecuritySettings.WifiSSID, "ssid", sizeof(SecuritySettings.WifiSSID)); diff --git a/src/src/WebServer/SetupPage.h b/src/src/WebServer/SetupPage.h index 52359534f..8c82cfef6 100644 --- a/src/src/WebServer/SetupPage.h +++ b/src/src/WebServer/SetupPage.h @@ -14,7 +14,7 @@ void handle_setup(); void handle_setup_scan_and_show(const String& ssid, const String& other, const String& password); -bool handle_setup_connectingStage(byte refreshCount); +bool handle_setup_connectingStage(uint8_t refreshCount); #endif // ifdef WEBSERVER_SETUP diff --git a/src/src/WebServer/UploadPage.cpp b/src/src/WebServer/UploadPage.cpp index ad03c577c..845d8aaa8 100644 --- a/src/src/WebServer/UploadPage.cpp +++ b/src/src/WebServer/UploadPage.cpp @@ -132,8 +132,8 @@ void handleFileUpload() { for (unsigned int x = 0; x < sizeof(struct TempStruct); x++) { - byte b = upload.buf[x]; - memcpy((byte *)&Temp + x, &b, 1); + uint8_t b = upload.buf[x]; + memcpy((uint8_t *)&Temp + x, &b, 1); } if ((Temp.Version == VERSION) && (Temp.PID == ESP_PROJECT_PID)) { diff --git a/src/src/WebServer/WebServer.cpp b/src/src/WebServer/WebServer.cpp index 23aef9387..7d589c675 100644 --- a/src/src/WebServer/WebServer.cpp +++ b/src/src/WebServer/WebServer.cpp @@ -603,10 +603,10 @@ void getErrorNotifications() { // Check checksum of stored settings. } -byte navMenuIndex = MENU_INDEX_MAIN; +uint8_t navMenuIndex = MENU_INDEX_MAIN; // See https://github.com/letscontrolit/ESPEasy/issues/1650 -const __FlashStringHelper * getGpMenuIcon(byte index) { +const __FlashStringHelper * getGpMenuIcon(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return F("⌂"); case MENU_INDEX_CONFIG: return F("⚙"); @@ -620,7 +620,7 @@ const __FlashStringHelper * getGpMenuIcon(byte index) { return F(""); } -const __FlashStringHelper * getGpMenuLabel(byte index) { +const __FlashStringHelper * getGpMenuLabel(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return F("Main"); case MENU_INDEX_CONFIG: return F("Config"); @@ -634,7 +634,7 @@ const __FlashStringHelper * getGpMenuLabel(byte index) { return F(""); } -const __FlashStringHelper * getGpMenuURL(byte index) { +const __FlashStringHelper * getGpMenuURL(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return F("/"); case MENU_INDEX_CONFIG: return F("/config"); @@ -649,7 +649,7 @@ const __FlashStringHelper * getGpMenuURL(byte index) { } -bool GpMenuVisible(byte index) { +bool GpMenuVisible(uint8_t index) { switch (index) { case MENU_INDEX_MAIN: return MENU_INDEX_MAIN_VISIBLE; case MENU_INDEX_CONFIG: return MENU_INDEX_CONFIG_VISIBLE; @@ -683,7 +683,7 @@ void getWebPageTemplateVar(const String& varName) { addHtml(F("