display speed on leds - new value for btn speed + and speed -

in_progress_old_board
JbLb 4 years ago
parent 482c09161b
commit d836b77b09

@ -106,7 +106,7 @@ bool rel_marche = true;
// ################ Led definition ######################## // ################ Led definition ########################
#define LED_PIN 7 #define LED_PIN 7
#define NUM_LEDS 2 #define NUM_LEDS 10
#define LED_TYPE WS2812B #define LED_TYPE WS2812B
#define COLOR_ORDER GRB #define COLOR_ORDER GRB
@ -132,8 +132,9 @@ void setup()
} }
LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS); LEDS.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,NUM_LEDS);
LEDS.setBrightness(64); LEDS.setBrightness(64);
leds[0] = CRGB(255,0,0); FastLED.clear ();
LEDS.show(); // leds[0] = CRGB(255,0,0);
// LEDS.show();
Serial.begin(SERIAL_BAUD); Serial.begin(SERIAL_BAUD);
if (Serial) { if (Serial) {
@ -285,7 +286,7 @@ void speed_control(void) {
if (run_mode){ if (run_mode){
if (!digitalRead(BTN_PLUS)){ if (!digitalRead(BTN_PLUS)){
if (last_plus){ if (last_plus){
consigne_speed = consigne_speed + 5; consigne_speed = consigne_speed + 3;
if (consigne_speed > MAX_SPEED) { if (consigne_speed > MAX_SPEED) {
consigne_speed = MAX_SPEED ; consigne_speed = MAX_SPEED ;
} }
@ -297,7 +298,7 @@ void speed_control(void) {
} }
if (!digitalRead(BTN_MOINS)){ if (!digitalRead(BTN_MOINS)){
if (last_moins){ if (last_moins){
consigne_speed = consigne_speed - 5; consigne_speed = consigne_speed - 3;
if (consigne_speed < 0 ) { if (consigne_speed < 0 ) {
consigne_speed = 0 ; consigne_speed = 0 ;
} }
@ -324,8 +325,12 @@ void loop(void)
// Check for new received data // Check for new received data
Receive(); Receive();
if (iTimeSend > timeNow) Send(0,actual_speed);
return; if ( actual_speed != accel_speed){
accel_speed = actual_speed;
if (Serial) Serial.println(actual_speed);
}
if (iTimeSend > timeNow) return;
iTimeSend = timeNow + TIME_SEND; iTimeSend = timeNow + TIME_SEND;
if (Serial) { if (Serial) {
if (run_mode != last_run) { if (run_mode != last_run) {
@ -338,7 +343,7 @@ void loop(void)
} }
} }
if (run_mode){ 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){
if ( actual_speed < consigne_speed){ if ( actual_speed < consigne_speed){
actual_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 { } 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(); run_control();
btn_control --; btn_control --;
if (btn_control == 0){ if (btn_control == 0){
btn_control =10; btn_control =8;
speed_control(); speed_control();
} }
@ -372,3 +377,35 @@ void loop(void)
} }
// ########################## END ########################## // ########################## 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
*/

Loading…
Cancel
Save