altos: re-number csm85clio outputs 0..49 to match schematic and silkscreen
authorBdale Garbee <bdale@gag.com>
Wed, 15 Feb 2023 02:00:29 +0000 (19:00 -0700)
committerBdale Garbee <bdale@gag.com>
Wed, 15 Feb 2023 02:00:29 +0000 (19:00 -0700)
src/csm84clio-v0.1/ao_csm84clio.c

index e3562afc7a2b8d79de07139e7718f7f00706d7c9..d73af6468e67ef2735fee929d3cebbad8425c95c 100644 (file)
@@ -83,8 +83,8 @@ fet outputs[] = {
 static void
 ao_fet_control(uint32_t output, uint8_t value)
 {
-       /* map output 1-50 to corresponding GPIO port and pin, set to value */
-       ao_gpio_set(outputs[output - 1].port, outputs[output - 1].pin, value);
+       /* map output 0-49 to corresponding GPIO port and pin, set to value */
+       ao_gpio_set(outputs[output].port, outputs[output].pin, value);
 }
 
 static void
@@ -107,8 +107,8 @@ ao_fet_on(void)
        output = ao_cmd_decimal();
         if (ao_cmd_status != ao_cmd_success)
                 return;
-       if ((output < 1) || (output > 50))
-               printf ("Invalid FET selection %lu, must be 1..50\n", output);
+       if (output > 49)                /* can't be less than 0 since unsigned! */
+               printf ("Invalid FET selection %lu, must be 0..49\n", output);
        else {
                ao_fet_control(output, 1);
                ao_led_on(AO_LED_RED);
@@ -123,8 +123,8 @@ ao_fet_off(void)
        output = ao_cmd_decimal();
         if (ao_cmd_status != ao_cmd_success)
                 return;
-       if ((output < 1) || (output > 50))
-               printf ("Invalid FET selection %lu, must be 1..50\n", output);
+       if (output > 49)                /* can't be less than 0 since unsigned! */
+               printf ("Invalid FET selection %lu, must be 0..49\n", output);
        else {
                ao_fet_control(output, 0);
                ao_led_off(AO_LED_RED);