From d836b77b09d852d775dc47160e7673acfae201bd Mon Sep 17 00:00:00 2001 From: JbLb Date: Fri, 26 Nov 2021 22:15:15 +0100 Subject: [PATCH] display speed on leds - new value for btn speed + and speed - --- src/hoverserial.ino | 69 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/src/hoverserial.ino b/src/hoverserial.ino index 53ccb36..a39270b 100644 --- a/src/hoverserial.ino +++ b/src/hoverserial.ino @@ -106,7 +106,7 @@ bool rel_marche = true; // ################ Led definition ######################## #define LED_PIN 7 -#define NUM_LEDS 2 +#define NUM_LEDS 10 #define LED_TYPE WS2812B #define COLOR_ORDER GRB @@ -132,8 +132,9 @@ void setup() } LEDS.addLeds(leds,NUM_LEDS); LEDS.setBrightness(64); - leds[0] = CRGB(255,0,0); - LEDS.show(); + FastLED.clear (); + // leds[0] = CRGB(255,0,0); + // LEDS.show(); Serial.begin(SERIAL_BAUD); if (Serial) { @@ -285,7 +286,7 @@ void speed_control(void) { if (run_mode){ if (!digitalRead(BTN_PLUS)){ if (last_plus){ - consigne_speed = consigne_speed + 5; + consigne_speed = consigne_speed + 3; if (consigne_speed > MAX_SPEED) { consigne_speed = MAX_SPEED ; } @@ -297,7 +298,7 @@ void speed_control(void) { } if (!digitalRead(BTN_MOINS)){ if (last_moins){ - consigne_speed = consigne_speed - 5; + consigne_speed = consigne_speed - 3; if (consigne_speed < 0 ) { consigne_speed = 0 ; } @@ -324,8 +325,12 @@ void loop(void) // Check for new received data Receive(); - if (iTimeSend > timeNow) - return; + Send(0,actual_speed); + if ( actual_speed != accel_speed){ + accel_speed = actual_speed; + if (Serial) Serial.println(actual_speed); + } + if (iTimeSend > timeNow) return; iTimeSend = timeNow + TIME_SEND; if (Serial) { if (run_mode != last_run) { @@ -338,7 +343,7 @@ void loop(void) } } if (run_mode){ - leds[0] = CRGB(0,255,0); + leds[1] = CRGB(0,255,0); // Green if ( actual_speed != consigne_speed){ if ( actual_speed < consigne_speed){ actual_speed ++ ; @@ -347,20 +352,20 @@ void loop(void) } } + int max_vit = int(actual_speed / 70); + for (int i_led = 1; i_led < max_vit; i_led = i_led +1 ) + { + leds[i_led] = CRGB(0,255,0); + } } else { - leds[0] = CRGB(255,0,0); + FastLED.clear (); + leds[1] = CRGB(255,0,0); // Red } - Send(0,actual_speed); - if ( actual_speed != accel_speed){ - accel_speed = actual_speed; - if (Serial) Serial.println(actual_speed); - } - run_control(); btn_control --; if (btn_control == 0){ - btn_control =10; + btn_control =8; speed_control(); } @@ -372,3 +377,35 @@ void loop(void) } // ########################## END ########################## +/* + * + if (Feedback.cmdLed & LED1_SET) { gpio_bit_set(LED1_GPIO_Port, LED1_Pin); } else { gpio_bit_reset(LED1_GPIO_Port, LED1_Pin); } // red + if (Feedback.cmdLed & LED2_SET) { gpio_bit_set(LED2_GPIO_Port, LED2_Pin); } else { gpio_bit_reset(LED2_GPIO_Port, LED2_Pin); } // green + if (Feedback.cmdLed & LED3_SET) { gpio_bit_set(LED3_GPIO_Port, LED3_Pin); } else { gpio_bit_reset(LED3_GPIO_Port, LED3_Pin); } // orange + if (Feedback.cmdLed & LED4_SET) { gpio_bit_set(LED4_GPIO_Port, LED4_Pin); } else { gpio_bit_reset(LED4_GPIO_Port, LED4_Pin); } // blue + if (Feedback.cmdLed & LED5_SET) { gpio_bit_set(LED5_GPIO_Port, LED5_Pin); } else { gpio_bit_reset(LED5_GPIO_Port, LED5_Pin); } // blue + if (Feedback.cmdLed & LED4_SET) { gpio_bit_set(AUX3_GPIO_Port, AUX3_Pin); } else { gpio_bit_reset(AUX3_GPIO_Port, AUX3_Pin); } + } + * + * + #define LED1_SET (0x01) + #define LED2_SET (0x02) + #define LED3_SET (0x04) + #define LED4_SET (0x08) + #define LED5_SET (0x10) + +*********************************************************************************************** +cablage +Db9 arduino +1 gnd +2 nc +3 power_on +4 power_on +5 D7 led +6 D6 marche +7 D5 moin +8 D4 plus +9 5V + + +*/