vtx: fix VTX_SETTINGS_POWER_COUNT and add dummy entries to saPowerNames
[inav.git] / src / main / rx / sim.c
blob62d9a9b864ce4852e3226a6201ec4e6384976f04
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdbool.h>
19 #include <stdint.h>
21 #include "platform.h"
23 #ifdef USE_RX_SIM
25 #include "build/build_config.h"
27 #include "common/utils.h"
29 #include "rx/rx.h"
30 #include "rx/sim.h"
32 static uint16_t channels[MAX_SUPPORTED_RC_CHANNEL_COUNT];
33 static bool hasNewData = false;
34 static uint16_t rssi = 0;
36 static uint16_t rxSimReadRawRC(const rxRuntimeConfig_t *rxRuntimeConfigPtr, uint8_t chan) {
37 UNUSED(rxRuntimeConfigPtr);
38 return channels[chan];
41 void rxSimSetChannelValue(uint16_t* values, uint8_t count) {
42 for (size_t i = 0; i < count; i++) {
43 channels[i] = values[i];
46 hasNewData = true;
49 static uint8_t rxSimFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig) {
50 UNUSED(rxRuntimeConfig);
52 lqTrackerSet(rxRuntimeConfig->lqTracker, rssi);
54 if (!hasNewData) {
55 return RX_FRAME_PENDING;
58 hasNewData = false;
59 return RX_FRAME_COMPLETE;
62 void rxSimInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig) {
63 UNUSED(rxConfig);
65 rxRuntimeConfig->channelCount = MAX_SUPPORTED_RC_CHANNEL_COUNT;
66 rxRuntimeConfig->rxSignalTimeout = DELAY_5_HZ;
67 rxRuntimeConfig->rcReadRawFn = rxSimReadRawRC;
68 rxRuntimeConfig->rcFrameStatusFn = rxSimFrameStatus;
71 void rxSimSetRssi(uint16_t value) {
72 rssi = value;
74 #endif