Skip to content
Prev Previous commit
Next Next commit
Do explicit conversion from floating point to integer
IAR generates warning Pa093 'implicit conversion from floating point to
integer'.
  • Loading branch information
Ben Avison committed Sep 13, 2022
commit 8a6debada24d91697ab8fabf6d9bb9681ab53b30
2 changes: 1 addition & 1 deletion pio/apa102/apa102.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main() {
apa102_mini_program_init(pio, sm, offset, SERIAL_FREQ, PIN_CLK, PIN_DIN);

for (int i = 0; i < TABLE_SIZE; ++i)
wave_table[i] = powf(sinf(i * M_PI / TABLE_SIZE), 5.f) * 255;
wave_table[i] = (uint8_t) (powf(sinf(i * M_PI / TABLE_SIZE), 5.f) * 255);

uint t = 0;
while (true) {
Expand Down
4 changes: 2 additions & 2 deletions pio/st7789_lcd/st7789_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ int main() {
if (theta > theta_max)
theta -= theta_max;
int32_t rotate[4] = {
cosf(theta) * (1 << UNIT_LSB), -sinf(theta) * (1 << UNIT_LSB),
sinf(theta) * (1 << UNIT_LSB), cosf(theta) * (1 << UNIT_LSB)
(int32_t) (cosf(theta) * (1 << UNIT_LSB)), (int32_t) (-sinf(theta) * (1 << UNIT_LSB)),
(int32_t) (sinf(theta) * (1 << UNIT_LSB)), (int32_t) (cosf(theta) * (1 << UNIT_LSB))
};
interp0->base[0] = rotate[0];
interp0->base[1] = rotate[2];
Expand Down
2 changes: 1 addition & 1 deletion pwm/measure_duty_cycle/measure_duty_cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main() {
// values should be very close!
for (int i = 0; i < count_of(test_duty_cycles); ++i) {
float output_duty_cycle = test_duty_cycles[i];
pwm_set_gpio_level(OUTPUT_PIN, output_duty_cycle * (count_top + 1));
pwm_set_gpio_level(OUTPUT_PIN, (uint16_t) (output_duty_cycle * (count_top + 1)));
float measured_duty_cycle = measure_duty_cycle(MEASURE_PIN);
printf("Output duty cycle = %.1f%%, measured input duty cycle = %.1f%%\n",
output_duty_cycle * 100.f, measured_duty_cycle * 100.f);
Expand Down
2 changes: 1 addition & 1 deletion uart/lcd_uart/lcd_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int main() {
red = sin(frequency * i + 0) * 127 + 128;
green = sin(frequency * i + 2) * 127 + 128;
blue = sin(frequency * i + 4) * 127 + 128;
lcd_set_backlight_color(red, green, blue);
lcd_set_backlight_color((uint8_t) red, (uint8_t) green, (uint8_t) blue);
i++;
#endif
}
Expand Down