Skip to content

Commit

Permalink
fix linter findings
Browse files Browse the repository at this point in the history
  • Loading branch information
jandelgado committed Nov 10, 2024
1 parent 93b2130 commit b3570e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/esp32_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Esp32Hal {
}

uint32_t millis() const {
return (uint32_t)(esp_timer_get_time() / 1000ULL);
return static_cast<uint32_t>(esp_timer_get_time() / 1000ULL);
}

PinType chan() const { return chan_; }
Expand Down
4 changes: 2 additions & 2 deletions src/jled_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<uint16_t>(val)*static_cast<uint16_t>(1 + factor)) >> 8;
}

// interpolate a byte (val) to the interval [a,b].
Expand Down
12 changes: 6 additions & 6 deletions src/jled_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,18 @@ class TJLed {

trackLastUpdateTime(now);

if ((int32_t)(now - time_start_) < 0) return true;
if (static_cast<int32_t>(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<uint32_t>(period + delay_after_) *
num_repetitions_ - 1;

if ((int32_t)(now - time_end) >= 0) {
if (static_cast<int32_t>(now - time_end) >= 0) {
// make sure final value of t = (period-1) is set
state_ = ST_STOPPED;
const auto val = Eval(period - 1);
Expand Down Expand Up @@ -593,5 +593,5 @@ class TJLedSequence {
bool is_running_ = true;
};

}; // namespace jled
}; // namespace jled
#endif // SRC_JLED_BASE_H_
5 changes: 3 additions & 2 deletions src/pico_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(16 * clock_get_hz(clk_sys) /
static_cast<uint32_t>(freq));
*top_ = 1;
for (;;) {
// Try a few small prime factors to get close to the desired
Expand Down Expand Up @@ -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<uint32_t>(DUTY_100_PCT / 255) * val);
}

uint32_t millis() const { return to_ms_since_boot(get_absolute_time()); }
Expand Down

0 comments on commit b3570e3

Please sign in to comment.