Files
edgetx-gx12/radio/src/hal/switch_driver.h
T
3djcandGitHub 7f669f12d9 feat: Add initial Jumper T20 support (#3726)
* Jumper T20

* Fix center beeps

* Add option to pinch top trim as well to bootloader

* chore: Regenerate yaml

* chore: Add entry for Buddy

* Jumper T20

* Foldable section for fonction swith and fix preflight pot checks

* Remove duplicated entry

* Rename "function switches" to "customizable switches"

* chore: Add translations

* chore: Update translations

* chore: Update Companion translations/wording
2023-07-07 10:44:14 +10:00

83 lines
2.2 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>
#include "opentx_types.h"
enum SwitchHwType {
SWITCH_HW_2POS = 0,
SWITCH_HW_3POS,
SWITCH_HW_ADC,
};
enum SwitchHwPos {
SWITCH_HW_UP = 0,
SWITCH_HW_MID,
SWITCH_HW_DOWN,
};
#define SWITCH_HW_INVERTED 1
// init hardware for switches
void switchInit();
// returns the factory configuration for all switches
swconfig_t switchGetDefaultConfig();
// returns the maximum number of regular switches supported in hardware
uint8_t switchGetMaxSwitches();
// returns the number of configured switches
uint8_t getSwitchCount();
// returns the highest row for a specified column
uint8_t switchGetMaxRow(uint8_t col);
// returns the maximum number of customizable switches supported in hardware
uint8_t switchGetMaxFctSwitches();
struct switch_display_pos_t {
uint8_t col;
uint8_t row;
};
switch_display_pos_t switchGetDisplayPosition(uint8_t idx);
// The functions bellow support regular as well as customizable switches.
//
// Regular switches are indexed from `0` to `switchGetMaxSwitches() - 1`
// Customizable switches are indexed above the previous range.
//
// The total number of switches (and max index + 1) is:
// switchGetMaxSwitches() + switchGetMaxFctSwitches()
//
// returns state (0 / 1) of a specific switch position
uint32_t switchState(uint8_t pos_idx);
// returns a position for a switch index
SwitchHwPos switchGetPosition(uint8_t idx);
const char* switchGetName(uint8_t idx);
SwitchHwType switchGetHwType(uint8_t idx);