diff --git a/src/esp32_hal.h b/src/esp32_hal.h index 466fb77..7d235cb 100644 --- a/src/esp32_hal.h +++ b/src/esp32_hal.h @@ -133,7 +133,7 @@ class Esp32Hal { } uint32_t millis() const { - return (uint32_t)(esp_timer_get_time() / 1000ULL); + return static_cast(esp_timer_get_time() / 1000ULL); } PinType chan() const { return chan_; } diff --git a/src/jled_base.cpp b/src/jled_base.cpp index 4e95b59..6e59531 100644 --- a/src/jled_base.cpp +++ b/src/jled_base.cpp @@ -32,7 +32,7 @@ namespace jled { // fade-off and breath functions are all derived from fade-on, see // below. static constexpr uint8_t kFadeOnTable[] = {0, 3, 13, 33, 68, - 118, 179, 232, 255}; + 118, 179, 232, 255}; // NOLINT // https://www.wolframalpha.com/input/?i=plot+(exp(sin((x-100%2F2.)*PI%2F100))-0.36787944)*108.0++x%3D0+to+100 // The fade-on func is an approximation of @@ -70,7 +70,7 @@ uint8_t rand8() { // scale8(0, f) == 0 for all f // scale8(x, 255) == x for all x uint8_t scale8(uint8_t val, uint8_t factor) { - return ((uint16_t)val * (uint16_t)(1 + factor)) >> 8; + return (static_cast(val)*static_cast(1 + factor)) >> 8; } // interpolate a byte (val) to the interval [a,b]. diff --git a/src/jled_base.h b/src/jled_base.h index 4cc26b0..60c492e 100644 --- a/src/jled_base.h +++ b/src/jled_base.h @@ -400,18 +400,18 @@ class TJLed { trackLastUpdateTime(now); - if ((int32_t)(now - time_start_) < 0) return true; + if (static_cast(now - time_start_) < 0) return true; // t cycles in range [0..period+delay_after-1] const auto period = brightness_eval_->Period(); const auto t = (now - time_start_) % (period + delay_after_); if (!IsForever()) { - const auto time_end = - time_start_ + - (uint32_t)(period + delay_after_) * num_repetitions_ - 1; + const auto time_end = time_start_ + + static_cast(period + delay_after_) * + num_repetitions_ - 1; - if ((int32_t)(now - time_end) >= 0) { + if (static_cast(now - time_end) >= 0) { // make sure final value of t = (period-1) is set state_ = ST_STOPPED; const auto val = Eval(period - 1); @@ -593,5 +593,5 @@ class TJLedSequence { bool is_running_ = true; }; -}; // namespace jled +}; // namespace jled #endif // SRC_JLED_BASE_H_ diff --git a/src/pico_hal.h b/src/pico_hal.h index 9b85173..9e2b68c 100644 --- a/src/pico_hal.h +++ b/src/pico_hal.h @@ -43,7 +43,8 @@ class PicoHal { uint32_t *top_) { // Set the frequency, making "top_" as large as possible for maximum // resolution. - *div = (uint32_t)(16 * clock_get_hz(clk_sys) / (uint32_t)freq); + *div = static_cast(16 * clock_get_hz(clk_sys) / + static_cast(freq)); *top_ = 1; for (;;) { // Try a few small prime factors to get close to the desired @@ -100,7 +101,7 @@ class PicoHal { void analogWrite(uint8_t val) const { set_pwm_duty(slice_num_, channel_, top_, - (uint32_t)(DUTY_100_PCT / 255) * val); + static_cast(DUTY_100_PCT / 255) * val); } uint32_t millis() const { return to_ms_since_boot(get_absolute_time()); }