Revert "Code optimization - Change for(uint8_t in for (uint32_t"

This reverts commit 5e1eac3f74.
This commit is contained in:
Theo Arends 2019-06-30 15:56:55 +02:00
parent 5e1eac3f74
commit 30adce5648
69 changed files with 359 additions and 359 deletions

View File

@ -151,7 +151,7 @@ uint32_t GetRtcSettingsCrc(void)
uint32_t crc = 0;
uint8_t *bytes = (uint8_t*)&RtcSettings;
for (uint32_t i = 0; i < sizeof(RTCMEM); i++) {
for (uint16_t i = 0; i < sizeof(RTCMEM); i++) {
crc += bytes[i]*(i+1);
}
return crc;
@ -174,7 +174,7 @@ void RtcSettingsLoad(void)
RtcSettings.valid = RTC_MEM_VALID;
RtcSettings.energy_kWhtoday = Settings.energy_kWhtoday;
RtcSettings.energy_kWhtotal = Settings.energy_kWhtotal;
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
for (uint8_t i = 0; i < MAX_COUNTERS; i++) {
RtcSettings.pulse_counter[i] = Settings.pulse_counter[i];
}
RtcSettings.power = Settings.power;
@ -197,7 +197,7 @@ uint32_t GetRtcRebootCrc(void)
uint32_t crc = 0;
uint8_t *bytes = (uint8_t*)&RtcReboot;
for (uint32_t i = 0; i < sizeof(RTCRBT); i++) {
for (uint16_t i = 0; i < sizeof(RTCRBT); i++) {
crc += bytes[i]*(i+1);
}
return crc;
@ -442,7 +442,7 @@ uint16_t GetSettingsCrc(void)
uint16_t crc = 0;
uint8_t *bytes = (uint8_t*)&Settings;
for (uint32_t i = 0; i < sizeof(SYSCFG); i++) {
for (uint16_t i = 0; i < sizeof(SYSCFG); i++) {
if ((i < 14) || (i > 15)) { crc += bytes[i]*(i+1); } // Skip crc
}
return crc;
@ -526,7 +526,7 @@ void SettingsSave(uint8_t rotate)
#endif // USE_EEPROM
if (!stop_flash_rotate && rotate) {
for (uint32_t i = 1; i < CFG_ROTATES; i++) {
for (uint8_t i = 1; i < CFG_ROTATES; i++) {
ESP.flashEraseSector(settings_location -i); // Delete previous configurations by resetting to 0xFF
delay(1);
}
@ -553,7 +553,7 @@ void SettingsLoad(void)
settings_location = 0;
uint32_t flash_location = SETTINGS_LOCATION +1;
uint16_t cfg_holder = 0;
for (uint32_t i = 0; i < CFG_ROTATES; i++) {
for (uint8_t i = 0; i < CFG_ROTATES; i++) {
flash_location--;
ESP.flashRead(flash_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
@ -694,7 +694,7 @@ void SettingsDefaultSet2(void)
Settings.interlock[0] = 0xFF; // Legacy support using all relays in one interlock group
Settings.module = MODULE;
ModuleDefault(WEMOS);
// for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) { Settings.my_gp.io[i] = GPIO_NONE; }
// for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) { Settings.my_gp.io[i] = GPIO_NONE; }
strlcpy(Settings.friendlyname[0], FRIENDLY_NAME, sizeof(Settings.friendlyname[0]));
strlcpy(Settings.friendlyname[1], FRIENDLY_NAME"2", sizeof(Settings.friendlyname[1]));
strlcpy(Settings.friendlyname[2], FRIENDLY_NAME"3", sizeof(Settings.friendlyname[2]));
@ -710,7 +710,7 @@ void SettingsDefaultSet2(void)
Settings.ledstate = APP_LEDSTATE;
Settings.ledmask = APP_LEDMASK;
Settings.pulse_timer[0] = APP_PULSETIME;
// for (uint32_t i = 1; i < MAX_PULSETIMERS; i++) { Settings.pulse_timer[i] = 0; }
// for (uint8_t i = 1; i < MAX_PULSETIMERS; i++) { Settings.pulse_timer[i] = 0; }
// Serial
Settings.baudrate = APP_BAUDRATE / 1200;
@ -750,7 +750,7 @@ void SettingsDefaultSet2(void)
Settings.param[P_HOLD_TIME] = KEY_HOLD_TIME; // Default 4 seconds hold time
// Switch
for (uint32_t i = 0; i < MAX_SWITCHES; i++) { Settings.switchmode[i] = SWITCH_MODE; }
for (uint8_t i = 0; i < MAX_SWITCHES; i++) { Settings.switchmode[i] = SWITCH_MODE; }
// MQTT
Settings.flag.mqtt_enabled = MQTT_USE;
@ -785,12 +785,12 @@ void SettingsDefaultSet2(void)
char fingerprint[60];
strlcpy(fingerprint, MQTT_FINGERPRINT1, sizeof(fingerprint));
char *p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
for (uint8_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[0][i] = strtol(p, &p, 16);
}
strlcpy(fingerprint, MQTT_FINGERPRINT2, sizeof(fingerprint));
p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
for (uint8_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[1][i] = strtol(p, &p, 16);
}
Settings.tele_period = TELE_PERIOD;
@ -829,17 +829,17 @@ void SettingsDefaultSet2(void)
Settings.param[P_IR_UNKNOW_THRESHOLD] = IR_RCV_MIN_UNKNOWN_SIZE;
// RF Bridge
// for (uint32_t i = 0; i < 17; i++) { Settings.rf_code[i][0] = 0; }
// for (uint8_t i = 0; i < 17; i++) { Settings.rf_code[i][0] = 0; }
memcpy_P(Settings.rf_code[0], kDefaultRfCode, 9);
// Domoticz
Settings.domoticz_update_timer = DOMOTICZ_UPDATE_TIMER;
// for (uint32_t i = 0; i < MAX_DOMOTICZ_IDX; i++) {
// for (uint8_t i = 0; i < MAX_DOMOTICZ_IDX; i++) {
// Settings.domoticz_relay_idx[i] = 0;
// Settings.domoticz_key_idx[i] = 0;
// Settings.domoticz_switch_idx[i] = 0;
// }
// for (uint32_t i = 0; i < MAX_DOMOTICZ_SNS_IDX; i++) {
// for (uint8_t i = 0; i < MAX_DOMOTICZ_SNS_IDX; i++) {
// Settings.domoticz_sensor_idx[i] = 0;
// }
@ -854,7 +854,7 @@ void SettingsDefaultSet2(void)
// Rules
// Settings.rule_enabled = 0;
// Settings.rule_once = 0;
// for (uint32_t i = 1; i < MAX_RULE_SETS; i++) { Settings.rules[i][0] = '\0'; }
// for (uint8_t i = 1; i < MAX_RULE_SETS; i++) { Settings.rules[i][0] = '\0'; }
Settings.flag2.calc_resolution = CALC_RESOLUTION;
// Home Assistant
@ -872,7 +872,7 @@ void SettingsDefaultSet2(void)
//Settings.flag.decimal_text = 0;
Settings.pwm_frequency = PWM_FREQ;
Settings.pwm_range = PWM_RANGE;
for (uint32_t i = 0; i < MAX_PWMS; i++) {
for (uint8_t i = 0; i < MAX_PWMS; i++) {
Settings.light_color[i] = 255;
// Settings.pwm_value[i] = 0;
}
@ -901,8 +901,8 @@ void SettingsDefaultSet2(void)
strlcpy(Settings.ntp_server[0], NTP_SERVER1, sizeof(Settings.ntp_server[0]));
strlcpy(Settings.ntp_server[1], NTP_SERVER2, sizeof(Settings.ntp_server[1]));
strlcpy(Settings.ntp_server[2], NTP_SERVER3, sizeof(Settings.ntp_server[2]));
for (uint32_t j = 0; j < 3; j++) {
for (uint32_t i = 0; i < strlen(Settings.ntp_server[j]); i++) {
for (uint8_t j = 0; j < 3; j++) {
for (uint8_t i = 0; i < strlen(Settings.ntp_server[j]); i++) {
if (Settings.ntp_server[j][i] == ',') {
Settings.ntp_server[j][i] = '.';
}
@ -915,7 +915,7 @@ void SettingsDefaultSet2(void)
Settings.button_debounce = KEY_DEBOUNCE_TIME;
Settings.switch_debounce = SWITCH_DEBOUNCE_TIME;
for (uint32_t j = 0; j < 5; j++) {
for (uint8_t j = 0; j < 5; j++) {
Settings.rgbwwTable[j] = 255;
}
@ -996,7 +996,7 @@ void SettingsDefaultSet_5_13_1c(void)
void SettingsDefaultWebColor(void)
{
char scolor[10];
for (uint32_t i = 0; i < COL_LAST; i++) {
for (uint8_t i = 0; i < COL_LAST; i++) {
WebHexCode(i, GetTextIndexed(scolor, sizeof(scolor), i, kWebColors));
}
}
@ -1008,7 +1008,7 @@ void SettingsDelta(void)
if (Settings.version != VERSION) { // Fix version dependent changes
if (Settings.version < 0x05050000) {
for (uint32_t i = 0; i < 17; i++) { Settings.rf_code[i][0] = 0; }
for (uint8_t i = 0; i < 17; i++) { Settings.rf_code[i][0] = 0; }
memcpy_P(Settings.rf_code[0], kDefaultRfCode, 9);
}
if (Settings.version < 0x05080000) {
@ -1030,12 +1030,12 @@ void SettingsDelta(void)
Settings.altitude = 0;
}
if (Settings.version < 0x0508000B) {
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) { // Move GPIO_LEDs
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) { // Move GPIO_LEDs
if ((Settings.my_gp.io[i] >= 25) && (Settings.my_gp.io[i] <= 32)) { // Was GPIO_LED1
Settings.my_gp.io[i] += 23; // Move GPIO_LED1
}
}
for (uint32_t i = 0; i < MAX_PWMS; i++) { // Move pwm_value and reset additional pulse_timerrs
for (uint8_t i = 0; i < MAX_PWMS; i++) { // Move pwm_value and reset additional pulse_timerrs
Settings.pwm_value[i] = Settings.pulse_timer[4 +i];
Settings.pulse_timer[4 +i] = 0;
}
@ -1066,7 +1066,7 @@ void SettingsDelta(void)
char fingerprint[60];
memcpy(fingerprint, Settings.mqtt_fingerprint, sizeof(fingerprint));
char *p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
for (uint8_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[0][i] = strtol(p, &p, 16);
Settings.mqtt_fingerprint[1][i] = Settings.mqtt_fingerprint[0][i];
}
@ -1101,7 +1101,7 @@ void SettingsDelta(void)
SettingsDefaultSet_5_13_1c();
}
if (Settings.version < 0x050E0002) {
for (uint32_t i = 1; i < MAX_RULE_SETS; i++) { Settings.rules[i][0] = '\0'; }
for (uint8_t i = 1; i < MAX_RULE_SETS; i++) { Settings.rules[i][0] = '\0'; }
Settings.rule_enabled = Settings.flag.mqtt_serial_raw; // Was rules_enabled until 5.14.0b
Settings.rule_once = Settings.flag.pressure_conversion; // Was rules_once until 5.14.0b
}
@ -1110,14 +1110,14 @@ void SettingsDelta(void)
Settings.cfg_crc = GetSettingsCrc();
}
if (Settings.version < 0x06000002) {
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
if (i < 4) {
Settings.switchmode[i] = Settings.interlock[i];
} else {
Settings.switchmode[i] = SWITCH_MODE;
}
}
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
if (Settings.my_gp.io[i] >= GPIO_SWT5) { // Move up from GPIO_SWT5 to GPIO_KEY1
Settings.my_gp.io[i] += 4;
}
@ -1136,7 +1136,7 @@ void SettingsDelta(void)
Settings.switch_debounce = SWITCH_DEBOUNCE_TIME;
}
if (Settings.version < 0x0602010A) {
for (uint32_t j = 0; j < 5; j++) {
for (uint8_t j = 0; j < 5; j++) {
Settings.rgbwwTable[j] = 255;
}
}
@ -1160,7 +1160,7 @@ void SettingsDelta(void)
}
if (Settings.version < 0x0604010B) {
Settings.interlock[0] = 0xFF; // Legacy support using all relays in one interlock group
for (uint32_t i = 1; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; }
for (uint8_t i = 1; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; }
}
if (Settings.version < 0x0604010D) {
Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET;

View File

@ -269,7 +269,7 @@ char* GetTopic_P(char *stopic, uint8_t prefix, char *topic, const char* subtopic
fulltopic += F("/");
fulltopic += FPSTR(MQTT_TOKEN_PREFIX); // Need prefix for commands to handle mqtt topic loops
}
for (uint32_t i = 0; i < 3; i++) {
for (uint8_t i = 0; i < 3; i++) {
if ('\0' == Settings.mqtt_prefix[i][0]) {
snprintf_P(Settings.mqtt_prefix[i], sizeof(Settings.mqtt_prefix[i]), kPrefixes[i]);
}
@ -313,7 +313,7 @@ void SetLatchingRelay(power_t lpower, uint8_t state)
latching_relay_pulse = 2; // max 200mS (initiated by stateloop())
}
for (uint32_t i = 0; i < devices_present; i++) {
for (uint8_t i = 0; i < devices_present; i++) {
uint8_t port = (i << 1) + ((latching_power >> i) &1);
if (pin[GPIO_REL1 +port] < 99) {
digitalWrite(pin[GPIO_REL1 +port], bitRead(rel_inverted, port) ? !state : state);
@ -333,10 +333,10 @@ void SetDevicePower(power_t rpower, int source)
}
if (Settings.flag.interlock) { // Allow only one or no relay set
for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) {
for (uint8_t i = 0; i < MAX_INTERLOCKS; i++) {
power_t mask = 1;
uint8_t count = 0;
for (uint32_t j = 0; j < devices_present; j++) {
for (uint8_t j = 0; j < devices_present; j++) {
if ((Settings.interlock[i] & mask) && (rpower & mask)) { count++; }
mask <<= 1;
}
@ -368,7 +368,7 @@ void SetDevicePower(power_t rpower, int source)
SetLatchingRelay(rpower, 1);
}
else {
for (uint32_t i = 0; i < devices_present; i++) {
for (uint8_t i = 0; i < devices_present; i++) {
state = rpower &1;
if ((i < MAX_RELAYS) && (pin[GPIO_REL1 +i] < 99)) {
digitalWrite(pin[GPIO_REL1 +i], bitRead(rel_inverted, i) ? !state : state);
@ -401,7 +401,7 @@ void SetLedPower(uint8_t state)
SetLedPowerIdx(0, state);
} else {
power_t mask = 1;
for (uint32_t i = 0; i < leds_present; i++) { // Map leds to power
for (uint8_t i = 0; i < leds_present; i++) { // Map leds to power
bool tstate = (power & mask);
SetLedPowerIdx(i, tstate);
mask <<= 1;
@ -411,7 +411,7 @@ void SetLedPower(uint8_t state)
void SetLedPowerAll(uint8_t state)
{
for (uint32_t i = 0; i < leds_present; i++) {
for (uint8_t i = 0; i < leds_present; i++) {
SetLedPowerIdx(i, state);
}
}
@ -449,7 +449,7 @@ uint8_t GetFanspeed(void)
void SetFanspeed(uint8_t fanspeed)
{
for (uint32_t i = 0; i < MAX_FAN_SPEED -1; i++) {
for (uint8_t i = 0; i < MAX_FAN_SPEED -1; i++) {
uint8_t state = kIFan02Speed[fanspeed][i];
// uint8_t state = pgm_read_byte(kIFan02Speed +(speed *3) +i);
ExecuteCommandPower(i +2, state, SRC_IGNORE); // Use relay 2, 3 and 4
@ -728,7 +728,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if ((payload >= POWER_ALL_OFF) && (payload <= POWER_ALL_OFF_PULSETIME_ON)) {
Settings.poweronstate = payload;
if (POWER_ALL_ALWAYS_ON == Settings.poweronstate) {
for (uint32_t i = 1; i <= devices_present; i++) {
for (uint8_t i = 1; i <= devices_present; i++) {
ExecuteCommandPower(i, POWER_ON, SRC_IGNORE);
}
}
@ -942,7 +942,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
Settings.module = payload;
SetModuleType();
if (Settings.last_module != payload) {
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
Settings.my_gp.io[i] = GPIO_NONE;
}
}
@ -953,7 +953,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
else if (CMND_MODULES == command_code) {
uint8_t midx = USER_MODULE;
for (uint32_t i = 0; i <= sizeof(kModuleNiceList); i++) {
for (uint8_t i = 0; i <= sizeof(kModuleNiceList); i++) {
if (i > 0) { midx = pgm_read_byte(kModuleNiceList + i -1); }
if (!jsflg) {
Response_P(PSTR("{\"" D_CMND_MODULES "%d\":["), lines);
@ -981,7 +981,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
else if (CMND_ADCS == command_code) {
Response_P(PSTR("{\"" D_CMND_ADCS "\":["));
for (uint32_t i = 0; i < ADC0_END; i++) {
for (uint8_t i = 0; i < ADC0_END; i++) {
if (jsflg) {
ResponseAppend_P(PSTR(","));
}
@ -996,12 +996,12 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
ModuleGpios(&cmodule);
if (ValidGPIO(index, cmodule.io[index]) && (payload >= 0) && (payload < GPIO_SENSOR_END)) {
bool present = false;
for (uint32_t i = 0; i < sizeof(kGpioNiceList); i++) {
for (uint8_t i = 0; i < sizeof(kGpioNiceList); i++) {
uint8_t midx = pgm_read_byte(kGpioNiceList + i);
if (midx == payload) { present = true; }
}
if (present) {
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
if (ValidGPIO(i, cmodule.io[i]) && (Settings.my_gp.io[i] == payload)) {
Settings.my_gp.io[i] = GPIO_NONE;
}
@ -1011,7 +1011,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
}
Response_P(PSTR("{"));
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
if (ValidGPIO(i, cmodule.io[i])) {
if (jsflg) { ResponseAppend_P(PSTR(",")); }
jsflg = true;
@ -1028,7 +1028,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
myio cmodule;
ModuleGpios(&cmodule);
uint8_t midx;
for (uint32_t i = 0; i < sizeof(kGpioNiceList); i++) {
for (uint8_t i = 0; i < sizeof(kGpioNiceList); i++) {
midx = pgm_read_byte(kGpioNiceList + i);
if (!GetUsedInModule(midx, cmodule.io)) {
if (!jsflg) {
@ -1070,7 +1070,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
snprintf_P(Settings.user_template.name, sizeof(Settings.user_template.name), PSTR("Merged"));
uint8_t j = 0;
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
if (my_module.io[j] > GPIO_NONE) {
@ -1109,7 +1109,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
else if (CMND_PWMRANGE == command_code) {
if ((1 == payload) || ((payload > 254) && (payload < 1024))) {
Settings.pwm_range = (1 == payload) ? PWM_RANGE : payload;
for (uint32_t i = 0; i < MAX_PWMS; i++) {
for (uint8_t i = 0; i < MAX_PWMS; i++) {
if (Settings.pwm_value[i] > Settings.pwm_range) {
Settings.pwm_value[i] = Settings.pwm_range;
}
@ -1173,7 +1173,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
Serial.printf("%s\n", dataBuf); // "Hello Tiger\n"
}
else if (2 == index || 4 == index) {
for (uint32_t i = 0; i < data_len; i++) {
for (uint16_t i = 0; i < data_len; i++) {
Serial.write(dataBuf[i]); // "Hello Tiger" or "A0"
}
}
@ -1317,7 +1317,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if (max_relays > 1) { // Only interlock with more than 1 relay
if (data_len > 0) {
if (strstr(dataBuf, ",") != nullptr) { // Interlock entry
for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; } // Reset current interlocks
for (uint8_t i = 0; i < MAX_INTERLOCKS; i++) { Settings.interlock[i] = 0; } // Reset current interlocks
char *group;
char *q;
uint8_t group_index = 0;
@ -1336,9 +1336,9 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
group_index++;
}
for (uint32_t i = 0; i < group_index; i++) {
for (uint8_t i = 0; i < group_index; i++) {
uint8_t minimal_bits = 0;
for (uint32_t j = 0; j < max_relays; j++) {
for (uint8_t j = 0; j < max_relays; j++) {
if (bitRead(Settings.interlock[i], j)) { minimal_bits++; }
}
if (minimal_bits < 2) { Settings.interlock[i] = 0; } // Discard single relay as interlock
@ -1352,13 +1352,13 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
Response_P(PSTR("{\"" D_CMND_INTERLOCK "\":\"%s\",\"" D_JSON_GROUPS "\":\""), GetStateText(Settings.flag.interlock));
uint8_t anygroup = 0;
for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) {
for (uint8_t i = 0; i < MAX_INTERLOCKS; i++) {
if (Settings.interlock[i]) {
anygroup++;
ResponseAppend_P(PSTR("%s"), (anygroup > 1) ? " " : "");
uint8_t anybit = 0;
power_t mask = 1;
for (uint32_t j = 0; j < max_relays; j++) {
for (uint8_t j = 0; j < max_relays; j++) {
if (Settings.interlock[i] & mask) {
anybit++;
ResponseAppend_P(PSTR("%s%d"), (anybit > 1) ? "," : "", j +1);
@ -1368,7 +1368,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
}
}
if (!anygroup) {
for (uint32_t j = 1; j <= max_relays; j++) {
for (uint8_t j = 1; j <= max_relays; j++) {
ResponseAppend_P(PSTR("%s%d"), (j > 1) ? "," : "", j);
}
}
@ -1687,9 +1687,9 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
if (Settings.flag.interlock && !interlock_mutex) { // Clear all but masked relay in interlock group
interlock_mutex = true;
for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) {
for (uint8_t i = 0; i < MAX_INTERLOCKS; i++) {
if (Settings.interlock[i] & mask) { // Find interlock group
for (uint32_t j = 0; j < devices_present; j++) {
for (uint8_t j = 0; j < devices_present; j++) {
power_t imask = 1 << j;
if ((Settings.interlock[i] & imask) && (power & imask) && (mask != imask)) {
ExecuteCommandPower(j +1, POWER_OFF, SRC_IGNORE);
@ -1749,7 +1749,7 @@ void StopAllPowerBlink(void)
{
power_t mask;
for (uint32_t i = 1; i <= devices_present; i++) {
for (uint8_t i = 1; i <= devices_present; i++) {
mask = 1 << (i -1);
if (blink_mask & mask) {
blink_mask &= (POWER_MASK ^ mask); // Clear device mask
@ -1813,11 +1813,11 @@ void PublishStatus(uint8_t payload)
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
if (SONOFF_IFAN02 == my_module_type) { maxfn = 1; }
stemp[0] = '\0';
for (uint32_t i = 0; i < maxfn; i++) {
for (uint8_t i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s%s\"%s\"" ), stemp, (i > 0 ? "," : ""), Settings.friendlyname[i]);
}
stemp2[0] = '\0';
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
snprintf_P(stemp2, sizeof(stemp2), PSTR("%s%s%d" ), stemp2, (i > 0 ? "," : ""), Settings.switchmode[i]);
}
Response_P(PSTR("{\"" D_CMND_STATUS "\":{\"" D_CMND_MODULE "\":%d,\"" D_CMND_FRIENDLYNAME "\":[%s],\"" D_CMND_TOPIC "\":\"%s\",\"" D_CMND_BUTTONTOPIC "\":\"%s\",\"" D_CMND_POWER "\":%d,\"" D_CMND_POWERONSTATE "\":%d,\"" D_CMND_LEDSTATE "\":%d,\"" D_CMND_LEDMASK "\":\"%04X\",\"" D_CMND_SAVEDATA "\":%d,\"" D_JSON_SAVESTATE "\":%d,\"" D_CMND_SWITCHTOPIC "\":\"%s\",\"" D_CMND_SWITCHMODE "\":[%s],\"" D_CMND_BUTTONRETAIN "\":%d,\"" D_CMND_SWITCHRETAIN "\":%d,\"" D_CMND_SENSORRETAIN "\":%d,\"" D_CMND_POWERRETAIN "\":%d}}"),
@ -1919,7 +1919,7 @@ void MqttShowPWMState(void)
{
ResponseAppend_P(PSTR("\"" D_CMND_PWM "\":{"));
bool first = true;
for (uint32_t i = 0; i < MAX_PWMS; i++) {
for (uint8_t i = 0; i < MAX_PWMS; i++) {
if (pin[GPIO_PWM1 + i] < 99) {
ResponseAppend_P(PSTR("%s\"" D_CMND_PWM "%d\":%d"), first ? "" : ",", i+1, Settings.pwm_value[i]);
first = false;
@ -1942,7 +1942,7 @@ void MqttShowState(void)
ResponseAppend_P(PSTR(",\"SleepMode\":\"%s\",\"Sleep\":%u,\"LoadAvg\":%u"),
GetTextIndexed(stemp1, sizeof(stemp1), Settings.flag3.sleep_normal, kSleepMode), sleep, loop_load_avg);
for (uint32_t i = 0; i < devices_present; i++) {
for (uint8_t i = 0; i < devices_present; i++) {
#ifdef USE_LIGHT
if (i == light_device -1) {
LightState(1);
@ -1981,7 +1981,7 @@ bool MqttShowSensor(void)
{
ResponseAppend_P(PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
int json_data_start = strlen(mqtt_data);
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
#ifdef USE_TM1638
if ((pin[GPIO_SWT1 +i] < 99) || ((pin[GPIO_TM16CLK] < 99) && (pin[GPIO_TM16DIO] < 99) && (pin[GPIO_TM16STB] < 99))) {
#else
@ -2100,7 +2100,7 @@ void Every100mSeconds(void)
if (!latching_relay_pulse) SetLatchingRelay(0, 0);
}
for (uint32_t i = 0; i < MAX_PULSETIMERS; i++) {
for (uint8_t i = 0; i < MAX_PULSETIMERS; i++) {
if (pulse_timer[i] != 0L) { // Timer active?
if (TimeReached(pulse_timer[i])) { // Timer finished?
pulse_timer[i] = 0L; // Turn off this timer
@ -2267,7 +2267,7 @@ void Every250mSeconds(void)
if (save_data_counter <= 0) {
if (Settings.flag.save_state) {
power_t mask = POWER_MASK;
for (uint32_t i = 0; i < MAX_PULSETIMERS; i++) {
for (uint8_t i = 0; i < MAX_PULSETIMERS; i++) {
if ((Settings.pulse_timer[i] > 0) && (Settings.pulse_timer[i] < 30)) { // 3 seconds
mask &= ~(1 << i);
}
@ -2529,7 +2529,7 @@ void GpioInit(void)
baudrate = APP_BAUDRATE;
}
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
if ((Settings.user_template.gp.io[i] >= GPIO_SENSOR_END) && (Settings.user_template.gp.io[i] < GPIO_USER)) {
Settings.user_template.gp.io[i] = GPIO_USER; // Fix not supported sensor ids in template
}
@ -2537,7 +2537,7 @@ void GpioInit(void)
myio def_gp;
ModuleGpios(&def_gp);
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
if ((Settings.my_gp.io[i] >= GPIO_SENSOR_END) && (Settings.my_gp.io[i] < GPIO_USER)) {
Settings.my_gp.io[i] = GPIO_NONE; // Fix not supported sensor ids in module
}
@ -2560,10 +2560,10 @@ void GpioInit(void)
my_adc0 = template_adc0; // Force Template override
}
for (uint32_t i = 0; i < GPIO_MAX; i++) {
for (uint16_t i = 0; i < GPIO_MAX; i++) {
pin[i] = 99;
}
for (uint32_t i = 0; i < sizeof(my_module.io); i++) {
for (uint8_t i = 0; i < sizeof(my_module.io); i++) {
mpin = ValidPin(i, my_module.io[i]);
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: gpio pin %d, mpin %d"), i, mpin);
@ -2628,7 +2628,7 @@ void GpioInit(void)
#ifdef USE_SPI
spi_flg = ((((pin[GPIO_SPI_CS] < 99) && (pin[GPIO_SPI_CS] > 14)) || (pin[GPIO_SPI_CS] < 12)) || (((pin[GPIO_SPI_DC] < 99) && (pin[GPIO_SPI_DC] > 14)) || (pin[GPIO_SPI_DC] < 12)));
if (spi_flg) {
for (uint32_t i = 0; i < GPIO_MAX; i++) {
for (uint16_t i = 0; i < GPIO_MAX; i++) {
if ((pin[i] >= 12) && (pin[i] <=14)) pin[i] = 99;
}
my_module.io[12] = GPIO_SPI_MISO;
@ -2651,7 +2651,7 @@ void GpioInit(void)
light_type = LT_BASIC; // Use basic PWM control if SetOption15 = 0
#ifdef USE_LIGHT
if (Settings.flag.pwm_control) {
for (uint32_t i = 0; i < MAX_PWMS; i++) {
for (uint8_t i = 0; i < MAX_PWMS; i++) {
if (pin[GPIO_PWM1 +i] < 99) { light_type++; } // Use Dimmer/Color control for all PWM as SetOption15 = 1
}
}
@ -2699,7 +2699,7 @@ void GpioInit(void)
#endif // USE_LIGHT
else {
if (!light_type) { devices_present = 0; }
for (uint32_t i = 0; i < MAX_RELAYS; i++) {
for (uint8_t i = 0; i < MAX_RELAYS; i++) {
if (pin[GPIO_REL1 +i] < 99) {
pinMode(pin[GPIO_REL1 +i], OUTPUT);
devices_present++;
@ -2711,7 +2711,7 @@ void GpioInit(void)
}
}
for (uint32_t i = 0; i < MAX_LEDS; i++) {
for (uint8_t i = 0; i < MAX_LEDS; i++) {
if (pin[GPIO_LED1 +i] < 99) {
#ifdef USE_ARILUX_RF
if ((3 == i) && (leds_present < 2) && (99 == pin[GPIO_ARIRFSEL])) {
@ -2753,7 +2753,7 @@ void GpioInit(void)
#endif // USE_SM16716
#endif // USE_LIGHT
if (!light_type) {
for (uint32_t i = 0; i < MAX_PWMS; i++) { // Basic PWM control only
for (uint8_t i = 0; i < MAX_PWMS; i++) { // Basic PWM control only
if (pin[GPIO_PWM1 +i] < 99) {
pwm_present = true;
pinMode(pin[GPIO_PWM1 +i], OUTPUT);
@ -2828,7 +2828,7 @@ void setup(void)
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET]) { // Restart twice
Settings.flag3.user_esp8285_enable = 0; // Disable ESP8285 Generic GPIOs interfering with flash SPI
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET] +1) { // Restart 3 times
for (uint32_t i = 0; i < MAX_RULE_SETS; i++) {
for (uint8_t i = 0; i < MAX_RULE_SETS; i++) {
if (bitRead(Settings.rule_stop, i)) {
bitWrite(Settings.rule_enabled, i, 0); // Disable rules causing boot loop
}
@ -2838,7 +2838,7 @@ void setup(void)
Settings.rule_enabled = 0; // Disable all rules
}
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET] +3) { // Restarted 5 times
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
Settings.my_gp.io[i] = GPIO_NONE; // Reset user defined GPIO disabling sensors
}
Settings.my_adc0 = ADC0_NONE; // Reset user defined ADC0 disabling sensors
@ -2903,7 +2903,7 @@ void setup(void)
}
// Issue #526 and #909
for (uint32_t i = 0; i < devices_present; i++) {
for (uint8_t i = 0; i < devices_present; i++) {
if (!Settings.flag3.no_power_feedback) { // #5594 and #5663
if ((i < MAX_RELAYS) && (pin[GPIO_REL1 +i] < 99)) {
bitWrite(power, i, digitalRead(pin[GPIO_REL1 +i]) ^ bitRead(rel_inverted, i));

View File

@ -865,7 +865,7 @@ void SerialSendRaw(char *codes)
uint32_t GetHash(const char *buffer, size_t size)
{
uint32_t hash = 0;
for (uint32_t i = 0; i <= size; i++) {
for (uint16_t i = 0; i <= size; i++) {
hash += (uint8_t)*buffer++ * (i +1);
}
return hash;
@ -958,7 +958,7 @@ uint8_t ModuleNr()
bool ValidTemplateModule(uint8_t index)
{
for (uint32_t i = 0; i < sizeof(kModuleNiceList); i++) {
for (uint8_t i = 0; i < sizeof(kModuleNiceList); i++) {
if (index == pgm_read_byte(kModuleNiceList + i)) {
return true;
}
@ -1002,7 +1002,7 @@ void ModuleGpios(myio *gp)
// AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t *)&src, sizeof(mycfgio));
uint8_t j = 0;
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
dest[j] = src[i];
@ -1117,7 +1117,7 @@ bool GetUsedInModule(uint8_t val, uint8_t *arr)
offset = -(GPIO_CNTR1_NP - GPIO_CNTR1);
}
for (uint32_t i = 0; i < MAX_GPIO_PIN; i++) {
for (uint8_t i = 0; i < MAX_GPIO_PIN; i++) {
if (arr[i] == val) { return true; }
if (arr[i] == val + offset) { return true; }
}
@ -1140,7 +1140,7 @@ bool JsonTemplate(const char* dataBuf)
strlcpy(Settings.user_template.name, name, sizeof(Settings.user_template.name));
}
if (obj[D_JSON_GPIO].success()) {
for (uint32_t i = 0; i < sizeof(mycfgio); i++) {
for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
Settings.user_template.gp.io[i] = obj[D_JSON_GPIO][i] | 0;
}
}
@ -1159,7 +1159,7 @@ bool JsonTemplate(const char* dataBuf)
void TemplateJson()
{
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), Settings.user_template.name);
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
ResponseAppend_P(PSTR("%s%d"), (i>0)?",":"", Settings.user_template.gp.io[i]);
}
ResponseAppend_P(PSTR("],\"" D_JSON_FLAG "\":%d,\"" D_JSON_BASE "\":%d}"), Settings.user_template.flag, Settings.user_template_base +1);
@ -1249,7 +1249,7 @@ bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size)
if (0 == Wire.endTransmission(false)) { // Try to become I2C Master, send data and collect bytes, keep master status for next request...
Wire.requestFrom((int)addr, (int)size); // send data n-bytes read
if (Wire.available() == size) {
for (uint32_t i = 0; i < size; i++) {
for (uint8_t i = 0; i < size; i++) {
i2c_buffer = i2c_buffer << 8 | Wire.read(); // receive DATA
}
status = true;

View File

@ -52,7 +52,7 @@ void ButtonInvertFlag(uint8 button_bit)
void ButtonInit(void)
{
buttons_present = 0;
for (uint32_t i = 0; i < MAX_KEYS; i++) {
for (uint8_t i = 0; i < MAX_KEYS; i++) {
if (pin[GPIO_KEY1 +i] < 99) {
buttons_present++;
pinMode(pin[GPIO_KEY1 +i], bitRead(key_no_pullup, i) ? INPUT : ((16 == pin[GPIO_KEY1 +i]) ? INPUT_PULLDOWN_16 : INPUT_PULLUP));
@ -110,8 +110,8 @@ void ButtonHandler(void)
char scmnd[20];
// uint8_t maxdev = (devices_present > MAX_KEYS) ? MAX_KEYS : devices_present;
// for (uint32_t button_index = 0; button_index < maxdev; button_index++) {
for (uint32_t button_index = 0; button_index < MAX_KEYS; button_index++) {
// for (uint8_t button_index = 0; button_index < maxdev; button_index++) {
for (uint8_t button_index = 0; button_index < MAX_KEYS; button_index++) {
button = NOT_PRESSED;
button_present = 0;

View File

@ -71,7 +71,7 @@ void SwitchProbe(void)
uint8_t force_high = (Settings.switch_debounce % 50) &1; // 51, 101, 151 etc
uint8_t force_low = (Settings.switch_debounce % 50) &2; // 52, 102, 152 etc
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
if (pin[GPIO_SWT1 +i] < 99) {
// Olimex user_switch2.c code to fix 50Hz induced pulses
if (1 == digitalRead(pin[GPIO_SWT1 +i])) {
@ -111,7 +111,7 @@ void SwitchProbe(void)
void SwitchInit(void)
{
switches_found = 0;
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
lastwallswitch[i] = 1; // Init global to virtual switch state;
if (pin[GPIO_SWT1 +i] < 99) {
switches_found++;
@ -135,7 +135,7 @@ void SwitchHandler(uint8_t mode)
uint8_t switchflag;
uint16_t loops_per_second = 1000 / Settings.switch_debounce;
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
if ((pin[GPIO_SWT1 +i] < 99) || (mode)) {
if (holdwallswitch[i]) {

View File

@ -332,7 +332,7 @@ void WifiBeginAfterScan()
}
wifi_scan_state = 0;
// If bssid changed then (re)connect wifi
for (uint32_t i = 0; i < sizeof(wifi_bssid); i++) {
for (uint8_t i = 0; i < sizeof(wifi_bssid); i++) {
if (last_bssid[i] != wifi_bssid[i]) {
WifiBegin(ap, channel); // 0 (AP1), 1 (AP2) or 3 (default AP)
break;

View File

@ -944,12 +944,12 @@ void HandleRoot(void)
WSContentSend_P(PSTR("<tr>"));
if (SONOFF_IFAN02 == my_module_type) {
WSContentSend_P(HTTP_DEVICE_CONTROL, 36, 1, D_BUTTON_TOGGLE, "");
for (uint32_t i = 0; i < MAX_FAN_SPEED; i++) {
for (uint8_t i = 0; i < MAX_FAN_SPEED; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), i);
WSContentSend_P(HTTP_DEVICE_CONTROL, 16, i +2, stemp, "");
}
} else {
for (uint32_t idx = 1; idx <= devices_present; idx++) {
for (uint8_t idx = 1; idx <= devices_present; idx++) {
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx);
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx, (devices_present < 5) ? D_BUTTON_TOGGLE : "", (devices_present > 1) ? stemp : "");
}
@ -960,9 +960,9 @@ void HandleRoot(void)
WSContentSend_P(HTTP_TABLE100);
WSContentSend_P(PSTR("<tr>"));
uint8_t idx = 0;
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
if (idx > 0) { WSContentSend_P(PSTR("</tr><tr>")); }
for (uint32_t j = 0; j < 4; j++) {
for (uint8_t j = 0; j < 4; j++) {
idx++;
WSContentSend_P(PSTR("<td style='width:25%%'><button onclick='la(\"&k=%d\");'>%d</button></td>"), idx, idx); // &k is related to WebGetArg("k", tmp, sizeof(tmp));
}
@ -1048,7 +1048,7 @@ bool HandleRootStatusRefresh(void)
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed);
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? "bold" : "normal", 54, (fanspeed) ? svalue : GetStateText(0));
} else {
for (uint32_t idx = 1; idx <= devices_present; idx++) {
for (uint8_t idx = 1; idx <= devices_present; idx++) {
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(power, idx -1));
WSContentSend_P(HTTP_DEVICE_STATE, 100 / devices_present, (bitRead(power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(power, idx -1)) : svalue);
}
@ -1107,7 +1107,7 @@ void HandleTemplateConfiguration(void)
if (WebServer->hasArg("m")) {
WSContentBegin(200, CT_PLAIN);
for (uint32_t i = 0; i < sizeof(kModuleNiceList); i++) { // "}2'%d'>%s (%d)}3" - "}2'0'>Sonoff Basic (1)}3"
for (uint8_t i = 0; i < sizeof(kModuleNiceList); i++) { // "}2'%d'>%s (%d)}3" - "}2'0'>Sonoff Basic (1)}3"
uint8_t midx = pgm_read_byte(kModuleNiceList + i);
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, AnyModuleName(midx).c_str(), midx +1);
}
@ -1127,7 +1127,7 @@ void HandleTemplateConfiguration(void)
WSContentBegin(200, CT_PLAIN);
WSContentSend_P(PSTR("%s}1"), AnyModuleName(module).c_str()); // NAME: Generic
for (uint32_t i = 0; i < sizeof(kGpioNiceList); i++) { // GPIO: }2'0'>None (0)}3}2'17'>Button1 (17)}3...
for (uint8_t i = 0; i < sizeof(kGpioNiceList); i++) { // GPIO: }2'0'>None (0)}3}2'17'>Button1 (17)}3...
if (1 == i) {
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, 255, D_SENSOR_USER, 255); // }2'255'>User (255)}3
}
@ -1136,7 +1136,7 @@ void HandleTemplateConfiguration(void)
}
WSContentSend_P(PSTR("}1")); // Field separator
for (uint32_t i = 0; i < ADC0_END; i++) { // FLAG: }2'0'>None (0)}3}2'17'>Analog (17)}3...
for (uint8_t i = 0; i < ADC0_END; i++) { // FLAG: }2'0'>None (0)}3}2'17'>Analog (17)}3...
if (1 == i) {
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, ADC0_USER, D_SENSOR_USER, ADC0_USER); // }2'15'>User (15)}3
}
@ -1144,7 +1144,7 @@ void HandleTemplateConfiguration(void)
}
WSContentSend_P(PSTR("}1")); // Field separator
for (uint32_t i = 0; i < sizeof(cmodule); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255
for (uint8_t i = 0; i < sizeof(cmodule); i++) { // 17,148,29,149,7,255,255,255,138,255,139,255,255
if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11
WSContentSend_P(PSTR("%s%d"), (i>0)?",":"", cmodule.io[i]);
}
@ -1167,7 +1167,7 @@ void HandleTemplateConfiguration(void)
"</table>"
"<hr/>"));
WSContentSend_P(HTTP_TABLE100);
for (uint32_t i = 0; i < 17; i++) {
for (uint8_t i = 0; i < 17; i++) {
if ((i < 6) || ((i > 8) && (i != 11))) { // Ignore flash pins GPIO06, 7, 8 and 11
WSContentSend_P(PSTR("<tr><td><b><font color='#%06x'>" D_GPIO "%d</font></b></td><td%s><select id='g%d'></select></td></tr>"),
((9==i)||(10==i)) ? WebColor(COL_TEXT_WARNING) : WebColor(COL_TEXT), i, (0==i) ? " style='width:200px'" : "", i);
@ -1194,7 +1194,7 @@ void TemplateSaveSettings(void)
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp);
uint8_t j = 0;
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
if (6 == i) { j = 9; }
if (8 == i) { j = 12; }
snprintf_P(webindex, sizeof(webindex), PSTR("g%d"), j);
@ -1206,7 +1206,7 @@ void TemplateSaveSettings(void)
WebGetArg("g17", tmp, sizeof(tmp)); // FLAG - ADC0
uint8_t flag = atoi(tmp);
for (uint32_t i = 0; i < GPIO_FLAG_USED; i++) {
for (uint8_t i = 0; i < GPIO_FLAG_USED; i++) {
snprintf_P(webindex, sizeof(webindex), PSTR("c%d"), i);
uint8_t state = WebServer->hasArg(webindex) << i +4; // FLAG
flag += state;
@ -1238,7 +1238,7 @@ void HandleModuleConfiguration(void)
if (WebServer->hasArg("m")) {
WSContentBegin(200, CT_PLAIN);
uint8_t vidx = 0;
for (uint32_t i = 0; i <= sizeof(kModuleNiceList); i++) { // "}2'%d'>%s (%d)}3" - "}2'255'>UserTemplate (0)}3" - "}2'0'>Sonoff Basic (1)}3"
for (uint8_t i = 0; i <= sizeof(kModuleNiceList); i++) { // "}2'%d'>%s (%d)}3" - "}2'255'>UserTemplate (0)}3" - "}2'0'>Sonoff Basic (1)}3"
if (0 == i) {
midx = USER_MODULE;
vidx = 0;
@ -1254,7 +1254,7 @@ void HandleModuleConfiguration(void)
if (WebServer->hasArg("g")) {
WSContentBegin(200, CT_PLAIN);
for (uint32_t j = 0; j < sizeof(kGpioNiceList); j++) {
for (uint8_t j = 0; j < sizeof(kGpioNiceList); j++) {
midx = pgm_read_byte(kGpioNiceList + j);
if (!GetUsedInModule(midx, cmodule.io)) {
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx);
@ -1267,7 +1267,7 @@ void HandleModuleConfiguration(void)
#ifndef USE_ADC_VCC
if (WebServer->hasArg("a")) {
WSContentBegin(200, CT_PLAIN);
for (uint32_t j = 0; j < ADC0_END; j++) {
for (uint8_t j = 0; j < ADC0_END; j++) {
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE, j, GetTextIndexed(stemp, sizeof(stemp), j, kAdc0Names), j);
}
WSContentEnd();
@ -1280,7 +1280,7 @@ void HandleModuleConfiguration(void)
WSContentStart_P(S_CONFIGURE_MODULE);
WSContentSend_P(HTTP_SCRIPT_MODULE_TEMPLATE);
WSContentSend_P(HTTP_SCRIPT_MODULE1, Settings.module);
for (uint32_t i = 0; i < sizeof(cmodule); i++) {
for (uint8_t i = 0; i < sizeof(cmodule); i++) {
if (ValidGPIO(i, cmodule.io[i])) {
WSContentSend_P(PSTR("sk(%d,%d);"), my_module.io[i], i); // g0 - g16
}
@ -1288,7 +1288,7 @@ void HandleModuleConfiguration(void)
WSContentSend_P(HTTP_SCRIPT_MODULE2, Settings.my_adc0);
WSContentSendStyle();
WSContentSend_P(HTTP_FORM_MODULE, AnyModuleName(MODULE).c_str());
for (uint32_t i = 0; i < sizeof(cmodule); i++) {
for (uint8_t i = 0; i < sizeof(cmodule); i++) {
if (ValidGPIO(i, cmodule.io[i])) {
snprintf_P(stemp, 3, PINS_WEMOS +i*2);
char sesp8285[40];
@ -1321,7 +1321,7 @@ void ModuleSaveSettings(void)
myio cmodule;
ModuleGpios(&cmodule);
String gpios = "";
for (uint32_t i = 0; i < sizeof(cmodule); i++) {
for (uint8_t i = 0; i < sizeof(cmodule); i++) {
if (Settings.last_module != new_module) {
Settings.my_gp.io[i] = GPIO_NONE;
} else {
@ -1508,13 +1508,13 @@ void HandleLoggingConfiguration(void)
char stemp1[45];
char stemp2[32];
uint8_t dlevel[3] = { LOG_LEVEL_INFO, LOG_LEVEL_INFO, LOG_LEVEL_NONE };
for (uint32_t idx = 0; idx < 3; idx++) {
for (uint8_t idx = 0; idx < 3; idx++) {
uint8_t llevel = (0==idx)?Settings.seriallog_level:(1==idx)?Settings.weblog_level:Settings.syslog_level;
WSContentSend_P(PSTR("<p><b>%s</b> (%s)<br><select id='l%d'>"),
GetTextIndexed(stemp1, sizeof(stemp1), idx, kLoggingOptions),
GetTextIndexed(stemp2, sizeof(stemp2), dlevel[idx], kLoggingLevels),
idx);
for (uint32_t i = LOG_LEVEL_NONE; i < LOG_LEVEL_ALL; i++) {
for (uint8_t i = LOG_LEVEL_NONE; i < LOG_LEVEL_ALL; i++) {
WSContentSend_P(PSTR("<option%s value='%d'>%d %s</option>"),
(i == llevel) ? " selected" : "", i, i,
GetTextIndexed(stemp1, sizeof(stemp1), i, kLoggingLevels));
@ -1574,7 +1574,7 @@ void HandleOtherConfiguration(void)
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
if (SONOFF_IFAN02 == my_module_type) { maxfn = 1; }
for (uint32_t i = 0; i < maxfn; i++) {
for (uint8_t i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), i +1);
WSContentSend_P(PSTR("<b>" D_FRIENDLY_NAME " %d</b> (" FRIENDLY_NAME "%s)<br><input id='a%d' placeholder='" FRIENDLY_NAME "%s' value='%s'><p></p>"),
i +1,
@ -1586,7 +1586,7 @@ void HandleOtherConfiguration(void)
#ifdef USE_EMULATION
WSContentSend_P(PSTR("<p></p><fieldset><legend><b>&nbsp;" D_EMULATION "&nbsp;</b></legend><p>")); // Keep close to Friendlynames so do not use <br>
for (uint32_t i = 0; i < EMUL_MAX; i++) {
for (uint8_t i = 0; i < EMUL_MAX; i++) {
#ifndef USE_EMULATION_WEMO
if (i == EMUL_WEMO) { i++; }
#endif
@ -1623,7 +1623,7 @@ void OtherSaveSettings(void)
Settings.flag2.emulation = (!strlen(tmp)) ? 0 : atoi(tmp);
#endif // USE_EMULATION
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_OTHER D_MQTT_ENABLE " %s, " D_CMND_EMULATION " %d, " D_CMND_FRIENDLYNAME), GetStateText(Settings.flag.mqtt_enabled), Settings.flag2.emulation);
for (uint32_t i = 0; i < MAX_FRIENDLYNAMES; i++) {
for (uint8_t i = 0; i < MAX_FRIENDLYNAMES; i++) {
snprintf_P(webindex, sizeof(webindex), PSTR("a%d"), i);
WebGetArg(webindex, tmp, sizeof(tmp));
snprintf_P(friendlyname, sizeof(friendlyname), PSTR(FRIENDLY_NAME"%d"), i +1);
@ -1670,7 +1670,7 @@ void HandleBackupConfiguration(void)
memcpy(settings_buffer, &Settings, sizeof(Settings));
if (config_xor_on_set) {
for (uint32_t i = 2; i < sizeof(Settings); i++) {
for (uint16_t i = 2; i < sizeof(Settings); i++) {
settings_buffer[i] ^= (config_xor_on_set +i);
}
}
@ -1753,7 +1753,7 @@ void HandleInformation(void)
WSContentSend_P(PSTR("}1" D_RESTART_REASON "}2%s"), GetResetReason().c_str());
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
if (SONOFF_IFAN02 == my_module_type) { maxfn = 1; }
for (uint32_t i = 0; i < maxfn; i++) {
for (uint8_t i = 0; i < maxfn; i++) {
WSContentSend_P(PSTR("}1" D_FRIENDLY_NAME " %d}2%s"), i +1, Settings.friendlyname[i]);
}
WSContentSend_P(PSTR("}1}2&nbsp;")); // Empty line
@ -2061,7 +2061,7 @@ void HandleUploadLoop(void)
}
if (UPL_SETTINGS == upload_file_type) {
if (config_xor_on_set) {
for (uint32_t i = 2; i < sizeof(Settings); i++) {
for (uint16_t i = 2; i < sizeof(Settings); i++) {
settings_buffer[i] ^= (config_xor_on_set +i);
}
}
@ -2071,7 +2071,7 @@ void HandleUploadLoop(void)
uint16_t buffer_size = settings_buffer[3] << 8 | settings_buffer[2];
uint16_t buffer_crc = settings_buffer[15] << 8 | settings_buffer[14];
uint16_t crc = 0;
for (uint32_t i = 0; i < buffer_size; i++) {
for (uint16_t i = 0; i < buffer_size; i++) {
if ((i < 14) || (i > 15)) { crc += settings_buffer[i]*(i+1); } // Skip crc
}
valid_settings = (buffer_crc == crc);
@ -2267,7 +2267,7 @@ void HandleNotFound(void)
{
WSContentBegin(404, CT_PLAIN);
WSContentSend_P(PSTR(D_FILE_NOT_FOUND "\n\nURI: %s\nMethod: %s\nArguments: %d\n"), WebServer->uri().c_str(), (WebServer->method() == HTTP_GET) ? "GET" : "POST", WebServer->args());
for (uint32_t i = 0; i < WebServer->args(); i++) {
for (uint8_t i = 0; i < WebServer->args(); i++) {
WSContentSend_P(PSTR(" %s: %s\n"), WebServer->argName(i).c_str(), WebServer->arg(i).c_str());
}
WSContentEnd();
@ -2379,7 +2379,7 @@ int WebSend(char *buffer)
// Return received data to the user - Adds 900+ bytes to the code
String result = http.getString(); // File found at server - may need lot of ram or trigger out of memory!
uint16_t j = 0;
for (uint32_t i = 0; i < result.length(); i++) {
for (uint16_t i = 0; i < result.length(); i++) {
char text = result.charAt(i);
if (text > 31) { // Remove control characters like linefeed
mqtt_data[j++] = text;
@ -2422,7 +2422,7 @@ bool JsonWebColor(const char* dataBuf)
char parm_lc[10];
if (obj[LowerCase(parm_lc, D_CMND_WEBCOLOR)].success()) {
for (uint32_t i = 0; i < COL_LAST; i++) {
for (uint8_t i = 0; i < COL_LAST; i++) {
const char* color = obj[parm_lc][i];
if (color != nullptr) {
WebHexCode(i, color);
@ -2492,7 +2492,7 @@ bool WebCommand(void)
}
}
Response_P(PSTR("{\"" D_CMND_WEBCOLOR "\":["));
for (uint32_t i = 0; i < COL_LAST; i++) {
for (uint8_t i = 0; i < COL_LAST; i++) {
if (i) { ResponseAppend_P(PSTR(",")); }
ResponseAppend_P(PSTR("\"#%06x\""), WebColor(i));
}

View File

@ -289,7 +289,7 @@ void MqttPublishPrefixTopic_P(uint8_t prefix, const char* subtopic, bool retaine
char stopic[TOPSZ];
snprintf_P(romram, sizeof(romram), ((prefix > 3) && !Settings.flag.mqtt_response) ? S_RSLT_RESULT : subtopic);
for (uint32_t i = 0; i < strlen(romram); i++) {
for (uint8_t i = 0; i < strlen(romram); i++) {
romram[i] = toupper(romram[i]);
}
prefix &= 3;
@ -333,7 +333,7 @@ void MqttPublishPowerState(uint8_t device)
void MqttPublishAllPowerState()
{
for (uint32_t i = 1; i <= devices_present; i++) {
for (uint8_t i = 1; i <= devices_present; i++) {
MqttPublishPowerState(i);
if (SONOFF_IFAN02 == my_module_type) { break; } // Report status of light relay only
}
@ -656,13 +656,13 @@ bool MqttCommand(void)
if ((data_len > 0) && (data_len < sizeof(fingerprint))) {
strlcpy(fingerprint, (SC_CLEAR == Shortcut(dataBuf)) ? "" : (SC_DEFAULT == Shortcut(dataBuf)) ? (1 == index) ? MQTT_FINGERPRINT1 : MQTT_FINGERPRINT2 : dataBuf, sizeof(fingerprint));
char *p = fingerprint;
for (uint32_t i = 0; i < 20; i++) {
for (uint8_t i = 0; i < 20; i++) {
Settings.mqtt_fingerprint[index -1][i] = strtol(p, &p, 16);
}
restart_flag = 2;
}
fingerprint[0] = '\0';
for (uint32_t i = 0; i < sizeof(Settings.mqtt_fingerprint[index -1]); i++) {
for (uint8_t i = 0; i < sizeof(Settings.mqtt_fingerprint[index -1]); i++) {
snprintf_P(fingerprint, sizeof(fingerprint), PSTR("%s%s%02X"), fingerprint, (i) ? " " : "", Settings.mqtt_fingerprint[index -1][i]);
}
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, index, fingerprint);

View File

@ -1149,7 +1149,7 @@ uint8_t light_pdcki_pin;
void LightDiPulse(uint8_t times)
{
for (uint32_t i = 0; i < times; i++) {
for (uint8_t i = 0; i < times; i++) {
digitalWrite(light_pdi_pin, HIGH);
digitalWrite(light_pdi_pin, LOW);
}
@ -1157,7 +1157,7 @@ void LightDiPulse(uint8_t times)
void LightDckiPulse(uint8_t times)
{
for (uint32_t i = 0; i < times; i++) {
for (uint8_t i = 0; i < times; i++) {
digitalWrite(light_pdcki_pin, HIGH);
digitalWrite(light_pdcki_pin, LOW);
}
@ -1165,7 +1165,7 @@ void LightDckiPulse(uint8_t times)
void LightMy92x1Write(uint8_t data)
{
for (uint32_t i = 0; i < 4; i++) { // Send 8bit Data
for (uint8_t i = 0; i < 4; i++) { // Send 8bit Data
digitalWrite(light_pdcki_pin, LOW);
digitalWrite(light_pdi_pin, (data & 0x80));
digitalWrite(light_pdcki_pin, HIGH);
@ -1190,7 +1190,7 @@ void LightMy92x1Init(void)
// pulse's rising edge convert to command mode.
LightDiPulse(12);
os_delay_us(12); // Delay >12us, begin send CMD data
for (uint32_t n = 0; n < chips; n++) { // Send CMD data
for (uint8_t n = 0; n < chips; n++) { // Send CMD data
LightMy92x1Write(0x18); // ONE_SHOT_DISABLE, REACTION_FAST, BIT_WIDTH_8, FREQUENCY_DIVIDE_1, SCATTER_APDM
}
os_delay_us(12); // TStart > 12us. Delay 12 us.
@ -1213,7 +1213,7 @@ void LightMy92x1Duty(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b, uint8_t dut
{ duty_w, duty_c, 0, duty_g, duty_r, duty_b }}; // Definition for RGBWC channels
os_delay_us(12); // TStop > 12us.
for (uint32_t channel = 0; channel < channels[didx]; channel++) {
for (uint8_t channel = 0; channel < channels[didx]; channel++) {
LightMy92x1Write(duty[didx][channel]); // Send 8bit Data
}
os_delay_us(12); // TStart > 12us. Ready for send DI pulse.
@ -1317,7 +1317,7 @@ bool SM16716_ModuleSelected(void)
void SM16716_Init(void)
{
for (uint32_t t_init = 0; t_init < 50; ++t_init) {
for (uint8_t t_init = 0; t_init < 50; ++t_init) {
SM16716_SendBit(0);
}
}
@ -1346,7 +1346,7 @@ void LightInit(void)
Settings.light_color[0] = 255; // One channel only supports Dimmer but needs max color
}
if (light_type < LT_PWM6) { // PWM
for (uint32_t i = 0; i < light_type; i++) {
for (uint8_t i = 0; i < light_type; i++) {
Settings.pwm_value[i] = 0; // Disable direct PWM control
if (pin[GPIO_PWM1 +i] < 99) {
pinMode(pin[GPIO_PWM1 +i], OUTPUT);
@ -1382,7 +1382,7 @@ void LightInit(void)
#ifdef USE_SM16716
else if (LT_SM16716 == light_type - light_subtype) {
// init PWM
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
Settings.pwm_value[i] = 0; // Disable direct PWM control
if (pin[GPIO_PWM1 +i] < 99) {
pinMode(pin[GPIO_PWM1 +i], OUTPUT);
@ -1437,17 +1437,17 @@ void LightUpdateColorMapping(void)
uint8_t tmp[] = {0,1,2,3,4};
light_color_remap[0] = tmp[param / 24];
for (uint32_t i = param / 24; i<4; ++i){
for (uint8_t i = param / 24; i<4; ++i){
tmp[i] = tmp[i+1];
}
param = param % 24;
light_color_remap[1] = tmp[(param / 6)];
for (uint32_t i = param / 6; i<3; ++i){
for (uint8_t i = param / 6; i<3; ++i){
tmp[i] = tmp[i+1];
}
param = param % 6;
light_color_remap[2] = tmp[(param / 2)];
for (uint32_t i = param / 2; i<2; ++i){
for (uint8_t i = param / 2; i<2; ++i){
tmp[i] = tmp[i+1];
}
param = param % 2;
@ -1510,7 +1510,7 @@ char* LightGetColor(char* scolor, boolean force_hex = false)
{
light_controller.calcLevels();
scolor[0] = '\0';
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
if (!force_hex && Settings.flag.decimal_text) {
snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", light_current_color[i]);
} else {
@ -1550,7 +1550,7 @@ void LightState(uint8_t append)
ResponseAppend_P(PSTR(",\"" D_CMND_HSBCOLOR "\":\"%d,%d,%d\""), hue,sat,bri);
// Add status for each channel
ResponseAppend_P(PSTR(",\"" D_CMND_CHANNEL "\":[" ));
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
uint8_t channel_raw = light_current_color[i];
uint8_t channel = changeUIntScale(channel_raw,0,255,0,100);
// if non null, force to be at least 1
@ -1597,7 +1597,7 @@ void LightPreparePower(void)
void LightFade(void)
{
if (0 == Settings.light_fade) {
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
light_new_color[i] = light_current_color[i];
}
} else {
@ -1606,7 +1606,7 @@ void LightFade(void)
shift = (strip_timer_counter % (Settings.light_speed -6)) ? 0 : 8;
}
if (shift) {
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
if (light_new_color[i] != light_current_color[i]) {
if (light_new_color[i] < light_current_color[i]) {
light_new_color[i] += ((light_current_color[i] - light_new_color[i]) >> shift) +1;
@ -1641,7 +1641,7 @@ void LightWheel(uint8_t wheel_pos)
light_entry_color[3] = 0;
light_entry_color[4] = 0;
float dimmer = 100 / (float)Settings.light_dimmer;
for (uint32_t i = 0; i < LST_RGB; i++) {
for (uint8_t i = 0; i < LST_RGB; i++) {
float temp = (float)light_entry_color[i] / dimmer + 0.5f;
light_entry_color[i] = (uint8_t)temp;
}
@ -1660,7 +1660,7 @@ void LightCycleColor(int8_t direction)
void LightRandomColor(void)
{
uint8_t light_update = 0;
for (uint32_t i = 0; i < LST_RGB; i++) {
for (uint8_t i = 0; i < LST_RGB; i++) {
if (light_new_color[i] != light_current_color[i]) {
light_update = 1;
}
@ -1697,7 +1697,7 @@ void LightAnimate(void)
if (!light_power) { // Power Off
sleep = Settings.sleep;
strip_timer_counter = 0;
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
light_still_on += light_new_color[i];
}
if (light_still_on && Settings.light_fade && (Settings.light_scheme < LS_MAX)) {
@ -1705,13 +1705,13 @@ void LightAnimate(void)
if (speed > 6) {
speed = 6;
}
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
if (light_new_color[i] > 0) {
light_new_color[i] -= (light_new_color[i] >> speed) +1;
}
}
} else {
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
light_new_color[i] = 0;
}
}
@ -1730,7 +1730,7 @@ void LightAnimate(void)
case LS_WAKEUP:
if (2 == light_wakeup_active) {
light_wakeup_active = 1;
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
light_new_color[i] = 0;
}
light_wakeup_counter = 0;
@ -1743,7 +1743,7 @@ void LightAnimate(void)
if (light_wakeup_dimmer <= Settings.light_dimmer) {
light_state.setDimmer(light_wakeup_dimmer);
light_controller.calcLevels();
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
light_new_color[i] = light_current_color[i];
}
} else {
@ -1781,7 +1781,7 @@ void LightAnimate(void)
light_update = 0;
// first adjust all colors to RgbwwTable if needed
for (uint32_t i = 0; i < LST_MAX; i++) {
for (uint8_t i = 0; i < LST_MAX; i++) {
light_last_color[i] = light_new_color[i];
// adjust from 0.255 to 0..Settings.rgbwwTable[i] -- RgbwwTable command
// protect against overflow of rgbwwTable which is of size 5
@ -1808,7 +1808,7 @@ void LightAnimate(void)
// Apply gamma correction for 8 and 10 bits resolutions, if needed
if (Settings.light_correction) {
// first apply gamma correction to all channels independently, from 8 bits value
for (uint32_t i = 0; i < LST_MAX; i++) {
for (uint8_t i = 0; i < LST_MAX; i++) {
cur_col_10bits[i] = ledGamma(cur_col[i], 10);
}
// then apply a different correction for CW white channels
@ -1829,14 +1829,14 @@ void LightAnimate(void)
}
}
// still keep an 8 bits gamma corrected version
for (uint32_t i = 0; i < LST_MAX; i++) {
for (uint8_t i = 0; i < LST_MAX; i++) {
cur_col[i] = ledGamma(cur_col[i]);
}
}
}
// final adjusments for PMW, post-gamma correction
for (uint32_t i = 0; i < LST_MAX; i++) {
for (uint8_t i = 0; i < LST_MAX; i++) {
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
// Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01)
// but keep value 1023 if full range (PWM will be deactivated in this case)
@ -1853,14 +1853,14 @@ void LightAnimate(void)
uint16_t orig_col_10bits[LST_MAX];
memcpy(orig_col, cur_col, sizeof(orig_col));
memcpy(orig_col_10bits, cur_col_10bits, sizeof(orig_col_10bits));
for (uint32_t i = 0; i < LST_MAX; i++) {
for (uint8_t i = 0; i < LST_MAX; i++) {
cur_col[i] = orig_col[light_color_remap[i]];
cur_col_10bits[i] = orig_col_10bits[light_color_remap[i]];
}
// now apply the actual PWM values, adjusted and remapped 10-bits range
if (light_type < LT_PWM6) { // only for direct PWM lights, not for Tuya, Armtronix...
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
if (pin[GPIO_PWM1 +i] < 99) {
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d, Pwm%d %d"), i, cur_col[i], i+1, curcol);
analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - cur_col_10bits[i] : cur_col_10bits[i]);
@ -1884,7 +1884,7 @@ void LightAnimate(void)
#ifdef USE_SM16716
else if (LT_SM16716 == light_type - light_subtype) {
// handle any PWM pins, skipping the first 3 values for sm16716
for (uint32_t i = 3; i < light_subtype; i++) {
for (uint8_t i = 3; i < light_subtype; i++) {
if (pin[GPIO_PWM1 +i-3] < 99) {
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d, Pwm%d %d"), i, cur_col[i], i+1, curcol);
analogWrite(pin[GPIO_PWM1 +i-3], bitRead(pwm_inverted, i-3) ? Settings.pwm_range - cur_col_10bits[i] : cur_col_10bits[i]);
@ -1943,7 +1943,7 @@ bool LightColorEntry(char *buffer, uint8_t buffer_length)
entry_type = 2; // Decimal
}
else if (((2 * light_subtype) == buffer_length) || (buffer_length > 3)) { // Hexadecimal entry
for (uint32_t i = 0; i < tmin((uint)(buffer_length / 2), sizeof(light_entry_color)); i++) {
for (uint8_t i = 0; i < tmin((uint)(buffer_length / 2), sizeof(light_entry_color)); i++) {
strlcpy(scolor, buffer + (i *2), 3);
light_entry_color[i] = (uint8_t)strtol(scolor, &p, 16);
}
@ -2017,7 +2017,7 @@ bool LightCommand(void)
Settings.light_scheme = 0;
coldim = true;
} else { // Color3, 4, 5 and 6
for (uint32_t i = 0; i < LST_RGB; i++) {
for (uint8_t i = 0; i < LST_RGB; i++) {
Settings.ws_color[XdrvMailbox.index -3][i] = light_entry_color[i];
}
}
@ -2028,7 +2028,7 @@ bool LightCommand(void)
}
if (XdrvMailbox.index >= 3) {
scolor[0] = '\0';
for (uint32_t i = 0; i < LST_RGB; i++) {
for (uint8_t i = 0; i < LST_RGB; i++) {
if (Settings.flag.decimal_text) {
snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", Settings.ws_color[XdrvMailbox.index -3][i]);
} else {
@ -2245,7 +2245,7 @@ bool LightCommand(void)
light_update = 1;
}
scolor[0] = '\0';
for (uint32_t i = 0; i < LST_RGBWC; i++) {
for (uint8_t i = 0; i < LST_RGBWC; i++) {
snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", Settings.rgbwwTable[i]);
}
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, scolor);

View File

@ -175,7 +175,7 @@ void IrReceiveCheck(void)
if (strlen(mqtt_data) > sizeof(mqtt_data) - 40) { break; } // Quit if char string becomes too long
}
uint16_t extended_length = results.rawlen - 1;
for (uint32_t j = 0; j < results.rawlen - 1; j++) {
for (uint16_t j = 0; j < results.rawlen - 1; j++) {
uint32_t usecs = results.rawbuf[j] * kRawTick;
// Add two extra entries for multiple larger than UINT16_MAX it is.
extended_length += (usecs / (UINT16_MAX + 1)) * 2;
@ -568,7 +568,7 @@ bool IrSendCommand(void)
error = IE_INVALID_RAWDATA;
} else {
uint16_t parm[count];
for (uint32_t i = 0; i < count; i++) {
for (uint8_t i = 0; i < count; i++) {
parm[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0);
if (!parm[i]) {
if (!i) {
@ -641,7 +641,7 @@ bool IrSendCommand(void)
count++;
if (count < 200) {
uint16_t raw_array[count]; // It's safe to use stack for up to 200 packets (limited by mqtt_data length)
for (uint32_t i = 0; i < count; i++) {
for (uint16_t i = 0; i < count; i++) {
raw_array[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0); // Allow decimal (20496) and hexadecimal (0x5010) input
}
@ -654,7 +654,7 @@ bool IrSendCommand(void)
if (raw_array == nullptr) {
error = IE_INVALID_RAWDATA;
} else {
for (uint32_t i = 0; i < count; i++) {
for (uint16_t i = 0; i < count; i++) {
raw_array[i] = strtol(strtok_r(nullptr, ", ", &p), nullptr, 0); // Allow decimal (20496) and hexadecimal (0x5010) input
}

View File

@ -251,7 +251,7 @@ void SonoffBridgeReceived(void)
low_time = serial_in_buffer[3] << 8 | serial_in_buffer[4]; // Low time in uSec
high_time = serial_in_buffer[5] << 8 | serial_in_buffer[6]; // High time in uSec
if (low_time && high_time) {
for (uint32_t i = 0; i < 9; i++) {
for (uint8_t i = 0; i < 9; i++) {
Settings.rf_code[sonoff_bridge_learn_key][i] = serial_in_buffer[i +1];
}
Response_P(S_JSON_COMMAND_INDEX_SVALUE, D_CMND_RFKEY, sonoff_bridge_learn_key, D_JSON_LEARNED);
@ -274,7 +274,7 @@ void SonoffBridgeReceived(void)
sonoff_bridge_last_received_id = received_id;
sonoff_bridge_last_time = now;
strncpy_P(rfkey, PSTR("\"" D_JSON_NONE "\""), sizeof(rfkey));
for (uint32_t i = 1; i <= 16; i++) {
for (uint8_t i = 1; i <= 16; i++) {
if (Settings.rf_code[i][0]) {
uint32_t send_id = Settings.rf_code[i][6] << 16 | Settings.rf_code[i][7] << 8 | Settings.rf_code[i][8];
if (send_id == received_id) {
@ -370,7 +370,7 @@ void SonoffBridgeSendCode(uint32_t code)
{
Serial.write(0xAA); // Start of Text
Serial.write(0xA5); // Send following code
for (uint32_t i = 0; i < 6; i++) {
for (uint8_t i = 0; i < 6; i++) {
Serial.write(Settings.rf_code[0][i]);
}
Serial.write((code >> 16) & 0xff);
@ -387,7 +387,7 @@ void SonoffBridgeSend(uint8_t idx, uint8_t key)
key--; // Support 1 to 16
Serial.write(0xAA); // Start of Text
Serial.write(0xA5); // Send following code
for (uint32_t i = 0; i < 8; i++) {
for (uint8_t i = 0; i < 8; i++) {
Serial.write(Settings.rf_code[idx][i]);
}
if (0 == idx) {
@ -485,7 +485,7 @@ bool SonoffBridgeCommand(void)
Response_P(S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, D_JSON_SET_TO_DEFAULT);
}
else if (4 == XdrvMailbox.payload) { // Save RF data provided by RFSync, RfLow, RfHigh and last RfCode
for (uint32_t i = 0; i < 6; i++) {
for (uint8_t i = 0; i < 6; i++) {
Settings.rf_code[XdrvMailbox.index][i] = Settings.rf_code[0][i];
}
Settings.rf_code[XdrvMailbox.index][6] = (sonoff_bridge_last_send_code >> 16) & 0xff;

View File

@ -126,7 +126,7 @@ void DomoticzMqttUpdate(void)
domoticz_update_timer--;
if (domoticz_update_timer <= 0) {
domoticz_update_timer = Settings.domoticz_update_timer;
for (uint32_t i = 1; i <= devices_present; i++) {
for (uint8_t i = 1; i <= devices_present; i++) {
if ((SONOFF_IFAN02 == my_module_type) && (i > 1)) {
MqttPublishDomoticzFanState();
break;
@ -141,7 +141,7 @@ void DomoticzMqttUpdate(void)
void DomoticzMqttSubscribe(void)
{
uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present;
for (uint32_t i = 0; i < maxdev; i++) {
for (uint8_t i = 0; i < maxdev; i++) {
if (Settings.domoticz_relay_idx[i]) {
domoticz_subscribe = true;
}
@ -208,7 +208,7 @@ bool DomoticzMqttData(void)
if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) {
uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present;
for (uint32_t i = 0; i < maxdev; i++) {
for (uint8_t i = 0; i < maxdev; i++) {
if (idx == Settings.domoticz_relay_idx[i]) {
bool iscolordimmer = strcmp_P(domoticz["dtype"],PSTR("Color Switch")) == 0;
snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), i +1);
@ -489,7 +489,7 @@ void DomoticzSaveSettings(void)
char ssensor_indices[6 * MAX_DOMOTICZ_SNS_IDX];
char tmp[100];
for (uint32_t i = 0; i < MAX_DOMOTICZ_IDX; i++) {
for (uint8_t i = 0; i < MAX_DOMOTICZ_IDX; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("r%d"), i);
WebGetArg(stemp, tmp, sizeof(tmp));
Settings.domoticz_relay_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
@ -501,7 +501,7 @@ void DomoticzSaveSettings(void)
Settings.domoticz_switch_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
}
ssensor_indices[0] = '\0';
for (uint32_t i = 0; i < DZ_MAX_SENSORS; i++) {
for (uint8_t i = 0; i < DZ_MAX_SENSORS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("l%d"), i);
WebGetArg(stemp, tmp, sizeof(tmp));
Settings.domoticz_sensor_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);

View File

@ -256,7 +256,7 @@ void TimerSetRandomWindow(uint8_t index)
void TimerSetRandomWindows(void)
{
for (uint32_t i = 0; i < MAX_TIMERS; i++) { TimerSetRandomWindow(i); }
for (uint8_t i = 0; i < MAX_TIMERS; i++) { TimerSetRandomWindow(i); }
}
void TimerEverySecond(void)
@ -268,7 +268,7 @@ void TimerEverySecond(void)
int16_t time = (RtcTime.hour *60) + RtcTime.minute;
uint8_t days = 1 << (RtcTime.day_of_week -1);
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
for (uint8_t i = 0; i < MAX_TIMERS; i++) {
// if (Settings.timer[i].device >= devices_present) Settings.timer[i].data = 0; // Reset timer due to change in devices present
Timer xtimer = Settings.timer[i];
uint16_t set_time = xtimer.time;
@ -308,7 +308,7 @@ void PrepShowTimer(uint8_t index)
Timer xtimer = Settings.timer[index -1];
for (uint32_t i = 0; i < 7; i++) {
for (uint8_t i = 0; i < 7; i++) {
uint8_t mask = 1 << i;
snprintf(days, sizeof(days), "%s%d", days, ((xtimer.days & mask) > 0));
}
@ -468,7 +468,7 @@ bool TimerCommand(void)
uint8_t jsflg = 0;
uint8_t lines = 1;
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
for (uint8_t i = 0; i < MAX_TIMERS; i++) {
if (!jsflg) {
Response_P(PSTR("{\"" D_CMND_TIMERS "%d\":{"), lines++);
} else {
@ -713,7 +713,7 @@ void HandleTimerConfiguration(void)
WSContentSend_P(HTTP_TIMER_SCRIPT6, devices_present);
WSContentSendStyle_P(HTTP_TIMER_STYLE, WebColor(COL_FORM));
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? " checked" : "");
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
for (uint8_t i = 0; i < MAX_TIMERS; i++) {
WSContentSend_P(PSTR("%s%u"), (i > 0) ? "," : "", Settings.timer[i].data);
}
WSContentSend_P(HTTP_FORM_TIMER2);
@ -737,7 +737,7 @@ void TimerSaveSettings(void)
WebGetArg("t0", tmp, sizeof(tmp));
char *p = tmp;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CMND_TIMERS " %d"), Settings.flag3.timers_enable);
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
for (uint8_t i = 0; i < MAX_TIMERS; i++) {
timer.data = strtol(p, &p, 10);
p++; // Skip comma
if (timer.time < 1440) {

View File

@ -182,14 +182,14 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
double rule_value = 0;
if (compare != COMPARE_OPERATOR_NONE) {
String rule_param = rule_name.substring(pos + strlen(compare_operator));
for (uint32_t i = 0; i < MAX_RULE_VARS; i++) {
for (uint8_t i = 0; i < MAX_RULE_VARS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%VAR%d%%"), i +1);
if (rule_param.startsWith(stemp)) {
rule_param = vars[i];
break;
}
}
for (uint32_t i = 0; i < MAX_RULE_MEMS; i++) {
for (uint8_t i = 0; i < MAX_RULE_MEMS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%MEM%d%%"), i +1);
if (rule_param.startsWith(stemp)) {
rule_param = Settings.mems[i];
@ -349,11 +349,11 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
// if (!ucommand.startsWith("BACKLOG")) { commands = "backlog " + commands; } // Always use Backlog to prevent power race exception
if (ucommand.indexOf("EVENT ") != -1) { commands = "backlog " + commands; } // Always use Backlog with event to prevent rule event loop exception
commands.replace(F("%value%"), rules_event_value);
for (uint32_t i = 0; i < MAX_RULE_VARS; i++) {
for (uint8_t i = 0; i < MAX_RULE_VARS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%var%d%%"), i +1);
commands.replace(stemp, vars[i]);
}
for (uint32_t i = 0; i < MAX_RULE_MEMS; i++) {
for (uint8_t i = 0; i < MAX_RULE_MEMS; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%%mem%d%%"), i +1);
commands.replace(stemp, Settings.mems[i]);
}
@ -406,7 +406,7 @@ bool RulesProcessEvent(char *json_event)
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());
for (uint32_t i = 0; i < MAX_RULE_SETS; i++) {
for (uint8_t i = 0; i < MAX_RULE_SETS; i++) {
if (strlen(Settings.rules[i]) && bitRead(Settings.rule_enabled, i)) {
if (RuleSetProcess(i, event_saved)) { serviced = true; }
}
@ -422,7 +422,7 @@ bool RulesProcess(void)
void RulesInit(void)
{
rules_flag.data = 0;
for (uint32_t i = 0; i < MAX_RULE_SETS; i++) {
for (uint8_t i = 0; i < MAX_RULE_SETS; i++) {
if (Settings.rules[i][0] == '\0') {
bitWrite(Settings.rule_enabled, i, 0);
bitWrite(Settings.rule_once, i, 0);
@ -439,7 +439,7 @@ void RulesEvery50ms(void)
if (-1 == rules_new_power) { rules_new_power = power; }
if (rules_new_power != rules_old_power) {
if (rules_old_power != -1) {
for (uint32_t i = 0; i < devices_present; i++) {
for (uint8_t i = 0; i < devices_present; i++) {
uint8_t new_state = (rules_new_power >> i) &1;
if (new_state != ((rules_old_power >> i) &1)) {
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Power%d\":{\"State\":%d}}"), i +1, new_state);
@ -448,13 +448,13 @@ void RulesEvery50ms(void)
}
} else {
// Boot time POWER OUTPUTS (Relays) Status
for (uint32_t i = 0; i < devices_present; i++) {
for (uint8_t i = 0; i < devices_present; i++) {
uint8_t new_state = (rules_new_power >> i) &1;
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Power%d\":{\"Boot\":%d}}"), i +1, new_state);
RulesProcessEvent(json_event);
}
// Boot time SWITCHES Status
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
#ifdef USE_TM1638
if ((pin[GPIO_SWT1 +i] < 99) || ((pin[GPIO_TM16CLK] < 99) && (pin[GPIO_TM16DIO] < 99) && (pin[GPIO_TM16STB] < 99))) {
#else
@ -498,7 +498,7 @@ void RulesEvery50ms(void)
}
else if (vars_event || mems_event){
if (vars_event) {
for (uint32_t i = 0; i < MAX_RULE_VARS; i++) {
for (uint8_t i = 0; i < MAX_RULE_VARS; i++) {
if (bitRead(vars_event, i)) {
bitClear(vars_event, i);
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Var%d\":{\"State\":%s}}"), i+1, vars[i]);
@ -508,7 +508,7 @@ void RulesEvery50ms(void)
}
}
if (mems_event) {
for (uint32_t i = 0; i < MAX_RULE_MEMS; i++) {
for (uint8_t i = 0; i < MAX_RULE_MEMS; i++) {
if (bitRead(mems_event, i)) {
bitClear(mems_event, i);
snprintf_P(json_event, sizeof(json_event), PSTR("{\"Mem%d\":{\"State\":%s}}"), i+1, Settings.mems[i]);
@ -520,7 +520,7 @@ void RulesEvery50ms(void)
}
else if (rules_flag.data) {
uint16_t mask = 1;
for (uint32_t i = 0; i < MAX_RULES_FLAG; i++) {
for (uint8_t i = 0; i < MAX_RULES_FLAG; i++) {
if (rules_flag.data & mask) {
rules_flag.data ^= mask;
json_event[0] = '\0';
@ -575,7 +575,7 @@ void RulesEverySecond(void)
RulesProcessEvent(json_event);
}
}
for (uint32_t i = 0; i < MAX_RULE_TIMERS; i++) {
for (uint8_t i = 0; i < MAX_RULE_TIMERS; i++) {
if (rules_timer[i] != 0L) { // Timer active?
if (TimeReached(rules_timer[i])) { // Timer finished?
rules_timer[i] = 0L; // Turn off this timer
@ -1161,7 +1161,7 @@ bool RulesCommand(void)
#endif //USE_EXPRESSION
}
mqtt_data[0] = '\0';
for (uint32_t i = 0; i < MAX_RULE_TIMERS; i++) {
for (uint8_t i = 0; i < MAX_RULE_TIMERS; i++) {
ResponseAppend_P(PSTR("%c\"T%d\":%d"), (i) ? ',' : '{', i +1, (rules_timer[i]) ? (rules_timer[i] - millis()) / 1000 : 0);
}
ResponseJsonEnd();

View File

@ -202,7 +202,7 @@ const char kKnxCommands[] PROGMEM = D_CMND_KNXTXCMND "|" D_CMND_KNXTXVAL "|" D_C
uint8_t KNX_GA_Search( uint8_t param, uint8_t start = 0 )
{
for (uint32_t i = start; i < Settings.knx_GA_registered; ++i)
for (uint8_t i = start; i < Settings.knx_GA_registered; ++i)
{
if ( Settings.knx_GA_param[i] == param )
{
@ -218,7 +218,7 @@ uint8_t KNX_GA_Search( uint8_t param, uint8_t start = 0 )
uint8_t KNX_CB_Search( uint8_t param, uint8_t start = 0 )
{
for (uint32_t i = start; i < Settings.knx_CB_registered; ++i)
for (uint8_t i = start; i < Settings.knx_CB_registered; ++i)
{
if ( Settings.knx_CB_param[i] == param )
{
@ -391,7 +391,7 @@ void KNX_DEL_CB( uint8_t CBnum )
bool KNX_CONFIG_NOT_MATCH(void)
{
// Check for configured parameters that the device does not have (module changed)
for (uint32_t i = 0; i < KNX_MAX_device_param; ++i)
for (uint8_t i = 0; i < KNX_MAX_device_param; ++i)
{
if ( !device_param[i].show ) { // device has this parameter ?
// if not, search for all registered group address to this parameter for deletion
@ -413,7 +413,7 @@ bool KNX_CONFIG_NOT_MATCH(void)
}
// Check for invalid or erroneous configuration (tasmota flashed without clearing the memory)
for (uint32_t i = 0; i < Settings.knx_GA_registered; ++i)
for (uint8_t i = 0; i < Settings.knx_GA_registered; ++i)
{
if ( Settings.knx_GA_param[i] != 0 ) // the GA[i] have a parameter defined?
{
@ -423,7 +423,7 @@ bool KNX_CONFIG_NOT_MATCH(void)
}
}
}
for (uint32_t i = 0; i < Settings.knx_CB_registered; ++i)
for (uint8_t i = 0; i < Settings.knx_CB_registered; ++i)
{
if ( Settings.knx_CB_param[i] != 0 ) // the CB[i] have a parameter defined?
{
@ -524,7 +524,7 @@ void KNX_INIT(void)
// Search on the settings if there is a group address set for receive KNX messages for the type: device_param[j].type
// If there is, register the group address on the KNX_IP Library to Receive data for Executing Callbacks
uint8_t j;
for (uint32_t i = 0; i < Settings.knx_CB_registered; ++i)
for (uint8_t i = 0; i < Settings.knx_CB_registered; ++i)
{
j = Settings.knx_CB_param[i];
if ( j > 0 )
@ -887,7 +887,7 @@ void HandleKNXConfiguration(void)
if ( Settings.flag.knx_enable_enhancement ) { WSContentSend_P(PSTR(" checked")); }
WSContentSend_P(HTTP_FORM_KNX2);
for (uint32_t i = 0; i < KNX_MAX_device_param ; i++)
for (uint8_t i = 0; i < KNX_MAX_device_param ; i++)
{
if ( device_param[i].show )
{
@ -897,7 +897,7 @@ void HandleKNXConfiguration(void)
WSContentSend_P(PSTR("</select> -> "));
WSContentSend_P(HTTP_FORM_KNX_GA, "GA_FNUM", "GA_AREA", "GA_FDEF");
WSContentSend_P(HTTP_FORM_KNX_ADD_BTN, "GAwarning", (Settings.knx_GA_registered < MAX_KNX_GA) ? "" : "disabled", 1);
for (uint32_t i = 0; i < Settings.knx_GA_registered ; ++i)
for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i)
{
if ( Settings.knx_GA_param[i] )
{
@ -911,7 +911,7 @@ void HandleKNXConfiguration(void)
WSContentSend_P(HTTP_FORM_KNX4);
uint8_t j;
for (uint32_t i = 0; i < KNX_MAX_device_param ; i++)
for (uint8_t i = 0; i < KNX_MAX_device_param ; i++)
{
// Check How many Relays are available and add: RelayX and TogleRelayX
if ( (i > 8) && (i < 16) ) { j=i-8; } else { j=i; }
@ -924,7 +924,7 @@ void HandleKNXConfiguration(void)
WSContentSend_P(PSTR("</select> "));
WSContentSend_P(HTTP_FORM_KNX_ADD_BTN, "CBwarning", (Settings.knx_CB_registered < MAX_KNX_CB) ? "" : "disabled", 2);
for (uint32_t i = 0; i < Settings.knx_CB_registered ; ++i)
for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i)
{
if ( Settings.knx_CB_param[i] )
{
@ -964,7 +964,7 @@ void KNX_Save_Settings(void)
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA: %d"),
Settings.knx_GA_registered );
for (uint32_t i = 0; i < Settings.knx_GA_registered ; ++i)
for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i)
{
KNX_addr.value = Settings.knx_GA_addr[i];
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"),
@ -975,7 +975,7 @@ void KNX_Save_Settings(void)
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB: %d"),
Settings.knx_CB_registered );
for (uint32_t i = 0; i < Settings.knx_CB_registered ; ++i)
for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i)
{
KNX_addr.value = Settings.knx_CB_addr[i];
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"),

View File

@ -334,7 +334,7 @@ void HAssAnnounceSwitches(void)
char *tmp = Settings.switch_topic;
Format(sw_topic, tmp, sizeof(sw_topic));
if ((strlen(sw_topic) != 0) && strcmp(sw_topic, "0")) {
for (uint32_t switch_index = 0; switch_index < MAX_SWITCHES; switch_index++) {
for (uint8_t switch_index = 0; switch_index < MAX_SWITCHES; switch_index++) {
uint8_t switch_present = 0;
uint8_t toggle = 1;
@ -363,7 +363,7 @@ void HAssAnnounceButtons(void)
char *tmp = Settings.button_topic;
Format(key_topic, tmp, sizeof(key_topic));
if ((strlen(key_topic) != 0) && strcmp(key_topic, "0")) {
for (uint32_t button_index = 0; button_index < MAX_KEYS; button_index++) {
for (uint8_t button_index = 0; button_index < MAX_KEYS; button_index++) {
uint8_t button_present = 0;
uint8_t toggle = 1;

View File

@ -495,7 +495,7 @@ void DisplayText(void)
void DisplayClearScreenBuffer(void)
{
if (disp_screen_buffer_cols) {
for (uint32_t i = 0; i < disp_screen_buffer_rows; i++) {
for (uint8_t i = 0; i < disp_screen_buffer_rows; i++) {
memset(disp_screen_buffer[i], 0, disp_screen_buffer_cols);
}
}
@ -504,7 +504,7 @@ void DisplayClearScreenBuffer(void)
void DisplayFreeScreenBuffer(void)
{
if (disp_screen_buffer != nullptr) {
for (uint32_t i = 0; i < disp_screen_buffer_rows; i++) {
for (uint8_t i = 0; i < disp_screen_buffer_rows; i++) {
if (disp_screen_buffer[i] != nullptr) { free(disp_screen_buffer[i]); }
}
free(disp_screen_buffer);
@ -519,7 +519,7 @@ void DisplayAllocScreenBuffer(void)
disp_screen_buffer_rows = Settings.display_rows;
disp_screen_buffer = (char**)malloc(sizeof(*disp_screen_buffer) * disp_screen_buffer_rows);
if (disp_screen_buffer != nullptr) {
for (uint32_t i = 0; i < disp_screen_buffer_rows; i++) {
for (uint8_t i = 0; i < disp_screen_buffer_rows; i++) {
disp_screen_buffer[i] = (char*)malloc(sizeof(*disp_screen_buffer[i]) * (Settings.display_cols[0] +1));
if (disp_screen_buffer[i] == nullptr) {
DisplayFreeScreenBuffer();
@ -554,7 +554,7 @@ void DisplayFillScreen(uint8_t line)
void DisplayClearLogBuffer(void)
{
if (disp_log_buffer_cols) {
for (uint32_t i = 0; i < DISPLAY_LOG_ROWS; i++) {
for (uint8_t i = 0; i < DISPLAY_LOG_ROWS; i++) {
memset(disp_log_buffer[i], 0, disp_log_buffer_cols);
}
}
@ -563,7 +563,7 @@ void DisplayClearLogBuffer(void)
void DisplayFreeLogBuffer(void)
{
if (disp_log_buffer != nullptr) {
for (uint32_t i = 0; i < DISPLAY_LOG_ROWS; i++) {
for (uint8_t i = 0; i < DISPLAY_LOG_ROWS; i++) {
if (disp_log_buffer[i] != nullptr) { free(disp_log_buffer[i]); }
}
free(disp_log_buffer);
@ -576,7 +576,7 @@ void DisplayAllocLogBuffer(void)
if (!disp_log_buffer_cols) {
disp_log_buffer = (char**)malloc(sizeof(*disp_log_buffer) * DISPLAY_LOG_ROWS);
if (disp_log_buffer != nullptr) {
for (uint32_t i = 0; i < DISPLAY_LOG_ROWS; i++) {
for (uint8_t i = 0; i < DISPLAY_LOG_ROWS; i++) {
disp_log_buffer[i] = (char*)malloc(sizeof(*disp_log_buffer[i]) * (Settings.display_cols[0] +1));
if (disp_log_buffer[i] == nullptr) {
DisplayFreeLogBuffer();

View File

@ -123,7 +123,7 @@ enum MP3_Commands { // commands useable in conso
uint16_t MP3_Checksum(uint8_t *array)
{
uint16_t checksum = 0;
for (uint32_t i = 0; i < 6; i++) {
for (uint8_t i = 0; i < 6; i++) {
checksum += array[i];
}
checksum = checksum^0xffff;

View File

@ -56,7 +56,7 @@ void PCA9685_Reset(void)
{
I2cWrite8(USE_PCA9685_ADDR, PCA9685_REG_MODE1, 0x80);
PCA9685_SetPWMfreq(USE_PCA9685_FREQ);
for (uint32_t pin=0;pin<16;pin++) {
for (uint8_t pin=0;pin<16;pin++) {
PCA9685_SetPWM(pin,0,false);
pca9685_pin_pwm_value[pin] = 0;
}
@ -112,7 +112,7 @@ bool PCA9685_Command(void)
return serviced;
}
char sub_string[XdrvMailbox.data_len];
for (uint32_t ca=0;ca<XdrvMailbox.data_len;ca++) {
for (uint8_t ca=0;ca<XdrvMailbox.data_len;ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
if (',' == XdrvMailbox.data[ca]) { paramcount++; }
}
@ -168,7 +168,7 @@ void PCA9685_OutputTelemetry(bool telemetry) {
if (0 == pca9685_detected) { return; } // We do not do this if the PCA9685 has not been detected
Response_P(PSTR("{\"" D_JSON_TIME "\":\"%s\",\"PCA9685\": {"), GetDateAndTime(DT_LOCAL).c_str());
ResponseAppend_P(PSTR("\"PWM_FREQ\":%i,"),pca9685_freq);
for (uint32_t pin=0;pin<16;pin++) {
for (uint8_t pin=0;pin<16;pin++) {
ResponseAppend_P(PSTR("\"PWM%i\":%i,"),pin,pca9685_pin_pwm_value[pin]);
}
ResponseAppend_P(PSTR("\"END\":1}}"));

View File

@ -248,7 +248,7 @@ void TuyaPacketProcess(void)
uint8_t key1_gpio = tuya_buffer[7];
bool key1_set = false;
bool led1_set = false;
for (uint32_t i = 0; i < sizeof(Settings.my_gp); i++) {
for (uint8_t i = 0; i < sizeof(Settings.my_gp); i++) {
if (Settings.my_gp.io[i] == GPIO_LED1) led1_set = true;
else if (Settings.my_gp.io[i] == GPIO_KEY1) key1_set = true;
}

View File

@ -364,7 +364,7 @@ void HueGlobalConfig(String *path)
path->remove(0,1); // cut leading / to get <id>
response = F("{\"lights\":{\"");
for (uint32_t i = 1; i <= maxhue; i++) {
for (uint8_t i = 1; i <= maxhue; i++) {
response += EncodeLightId(i);
response += F("\":{\"state\":");
HueLightStatus1(i, &response);
@ -408,7 +408,7 @@ void HueLights(String *path)
path->remove(0,path->indexOf("/lights")); // Remove until /lights
if (path->endsWith("/lights")) { // Got /lights
response = "{\"";
for (uint32_t i = 1; i <= maxhue; i++) {
for (uint8_t i = 1; i <= maxhue; i++) {
response += EncodeLightId(i);
response += F("\":{\"state\":");
HueLightStatus1(i, &response);
@ -604,7 +604,7 @@ void HueGroups(String *path)
if (path->endsWith("/0")) {
response = FPSTR(HUE_GROUP0_STATUS_JSON);
String lights = F("\"1\"");
for (uint32_t i = 2; i <= maxhue; i++) {
for (uint8_t i = 2; i <= maxhue; i++) {
lights += ",\"";
lights += EncodeLightId(i);
lights += "\"";

View File

@ -327,11 +327,11 @@ void DebugCfgPeek(char* parms)
uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + data16;
snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), address);
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[address +i]);
}
snprintf_P(log_data, sizeof(log_data), PSTR("%s |"), log_data);
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
snprintf_P(log_data, sizeof(log_data), PSTR("%s%c"), log_data, ((buffer[address +i] > 0x20) && (buffer[address +i] < 0x7F)) ? (char)buffer[address +i] : ' ');
}
snprintf_P(log_data, sizeof(log_data), PSTR("%s| 0x%02X (%d), 0x%04X (%d), 0x%0LX (%lu)"), log_data, data8, data8, data16, data16, data32, data32);
@ -352,7 +352,7 @@ void DebugCfgPoke(char* parms)
uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + (buffer[address +1] << 8) + buffer[address];
uint8_t *nbuffer = (uint8_t *) &data;
for (uint32_t i = 0; i < 4; i++) { buffer[address +i] = nbuffer[+i]; }
for (uint8_t i = 0; i < 4; i++) { buffer[address +i] = nbuffer[+i]; }
uint32_t ndata32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + (buffer[address +1] << 8) + buffer[address];

View File

@ -225,7 +225,7 @@ bool XdrvCall(uint8_t Function)
{
bool result = false;
for (uint32_t x = 0; x < xdrv_present; x++) {
for (uint8_t x = 0; x < xdrv_present; x++) {
// WifiAddDelayWhenDisconnected();
result = xdrv_func_ptr[x](Function);

View File

@ -110,7 +110,7 @@ void LcdCenter(uint8_t row, char* txt)
}
memset(line, 0x20, Settings.display_cols[0]);
line[Settings.display_cols[0]] = 0;
for (uint32_t i = 0; i < len; i++) {
for (uint8_t i = 0; i < len; i++) {
line[offset +i] = txt[i];
}
lcd->setCursor(0, row);
@ -130,7 +130,7 @@ bool LcdPrintLog(void)
if (txt != nullptr) {
uint8_t last_row = Settings.display_rows -1;
for (uint32_t i = 0; i < last_row; i++) {
for (uint8_t i = 0; i < last_row; i++) {
strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols);
lcd->setCursor(0, i); // Col 0, Row i
lcd->print(disp_screen_buffer[i +1]);

View File

@ -147,7 +147,7 @@ void Ssd1306PrintLog(void)
oled->clearDisplay();
oled->setTextSize(Settings.display_size);
oled->setCursor(0,0);
for (uint32_t i = 0; i < last_row; i++) {
for (uint8_t i = 0; i < last_row; i++) {
strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols);
oled->println(disp_screen_buffer[i]);
}

View File

@ -47,14 +47,14 @@ uint8_t mtx_done = 0;
void MatrixWrite(void)
{
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->writeDisplay();
}
}
void MatrixClear(void)
{
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->clear();
}
MatrixWrite();
@ -62,7 +62,7 @@ void MatrixClear(void)
void MatrixFixed(char* txt)
{
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->clear();
matrix[i]->setCursor(-i *8, 0);
matrix[i]->print(txt);
@ -77,7 +77,7 @@ void MatrixCenter(char* txt)
int len = strlen(txt);
offset = (len < 8) ? offset = ((mtx_matrices *8) - (len *6)) / 2 : 0;
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->clear();
matrix[i]->setCursor(-(i *8)+offset, 0);
matrix[i]->print(txt);
@ -101,7 +101,7 @@ void MatrixScrollLeft(char* txt, int loop)
disp_refresh--;
if (!disp_refresh) {
disp_refresh = Settings.display_refresh;
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->clear();
matrix[i]->setCursor(mtx_x - i *8, 0);
matrix[i]->print(txt);
@ -144,9 +144,9 @@ void MatrixScrollUp(char* txt, int loop)
words[wordcounter++] = p;
p = strtok(nullptr, separators);
}
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->clear();
for (uint32_t j = 0; j < wordcounter; j++) {
for (uint8_t j = 0; j < wordcounter; j++) {
matrix[i]->setCursor(-i *8, mtx_y + (j *8));
matrix[i]->println(words[j]);
}
@ -169,7 +169,7 @@ void MatrixScrollUp(char* txt, int loop)
void MatrixInitMode(void)
{
for (uint32_t i = 0; i < mtx_matrices; i++) {
for (uint8_t i = 0; i < mtx_matrices; i++) {
matrix[i]->setRotation(Settings.display_rotate); // 1
matrix[i]->setBrightness(Settings.display_dimmer);
matrix[i]->blinkRate(0); // 0 - 3

View File

@ -167,7 +167,7 @@ void Ili9341PrintLog(void)
tft_scroll = theight; // Start below header
tft->setCursor(0, tft_scroll);
for (uint32_t i = 0; i < last_row; i++) {
for (uint8_t i = 0; i < last_row; i++) {
strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols);
// tft->fillRect(0, tft_scroll, tft->width(), theight, ILI9341_BLACK); // Erase line
tft->print(disp_screen_buffer[i]);

View File

@ -209,7 +209,7 @@ void EpdPrintLog(void)
// epd_scroll = theight; // Start below header
epd_scroll = 0; // Start at top with no header
for (uint32_t i = 0; i < last_row; i++) {
for (uint8_t i = 0; i < last_row; i++) {
strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols);
EpdDrawStringAt(0, epd_scroll, disp_screen_buffer[i], COLORED, 0);
epd_scroll += theight;

View File

@ -123,7 +123,7 @@ bool XdspCall(uint8_t Function)
{
bool result = false;
for (uint32_t x = 0; x < xdsp_present; x++) {
for (uint8_t x = 0; x < xdsp_present; x++) {
result = xdsp_func_ptr[x](Function);
if (result && (FUNC_DISPLAY_MODEL == Function)) {

View File

@ -153,11 +153,11 @@ void HlwEvery200ms(void)
// Debugging for calculating mean and median
char stemp[100];
stemp[0] = '\0';
for (uint32_t i = 0; i < hlw_cf1_pulse_counter; i++) {
for (uint8_t i = 0; i < hlw_cf1_pulse_counter; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s %d"), stemp, hlw_debug[i]);
}
for (uint32_t i = 0; i < hlw_cf1_pulse_counter; i++) {
for (uint32_t j = i + 1; j < hlw_cf1_pulse_counter; j++) {
for (uint8_t i = 0; i < hlw_cf1_pulse_counter; i++) {
for (uint8_t j = i + 1; j < hlw_cf1_pulse_counter; j++) {
if (hlw_debug[i] > hlw_debug[j]) { // Sort ascending
std::swap(hlw_debug[i], hlw_debug[j]);
}

View File

@ -138,7 +138,7 @@ bool CseSerialInput(void)
AddLogSerial(LOG_LEVEL_DEBUG_MORE);
uint8_t checksum = 0;
for (uint32_t i = 2; i < 23; i++) { checksum += serial_in_buffer[i]; }
for (uint8_t i = 2; i < 23; i++) { checksum += serial_in_buffer[i]; }
if (checksum == serial_in_buffer[23]) {
energy_data_valid = 0;
CseReceived();

View File

@ -68,7 +68,7 @@ IPAddress pzem_ip(192, 168, 1, 1);
uint8_t PzemCrc(uint8_t *data)
{
uint16_t crc = 0;
for (uint32_t i = 0; i < sizeof(PZEMCommand) -1; i++) crc += *data++;
for (uint8_t i = 0; i < sizeof(PZEMCommand) -1; i++) crc += *data++;
return (uint8_t)(crc & 0xFF);
}
@ -77,7 +77,7 @@ void PzemSend(uint8_t cmd)
PZEMCommand pzem;
pzem.command = cmd;
for (uint32_t i = 0; i < sizeof(pzem.addr); i++) pzem.addr[i] = pzem_ip[i];
for (uint8_t i = 0; i < sizeof(pzem.addr); i++) pzem.addr[i] = pzem_ip[i];
pzem.data = 0;
uint8_t *bytes = (uint8_t*)&pzem;

View File

@ -121,7 +121,7 @@ uint8_t McpChecksum(uint8_t *data)
uint8_t offset = 0;
uint8_t len = data[1] -1;
for (uint32_t i = offset; i < len; i++) { checksum += data[i]; }
for (uint8_t i = offset; i < len; i++) { checksum += data[i]; }
return checksum;
}
@ -130,7 +130,7 @@ unsigned long McpExtractInt(char *data, uint8_t offset, uint8_t size)
unsigned long result = 0;
unsigned long pow = 1;
for (uint32_t i = 0; i < size; i++) {
for (uint8_t i = 0; i < size; i++) {
result = result + (uint8_t)data[offset + i] * pow;
pow = pow * 256;
}
@ -139,7 +139,7 @@ unsigned long McpExtractInt(char *data, uint8_t offset, uint8_t size)
void McpSetInt(unsigned long value, uint8_t *data, uint8_t offset, size_t size)
{
for (uint32_t i = 0; i < size; i++) {
for (uint8_t i = 0; i < size; i++) {
data[offset + i] = ((value >> (i * 8)) & 0xFF);
}
}
@ -154,7 +154,7 @@ void McpSend(uint8_t *data)
// AddLogBuffer(LOG_LEVEL_DEBUG_MORE, data, data[1]);
for (uint32_t i = 0; i < data[1]; i++) {
for (uint8_t i = 0; i < data[1]; i++) {
McpSerial->write(data[i]);
}
}

View File

@ -40,9 +40,9 @@ TasmotaModbus *PzemAcModbus;
uint16_t PzemCalculateCRC(uint8_t *buffer, uint8_t num)
{
uint16_t crc = 0xFFFF;
for (uint32_t i = 0; i < num; i++) {
for (uint8_t i = 0; i < num; i++) {
crc ^= buffer[i];
for (uint32_t j = 8; j; j--) {
for (uint8_t j = 8; j; j--) {
if ((crc & 0x0001) != 0) { // If the LSB is set
crc >>= 1; // Shift right and XOR 0xA001
crc ^= 0xA001;

View File

@ -96,7 +96,7 @@ int XnrgCall(uint8_t Function)
{
int result = 0;
for (uint32_t x = 0; x < xnrg_present; x++) {
for (uint8_t x = 0; x < xnrg_present; x++) {
result = xnrg_func_ptr[x](Function);
if (result && ((FUNC_SERIAL == Function) ||

View File

@ -98,7 +98,7 @@ void Ws2812StripShow(void)
#endif
if (Settings.light_correction) {
for (uint32_t i = 0; i < Settings.light_pixels; i++) {
for (uint16_t i = 0; i < Settings.light_pixels; i++) {
c = strip->GetPixelColor(i);
c.R = ledGamma(c.R);
c.G = ledGamma(c.G);
@ -149,7 +149,7 @@ void Ws2812UpdateHand(int position, uint8_t index)
uint8_t range = 1;
if (index < WS_MARKER) range = ((Settings.ws_width[index] -1) / 2) +1;
for (uint32_t h = 1; h < range; h++) {
for (uint8_t h = 1; h < range; h++) {
float offset = (float)(range - h) / (float)range;
Ws2812UpdatePixelColor(position -h, hand_color, offset);
Ws2812UpdatePixelColor(position +h, hand_color, offset);
@ -165,7 +165,7 @@ void Ws2812Clock(void)
Ws2812UpdateHand((RtcTime.minute * 1000) / clksize, WS_MINUTE);
Ws2812UpdateHand((((RtcTime.hour % 12) * 5000) + ((RtcTime.minute * 1000) / 12 )) / clksize, WS_HOUR);
if (Settings.ws_color[WS_MARKER][WS_RED] + Settings.ws_color[WS_MARKER][WS_GREEN] + Settings.ws_color[WS_MARKER][WS_BLUE]) {
for (uint32_t i = 0; i < 12; i++) {
for (uint8_t i = 0; i < 12; i++) {
Ws2812UpdateHand((i * 5000) / clksize, WS_MARKER);
}
}
@ -224,7 +224,7 @@ void Ws2812Gradient(uint8_t schemenr)
WsColor oldColor, currentColor;
Ws2812GradientColor(schemenr, &oldColor, range, gradRange, offset);
currentColor = oldColor;
for (uint32_t i = 0; i < Settings.light_pixels; i++) {
for (uint16_t i = 0; i < Settings.light_pixels; i++) {
if (kWsRepeat[Settings.light_width] > 1) {
Ws2812GradientColor(schemenr, &currentColor, range, gradRange, i +offset);
}
@ -329,7 +329,7 @@ void Ws2812SetColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue, uint
strip->SetPixelColor(led -1, lcolor); // Led 1 is strip Led 0 -> substract offset 1
} else {
// strip->ClearTo(lcolor); // Set WS2812_MAX_LEDS pixels
for (uint32_t i = 0; i < Settings.light_pixels; i++) {
for (uint16_t i = 0; i < Settings.light_pixels; i++) {
strip->SetPixelColor(i, lcolor);
}
}
@ -364,7 +364,7 @@ char* Ws2812GetColor(uint16_t led, char* scolor)
sl_ledcolor[1] = lcolor.G;
sl_ledcolor[2] = lcolor.B;
scolor[0] = '\0';
for (uint32_t i = 0; i < light_subtype; i++) {
for (uint8_t i = 0; i < light_subtype; i++) {
if (Settings.flag.decimal_text) {
snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", sl_ledcolor[i]);
} else {

View File

@ -73,7 +73,7 @@ void CounterUpdate4(void)
void CounterSaveState(void)
{
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
for (uint8_t i = 0; i < MAX_COUNTERS; i++) {
if (pin[GPIO_CNTR1 +i] < 99) {
Settings.pulse_counter[i] = RtcSettings.pulse_counter[i];
}
@ -85,7 +85,7 @@ void CounterInit(void)
typedef void (*function) () ;
function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 };
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
for (uint8_t i = 0; i < MAX_COUNTERS; i++) {
if (pin[GPIO_CNTR1 +i] < 99) {
pinMode(pin[GPIO_CNTR1 +i], bitRead(counter_no_pullup, i) ? INPUT : INPUT_PULLUP);
attachInterrupt(pin[GPIO_CNTR1 +i], counter_callbacks[i], FALLING);
@ -104,7 +104,7 @@ void CounterShow(bool json)
uint8_t dsxflg = 0;
uint8_t header = 0;
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
for (uint8_t i = 0; i < MAX_COUNTERS; i++) {
if (pin[GPIO_CNTR1 +i] < 99) {
char counter[33];
if (bitRead(Settings.pulse_counter_type, i)) {

View File

@ -78,7 +78,7 @@ uint16_t AdcRead(uint8_t factor)
// factor 5 = 32 samples
uint8_t samples = 1 << factor;
uint16_t analog = 0;
for (uint32_t i = 0; i < samples; i++) {
for (uint8_t i = 0; i < samples; i++) {
analog += analogRead(A0);
delay(1);
}

View File

@ -85,7 +85,7 @@ void SonoffScSerialInput(char *rcvstat)
value[i++] = atoi(str);
}
if (value[0] > 0) {
for (uint32_t i = 0; i < 5; i++) {
for (uint8_t i = 0; i < 5; i++) {
sc_value[i] = value[i];
}
sc_value[2] = (11 - sc_value[2]) * 10; // Invert light level

View File

@ -127,7 +127,7 @@ bool OneWireCrc8(uint8_t *addr)
while (len--) {
uint8_t inbyte = *addr++; // from 0 to 7
for (uint32_t i = 8; i; i--) {
for (uint8_t i = 8; i; i--) {
uint8_t mix = (crc ^ inbyte) & 0x01;
crc >>= 1;
if (mix) {
@ -161,11 +161,11 @@ bool Ds18b20Read(void)
return;
}
*/
for (uint32_t retry = 0; retry < 3; retry++) {
for (uint8_t retry = 0; retry < 3; retry++) {
OneWireReset();
OneWireWrite(W1_SKIP_ROM);
OneWireWrite(W1_READ_SCRATCHPAD);
for (uint32_t i = 0; i < 9; i++) {
for (uint8_t i = 0; i < 9; i++) {
data[i] = OneWireRead();
}
if (OneWireCrc8(data)) {

View File

@ -143,7 +143,7 @@ uint8_t OneWireRead(void)
void OneWireSelect(const uint8_t rom[8])
{
OneWireWrite(W1_MATCH_ROM);
for (uint32_t i = 0; i < 8; i++) {
for (uint8_t i = 0; i < 8; i++) {
OneWireWrite(rom[i]);
}
}
@ -153,7 +153,7 @@ void OneWireResetSearch(void)
onewire_last_discrepancy = 0;
onewire_last_device_flag = false;
onewire_last_family_discrepancy = 0;
for (uint32_t i = 0; i < 8; i++) {
for (uint8_t i = 0; i < 8; i++) {
onewire_rom_id[i] = 0;
}
}
@ -227,7 +227,7 @@ uint8_t OneWireSearch(uint8_t *newAddr)
onewire_last_family_discrepancy = 0;
search_result = false;
}
for (uint32_t i = 0; i < 8; i++) {
for (uint8_t i = 0; i < 8; i++) {
newAddr[i] = onewire_rom_id[i];
}
return search_result;
@ -240,7 +240,7 @@ bool OneWireCrc8(uint8_t *addr)
while (len--) {
uint8_t inbyte = *addr++; // from 0 to 7
for (uint32_t i = 8; i; i--) {
for (uint8_t i = 8; i; i--) {
uint8_t mix = (crc ^ inbyte) & 0x01;
crc >>= 1;
if (mix) {
@ -274,14 +274,14 @@ void Ds18x20Init(void)
(ds18x20_sensor[ds18x20_sensors].address[0] == MAX31850_CHIPID))) {
ds18x20_sensor[ds18x20_sensors].index = ds18x20_sensors;
ids[ds18x20_sensors] = ds18x20_sensor[ds18x20_sensors].address[0]; // Chip id
for (uint32_t j = 6; j > 0; j--) {
for (uint8_t j = 6; j > 0; j--) {
ids[ds18x20_sensors] = ids[ds18x20_sensors] << 8 | ds18x20_sensor[ds18x20_sensors].address[j];
}
ds18x20_sensors++;
}
}
for (uint32_t i = 0; i < ds18x20_sensors; i++) {
for (uint32_t j = i + 1; j < ds18x20_sensors; j++) {
for (uint8_t i = 0; i < ds18x20_sensors; i++) {
for (uint8_t j = i + 1; j < ds18x20_sensors; j++) {
if (ids[ds18x20_sensor[i].index] > ids[ds18x20_sensor[j].index]) { // Sort ascending
std::swap(ds18x20_sensor[i].index, ds18x20_sensor[j].index);
}
@ -312,11 +312,11 @@ bool Ds18x20Read(uint8_t sensor)
uint8_t index = ds18x20_sensor[sensor].index;
if (ds18x20_sensor[index].valid) { ds18x20_sensor[index].valid--; }
for (uint32_t retry = 0; retry < 3; retry++) {
for (uint8_t retry = 0; retry < 3; retry++) {
OneWireReset();
OneWireSelect(ds18x20_sensor[index].address);
OneWireWrite(W1_READ_SCRATCHPAD);
for (uint32_t i = 0; i < 9; i++) {
for (uint8_t i = 0; i < 9; i++) {
data[i] = OneWireRead();
}
if (OneWireCrc8(data)) {
@ -403,7 +403,7 @@ void Ds18x20EverySecond(void)
// 2mS
Ds18x20Convert(); // Start conversion, takes up to one second
} else {
for (uint32_t i = 0; i < ds18x20_sensors; i++) {
for (uint8_t i = 0; i < ds18x20_sensors; i++) {
// 12mS per device
if (!Ds18x20Read(i)) { // Read temperature
Ds18x20Name(i);
@ -421,7 +421,7 @@ void Ds18x20EverySecond(void)
void Ds18x20Show(bool json)
{
for (uint32_t i = 0; i < ds18x20_sensors; i++) {
for (uint8_t i = 0; i < ds18x20_sensors; i++) {
uint8_t index = ds18x20_sensor[i].index;
if (ds18x20_sensor[index].valid) { // Check for valid temperature
@ -435,7 +435,7 @@ void Ds18x20Show(bool json)
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s}"), ds18x20_types, temperature);
} else {
char address[17];
for (uint32_t j = 0; j < 6; j++) {
for (uint8_t j = 0; j < 6; j++) {
sprintf(address+2*j, "%02X", ds18x20_sensor[index].address[6-j]); // Skip sensor type and crc
}
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_ID "\":\"%s\",\"" D_JSON_TEMPERATURE "\":%s}"), ds18x20_types, address, temperature);

View File

@ -65,11 +65,11 @@ void Ds18x20Search(void)
num_sensors++;
}
}
for (uint32_t i = 0; i < num_sensors; i++) {
for (uint8_t i = 0; i < num_sensors; i++) {
ds18x20_index[i] = i;
}
for (uint32_t i = 0; i < num_sensors; i++) {
for (uint32_t j = i + 1; j < num_sensors; j++) {
for (uint8_t i = 0; i < num_sensors; i++) {
for (uint8_t j = i + 1; j < num_sensors; j++) {
if (uint32_t(ds18x20_address[ds18x20_index[i]]) > uint32_t(ds18x20_address[ds18x20_index[j]])) {
std::swap(ds18x20_index[i], ds18x20_index[j]);
}
@ -87,7 +87,7 @@ String Ds18x20Addresses(uint8_t sensor)
{
char address[20];
for (uint32_t i = 0; i < 8; i++) {
for (uint8_t i = 0; i < 8; i++) {
sprintf(address+2*i, "%02X", ds18x20_address[ds18x20_index[sensor]][i]);
}
return String(address);
@ -116,7 +116,7 @@ bool Ds18x20Read(uint8_t sensor, float &t)
ds->select(ds18x20_address[ds18x20_index[sensor]]);
ds->write(W1_READ_SCRATCHPAD); // Read Scratchpad
for (uint32_t i = 0; i < 9; i++) {
for (uint8_t i = 0; i < 9; i++) {
data[i] = ds->read();
}
if (OneWire::crc8(data, 8) == data[8]) {
@ -170,7 +170,7 @@ void Ds18x20Show(bool json)
float t;
uint8_t dsxflg = 0;
for (uint32_t i = 0; i < Ds18x20Sensors(); i++) {
for (uint8_t i = 0; i < Ds18x20Sensors(); i++) {
if (Ds18x20Read(i, t)) { // Check if read failed
Ds18x20Type(i);
char temperature[33];

View File

@ -47,7 +47,7 @@ struct DHTSTRUCT {
void DhtReadPrep(void)
{
for (uint32_t i = 0; i < dht_sensors; i++) {
for (uint8_t i = 0; i < dht_sensors; i++) {
digitalWrite(Dht[i].pin, HIGH);
}
}
@ -181,7 +181,7 @@ void DhtInit(void)
{
dht_max_cycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for reading pulses from DHT sensor.
for (uint32_t i = 0; i < dht_sensors; i++) {
for (uint8_t i = 0; i < dht_sensors; i++) {
pinMode(Dht[i].pin, INPUT_PULLUP);
Dht[i].lastreadtime = 0;
Dht[i].lastresult = 0;
@ -198,7 +198,7 @@ void DhtEverySecond(void)
// <1mS
DhtReadPrep();
} else {
for (uint32_t i = 0; i < dht_sensors; i++) {
for (uint8_t i = 0; i < dht_sensors; i++) {
// DHT11 and AM2301 25mS per sensor, SI7021 5mS per sensor
DhtReadTempHum(i);
}
@ -207,7 +207,7 @@ void DhtEverySecond(void)
void DhtShow(bool json)
{
for (uint32_t i = 0; i < dht_sensors; i++) {
for (uint8_t i = 0; i < dht_sensors; i++) {
char temperature[33];
dtostrfd(Dht[i].t, Settings.flag2.temperature_resolution, temperature);
char humidity[33];

View File

@ -49,7 +49,7 @@ bool ShtReset(void)
pinMode(sht_sda_pin, INPUT_PULLUP);
pinMode(sht_scl_pin, OUTPUT);
delay(11);
for (uint32_t i = 0; i < 9; i++) {
for (uint8_t i = 0; i < 9; i++) {
digitalWrite(sht_scl_pin, HIGH);
digitalWrite(sht_scl_pin, LOW);
}
@ -93,7 +93,7 @@ bool ShtSendCommand(const uint8_t cmd)
bool ShtAwaitResult(void)
{
// Maximum 320ms for 14 bit measurement
for (uint32_t i = 0; i < 16; i++) {
for (uint8_t i = 0; i < 16; i++) {
if (LOW == digitalRead(sht_sda_pin)) {
return true;
}

View File

@ -69,7 +69,7 @@ char htu_types[7];
uint8_t HtuCheckCrc8(uint16_t data)
{
for (uint32_t bit = 0; bit < 16; bit++) {
for (uint8_t bit = 0; bit < 16; bit++) {
if (data & 0x8000) {
data = (data << 1) ^ HTU21_CRC8_POLYNOM;
} else {

View File

@ -455,7 +455,7 @@ void BmpDetect(void)
if (!bmp_sensors) { return; }
memset(bmp_sensors, 0, bmp_sensor_size); // Init defaults to 0
for (uint32_t i = 0; i < BMP_MAX_SENSORS; i++) {
for (uint8_t i = 0; i < BMP_MAX_SENSORS; i++) {
uint8_t bmp_type = I2cRead8(bmp_addresses[i], BMP_REGISTER_CHIPID);
if (bmp_type) {
bmp_sensors[bmp_count].bmp_address = bmp_addresses[i];
@ -493,7 +493,7 @@ void BmpRead(void)
{
if (!bmp_sensors) { return; }
for (uint32_t bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) {
for (uint8_t bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) {
switch (bmp_sensors[bmp_idx].bmp_type) {
case BMP180_CHIPID:
Bmp180Read(bmp_idx);
@ -529,7 +529,7 @@ void BmpShow(bool json)
{
if (!bmp_sensors) { return; }
for (uint32_t bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) {
for (uint8_t bmp_idx = 0; bmp_idx < bmp_count; bmp_idx++) {
if (bmp_sensors[bmp_idx].bmp_type) {
float bmp_sealevel = 0.0;
if (bmp_sensors[bmp_idx].bmp_pressure != 0.0) {

View File

@ -59,7 +59,7 @@ void Bh1750Detect(void)
return;
}
for (uint32_t i = 0; i < sizeof(bh1750_addresses); i++) {
for (uint8_t i = 0; i < sizeof(bh1750_addresses); i++) {
bh1750_address = bh1750_addresses[i];
Wire.beginTransmission(bh1750_address);
Wire.write(BH1750_CONTINUOUS_HIGH_RES_MODE);

View File

@ -149,7 +149,7 @@ void Veml6070Detect(void)
void Veml6070UvTableInit(void)
{
// fill the uv-risk compare table once, based on the coefficient calculation
for (uint32_t i = 0; i < VEML6070_UV_MAX_INDEX; i++) {
for (uint8_t i = 0; i < VEML6070_UV_MAX_INDEX; i++) {
#ifdef USE_VEML6070_RSET
if ( (USE_VEML6070_RSET >= 220000) && (USE_VEML6070_RSET <= 1000000) ) {
uv_risk_map[i] = ( (USE_VEML6070_RSET / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);

View File

@ -161,7 +161,7 @@ int16_t Ads1115GetConversion(uint8_t channel)
void Ads1115Detect(void)
{
uint16_t buffer;
for (uint32_t i = 0; i < sizeof(ads1115_addresses); i++) {
for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) {
if (!ads1115_found[i]) {
ads1115_address = ads1115_addresses[i];
if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) &&
@ -179,7 +179,7 @@ void Ads1115GetValues(uint8_t address)
{
uint8_t old_address = ads1115_address;
ads1115_address = address;
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
ads1115_values[i] = Ads1115GetConversion(i);
//AddLog_P2(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", address, i, ads1115_values[i] );
}
@ -190,7 +190,7 @@ void Ads1115toJSON(char *comma_j)
{
ResponseAppend_P(PSTR("%s{"), comma_j);
char *comma = (char*)"";
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
ResponseAppend_P(PSTR("%s\"A%d\":%d"), comma, i, ads1115_values[i]);
comma = (char*)",";
}
@ -202,7 +202,7 @@ void Ads1115toString(uint8_t address)
char label[15];
snprintf_P(label, sizeof(label), "ADS1115(%02x)", address);
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
WSContentSend_PD(HTTP_SNS_ANALOG, label, i, ads1115_values[i]);
}
}
@ -217,7 +217,7 @@ void Ads1115Show(bool json)
char *comma = (char*)"";
for (uint32_t t = 0; t < sizeof(ads1115_addresses); t++) {
for (uint8_t t = 0; t < sizeof(ads1115_addresses); t++) {
//AddLog_P2(LOG_LEVEL_INFO, "Logging ADS1115 %02x", ads1115_addresses[t]);
if (ads1115_found[t]) {
Ads1115GetValues(ads1115_addresses[t]);

View File

@ -81,7 +81,7 @@ void Ads1115Detect(void)
return;
}
for (uint32_t i = 0; i < sizeof(ads1115_addresses); i++) {
for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) {
ads1115_address = ads1115_addresses[i];
ADS1115 adc0(ads1115_address);
if (adc0.testConnection()) {
@ -101,7 +101,7 @@ void Ads1115Show(bool json)
if (ads1115_type) {
uint8_t dsxflg = 0;
for (uint32_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 4; i++) {
int16_t adc_value = Ads1115GetConversion(i);
if (json) {

View File

@ -194,7 +194,7 @@ void Ina219Detect(void)
{
if (ina219_type) { return; }
for (uint32_t i = 0; i < sizeof(ina219_addresses); i++) {
for (uint8_t i = 0; i < sizeof(ina219_addresses); i++) {
ina219_address = ina219_addresses[i];
if (Ina219SetCalibration(Settings.ina219_mode)) {
ina219_type = 1;

View File

@ -82,7 +82,7 @@ void Sht3xDetect(void)
float t;
float h;
for (uint32_t i = 0; i < SHT3X_MAX_SENSORS; i++) {
for (uint8_t i = 0; i < SHT3X_MAX_SENSORS; i++) {
if (Sht3xRead(t, h, sht3x_addresses[i])) {
sht3x_sensors[sht3x_count].address = sht3x_addresses[i];
GetTextIndexed(sht3x_sensors[sht3x_count].types, sizeof(sht3x_sensors[sht3x_count].types), i, kShtTypes);
@ -98,7 +98,7 @@ void Sht3xShow(bool json)
float t;
float h;
char types[11];
for (uint32_t i = 0; i < sht3x_count; i++) {
for (uint8_t i = 0; i < sht3x_count; i++) {
if (Sht3xRead(t, h, sht3x_sensors[i].address)) {
char temperature[33];
dtostrfd(t, Settings.flag2.temperature_resolution, temperature);

View File

@ -102,7 +102,7 @@ uint8_t mhz_state = 0;
uint8_t MhzCalculateChecksum(uint8_t *array)
{
uint8_t checksum = 0;
for (uint32_t i = 1; i < 8; i++) {
for (uint8_t i = 1; i < 8; i++) {
checksum += array[i];
}
checksum = 255 - checksum;

View File

@ -65,12 +65,12 @@ bool PmsReadData(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 32);
// get checksum ready
for (uint32_t i = 0; i < 30; i++) {
for (uint8_t i = 0; i < 30; i++) {
sum += buffer[i];
}
// The data comes in endian'd, this solves it so it works on all platforms
uint16_t buffer_u16[15];
for (uint32_t i = 0; i < 15; i++) {
for (uint8_t i = 0; i < 15; i++) {
buffer_u16[i] = buffer[2 + i*2 + 1];
buffer_u16[i] += (buffer[2 + i*2] << 8);
}

View File

@ -77,7 +77,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
uint8_t novasds_cmnd[19] = {0xAA, 0xB4, byte1, byte2, byte3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (uint8_t)(sensorid & 0xFF), (uint8_t)((sensorid>>8) & 0xFF), 0x00, 0xAB};
// calc crc
for (uint32_t i = 2; i < 17; i++) {
for (uint8_t i = 2; i < 17; i++) {
novasds_cmnd[17] += novasds_cmnd[i];
}
//~ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SDS: Send %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X"),

View File

@ -128,9 +128,9 @@ uint16_t SDM120_calculateCRC(uint8_t *frame, uint8_t num)
{
uint16_t crc, flag;
crc = 0xFFFF;
for (uint32_t i = 0; i < num; i++) {
for (uint8_t i = 0; i < num; i++) {
crc ^= frame[i];
for (uint32_t j = 8; j; j--) {
for (uint8_t j = 8; j; j--) {
if ((crc & 0x0001) != 0) { // If the LSB is set
crc >>= 1; // Shift right and XOR 0xA001
crc ^= 0xA001;

View File

@ -105,9 +105,9 @@ uint16_t SDM630_calculateCRC(uint8_t *frame, uint8_t num)
{
uint16_t crc, flag;
crc = 0xFFFF;
for (uint32_t i = 0; i < num; i++) {
for (uint8_t i = 0; i < num; i++) {
crc ^= frame[i];
for (uint32_t j = 8; j; j--) {
for (uint8_t j = 8; j; j--) {
if ((crc & 0x0001) != 0) { // If the LSB is set
crc >>= 1; // Shift right and XOR 0xA001
crc ^= 0xA001;

View File

@ -53,7 +53,7 @@ void LM75ADDetect(void)
if (lm75ad_type) { return; }
uint16_t buffer;
for (uint32_t i = 0; i < sizeof(lm75ad_addresses); i++) {
for (uint8_t i = 0; i < sizeof(lm75ad_addresses); i++) {
lm75ad_address = lm75ad_addresses[i];
if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER)) {
if (buffer == 0x4B00) {

View File

@ -48,7 +48,7 @@ uint8_t tm1638_state = 0;
void Tm16XXSend(uint8_t data)
{
for (uint32_t i = 0; i < 8; i++) {
for (uint8_t i = 0; i < 8; i++) {
digitalWrite(tm1638_data_pin, !!(data & (1 << i)));
digitalWrite(tm1638_clock_pin, LOW);
delayMicroseconds(TM1638_CLOCK_DELAY);
@ -80,7 +80,7 @@ uint8_t Tm16XXReceive(void)
pinMode(tm1638_data_pin, INPUT);
digitalWrite(tm1638_data_pin, HIGH);
for (uint32_t i = 0; i < 8; ++i) {
for (uint8_t i = 0; i < 8; ++i) {
digitalWrite(tm1638_clock_pin, LOW);
delayMicroseconds(TM1638_CLOCK_DELAY);
temp |= digitalRead(tm1638_data_pin) << i;
@ -175,7 +175,7 @@ void TmLoop(void)
{
if (tm1638_state) {
uint8_t buttons = Tm1638GetButtons();
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
SwitchSetVirtual(i, (buttons &1) ^1);
uint8_t color = (SwitchGetVirtual(i)) ? TM1638_COLOR_NONE : TM1638_COLOR_RED;
Tm1638SetLED(color, i);

View File

@ -68,7 +68,7 @@ const char MCP230XX_CMND_RESPONSE[] PROGMEM = "{\"S29cmnd_D%i\":{\"COMMAND\":\"%
void MCP230xx_CheckForIntCounter(void) {
uint8_t en = 0;
for (uint32_t ca=0;ca<16;ca++) {
for (uint8_t ca=0;ca<16;ca++) {
if (Settings.mcp230xx_config[ca].int_count_en) {
en=1;
}
@ -76,7 +76,7 @@ void MCP230xx_CheckForIntCounter(void) {
if (!Settings.mcp230xx_int_timer) en=0;
mcp230xx_int_counter_en=en;
if (!mcp230xx_int_counter_en) { // Interrupt counters are disabled, so we clear all the counters
for (uint32_t ca=0;ca<16;ca++) {
for (uint8_t ca=0;ca<16;ca++) {
mcp230xx_int_counter[ca] = 0;
}
}
@ -84,14 +84,14 @@ void MCP230xx_CheckForIntCounter(void) {
void MCP230xx_CheckForIntRetainer(void) {
uint8_t en = 0;
for (uint32_t ca=0;ca<16;ca++) {
for (uint8_t ca=0;ca<16;ca++) {
if (Settings.mcp230xx_config[ca].int_retain_flag) {
en=1;
}
}
mcp230xx_int_retainer_en=en;
if (!mcp230xx_int_retainer_en) { // Interrupt counters are disabled, so we clear all the counters
for (uint32_t ca=0;ca<16;ca++) {
for (uint8_t ca=0;ca<16;ca++) {
mcp230xx_int_retainer[ca] = 0;
}
}
@ -141,14 +141,14 @@ uint8_t MCP230xx_readGPIO(uint8_t port) {
void MCP230xx_ApplySettings(void) {
uint8_t int_en = 0;
for (uint32_t mcp230xx_port=0;mcp230xx_port<mcp230xx_type;mcp230xx_port++) {
for (uint8_t mcp230xx_port=0;mcp230xx_port<mcp230xx_type;mcp230xx_port++) {
uint8_t reg_gppu = 0;
uint8_t reg_gpinten = 0;
uint8_t reg_iodir = 0xFF;
#ifdef USE_MCP230xx_OUTPUT
uint8_t reg_portpins = 0x00;
#endif // USE_MCP230xx_OUTPUT
for (uint32_t idx = 0; idx < 8; idx++) {
for (uint8_t idx = 0; idx < 8; idx++) {
switch (Settings.mcp230xx_config[idx+(mcp230xx_port*8)].pinmode) {
case 0 ... 1:
reg_iodir |= (1 << idx);
@ -190,7 +190,7 @@ void MCP230xx_ApplySettings(void) {
I2cWrite8(USE_MCP230xx_ADDR, MCP230xx_GPIO+mcp230xx_port, reg_portpins);
#endif // USE_MCP230xx_OUTPUT
}
for (uint32_t idx=0;idx<mcp230xx_pincount;idx++) {
for (uint8_t idx=0;idx<mcp230xx_pincount;idx++) {
int_millis[idx]=millis();
}
mcp230xx_int_en = int_en;
@ -236,11 +236,11 @@ void MCP230xx_CheckForInterrupt(void) {
uint8_t intf;
uint8_t mcp230xx_intcap = 0;
uint8_t report_int;
for (uint32_t mcp230xx_port=0;mcp230xx_port<mcp230xx_type;mcp230xx_port++) {
for (uint8_t mcp230xx_port=0;mcp230xx_port<mcp230xx_type;mcp230xx_port++) {
if (I2cValidRead8(&intf,USE_MCP230xx_ADDR,MCP230xx_INTF+mcp230xx_port)) {
if (intf > 0) {
if (I2cValidRead8(&mcp230xx_intcap, USE_MCP230xx_ADDR, MCP230xx_INTCAP+mcp230xx_port)) {
for (uint32_t intp = 0; intp < 8; intp++) {
for (uint8_t intp = 0; intp < 8; intp++) {
if ((intf >> intp) & 0x01) { // we know which pin caused interrupt
report_int = 0;
if (Settings.mcp230xx_config[intp+(mcp230xx_port*8)].pinmode > 1) {
@ -394,7 +394,7 @@ void MCP230xx_SetOutPin(uint8_t pin,uint8_t pinstate) {
void MCP230xx_Reset(uint8_t pinmode) {
uint8_t pullup = 0;
if ((pinmode > 1) && (pinmode < 5)) { pullup=1; }
for (uint32_t pinx=0;pinx<16;pinx++) {
for (uint8_t pinx=0;pinx<16;pinx++) {
Settings.mcp230xx_config[pinx].pinmode=pinmode;
Settings.mcp230xx_config[pinx].pullup=pullup;
Settings.mcp230xx_config[pinx].saved_state=0;
@ -433,7 +433,7 @@ bool MCP230xx_Command(void) {
return serviced;
}
char sub_string[XdrvMailbox.data_len];
for (uint32_t ca=0;ca<XdrvMailbox.data_len;ca++) {
for (uint8_t ca=0;ca<XdrvMailbox.data_len;ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
if (',' == XdrvMailbox.data[ca]) { paramcount++; }
}
@ -702,7 +702,7 @@ void MCP230xx_UpdateWebData(void) {
gpio2 = MCP230xx_readGPIO(1);
}
uint16_t gpio = (gpio2 << 8) + gpio1;
for (uint32_t pin = 0; pin < mcp230xx_pincount; pin++) {
for (uint8_t pin = 0; pin < mcp230xx_pincount; pin++) {
if (Settings.mcp230xx_config[pin].pinmode >= 5) {
char stt[7];
sprintf(stt,ConvertNumTxt((gpio>>pin)&1,Settings.mcp230xx_config[pin].pinmode));
@ -724,13 +724,13 @@ void MCP230xx_OutputTelemetry(void) {
gpioa=MCP230xx_readGPIO(0);
if (2 == mcp230xx_type) { gpiob=MCP230xx_readGPIO(1); }
gpiototal=((uint16_t)gpiob << 8) | gpioa;
for (uint32_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
if (Settings.mcp230xx_config[pinx].pinmode >= 5) outputcount++;
}
if (outputcount) {
char stt[7];
Response_P(PSTR("{\"" D_JSON_TIME "\":\"%s\",\"MCP230_OUT\": {"), GetDateAndTime(DT_LOCAL).c_str());
for (uint32_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
if (Settings.mcp230xx_config[pinx].pinmode >= 5) {
sprintf(stt,ConvertNumTxt(((gpiototal>>pinx)&1),Settings.mcp230xx_config[pinx].pinmode));
ResponseAppend_P(PSTR("\"OUT_D%i\":\"%s\","),pinx,stt);
@ -745,7 +745,7 @@ void MCP230xx_OutputTelemetry(void) {
void MCP230xx_Interrupt_Counter_Report(void) {
Response_P(PSTR("{\"" D_JSON_TIME "\":\"%s\",\"MCP230_INTTIMER\": {"), GetDateAndTime(DT_LOCAL).c_str());
for (uint32_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
if (Settings.mcp230xx_config[pinx].int_count_en) { // Counting is enabled for this pin so we add to report
ResponseAppend_P(PSTR("\"INTCNT_D%i\":%i,"),pinx,mcp230xx_int_counter[pinx]);
mcp230xx_int_counter[pinx]=0;
@ -759,7 +759,7 @@ void MCP230xx_Interrupt_Counter_Report(void) {
void MCP230xx_Interrupt_Retain_Report(void) {
uint16_t retainresult = 0;
Response_P(PSTR("{\"" D_JSON_TIME "\":\"%s\",\"MCP_INTRETAIN\": {"), GetDateAndTime(DT_LOCAL).c_str());
for (uint32_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
if (Settings.mcp230xx_config[pinx].int_retain_flag) {
ResponseAppend_P(PSTR("\"D%i\":%i,"),pinx,mcp230xx_int_retainer[pinx]);
retainresult |= (((mcp230xx_int_retainer[pinx])&1) << pinx);

View File

@ -212,7 +212,7 @@ void Mpr121Init(struct mpr121 *pS)
{
// Loop through I2C addresses
for (uint32_t i = 0; i < sizeof(pS->i2c_addr[i]); i++) {
for (uint8_t i = 0; i < sizeof(pS->i2c_addr[i]); i++) {
// Soft reset sensor and check if connected at I2C address
pS->connected[i] = (I2cWrite8(pS->i2c_addr[i], MPR121_SRST_REG, MPR121_SRST_VAL)
@ -223,7 +223,7 @@ void Mpr121Init(struct mpr121 *pS)
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121(%c) " D_FOUND_AT " 0x%X"), pS->id[i], pS->i2c_addr[i]);
// Set thresholds for registers 0x41 - 0x5A (ExTTH and ExRTH)
for (uint32_t j = 0; j < 13; j++) {
for (uint8_t j = 0; j < 13; j++) {
// Touch
I2cWrite8(pS->i2c_addr[i], MPR121_E0TTH_REG + 2 * j, MPR121_E0TTH_VAL);
@ -317,7 +317,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
{
// Loop through sensors
for (uint32_t i = 0; i < sizeof(pS->i2c_addr[i]); i++) {
for (uint8_t i = 0; i < sizeof(pS->i2c_addr[i]); i++) {
// Check if sensor is connected
if (pS->connected[i]) {
@ -346,7 +346,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
ResponseAppend_P(PSTR(",\"MPR121%c\":{"), pS->id[i]);
}
// Loop through buttons
for (uint32_t j = 0; j < 13; j++) {
for (uint8_t j = 0; j < 13; j++) {
// Add sensor, button and state to MQTT JSON message string
if ((FUNC_EVERY_50_MSECOND == function)

View File

@ -120,7 +120,7 @@ void MPU_6050Detect(void)
return;
}
for (uint32_t i = 0; i < sizeof(MPU_6050_addresses); i++)
for (uint8_t i = 0; i < sizeof(MPU_6050_addresses); i++)
{
if(!I2cDevice(MPU_6050_addresses[i]))
{

View File

@ -164,7 +164,7 @@ bool HxCommand(void)
bool show_parms = false;
char sub_string[XdrvMailbox.data_len +1];
for (uint32_t ca = 0; ca < XdrvMailbox.data_len; ca++) {
for (uint8_t ca = 0; ca < XdrvMailbox.data_len; ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
}

View File

@ -259,7 +259,7 @@ void RfSnsTheoV2Show(bool json)
{
bool sensor_once = false;
for (uint32_t i = 0; i < RFSNS_THEOV2_MAX_CHANNEL; i++) {
for (uint8_t i = 0; i < RFSNS_THEOV2_MAX_CHANNEL; i++) {
if (rfsns_theo_v2_t1[i].time) {
char sensor[10];
snprintf_P(sensor, sizeof(sensor), PSTR("TV2T1C%d"), i +1);
@ -296,7 +296,7 @@ void RfSnsTheoV2Show(bool json)
}
sensor_once = false;
for (uint32_t i = 0; i < RFSNS_THEOV2_MAX_CHANNEL; i++) {
for (uint8_t i = 0; i < RFSNS_THEOV2_MAX_CHANNEL; i++) {
if (rfsns_theo_v2_t2[i].time) {
char sensor[10];
snprintf_P(sensor, sizeof(sensor), PSTR("TV2T2C%d"), i +1);
@ -453,7 +453,7 @@ void RfSnsAnalyzeAlectov2()
if (rfsns_raw_signal->Number > RFSNS_ACH2010_MAX_PULSECOUNT) { maxidx = 9; }
// Get message back to front as the header is almost never received complete for ACH2010
uint8_t idx = maxidx;
for (uint32_t x = rfsns_raw_signal->Number; x > 0; x = x-2) {
for (uint8_t x = rfsns_raw_signal->Number; x > 0; x = x-2) {
if (rfsns_raw_signal->Pulses[x-1] * rfsns_raw_signal->Multiply < 0x300) {
rfbit = 0x80;
} else {
@ -528,7 +528,7 @@ uint8_t RfSnsAlectoCRC8(uint8_t *addr, uint8_t len)
uint8_t crc = 0;
while (len--) {
uint8_t inbyte = *addr++;
for (uint32_t i = 8; i; i--) {
for (uint8_t i = 8; i; i--) {
uint8_t mix = (crc ^ inbyte) & 0x80;
crc <<= 1;
if (mix) { crc ^= 0x31; }

View File

@ -142,12 +142,12 @@ int8_t PN532_writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *bo
uint8_t sum = PN532_HOSTTOPN532; // sum of TFI + DATA
PN532_Serial->write(header, hlen);
for (uint32_t i = 0; i < hlen; i++) {
for (uint8_t i = 0; i < hlen; i++) {
sum += header[i];
}
PN532_Serial->write(body, blen);
for (uint32_t i = 0; i < blen; i++) {
for (uint8_t i = 0; i < blen; i++) {
sum += body[i];
}
@ -198,7 +198,7 @@ int16_t PN532_readResponse(uint8_t buf[], uint8_t len, uint16_t timeout = 50)
}
uint8_t sum = PN532_PN532TOHOST + cmd;
for (uint32_t i=0; i<length[0]; i++) {
for (uint8_t i=0; i<length[0]; i++) {
sum += buf[i];
}
@ -282,7 +282,7 @@ bool PN532_readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidL
/* Card appears to be Mifare Classic */
*uidLength = pn532_packetbuffer[5];
for (uint32_t i = 0; i < pn532_packetbuffer[5]; i++) {
for (uint8_t i = 0; i < pn532_packetbuffer[5]; i++) {
uid[i] = pn532_packetbuffer[6 + i];
}
@ -418,7 +418,7 @@ void PN532_ScanForTag(void)
#endif // USE_PN532_DATA_FUNCTION
sprintf(uids,"");
for (uint32_t i = 0;i < uid_len;i++) {
for (uint8_t i = 0;i < uid_len;i++) {
sprintf(uids,"%s%02X",uids,uid[i]);
}
@ -430,7 +430,7 @@ void PN532_ScanForTag(void)
#ifdef USE_PN532_DATA_RAW
memcpy(&card_datas,&card_data,sizeof(card_data));
#else
for (uint32_t i = 0;i < sizeof(card_data);i++) {
for (uint8_t i = 0;i < sizeof(card_data);i++) {
if ((isalpha(card_data[i])) || ((isdigit(card_data[i])))) {
card_datas[i] = char(card_data[i]);
} else {
@ -440,7 +440,7 @@ void PN532_ScanForTag(void)
#endif // USE_PN532_DATA_RAW
}
if (pn532_function == 1) { // erase block 1 of card
for (uint32_t i = 0;i<16;i++) {
for (uint8_t i = 0;i<16;i++) {
card_data[i] = 0x00;
}
if (mifareclassic_WriteDataBlock(1, card_data)) {
@ -459,7 +459,7 @@ void PN532_ScanForTag(void)
}
#else
bool IsAlphaNumeric = true;
for (uint32_t i = 0;i < pn532_newdata_len;i++) {
for (uint8_t i = 0;i < pn532_newdata_len;i++) {
if ((!isalpha(pn532_newdata[i])) && (!isdigit(pn532_newdata[i]))) {
IsAlphaNumeric = false;
}
@ -536,7 +536,7 @@ bool PN532_Command(void)
}
char sub_string[XdrvMailbox.data_len];
char sub_string_tmp[XdrvMailbox.data_len];
for (uint32_t ca=0;ca<XdrvMailbox.data_len;ca++) {
for (uint8_t ca=0;ca<XdrvMailbox.data_len;ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
if (',' == XdrvMailbox.data[ca]) { paramcount++; }
}

View File

@ -74,7 +74,7 @@ void Max4409Detect(void)
uint8_t buffer1;
uint8_t buffer2;
for (uint32_t i = 0; 0 != max44009_addresses[i]; i++) {
for (uint8_t i = 0; 0 != max44009_addresses[i]; i++) {
max44009_address = max44009_addresses[i];

View File

@ -58,7 +58,7 @@ struct SPS30 {
uint8_t sps30_calc_CRC(uint8_t *data) {
uint8_t crc = 0xFF;
for (uint32_t i = 0; i < 2; i++) {
for (uint8_t i = 0; i < 2; i++) {
crc ^= data[i];
for(uint8_t bit = 8; bit > 0; --bit) {
if(crc & 0x80) {
@ -172,8 +172,8 @@ void SPS30_Every_Second() {
ByteToFloat conv;
for (uint32_t count=0; count<10; count++) {
for (uint32_t i = 0; i < 4; i++){
for (uint8_t count=0; count<10; count++) {
for (uint8_t i = 0; i < 4; i++){
conv.array[3-i] = vars[count*sizeof(float)+i];
}
*fp++=conv.value;

View File

@ -290,7 +290,7 @@ bool XsnsCall(uint8_t Function)
uint32_t profile_start_millis = millis();
#endif // PROFILE_XSNS_EVERY_SECOND
for (uint32_t x = 0; x < xsns_present; x++) {
for (uint8_t x = 0; x < xsns_present; x++) {
#ifdef USE_DEBUG_DRIVER
if (XsnsEnabled(x)) {
#endif

View File

@ -277,7 +277,7 @@ bool XsnsEnabled(uint8_t sns_index)
bool XsnsPresent(uint8_t sns_index)
{
uint8_t index = 0;
for (uint32_t i = 0; i < sizeof(kXsnsList); i++) {
for (uint8_t i = 0; i < sizeof(kXsnsList); i++) {
#ifdef XFUNC_PTR_IN_ROM
index = pgm_read_byte(kXsnsList + i);
#else
@ -293,7 +293,7 @@ String XsnsGetSensors(void)
char state[2] = { 0 };
String data = F("[");
for (uint32_t i = 0; i < MAX_XSNS_DRIVERS; i++) {
for (uint8_t i = 0; i < MAX_XSNS_DRIVERS; i++) {
if (i && (!(i % 16))) { data += F(","); }
if (!(i % 16)) { data += F("\""); }
state[0] = '-';