1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00
Commit graph

215 commits

Author SHA1 Message Date
ctzsnooze
7156dc84a3
Update turtle / crashflip mode (#13905)
* stop motors after 90 degrees of rotation and with max rate

* handle no accelerometer data

* improve check for acc, although seems to be OK without it

* disable all attenuation if rate is set to zero

* refactoring thanks Karate

* use sensors.h

* remove unnecessary arming check

* exit crashFlip immediately switch is reverted if throttle is zero

* add Crashflip Rate to OSD

* Revert unnecessary changes in crashflip core.c code

and clarify comments about crashflip switch

* update / minimise comments, thanks Karate

* ensure all names say `crashflip` consistently

* Undo quick re-arm because motrors were not reversed

* fix issue with reversed motors, we must disarm

* ignore yaw rotation and set gyro limit to 1900 deg/s

* default attenuation to off (crashflip_rate = 0)

* refactoring, increase rate limit to allow stronger inhibition

* enable in race_pro mode

* don't attenuate on attitude until a significant change occurs

* no attenuation for small changes

* Updates from review by PL

* remove whitespace

* refactor motorOutput, update comments, renaming variables

thanks PL

* changes from review PL

* only permit fast re-arm if crashflip rate set and crashflip was successful

* properly exit turtle mode

* add crashFlipSuccessful to unit test extern c

* small updates from review

* improved crashflip switch handling

* remove unnecessary motors normal check
2024-10-05 07:58:33 +10:00
ctzsnooze
776e8c7b3c
Refactor Rx code and better support 25Hz links (#13435)
* RX task update rate to 22Hz, to improve 25Hz link stability

* modified Rx code

* add LQ to debug

* use max of frameAge or FrameDelta

* Require a dropouit of 200ms, not 100ms, before RXLOSS

* remove FrameAge, use 150ms timeout 50ms checks

* fix tests and tidy up the comments

* Handle NULL input as before, log frame time

* possible solutions to review comment about names

* Remove rxFrameTimeUs

- prepare for direct use of lastRcFrameTimeUs
- refactor rx_spi callback

* remove global currentRxRateHz

* simplify updateRcRefreshRate

* re-name to recheck interval, return frame time debug

* Calculate RxRate only once

* use rxReceivingSignal for consistency

* use signalReceived not rxDataReceived for consistency

* suggestions from review PL

* move defines, thanks K

* fixes from review, thanks MH

* review changes, undo task interval change

rename bool rxIsReceivingSignal to isRxReceivingSignal
thanks Steve for resolving that tasks changes are not needed
thanks PL for your feedback also

---------

Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
2024-10-01 09:23:24 +10:00
Mark Haslinghuis
5a28ce5129
Make Cppcheck happier revived (#13566)
Co-authored-by: Štěpán Dalecký <daleckystepan@gmail.com>
2024-05-10 13:23:32 +10:00
Jonas Becker
d1ffa46aa6
New led functions gps bar battery bar altitude (#13404)
* Add LED functions: Battery Bar, GPS Bar

Battery Bar:
Indicates the battery percentage with a loading bar style

GPS Bar:
Indicates the amount of locked GPS satellites with a loading bar style

* LED altitude function

Adds a new function: LED altitude.
Sets the LED color based on the altitude, measured from the initialized position.

* set led color to background if value decreases

Even if the gps satellite count decreases at a later point in time, the LEDs update correctly now.
It is the same for the battery level function.
LEDs color changes more strongly now when based on altitude.

* Added proper ifdefs for GPS and Barometer

* fixed unittest and use estimate altitute

- fixed unittest

- cleaner indentation

- the altitude function now uses the estimate function instead of the raw value (gps+barometer)

* counters in struct, gps bar color gradient

- Counters for the led bar are now handled in a structure.

- Moved the led bar code to a seperate function that is only called when the led config changes.

- improved usefulness of the gps led bar with less than 4 leds installed by adding a color gradient.

* Update src/main/io/ledstrip.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Update src/main/io/ledstrip.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Update src/main/io/ledstrip.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Update src/main/io/ledstrip.h

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Update src/main/io/ledstrip.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* one min led for very low battery, use failsafe sats to interpolate

- at least one led is lit up for the battery/gps bar at all time (to show color gradient, also making the function more useful when only applying it to 1 led).

- gps bar now takes the failsafe min sats (or default 8) to interpolate between red and green.

- rewrote the led codes to be less fragile

- some structural changes that also adress comments on the pull request

* fix code if no gps rescue is used

fixes code if no gps rescue is used.
sets the default min sats to 8.

* Update src/main/io/ledstrip.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Fixes per review ledvinap

* Fixes per review Ledvinap 2

* Update src/main/io/ledstrip.c

* Update src/main/io/ledstrip.c

---------

Co-authored-by: jonas-becker <jonas@Thinkpad>
Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
2024-05-05 16:32:18 +02:00
Steve Evans
ddc81cb4fa
Fix timer interval for battery and RSSI LED indication (#13412) 2024-03-04 13:29:38 +01:00
ASDosjani
a190ed98dc
Naming LED Strip overlay rates (#13363)
Add names to LED Strip overlay rates
2024-02-14 13:39:18 +01:00
Bryan Mayland
3ef7a188d0
Use fixed LED color table in RACE / BEACON LED profiles (#13339)
Use the non-custom color table when requiring fixed colors
2024-02-14 00:01:09 +01:00
Steve Evans
c996d5f77b
Led task optimistion (#13247)
* LED task optimisation

* Drop LED task rate from 100Hz to 50Hz to reduce CPU load
2023-12-28 10:55:24 +11:00
Steve Evans
03495f9273
Break LED_STRIP update into 20us chunks (#13218) 2023-12-12 13:15:32 +01:00
Cru Waller
57fbf61331
Fix: ledstrip vtx freq based color selection in RACE mode (#13096)
Fix: ledstrip vtx freq handling in race mode
2023-12-01 09:49:22 +01:00
ASDosjani
5cd2ab50e4
Add LED strip config values to MSP (#12995)
* Add LED strip config values to MSP

* change hue calculation + higher max frequency

* higher rainbow frequency

* define LED Strip task rate

* msp2

* fix delta size

* Update src/main/msp/msp.c

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

* Update src/main/msp/msp.c

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
2023-09-05 17:09:31 +02:00
J Blackman
d5d3ee88be
Removing STM specific defines from common_pre, and other cleanups (#12982)
Removing STM specific defines from common_pre, and other cleanup
2023-07-27 11:34:28 +02:00
ASDosjani
e195bf7717
Cleanup + led overlay expansion (#12554)
* Cleanup + led overlay expansion

* fix tests
2023-04-06 20:54:31 +10:00
ASDosjani
7735a7129e
Add rainbow effect to led strip (#12323)
* Add rainbow effect

* unit test

* default values + version change
2023-03-16 15:07:17 +01:00
J Blackman
19f22f5120
Method for adding defaults using defines for resources. (#12342)
* Method for adding defaults using defines for resources.

* As we will always be using the fullTimerHardware, we just need to configure the pin mapping.

This is done in the config.h as

#define TIMER_PIN_MAPPING   \
    TIMER_PIN_MAP(0, PA0, 1, 0) \
    TIMER_PIN_MAP(0, PA1, 1, 0)

timerHardware[] dependencies to be removed in another PR

* Adding missing pin definitions (removing dependency on timerHardware)

* Typo

* In case MOTOR1_PIN is not defined, but a motor is configured
2023-02-12 04:06:49 +01:00
Mathias Rasmussen
61ded491cd Use std abs() instead of ABS() macro
Changes uses of ABS() macro to <stdlib.h> abs() and <math.h> fabsf()
2022-10-12 19:49:03 +02:00
Mathias Rasmussen
9957ceb275 Fix function brace style 2022-10-12 16:31:55 +02:00
ctzsnooze
aa4f0f7517
Merge pull request #10972 from SteveCEvans/ledstrip_dim
Add ledstrip_brightness to control LED strip brightness by percentage
2021-12-20 10:30:59 +11:00
Steve Evans
29d221502e Use peak tracking as default for task duration estimation rather than a moving average 2021-12-17 22:09:52 +00:00
Steve Evans
ab1baccc66 Track state execution time for OSD, baro, rx and GPS tasks and inform scheduler of next state execution time 2021-12-17 15:40:01 +00:00
Steve Evans
fe12e356b9 Add ledstrip_brightness to control LED strip brightness by percentage 2021-09-30 23:21:21 +01:00
Steve Evans
d5f62be013 Trigger gyro SPI DMA reads in EXTI handler if supported and lock gyroTask loop to gyro to eliminate missed updates and jitter 2021-09-28 01:38:18 +13:00
Steve Evans
14236be7e3 Handle timing for ledStripUpdate task 2021-04-12 01:12:49 +01:00
mikeller
99f77fa88d Moved configuration validation into 'config.c'. 2019-11-24 21:19:26 +13:00
mikeller
4a7904695e Moved 'config.[ch]' into the 'config/' directory. 2019-10-28 11:17:25 +13:00
Bruce Luckcuck
e1f10b0430 Optimize ledstrip DMA buffer update to reduce task processing time
Previous logic was updating updating the DMA buffer for all possible LED positions (32) regardless of how many were used. Since there are 24 bytes per LED, this performed a lot of unnecessary processing in cases where the user had less than 32 LEDs configured.

Also includes a bug fix in that if the LED count was decreased (like making changed using the Configurator LED tab), the now unused LEDs at the end of the string would remain on at the last color applied. Now they will be properly turned off. The bug was minor as it was resolved by a reboot, but made setup using the Configurator confusing since changes made are reflected when the user clicked the "Save" button (which does not reboot).
2019-09-05 16:10:19 -04:00
mikeller
aeca5665e6 Add support for IRC Tramp race lock flag, and extended VTX status.
Display '-' for settings when VTX is locked.
2019-07-01 01:30:18 +12:00
functionpointer
7cb34205b3 [VTX] vtxTable factory flag and full integration of vtxTable (#8380)
Moved vtxtable frequency mode implementation into `vtx_common.c`.
This makes the implementation available for all vtx types and allows
for some code deduplication (see point below)

Removed band and channel tracking from tramp and rtc6705.
The hardware underlying both only support frequency mode and
the tracking is now done in `vtx_common.c` using the new factory flag.

Deleted vtxStringXXX. to continue supporting builds without
`USE_VTX_TABLE`, new infrastructure was created in
`drivers/vtx_table.c`, which loads fixed tables into vtxTableXXX
when built witout `USE_VTX_TABLE`. Individual vtx implementations no
longer need to load any band/channel tables. They only need to load
their individual power tables when built without `USE_VTX_TABLE`.
Additionally this allows for the next point:

Fully integrated vtxTableXXX and removed the old and no longer needed
indirection of frequency and power tables in `vtxDevice_t`.

Removed VTX_SETTINGS_* constants from `vtx_common.h` and replaced them
with the vtxtable equivalent.

rtc6705 implementation now uses power values from vtxtable instead of
using indices directly. It also stops using index 0. This makes it
consistent with other vtx implementations and is more user configurable.
It also cleans up `telemetry\srxl.c` which had to have a special case for rtc6705.

Finally, frequency entries in the vtxtable can now be marked as empty
by setting their frequency to 0. Betaflight will never allow a blocked
channel to be selected. This is useful for vtxtable index mode
(FACTORY flag set) where manufacturer-defined bands can be truncated
to ensure compliance with local laws and regulations.
2019-06-24 12:28:46 +02:00
mikeller
9f8cafbf8b Fixed initialisation problem with LED_STRIP. 2019-02-08 12:29:57 +13:00
mikeller
37d0d402c8 Added single colour mode to WS2811 driver for RAM savings. 2019-02-06 12:04:34 +13:00
mikeller
5006387c59 Dang, forgot to push the changeset that reverts the test code. 2019-02-05 20:13:05 +13:00
mikeller
e121e1e92b Separated LED_STRIP parameter groups, separated out LED_STRIP status mode code. 2019-02-05 08:39:42 +13:00
Bruce Luckcuck
12a29eb7a9 Enhance ledstrip BEACON profile
Added features to the BEACON ledstrip profile:

Added a `ledstrip_beacon_color` to allow color selection rather than forcing to white.

Added `ledstrip_beacon_period_ms` to configure the blink period in milliseconds. Smaller time periods mean faster blinking.

Added `ledstrip_beacon_percent` to configure the "ON" time duty cycle. User can set to 100% to have the beacon display a solid color. 0% can be used to turn the becaon completely off.

Added `ledstrip_beacon_armed_only` to allow the user to configure whether the beacon is only on when armed.

Added `ledstrip_visual_beeper_color` to allow configuration of the visual beeper color.

Added the new parameters to the CMS menu.

Simplified the code and combined the RACE and BEACON profile processing.

Added support for auutomatically displaying a beacon that indicates RX_SET or failsafe regardless of the other RACE or BEACON settings.
2019-01-29 15:26:13 -05:00
Bruce Luckcuck
f6dc0ce516 Fix color range for ledstrip battery and rssi layers
The range was underflowing the calculated hue value causing it to loop back to other colors. For example when battery ranged from below 20% the color would shift from red (the correct color for minimum battery) to shades of magenta. RSSI had the same problem.

Now the logic reserves the base color (red in these cases) for the minimum 20% of the range. From 20-100% the color will scale from red through to green.
2019-01-24 18:50:53 -05:00
Bruce Luckcuck
744d9eb7a3 Refactor ledstrip profiles to fix excessive cpu load
Previous logic bypassed optimizations and updated the ws2811 on every task execution - leading to and average of 92us task execution time. Restored the previous optimizations and additionally optimized the new "RACE" and "BEACON" modes so that they only update the led's when there's an actual state change. Task time for these modes is now in the 2-4us range for F405. For the normal "STATUS" profile the performance has been restored to previous optimized levels and typical configurations will generally have task times in the 8-14us range.

Revised the LEDLOW disable mode to function all the time and disable the ledstrip completely. Previously if visual beeper was enabled that would override the disable and the ledstrip would display whatever would be otherwise displayed but only during the duration of the beep. The resulted to a very inconsistent behavior depending on the user's settings.

Added visual beeper support to the new "RACE" and "BEACON" profile modes.

General cleanup and refactoring.
2019-01-20 19:21:47 -05:00
Bruce Luckcuck
3d671c7134 Use fabsf() instead of ABS() for floats
The ABS() macro doesn't handle -0 floats correctly. Also fabsf() is more efficient.
2019-01-19 14:15:54 -05:00
Pieter Kruger
4ec536a317 Add LED profile feature - 4278 2019-01-19 20:23:03 +10:00
jflyper
d8f55f35ef Convert direct reference to string and freq table to vtxCommonXXX services 2019-01-14 11:31:45 +09:00
Michael Keller
3492bcff3d
Merge pull request #7028 from mikeller/add_crash_flip_led_warning
Added 'crash flip active' to the list of warnings to be shown on LED_STRIP.
2018-11-04 14:52:40 +13:00
mikeller
79fd505a8c Changed warning to only be shown when armed. 2018-11-04 13:37:39 +13:00
mikeller
286f21150c Unified warning activation conditions. 2018-11-03 19:25:43 +13:00
mikeller
09353a2b5d Fixed ordering of the LED_STRIP overlays. 2018-11-03 18:01:09 +13:00
mikeller
99eab92200 Added 'crash flip active' to the list of warnings to be shown on LED_STRIP. 2018-11-02 01:48:06 +13:00
mikeller
7b7ddd099f Remove unused BARO, GPS_HOME, GPS_HOLD modes. 2018-10-29 00:50:44 +13:00
mikeller
4ec481a843 Added '-fno-common' build option, fixed resulting problems. 2018-08-30 18:58:34 +12:00
mikeller
70ac9423c7 Unified BUILD_BUG_ON and STATIC_ASSERT into STATIC_ASSERT. 2018-08-20 10:50:06 +12:00
mikeller
d401e3bbbe Fix usages, scaling. 2018-05-29 23:08:26 +12:00
jflyper
041bfb22c6 Create a pg for rxConfig 2018-05-27 09:13:04 +09:00
mikeller
2feae20c32 Replaced instances of '#include <platform.h>' with '#include "platform.h"'. 2018-05-24 23:46:19 +12:00
s0up
de5fa47c4c navigation feature / reference removal 2018-05-09 10:28:36 -07:00