| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * @file | ||
| 3 | * @brief Implementation of the main control knob module | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include "main_control_knob.h" | ||
| 7 | #include "rte.h" | ||
| 8 | |||
| 9 | #define CONTROL_KEY_UP KEY_UP | ||
| 10 | #define CONTROL_KEY_DOWN KEY_DOWN | ||
| 11 | #define KNOB_UPDATE_INCREMENT 2u | ||
| 12 | |||
| 13 | /** | ||
| 14 | * ```{impl} Main Control Knob's main function | ||
| 15 | * :id: SWIMPL_MCK-001 | ||
| 16 | * :implements: SWDD_MCK-100, SWDD_MCK-101, SWDD_MCK-200, SWDD_MCK-201, SWDD_MCK-202, SWDD_MCK-203 | ||
| 17 | * ``` | ||
| 18 | */ | ||
| 19 | 31 | void mainControlKnob(void) | |
| 20 | { | ||
| 21 | 31 | percentage_t currentValue = RteGetMainKnobValue(); | |
| 22 |
2/2✓ Branch 4 → 5 taken 19 times.
✓ Branch 4 → 8 taken 12 times.
|
31 | if (RteIsKeyPressed(CONTROL_KEY_UP)) |
| 23 | { | ||
| 24 | // Increase knob's percentage value by 5 with a maximum of 100. | ||
| 25 |
2/2✓ Branch 5 → 6 taken 13 times.
✓ Branch 5 → 7 taken 6 times.
|
19 | if (currentValue < (100 - KNOB_UPDATE_INCREMENT)) |
| 26 | { | ||
| 27 | 13 | currentValue += KNOB_UPDATE_INCREMENT; | |
| 28 | } | ||
| 29 | else | ||
| 30 | { | ||
| 31 | 6 | currentValue = 100; | |
| 32 | } | ||
| 33 | } | ||
| 34 |
2/2✓ Branch 9 → 10 taken 9 times.
✓ Branch 9 → 13 taken 3 times.
|
12 | else if (RteIsKeyPressed(CONTROL_KEY_DOWN)) |
| 35 | { | ||
| 36 | // Decrease knob's percentage value by 5 with a minimum of 0. | ||
| 37 |
2/2✓ Branch 10 → 11 taken 3 times.
✓ Branch 10 → 12 taken 6 times.
|
9 | if (currentValue > KNOB_UPDATE_INCREMENT) |
| 38 | { | ||
| 39 | 3 | currentValue -= KNOB_UPDATE_INCREMENT; | |
| 40 | } | ||
| 41 | else | ||
| 42 | { | ||
| 43 | 6 | currentValue = 0; | |
| 44 | } | ||
| 45 | } | ||
| 46 | 31 | RteSetMainKnobValue(currentValue); | |
| 47 | 31 | } | |
| 48 |