Files
edgetx-gx12/radio/src/hal/adc_driver.h
T
RistoandGitHub 60bbe52f63 feat: More analog diagnostics screens on B&W colorlcd (#1421)
* Show true unscaled and unfiltered analogs for diagnose purpose on the analog diagnose screen.
Tested on physical RM TX16S, not yet tested on B/W targets.

* Changed to decimal display also on B/W targets. Tested now with RM Zorro as well.

* 5 fps refresh rate of the raw analog values. Much nicer to look at.

* Time-changing 3 views for color radios: std., filtered raw with deviation, unfiltered raw.

* Corrected deviation view output to not use old values.

* Changed analogs diagnose page to user navigatable TabsGroup with 3 tabs.

* Added fourth analog diagnose tab to show minimum and maximum values and the range (difference between min and max).
Left touch screen and IMU output tests only on first page (should also move in the future to their respective dedicated pages).

* Use Std. JitterAlpha filtering for Deviation screen to minimize delay, omit filtering for FlySky digital hall gimbals - not necessary, the signal is stable enough.

* 2 analog diagnose pages for 128x64 B/W radios: calibrated analogs and raw values with display output limited to 5 frames-per-second due to visibility reasons.

* Added 2 analogs diagnose pages also for 212x64 display B/W radios.
I was only able to simulate it, not tested on real hardware.

* Support also radios that do not have PageUp/PageDn keys, but only Page key (e.g. X7).

* Better key handling and improved style thx to @pfeerick
2022-01-21 14:45:56 +10:00

61 lines
1.8 KiB
C

/*
* Copyright (C) EdgeTx
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include <stdint.h>
// TODO: move this to the targets
#if NUM_PWMSTICKS > 0
#define FIRST_ANALOG_ADC (STICKS_PWM_ENABLED() ? NUM_PWMSTICKS : 0)
#define NUM_ANALOGS_ADC (STICKS_PWM_ENABLED() ? (NUM_ANALOGS - NUM_PWMSTICKS) : NUM_ANALOGS)
#elif defined(PCBX9E)
#define FIRST_ANALOG_ADC 0
#define NUM_ANALOGS_ADC 11
#define NUM_ANALOGS_ADC_EXT (NUM_ANALOGS - NUM_ANALOGS_ADC)
#else
#define FIRST_ANALOG_ADC_FS 4
#define NUM_ANALOGS_ADC_FS 10
#define NUM_ANALOGS_ADC_EXT 2
#define FIRST_ANALOG_ADC 0
#define NUM_ANALOGS_ADC NUM_ANALOGS
#endif
#define ADCMAXVALUE 4095
// TODO: get rid of this special case
#if defined(PCBX10) || defined(PCBX12S)
extern uint16_t rtcBatteryVoltage;
#endif
struct etx_hal_adc_driver_t {
bool (*init)();
bool (*start_conversion)();
void (*wait_completion)();
};
bool adcInit(const etx_hal_adc_driver_t* driver);
// void adcDeInit();
bool adcRead();
uint16_t getRTCBatteryVoltage();
uint16_t getAnalogValue(uint8_t index);