mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-10-26 22:10:45 +00:00
[Build] Change 'long' to 'int32_t' and fix some signed/unsigned issues
This commit is contained in:
1 parent
157a954e5d
commit
c46d726f21
28 files changed
+79
-69
No files matched your search
+1
-1
@@ -85,7 +85,7 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String&
|
||||
if (validControllerIndex(ControllerID)) {
|
||||
unsigned int idx;
|
||||
float nvalue;
|
||||
long nvaluealt;
|
||||
int32_t nvaluealt;
|
||||
String svalue1, switchtype;
|
||||
|
||||
if (deserializeDomoticzJson(event->String2, idx, nvalue, nvaluealt, svalue1, switchtype)) {
|
||||
|
||||
@@ -382,7 +382,7 @@ void Dallas_plugin_set_addr(uint8_t addr[], taskIndex_t TaskIndex, uint8_t var_i
|
||||
uint32_t value = (uint32_t)ExtraTaskSettings.TaskDevicePluginConfigLong[x];
|
||||
value &= mask;
|
||||
value += (static_cast<uint32_t>(addr[x]) << (var_index * 8));
|
||||
ExtraTaskSettings.TaskDevicePluginConfigLong[x] = (long)value;
|
||||
ExtraTaskSettings.TaskDevicePluginConfigLong[x] = (int32_t)value;
|
||||
}
|
||||
Cache.updateExtraTaskSettingsCache();
|
||||
}
|
||||
@@ -771,7 +771,7 @@ bool Dallas_setResolution(const uint8_t ROM[8], uint8_t res, int8_t gpio_pin_rx,
|
||||
|
||||
// save the newly written values to eeprom
|
||||
Dallas_write(0x48, gpio_pin_rx, gpio_pin_tx);
|
||||
delay(100); // <--- added 20ms delay to allow 10ms long EEPROM write operation (as specified by datasheet)
|
||||
delay(100); // <--- added 20ms delay to allow 10ms int32_t EEPROM write operation (as specified by datasheet)
|
||||
Dallas_reset(gpio_pin_rx, gpio_pin_tx);
|
||||
|
||||
return true; // new value set
|
||||
@@ -860,7 +860,7 @@ uint8_t Dallas_reset(int8_t gpio_pin_rx, int8_t gpio_pin_tx)
|
||||
// t_PDL 60 ... 240 usec
|
||||
|
||||
// Signal will rise only due to pull-up resistor
|
||||
// Meaning measured duration may be off by usec_release (too long)
|
||||
// Meaning measured duration may be off by usec_release (too int32_t)
|
||||
presence_end = Dallas_measureWaitForPinHigh(gpio_pin_rx, start, 60 + 240);
|
||||
|
||||
// Set the pin high, just in case we have a (single) parasitic powered sensor
|
||||
@@ -1174,8 +1174,8 @@ void Dallas_write_bit(uint8_t v, int8_t gpio_pin_rx, int8_t gpio_pin_tx)
|
||||
// write 1: low 6 usec, high 64 usec (no less than 6 usec low, or else scanning will no longer work)
|
||||
// write 0: low 60 usec, high 20 usec
|
||||
// High time is based on the recovery time, which is detected during reset
|
||||
const long low_time = (v & 1) ? 7 : 60;
|
||||
const long high_time = (v & 1) ? (40 + usec_release) : (2 * usec_release + 20); // Recovery time
|
||||
const int32_t low_time = (v & 1) ? 7 : 60;
|
||||
const int32_t high_time = (v & 1) ? (40 + usec_release) : (2 * usec_release + 20); // Recovery time
|
||||
uint32_t start = 0;
|
||||
|
||||
Dallas_write_bit_ISR(v, gpio_pin_rx, gpio_pin_tx, low_time, high_time, start);
|
||||
@@ -1191,8 +1191,8 @@ void Dallas_write_bit(uint8_t v, int8_t gpio_pin_rx, int8_t gpio_pin_tx)
|
||||
void DALLAS_IRAM_ATTR Dallas_write_bit_ISR(uint8_t v,
|
||||
int8_t gpio_pin_rx,
|
||||
int8_t gpio_pin_tx,
|
||||
long low_time,
|
||||
long high_time,
|
||||
int32_t low_time,
|
||||
int32_t high_time,
|
||||
uint32_t& start)
|
||||
{
|
||||
ISR_noInterrupts();
|
||||
|
||||
@@ -239,8 +239,8 @@ void Dallas_write_bit(uint8_t v,
|
||||
void Dallas_write_bit_ISR(uint8_t v,
|
||||
int8_t gpio_pin_rx,
|
||||
int8_t gpio_pin_tx,
|
||||
long low_time,
|
||||
long high_time,
|
||||
int32_t low_time,
|
||||
int32_t high_time,
|
||||
uint32_t& start);
|
||||
|
||||
/*********************************************************************************************\
|
||||
|
||||
@@ -21,49 +21,55 @@ inline uint64_t getMicros64() {
|
||||
// Returned timediff for millis() is between -24.9 days and +24.9 days.
|
||||
// for micros() is between -35.79 and +35.79 minutes
|
||||
// Returned value is positive when "next" is after "prev"
|
||||
inline int32_t timeDiff(const uint32_t prev, const uint32_t next) {
|
||||
inline int32_t timeDiff(const uint32_t& prev, const uint32_t& next) {
|
||||
return ((int32_t) (next - prev));
|
||||
}
|
||||
|
||||
inline int64_t timeDiff64(uint64_t prev, uint64_t next) {
|
||||
inline int64_t timeDiff64(const uint64_t& prev, const uint64_t& next) {
|
||||
return ((int64_t) (next - prev));
|
||||
}
|
||||
|
||||
// Compute the number of milliSeconds passed since timestamp given.
|
||||
// N.B. value can be negative if the timestamp has not yet been reached.
|
||||
inline long timePassedSince(const uint32_t& timestamp) {
|
||||
inline int32_t timePassedSince(const uint32_t& timestamp) {
|
||||
return timeDiff(timestamp, millis());
|
||||
}
|
||||
|
||||
// Long term usec calculations
|
||||
inline int64_t usecPassedSince(ESPEASY_VOLATILE(uint64_t)& timestamp) {
|
||||
return timeDiff64(timestamp, getMicros64());
|
||||
inline int64_t usecPassedSince_volatile(ESPEASY_VOLATILE(uint64_t)& timestamp) {
|
||||
const uint64_t timestamp_tmp(timestamp);
|
||||
return timeDiff64(timestamp_tmp, getMicros64());
|
||||
}
|
||||
|
||||
inline int64_t usecPassedSince(const uint64_t& timestamp) {
|
||||
return timeDiff64(timestamp, getMicros64());
|
||||
}
|
||||
|
||||
/*
|
||||
inline int64_t usecPassedSince(uint64_t& timestamp) { //-V669
|
||||
return timeDiff64(timestamp, getMicros64());
|
||||
}
|
||||
*/
|
||||
|
||||
// Fast short-term usec calculations
|
||||
inline int32_t usecPassedSince_fast(ESPEASY_VOLATILE(uint32_t)& timestamp) {
|
||||
return timeDiff(timestamp, micros());
|
||||
|
||||
inline int32_t usecPassedSince_fast_volatile(ESPEASY_VOLATILE(uint32_t)& timestamp) {
|
||||
const uint32_t timestamp_tmp(timestamp);
|
||||
return timeDiff(timestamp_tmp, micros());
|
||||
}
|
||||
|
||||
inline int32_t usecPassedSince_fast(const uint32_t& timestamp) {
|
||||
return timeDiff(timestamp, micros());
|
||||
}
|
||||
|
||||
/*
|
||||
inline int32_t usecPassedSince_fast(uint32_t& timestamp) { //-V669
|
||||
return timeDiff(timestamp, micros());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Check if a certain timeout has been reached.
|
||||
inline bool timeOutReached(uint32_t timer) {
|
||||
inline bool timeOutReached(const uint32_t& timer) {
|
||||
return timePassedSince(timer) >= 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// For those it is more important to actually run it than keeping pace.
|
||||
void ESPEasy_Scheduler::setNextTimeInterval(uint32_t& timer, const uint32_t step) {
|
||||
timer += step;
|
||||
const long passed = timePassedSince(timer);
|
||||
const int32_t passed = timePassedSince(timer);
|
||||
|
||||
if (passed < 0) {
|
||||
// Event has not yet happened, which is fine.
|
||||
@@ -48,7 +48,7 @@ void ESPEasy_Scheduler::setNextTimeInterval(uint32_t& timer, const uint32_t step
|
||||
void ESPEasy_Scheduler::setNextStrictTimeInterval(uint32_t & timer,
|
||||
const uint32_t step) {
|
||||
timer += step;
|
||||
const long passed = timePassedSince(timer);
|
||||
const int32_t passed = timePassedSince(timer);
|
||||
|
||||
if (passed <= 0) {
|
||||
// Event has not yet happened, which is fine.
|
||||
@@ -101,7 +101,7 @@ void ESPEasy_Scheduler::setIntervalTimer(SchedulerIntervalTimer_e intervalTimer,
|
||||
case SchedulerIntervalTimer_e::TIMER_GRATUITOUS_ARP: interval = timer_gratuitous_arp_interval; break;
|
||||
|
||||
// Fall-through for all DelayQueue, which are just the fall-back timers.
|
||||
// The timers for all delay queues will be set according to their own settings as long as there is something to process.
|
||||
// The timers for all delay queues will be set according to their own settings as int32_t as there is something to process.
|
||||
case SchedulerIntervalTimer_e::TIMER_MQTT_DELAY_QUEUE:
|
||||
case SchedulerIntervalTimer_e::TIMER_C001_DELAY_QUEUE:
|
||||
case SchedulerIntervalTimer_e::TIMER_C002_DELAY_QUEUE:
|
||||
|
||||
@@ -101,7 +101,7 @@ bool ESPEasy_Scheduler::pause_rules_timer(uint32_t timerIndex) {
|
||||
#endif
|
||||
} else {
|
||||
// Store remainder of interval
|
||||
const long timeLeft = timePassedSince(timer) * -1;
|
||||
const int32_t timeLeft = timePassedSince(timer) * -1;
|
||||
|
||||
if (timeLeft > 0) {
|
||||
it->second.setRemainder(timeLeft);
|
||||
|
||||
@@ -168,7 +168,7 @@ String formatDomoticzSensorType(struct EventStruct *event) {
|
||||
# include <ArduinoJson.h>
|
||||
|
||||
bool deserializeDomoticzJson(const String& json,
|
||||
unsigned int& idx, float& nvalue, long& nvaluealt,
|
||||
unsigned int& idx, float& nvalue, int32_t& nvaluealt,
|
||||
String& svalue1, String& switchtype) {
|
||||
uint16_t jsonlength = 512;
|
||||
|
||||
@@ -180,8 +180,8 @@ bool deserializeDomoticzJson(const String& json,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use long here as intermediate object type to prevent ArduinoJSON from adding a new template variant to the code.
|
||||
const long idx_long = root[F("idx")];
|
||||
// Use int32_t here as intermediate object type to prevent ArduinoJSON from adding a new template variant to the code.
|
||||
const int32_t idx_long = root[F("idx")];
|
||||
|
||||
idx = idx_long;
|
||||
nvalue = root[F("nvalue")];
|
||||
|
||||
@@ -26,7 +26,7 @@ String formatDomoticzSensorType(struct EventStruct *event);
|
||||
bool deserializeDomoticzJson(const String& json,
|
||||
unsigned int& idx,
|
||||
float & nvalue,
|
||||
long & nvaluealt,
|
||||
int32_t & nvaluealt,
|
||||
String & svalue1,
|
||||
String & switchtype);
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
return 0;
|
||||
}
|
||||
const timer_id_couple item = _timer_ids.front();
|
||||
const long passed = timePassedSince(item._timer);
|
||||
const int32_t passed = timePassedSince(item._timer);
|
||||
|
||||
if (passed < 0) {
|
||||
// No timeOutReached
|
||||
recordIdle();
|
||||
|
||||
if (eco_mode) {
|
||||
long waitTime = (-1 * passed) - 1; // will be non negative
|
||||
int32_t waitTime = (-1 * passed) - 1; // will be non negative
|
||||
|
||||
if (waitTime > MAX_SCHEDULER_WAIT_TIME) {
|
||||
waitTime = MAX_SCHEDULER_WAIT_TIME;
|
||||
@@ -98,7 +98,7 @@
|
||||
#endif
|
||||
|
||||
void msecTimerHandlerStruct::updateIdleTimeStats() {
|
||||
const long duration = timePassedSince(last_log_start_time) * 10;
|
||||
const int32_t duration = timePassedSince(last_log_start_time) * 10;
|
||||
if (duration <= 1000) {
|
||||
// No need to recompute it over a small interval
|
||||
// Also makes sure duration != 0 as it is used in division
|
||||
@@ -149,7 +149,7 @@
|
||||
// Stats are just some indication, don't need to be that exact.
|
||||
// std::forward_list doesn't have size()
|
||||
// for (; stats_it != _timer_ids.end(); ++stats_it, ++size) {}
|
||||
if (size > max_queue_length) { max_queue_length = size; }
|
||||
if (static_cast<uint32_t>(size) > max_queue_length) { max_queue_length = size; }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ bool P014_data_struct::readHumidity(uint8_t i2caddr, uint8_t resolution)
|
||||
|
||||
// Convert raw value to Humidity percent
|
||||
// pm-cz: it is possible to enable decimal places for humidity as well by multiplying the value in formula by 100
|
||||
int data = ((1250 * (long)raw) >> 16) - 60;
|
||||
int data = ((1250 * (int32_t)raw) >> 16) - 60;
|
||||
|
||||
// Datasheet says doing this check
|
||||
if (data>1000) data = 1000;
|
||||
@@ -571,7 +571,7 @@ bool P014_data_struct::readTemperatureFromHumidity(uint8_t i2caddr, uint8_t reso
|
||||
int16_t P014_data_struct::convertRawTemperature(uint16_t raw, uint8_t resolution){
|
||||
// Convert raw value to Temperature (*100)
|
||||
// for 23.45C value will be 2345
|
||||
int16_t data = ((17572 * (long)raw) >> 16) - 4685;
|
||||
int16_t data = ((17572 * (int32_t)raw) >> 16) - 4685;
|
||||
|
||||
// pm-cz: We should probably check for precision here as well
|
||||
if (resolution != SI70xx_RESOLUTION_14T_12RH) {
|
||||
|
||||
@@ -203,7 +203,7 @@ P025_sensorType P025_data_struct::detectType(uint8_t i2cAddress)
|
||||
(0x8000); // Start a single conversion
|
||||
|
||||
if (startMeasurement(i2cAddress, defaultValue)) {
|
||||
const long sps = waitReady025(i2cAddress);
|
||||
const int32_t sps = waitReady025(i2cAddress);
|
||||
|
||||
if (sps > 0) {
|
||||
// Sample rate is either 250 (ADS1115) or 2400 (ADS1015)
|
||||
@@ -231,7 +231,7 @@ bool P025_data_struct::startMeasurement(uint8_t i2cAddress, uint16_t configRegis
|
||||
return false;
|
||||
}
|
||||
|
||||
long P025_data_struct::waitReady025(uint8_t i2cAddress)
|
||||
int32_t P025_data_struct::waitReady025(uint8_t i2cAddress)
|
||||
{
|
||||
const uint32_t start = micros();
|
||||
uint32_t timeout = millis();
|
||||
@@ -257,8 +257,8 @@ long P025_data_struct::waitReady025(uint8_t i2cAddress)
|
||||
const bool ready = reg.operatingStatus == 1;
|
||||
|
||||
if (ready && is_ok) {
|
||||
const long res = usecPassedSince_fast(start);
|
||||
const long sps = (res > 0) ? 1000000 / res : 0;
|
||||
const int32_t res = usecPassedSince_fast(start);
|
||||
const int32_t sps = (res > 0) ? 1000000 / res : 0;
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
|
||||
@@ -91,7 +91,7 @@ private:
|
||||
|
||||
// Check to see if the sensor is ready for new values
|
||||
// @retval detected SPS, 0 if timeout
|
||||
static long waitReady025(uint8_t i2cAddress);
|
||||
static int32_t waitReady025(uint8_t i2cAddress);
|
||||
|
||||
float _fullScaleFactor{};
|
||||
uint16_t _configRegisterValue{};
|
||||
|
||||
@@ -225,7 +225,7 @@ bool P049_data_struct::read_ppm(unsigned int& ppm, signed int& temp, unsigned in
|
||||
// get response
|
||||
memset(mhzResp, 0, sizeof(mhzResp));
|
||||
|
||||
long timer = millis() + PLUGIN_READ_TIMEOUT;
|
||||
uint32_t timer = millis() + PLUGIN_READ_TIMEOUT;
|
||||
int counter = 0;
|
||||
|
||||
while (!timeOutReached(timer) && (counter < 9)) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
# include <ESPeasySerial.h>
|
||||
|
||||
|
||||
const __FlashStringHelper* Plugin_077_valuename(P077_query value_nr, bool displayString)
|
||||
{
|
||||
const __FlashStringHelper *strings[] = {
|
||||
@@ -27,6 +26,7 @@ const __FlashStringHelper* Plugin_077_valuename(P077_query value_nr, bool displa
|
||||
}
|
||||
|
||||
# if FEATURE_MQTT_DISCOVER
|
||||
|
||||
int Plugin_077_QueryVType(uint8_t value_nr) {
|
||||
const Sensor_VType vtypes[] = {
|
||||
Sensor_VType::SENSOR_TYPE_VOLTAGE_ONLY,
|
||||
@@ -126,9 +126,9 @@ bool P077_data_struct::processCseReceived(struct EventStruct *event) {
|
||||
}
|
||||
|
||||
// Get chip calibration data (coefficients) and use as initial defaults
|
||||
long voltage_coefficient = 191200; // uSec
|
||||
long current_coefficient = 16140; // uSec
|
||||
long power_coefficient = 5364000; // uSec
|
||||
int32_t voltage_coefficient = 191200; // uSec
|
||||
int32_t current_coefficient = 16140; // uSec
|
||||
int32_t power_coefficient = 5364000; // uSec
|
||||
|
||||
// V1R = shunt resistor
|
||||
// V2R = Voltage resistor
|
||||
@@ -214,7 +214,7 @@ bool P077_data_struct::processCseReceived(struct EventStruct *event) {
|
||||
float activePower{};
|
||||
|
||||
if (!power_cycle_exceeds_range) {
|
||||
const long power_cycle = get_24bit_value(17);
|
||||
const int32_t power_cycle = get_24bit_value(17);
|
||||
|
||||
if (0 == power_cycle_first) {
|
||||
power_cycle_first = power_cycle; // Skip first incomplete power_cycle
|
||||
@@ -286,8 +286,8 @@ bool P077_data_struct::processCseReceived(struct EventStruct *event) {
|
||||
}
|
||||
|
||||
bool P077_data_struct::processSerialData() {
|
||||
long t_start = millis();
|
||||
bool found = false;
|
||||
const uint32_t t_start = millis();
|
||||
bool found = false;
|
||||
|
||||
if (isInitialized()) {
|
||||
int available = easySerial->available();
|
||||
@@ -306,7 +306,7 @@ bool P077_data_struct::processSerialData() {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
long t_diff = timePassedSince(t_start);
|
||||
int32_t t_diff = timePassedSince(t_start);
|
||||
|
||||
t_all += t_diff;
|
||||
|
||||
@@ -316,7 +316,7 @@ bool P077_data_struct::processSerialData() {
|
||||
|
||||
if (found) {
|
||||
count_max = max(count_max, count_bytes);
|
||||
t_pkt = t_start - t_pkt_tmp;
|
||||
t_pkt = timeDiff(t_pkt_tmp, t_start);
|
||||
t_pkt_tmp = t_start;
|
||||
}
|
||||
}
|
||||
@@ -435,6 +435,7 @@ bool P077_data_struct::plugin_write(struct EventStruct *event,
|
||||
}
|
||||
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
|
||||
int P077_data_struct::serial_Available() {
|
||||
if (isInitialized()) {
|
||||
return easySerial->available();
|
||||
|
||||
@@ -43,6 +43,7 @@ enum class P077_query : uint8_t {
|
||||
|
||||
|
||||
P077_QUERY_NR_OUTPUT_OPTIONS
|
||||
|
||||
};
|
||||
|
||||
const __FlashStringHelper* Plugin_077_valuename(P077_query value_nr,
|
||||
@@ -70,7 +71,7 @@ public:
|
||||
bool init(ESPEasySerialPort port,
|
||||
const int16_t serial_rx,
|
||||
const int16_t serial_tx,
|
||||
uint32_t baudrate,
|
||||
uint32_t baudrate,
|
||||
uint8_t config);
|
||||
|
||||
bool plugin_read(struct EventStruct *event);
|
||||
@@ -94,7 +95,7 @@ public:
|
||||
|
||||
|
||||
uint8_t serial_in_buffer[24] = { 0 };
|
||||
long power_cycle_first = 0;
|
||||
int32_t power_cycle_first = 0;
|
||||
uint32_t last_cf_pulses = 0;
|
||||
uint32_t cf_pulses = 0;
|
||||
float cf_frequency = (1e9f / 5364000);
|
||||
@@ -107,10 +108,10 @@ private:
|
||||
public:
|
||||
|
||||
// stats
|
||||
long t_max = 0;
|
||||
long t_all = 0;
|
||||
long t_pkt = 0;
|
||||
long t_pkt_tmp = 0;
|
||||
int32_t t_max = 0;
|
||||
int32_t t_all = 0;
|
||||
int32_t t_pkt = 0;
|
||||
uint32_t t_pkt_tmp = 0;
|
||||
uint16_t count_bytes = 0;
|
||||
uint16_t count_max = 0;
|
||||
uint16_t count_pkt = 0;
|
||||
@@ -121,6 +122,7 @@ public:
|
||||
private:
|
||||
|
||||
ESPeasySerial *easySerial = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // ifdef USES_P077
|
||||
|
||||
@@ -537,7 +537,7 @@ bool P082_data_struct::tryUpdateSystemTime() {
|
||||
if (hasFix(P082_TIMESTAMP_AGE)) {
|
||||
// Using PPS sync should be extremely stable without any significant time wander.
|
||||
// When we only can rely on keeping track of the timestamp at the start of a sentence, the fluctuation is significant.
|
||||
if (usecPassedSince(_pps_time_micros) < 1000000ll) {
|
||||
if (usecPassedSince_volatile(_pps_time_micros) < 1000000ll) {
|
||||
timeSource = timeSource_t::GPS_PPS_time_source;
|
||||
} else {
|
||||
timeSource = timeSource_t::GPS_time_source;
|
||||
|
||||
@@ -265,7 +265,7 @@ public:
|
||||
// So we keep only track of the micros() % 1000000 so we have some offset from the system micros counter.
|
||||
// This will also be used to keep track of when the first sentence is received as the GPS will send those out in a burst at the start of a
|
||||
// new second.
|
||||
ESPEASY_VOLATILE(int64_t) _pps_time_micros = -1;
|
||||
ESPEASY_VOLATILE(uint64_t) _pps_time_micros = 0;
|
||||
|
||||
int8_t _ppsPin = -1;
|
||||
};
|
||||
|
||||
@@ -479,7 +479,7 @@ CCS811Core::status CCS811::readNTC(void)
|
||||
|
||||
// Code from Milan Malesevic and Zoran Stupic, 2011,
|
||||
// Modified by Max Mayfield,
|
||||
_temperature = log(static_cast<long>(resistance));
|
||||
_temperature = log(static_cast<int32_t>(resistance));
|
||||
_temperature = 1 / (0.001129148f + (0.000234125f * _temperature) + (0.0000000876741f * _temperature * _temperature * _temperature));
|
||||
_temperature = _temperature - 273.15f; // Convert Kelvin to Celsius
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void IRAM_ATTR DLBus::ISR(void)
|
||||
|
||||
void IRAM_ATTR DLBus::ISR_PinChanged(void)
|
||||
{
|
||||
// long TimeDiff = usecPassedSince(ISR_TimeLastBitChange); // time difference to previous pulse in µs
|
||||
// int32_t TimeDiff = usecPassedSince(ISR_TimeLastBitChange); // time difference to previous pulse in µs
|
||||
uint32_t _now = micros();
|
||||
int32_t TimeDiff = (int32_t)(_now - ISR_TimeLastBitChange);
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ bool P098_data_struct::check_encoder_timeout(const P098_GPIO_config & gpio_confi
|
||||
if (enc_lastChanged_us == 0) {
|
||||
return false;
|
||||
}
|
||||
const bool expired = usecPassedSince(enc_lastChanged_us) > static_cast<int64_t>(_config.encoder.timer_us);
|
||||
const bool expired = usecPassedSince_volatile(enc_lastChanged_us) > static_cast<int64_t>(_config.encoder.timer_us);
|
||||
if (!expired) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -399,6 +399,7 @@ bool P111_data_struct::plugin_fifty_per_second(struct EventStruct *event) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO TD-er: We don't use the timestamp, would a simple boolean flag also be enough?
|
||||
if (_irq_pin_time_micros > _last_served_irq_pin_time_micros) {
|
||||
_last_served_irq_pin_time_micros = _irq_pin_time_micros;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ bool P118_data_struct::plugin_init(struct EventStruct *event) {
|
||||
_rf->setDeviceID(P118_CONFIG_DEVID1, P118_CONFIG_DEVID2, P118_CONFIG_DEVID3);
|
||||
_rf->init();
|
||||
|
||||
const long duration = timePassedSince(startInit);
|
||||
const int32_t duration = timePassedSince(startInit);
|
||||
|
||||
if (duration > P118_TIMEOUT_LIMIT) {
|
||||
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
|
||||
|
||||
@@ -868,7 +868,7 @@ bool P128_data_struct::plugin_fifty_per_second(struct EventStruct *event) {
|
||||
|
||||
void P128_data_struct::fade(void) {
|
||||
for (int pixel = 0; pixel < pixelCount; pixel++) {
|
||||
long counter = 20 * (counter20ms - starttime[pixel]);
|
||||
int32_t counter = 20 * (counter20ms - starttime[pixel]);
|
||||
float progress = (float)counter / (float)fadetime;
|
||||
progress = constrain(progress, 0.0f, 1.0f);
|
||||
|
||||
@@ -1033,7 +1033,7 @@ void P128_data_struct::faketv(void) {
|
||||
* Cycles a rainbow over the entire string of LEDs.
|
||||
*/
|
||||
void P128_data_struct::rainbow(void) {
|
||||
const long counter = 20 * (counter20ms - starttimerb);
|
||||
const int32_t counter = 20 * (counter20ms - starttimerb);
|
||||
const float progress = (float)counter / (float)fadetime;
|
||||
|
||||
if (fadeIn == true) {
|
||||
|
||||
@@ -829,7 +829,7 @@ int P145_data_struct::getNbrOfTypes()
|
||||
void P145_data_struct::calibrate(float currentRcal)
|
||||
{
|
||||
uint32_t now = millis();
|
||||
long time = timePassedSince(last_cal);
|
||||
int32_t time = timePassedSince(last_cal);
|
||||
float lastRcal = cal_data; // Last calculated Rcal this calibration sequence
|
||||
|
||||
if (currentRcal > lastRcal)
|
||||
@@ -874,7 +874,7 @@ void P145_data_struct::calibrate(float currentRcal)
|
||||
void P145_data_struct::heaterControl(void)
|
||||
{
|
||||
uint32_t now = millis();
|
||||
long time = timePassedSince(heaterChangeTime); // Time a state is active
|
||||
int32_t time = timePassedSince(heaterChangeTime); // Time a state is active
|
||||
|
||||
# ifdef P145_DEBUG
|
||||
P145_heaterState lastState = heaterState; // To detect a state change
|
||||
|
||||
@@ -381,7 +381,7 @@ bool P147_data_struct::plugin_get_config_value(struct EventStruct *event,
|
||||
/*****************************************************
|
||||
* readCheckedWord : Read 2 data bytes from I2C and validate checksum (3rd byte)
|
||||
****************************************************/
|
||||
uint16_t P147_data_struct::readCheckedWord(bool& is_ok, long extraDelay) {
|
||||
uint16_t P147_data_struct::readCheckedWord(bool& is_ok, int32_t extraDelay) {
|
||||
uint16_t result = 0;
|
||||
uint8_t data[3] = { 0 };
|
||||
const uint32_t timeOut = millis();
|
||||
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
# endif // if P147_FEATURE_GASINDEXALGORITHM
|
||||
|
||||
uint16_t readCheckedWord(bool& is_ok,
|
||||
long extraDelay = 5);
|
||||
int32_t extraDelay = 5);
|
||||
bool startSensorRead(uint16_t compensationRh,
|
||||
uint16_t compensationT);
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ private:
|
||||
uint32_t cclkw : 1; // number-plan counter-clockwise (tbd)
|
||||
uint32_t gstrt : 1; // start numbering at g-segment
|
||||
uint32_t unused : 2;
|
||||
uint32_t aoffs : 16; // Add-on pixels offset (use uin32_t for better memory alignment)
|
||||
uint32_t aoffs : 16; // Add-on pixels offset (use uint32_t for better memory alignment)
|
||||
uint32_t boffs : 16; // Before pixels offset
|
||||
};
|
||||
|
||||
|
||||
@@ -616,7 +616,7 @@ void P169_data_struct::adjustForDisturbances(struct EventStruct *event)
|
||||
F("AS3935: Watchdog Threshold and Spike Rejection settings are already maxed out. Freq = %d"),
|
||||
frequency));
|
||||
}
|
||||
} else if (timePassedSince(_sense_adj_last) > static_cast<long>(_sense_increase_interval))
|
||||
} else if (timePassedSince(_sense_adj_last) > static_cast<int32_t>(_sense_increase_interval))
|
||||
{
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, strformat(
|
||||
@@ -692,7 +692,7 @@ void P169_data_struct::tryIncreasedSensitivity(struct EventStruct *event)
|
||||
|
||||
// increase sensor sensitivity every once in a while. _sense_increase_interval controls how quickly the code
|
||||
// attempts to increase sensitivity.
|
||||
if (timePassedSince(_sense_adj_last) > static_cast<long>(_sense_increase_interval))
|
||||
if (timePassedSince(_sense_adj_last) > static_cast<int32_t>(_sense_increase_interval))
|
||||
{
|
||||
_sense_adj_last = millis();
|
||||
|
||||
|
||||
Reference in new issue
Block a user