kalman, report, romconfig, sample, send_packet: Clean up -Wconversion warnings
authorKeith Packard <keithp@keithp.com>
Fri, 28 Jan 2022 23:39:45 +0000 (15:39 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Feb 2022 01:26:49 +0000 (17:26 -0800)
No bugs detected

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_kalman.c
src/kernel/ao_report.c
src/kernel/ao_report_micro.c
src/kernel/ao_romconfig.c
src/kernel/ao_sample.c
src/kernel/ao_send_packet.c

index cdf64bec9052e106fa43cabdbb3015955c9645d2..5f32eb7275de8357d8bb50a80680644dee4817e9 100644 (file)
@@ -314,9 +314,9 @@ ao_kalman(void)
        ao_kalman_correct_accel();
 #endif
 #endif
-       ao_height = from_fix(ao_k_height);
-       ao_speed = from_fix(ao_k_speed);
-       ao_accel = from_fix(ao_k_accel);
+       ao_height = (ao_v_t) from_fix(ao_k_height);
+       ao_speed = (ao_v_t) from_fix(ao_k_speed);
+       ao_accel = (ao_v_t) from_fix(ao_k_accel);
        if (ao_height > ao_max_height)
                ao_max_height = ao_height;
 #if HAS_BARO
index 831ba874cc3656d312aca76ff2409cbb03e8a7fa..4624403a10d61e0a255caf38f56fecdc8bcff4af 100644 (file)
@@ -149,7 +149,7 @@ ao_report_digit(uint8_t digit)
 }
 
 static void
-ao_report_number(int16_t n)
+ao_report_number(ao_v_t n)
 {
        uint8_t digits[10];
        uint8_t ndigits, i;
@@ -158,7 +158,7 @@ ao_report_number(int16_t n)
                n = 0;
        ndigits = 0;
        do {
-               digits[ndigits++] = n % 10;
+               digits[ndigits++] = (uint8_t) (n % 10);
                n /= 10;
        } while (n);
 
@@ -200,8 +200,8 @@ ao_report_igniter_ready(enum ao_igniter igniter)
 uint8_t
 ao_report_igniter(void)
 {
-       return (ao_report_igniter_ready(ao_igniter_drogue) |
-                    (ao_report_igniter_ready(ao_igniter_main) << 1));
+       return (uint8_t) (ao_report_igniter_ready(ao_igniter_drogue) |
+                         (ao_report_igniter_ready(ao_igniter_main) << 1));
 }
 #endif
 
index efada54b516be302d477c891e05947292e9640f8..7abd2311bc4bdcd827ebc3ab332cdfa03cb05eab 100644 (file)
@@ -48,7 +48,7 @@ ao_report_altitude(void)
                agl = 0;
        ndigits = 0;
        do {
-               digits[ndigits++] = agl % 10;
+               digits[ndigits++] = (uint8_t) agl % 10;
                agl /= 10;
        } while (agl);
 
index b75142f52af605c45ac5b2802fe3cc7548112d0a..fe2bc7f5e3126ae44877cf3ca8f174636fad67cf 100644 (file)
@@ -19,7 +19,7 @@
 #include "ao.h"
 
 AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION;
-AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION;
+AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = (uint16_t) ~AO_ROMCONFIG_VERSION;
 AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number = 0;
 #if HAS_RADIO
 AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
index e3b5e084d8f4c52ec454e30739910bfada8a9912..3f5fc7a98c557af012d053dd0b14068305f6924b 100644 (file)
@@ -161,7 +161,7 @@ static void
 ao_sample_set_one_orient(void)
 {
        ao_sample_orients[ao_sample_orient_pos] = ao_sample_orient;
-       ao_sample_orient_pos = (ao_sample_orient_pos + 1) % AO_NUM_ORIENT;
+       ao_sample_orient_pos = (uint8_t) ((ao_sample_orient_pos + 1) % AO_NUM_ORIENT);
 }
 
 static void
@@ -190,7 +190,7 @@ ao_sample_compute_orient(void)
        float rotz;
        rotz = ao_rotation.z * ao_rotation.z - ao_rotation.y * ao_rotation.y - ao_rotation.x * ao_rotation.x + ao_rotation.r * ao_rotation.r;
 
-       ao_sample_orient = acosf(rotz) * (float) (180.0/M_PI);
+       ao_sample_orient = (angle_t) (acosf(rotz) * (float) (180.0/M_PI));
 }
 #endif /* HAS_GYRO */
 
@@ -198,7 +198,7 @@ static void
 ao_sample_preflight_set(void)
 {
 #if HAS_ACCEL
-       ao_ground_accel = ao_sample_accel_sum >> 9;
+       ao_ground_accel = (accel_t) (ao_sample_accel_sum >> 9);
        ao_sample_accel_sum = 0;
 #endif
 #if HAS_BARO
@@ -207,15 +207,15 @@ ao_sample_preflight_set(void)
        ao_sample_pres_sum = 0;
 #endif
 #if HAS_IMU
-       ao_ground_accel_along = ao_sample_accel_along_sum >> 9;
-       ao_ground_accel_across = ao_sample_accel_across_sum >> 9;
-       ao_ground_accel_through = ao_sample_accel_through_sum >> 9;
+       ao_ground_accel_along = (accel_t) (ao_sample_accel_along_sum >> 9);
+       ao_ground_accel_across = (accel_t) (ao_sample_accel_across_sum >> 9);
+       ao_ground_accel_through = (accel_t) (ao_sample_accel_through_sum >> 9);
        ao_sample_accel_along_sum = 0;
        ao_sample_accel_across_sum = 0;
        ao_sample_accel_through_sum = 0;
 #endif
 #if HAS_MOTOR_PRESSURE
-       ao_ground_motor_pressure = ao_sample_motor_pressure_sum >> 9;
+       ao_ground_motor_pressure = (motor_pressure_t) (ao_sample_motor_pressure_sum >> 9);
        ao_sample_motor_pressure_sum = 0;
 #endif
 #if HAS_GYRO
index ee4685998215a7899f123caf2780abc88ebdc00a..ff3ab68d15caa9d0944e6b7ff2c621f98c5e8cf4 100644 (file)
@@ -26,7 +26,7 @@ static uint8_t ao_send[AO_MAX_SEND];
 static void
 ao_send_packet(void)
 {
-       uint16_t count;
+       uint32_t count;
        uint8_t b;
        uint8_t i;
 
@@ -44,7 +44,7 @@ ao_send_packet(void)
                        return;
                ao_send[i] = b;
        }
-       ao_radio_send(ao_send, count);
+       ao_radio_send(ao_send, (uint8_t) count);
 }
 
 static const struct ao_cmds ao_send_packet_cmds[] = {