Motor LEDs Behaviours

Hi, I had a look at the codeof update_motor_leds(void), and I think it might be usefull to code some logic in order to have visual signification from these motor LEDs.

I will try this, which test Motor arming ang GPS lock. I have a quad in X configuration:

 

static void update_motor_leds(void)
{

    static bool blink = false;
    static int blinkCycle = 4;
   
    // Motor not armed : Test GPS
    if(motor_armed == false){
      switch (g_gps->status()){
 
          case(2): // GPS lock : Blink front/back
          if (blink){
              digitalWrite(LE_LED, HIGH);
              digitalWrite(FR_LED, HIGH);
              digitalWrite(RI_LED, LOW);
              digitalWrite(RE_LED, LOW);
          }else{
              digitalWrite(LE_LED, LOW);
              digitalWrite(FR_LED, LOW);
              digitalWrite(RI_LED, HIGH);
              digitalWrite(RE_LED, HIGH);
          }
              break;
  
          default:  // GPS not lock : Blink sequence

              digitalWrite(LE_LED, ( (blinkCycle == 4 ) ? HIGH : LOW));
              digitalWrite(FR_LED, ( (blinkCycle == 3 ) ? HIGH : LOW));
              digitalWrite(RI_LED, ( (blinkCycle == 2 ) ? HIGH : LOW));
              digitalWrite(RE_LED, ( (blinkCycle == 1 ) ? HIGH : LOW));
              break;
      }   
  }else{ // Motor armed : Blink Simultaneously
          if(blinkCycle <2){
            digitalWrite(LE_LED, HIGH);
              digitalWrite(FR_LED, HIGH);
              digitalWrite(RI_LED, HIGH);
              digitalWrite(RE_LED, HIGH);
          } else{
            digitalWrite(LE_LED, LOW);
              digitalWrite(FR_LED, LOW);
              digitalWrite(RI_LED, LOW);
              digitalWrite(RE_LED, LOW);
        }
  }
       
    blink = !blink;
    //blincking cycle management
    blinkCycle--;
    if( blinkCycle<1) blinkCycle = 4;

    // the variable low_batt is here to let people know the voltage is low or the pack capacity is finished
    // I don't know what folks want here.
    // low_batt
}

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • 100KM

    Would be a nice addition !!!  

     

This reply was deleted.

Activity