Learn how to modify the code

Hello, I'm trying to make works some strobe leds on my Hexacopter plug them into the A7 pin...

I would like the leds to be off when not armed and blink when armed so I need the pin A7 to be 0 (NO BLINK) when not armed, and 1 when armed...

I've never work with the arducopter code and the wiki is still under construction... My knowledge on C++ is very very basic but I'm triying to learn...

I've found a tab in the code that manage all the LEDS stuff and I have modified the last param that says ''//if motors are not armed, blink motor leds''   I have changed to ''copter_leds_off();''

So I think that when the copter is not armed no the output motor leds will not flash... Is it right?

static void update_copter_leds(void)

{
if (g.copter_leds_mode == 0) {
copter_leds_reset(); //method of reintializing LED state
}

// motor leds control
if (g.copter_leds_mode & COPTER_LEDS_BITMASK_ENABLED) {
if (motors.armed()) {
if (ap.low_battery) {
if (g.copter_leds_mode & COPTER_LEDS_BITMASK_BATT_OSCILLATE) {
copter_leds_oscillate(); //if motors are armed, but battery level is low, motor leds fast blink
} else {
copter_leds_fast_blink(); //if motors are armed, but battery level is low, motor leds oscillate
}
} else {
if (g.copter_leds_mode & COPTER_LEDS_BITMASK_MOTOR_NAV_BLINK) {
if (copter_leds_nav_blink > 0) {
copter_leds_slow_blink(); //if nav command was seen, blink LEDs.
} else {
copter_leds_on();
}
} else {
copter_leds_on(); //if motors are armed, battery level OK, all motor leds ON
}
}
} else {
copter_leds_off(); //if motors are not armed, blink motor leds
}
}

If it is right, now I have some questions... 

- How could I make the HEX file to upload to the APM... I have tried and always the same error

Building for ArduPilot Mega 2.x

Excluding arduino core from include paths

- When I upload the HEX file to the APM... could I config all the params with mission planner as always?

Thank you very much !

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

Join diydrones

Email me when people reply –

Replies

  • Hola Jorge,

    At the beginning of config.h appears the following statement:

    // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
    //
    //  DO NOT EDIT this file to adjust your configuration.  Create your own
    //  APM_Config.h and use APM_Config.h.example as a reference.
    //
    // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING

    This means that modifying the config.h file isn't a recomendable practice. Instead, you should introduce any changes in the code through the APM_config.h file.

    Since Arducopter V3, due to Hardware Abstraction Layer (HAL), you can´t use the standard Arduino IDE (anyway, this standard IDE was useful only from V1.0.1, due to Arducopter's code size...).. Now, you MUST to use the Arduino version for Ardupilot, here.

    As usually, before to conpile you must:

    1. set your sketchbook pointing to Ardocopter folder
    2. select the correct board (APM 2 ->Arduino mega 2560)
    3. and now, aditionally, you must also select  the correct HAL type.

    I hope this help.

  • So, as I've understood... I've modified the LED param above and in my case I have a Hexa X config so I modify it in the config.h tab... I try to compile, but it always give me compilation fails, also with the default program without modifying the LED param.

    Do I have to modify any other param in the Config.h tab?

  • Hola Jorge, que tal?

    Check this link:

    http://vcctoground.com/tutorials/changing-the-default-hex-file-buil...

    Anyway, you can load the compiled code directly into your APM board, without to use the Mission Planner software to load the hex file (it seems that this is what you want to do). But be careful: If you use your own code, you must select properly your complete hardware&frame configuration before to compile&load it (see config.h for default settings).

    http://vcctoground.com/tutorials/changing-the-default-hex-file-build-path-in-the-arduino-ide/
  • Please, does anybody knows how to compile the code to get the .hex file?
This reply was deleted.

Activity