1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 16:55:20 +03:00

Default switchs / pots / sliders configuration moved to the HAL (#6514)

Default switchs / pots / sliders configuration moved to the HAL
This commit is contained in:
Bertrand Songis 2019-06-18 15:47:38 +02:00 committed by GitHub
parent 6ab73f3ece
commit 0ec02f096c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 93 additions and 79 deletions

View file

@ -23,14 +23,6 @@
#define XPOT_DELTA 10
#define XPOT_DELAY 10 /* cycles */
enum CalibrationState {
CALIB_START = 0,
CALIB_SET_MIDPOINT,
CALIB_MOVE_STICKS,
CALIB_STORE,
CALIB_FINISHED
};
void menuCommonCalib(event_t event)
{
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) { // get low and high vals for sticks and trims

View file

@ -25,14 +25,6 @@
#define BAR_SPACING 12
#define BAR_HEIGHT 22
enum CalibrationState {
CALIB_START = 0,
CALIB_SET_MIDPOINT,
CALIB_MOVE_STICKS,
CALIB_STORE,
CALIB_FINISHED
};
void drawPotsBars()
{
// Optimization by Mike Blandford

View file

@ -26,15 +26,6 @@
#define STICKS_Y 60
#define STICK_LEFT_X 25
#define STICK_RIGHT_X (LCD_W-STICK_LEFT_X-STICKS_WIDTH)
enum CalibrationState {
CALIB_START = 0,
CALIB_SET_MIDPOINT,
CALIB_MOVE_STICKS,
CALIB_STORE,
CALIB_FINISHED
};
#define STICK_PANEL_WIDTH 68
void drawStick(coord_t x, coord_t y, const BitmapBuffer * background, int16_t xval, int16_t yval)

View file

@ -80,22 +80,6 @@
#define MODEL_GVAR_MAX(idx) (CFN_GVAR_CST_MAX - g_model.gvars[idx].max)
#if defined(PCBTARANIS) || defined(PCBHORUS)
enum SwitchConfig {
SWITCH_NONE,
SWITCH_TOGGLE,
SWITCH_2POS,
SWITCH_3POS,
};
enum PotConfig {
POT_NONE,
POT_WITH_DETENT,
POT_MULTIPOS_SWITCH,
POT_WITHOUT_DETENT
};
enum SliderConfig {
SLIDER_NONE,
SLIDER_WITH_DETENT,
};
#define SWITCH_CONFIG(x) (bfGet<uint32_t>(g_eeGeneral.switchConfig, 2*(x), 2))
#define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE)
#define IS_CONFIG_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS)

View file

@ -235,41 +235,22 @@ void generalDefault()
g_eeGeneral.version = EEPROM_VER;
g_eeGeneral.variant = EEPROM_VARIANT;
#if !defined(PCBHORUS)
#if defined(PCBHORUS)
g_eeGeneral.blOffBright = 20;
#else
g_eeGeneral.contrast = LCD_CONTRAST_DEFAULT;
#endif
#if defined(PCBHORUS)
#if PCBREV >= 13
g_eeGeneral.potsConfig = 0x1B; // S1 = pot, 6P = multipos, S2 = pot with detent
#else
g_eeGeneral.potsConfig = 0x19; // S1 = pot without detent, 6P = multipos, S2 = pot with detent
#endif
g_eeGeneral.slidersConfig = 0x0f; // 4 sliders
g_eeGeneral.blOffBright = 20;
#elif defined(PCBXLITE)
g_eeGeneral.potsConfig = 0x0F; // S1 and S2 = pot without detent
#elif defined(PCBX7)
g_eeGeneral.potsConfig = (POT_WITHOUT_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent
#elif defined(PCBX9LITE)
g_eeGeneral.potsConfig = (POT_WITH_DETENT << 0); // S1 = pot with detent
#elif defined(PCBTARANIS)
g_eeGeneral.potsConfig = 0x05; // S1 and S2 = pots with detent
g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent
#if defined(DEFAULT_POTS_CONFIG)
g_eeGeneral.potsConfig = DEFAULT_POTS_CONFIG;
#endif
#if defined(PCBXLITES)
g_eeGeneral.switchConfig = (SWITCH_TOGGLE << 10) + (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0);
#elif defined(PCBXLITE)
g_eeGeneral.switchConfig = (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0);
#elif defined(RADIO_X7)
g_eeGeneral.switchConfig = 0x000006ff; // 4x3POS, 1x2POS, 1xTOGGLE
#elif defined(RADIO_T12)
g_eeGeneral.switchConfig = (SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0);
#elif defined(PCBX9LITE)
g_eeGeneral.switchConfig = (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0);
#elif defined(PCBTARANIS) || defined(PCBHORUS)
g_eeGeneral.switchConfig = 0x00007bff; // 6x3POS, 1x2POS, 1xTOGGLE
#if defined(DEFAULT_SWITCH_CONFIG)
g_eeGeneral.switchConfig = DEFAULT_SWITCH_CONFIG;
#endif
#if defined(DEFAULT_SLIDERS_CONFIG)
g_eeGeneral.slidersConfig = DEFAULT_SLIDERS_CONFIG;
#endif
// vBatWarn is voltage in 100mV, vBatMin is in 100mV but with -9V offset, vBatMax has a -12V offset
@ -311,7 +292,7 @@ void generalDefault()
strcpy(g_eeGeneral.currModelFilename, DEFAULT_MODEL_FILENAME);
#endif
#if defined(PCBHORUS)
#if defined(COLORLCD)
strcpy(g_eeGeneral.themeName, theme->getName());
theme->init();
#endif
@ -1563,7 +1544,7 @@ void opentxClose(uint8_t shutdown)
#endif
#if defined(LUA)
luaClose(&lsScripts);
#if defined(PCBHORUS)
#if defined(COLORLCD)
luaClose(&lsWidgets);
#endif
#endif
@ -1614,7 +1595,8 @@ void opentxResume()
sdMount();
storageReadAll();
#if defined(PCBHORUS)
#if defined(COLORLCD)
loadTheme();
loadFontCache();
#endif
@ -1790,7 +1772,7 @@ void opentxInit()
storageReadCurrentModel();
#endif
#if defined(PCBHORUS)
#if defined(COLORLCD)
if (!unexpectedShutdown) {
// g_model.topbarData is still zero here (because it was not yet read from SDCARD),
// but we only remember the pointer to in in constructor.
@ -1861,7 +1843,7 @@ void opentxInit()
btInit();
#endif
#if defined(PCBHORUS)
#if defined(COLORLCD)
loadTheme();
loadFontCache();
#endif
@ -1919,11 +1901,10 @@ int main()
boardInit();
#if defined(PCBHORUS)
#if defined(COLORLCD)
loadFonts();
#endif
#if defined(GUI) && !defined(PCBTARANIS) && !defined(PCBHORUS)
// TODO remove this
lcdInit();

View file

@ -0,0 +1,51 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* 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.
*/
#ifndef _OPENTX_CONSTANTS_H_
#define _OPENTX_CONSTANTS_H_
enum SwitchConfig {
SWITCH_NONE,
SWITCH_TOGGLE,
SWITCH_2POS,
SWITCH_3POS,
};
enum PotConfig {
POT_NONE,
POT_WITH_DETENT,
POT_MULTIPOS_SWITCH,
POT_WITHOUT_DETENT
};
enum SliderConfig {
SLIDER_NONE,
SLIDER_WITH_DETENT,
};
enum CalibrationState {
CALIB_START,
CALIB_SET_MIDPOINT,
CALIB_MOVE_STICKS,
CALIB_STORE,
CALIB_FINISHED
};
#endif // _OPENTX_CONSTANTS_H_

View file

@ -22,6 +22,7 @@
#define _BOARD_HORUS_H_
#include "../definitions.h"
#include "../opentx_constants.h"
#include "cpu_id.h"
#if defined(__cplusplus) && !defined(SIMU)
@ -425,6 +426,10 @@ enum Analogs {
#define POT_LAST (SLIDER_FIRST - 1)
#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0)
#define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 4) + (POT_MULTIPOS_SWITCH << 2) + (POT_WITHOUT_DETENT << 0)
#define DEFAULT_SLIDERS_CONFIG (SLIDER_WITH_DETENT << 3) + (SLIDER_WITH_DETENT << 2) + (SLIDER_WITH_DETENT << 1) + (SLIDER_WITH_DETENT << 0)
enum CalibratedAnalogs {
CALIBRATED_STICK1,
CALIBRATED_STICK2,
@ -521,6 +526,7 @@ void ledBlue(void);
#define LCD_DEPTH 16
void lcdInit(void);
void lcdRefresh(void);
void lcdCopy(void * dest, void * src);
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);

View file

@ -26,6 +26,7 @@
#include <stdio.h>
#include "board_lowlevel.h"
#include "audio_driver.h"
#include "../opentx_constants.h"
extern uint16_t ResetReason;

View file

@ -23,6 +23,7 @@
#include <inttypes.h>
#include "../definitions.h"
#include "../opentx_constants.h"
#include "cpu_id.h"
#if defined(__cplusplus) && !defined(SIMU)
@ -448,28 +449,43 @@ enum EnumSwitchesPositions
#if defined(PCBXLITES)
#define NUM_SWITCHES 6
#define STORAGE_NUM_SWITCHES NUM_SWITCHES
#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 10) + (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0)
#define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 2) + (POT_WITHOUT_DETENT << 0)
#elif defined(PCBXLITE)
#define NUM_SWITCHES 4
#define STORAGE_NUM_SWITCHES 6
#define DEFAULT_SWITCH_CONFIG (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0);
#define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 2) + (POT_WITHOUT_DETENT << 0)
#elif defined(PCBT12)
#define NUM_SWITCHES 6
#define STORAGE_NUM_SWITCHES 8
#define DEFAULT_SWITCH_CONFIG (SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0)
#define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent
#elif defined(PCBX7)
#define NUM_SWITCHES 8
#define STORAGE_NUM_SWITCHES NUM_SWITCHES
#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 10) + (SWITCH_2POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0)
#define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent
#elif defined(PCBX9LITE)
#define NUM_SWITCHES 5
#define STORAGE_NUM_SWITCHES NUM_SWITCHES
#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0);
#define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 0); // S1 = pot with detent
#elif defined(PCBX9E)
#define NUM_SWITCHES 18 // yes, it's perfect like that !
#define STORAGE_NUM_SWITCHES NUM_SWITCHES
#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0)
#define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent
#define DEFAULT_SLIDERS_CONFIG (SLIDER_WITH_DETENT << 1) + (SLIDER_WITH_DETENT << 0)
#else
#define NUM_SWITCHES 8
#define STORAGE_NUM_SWITCHES NUM_SWITCHES
#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0)
#define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent
#define DEFAULT_SLIDERS_CONFIG (SLIDER_WITH_DETENT << 1) + (SLIDER_WITH_DETENT << 0)
#endif
#define STORAGE_NUM_SWITCHES_POSITIONS (STORAGE_NUM_SWITCHES * 3)
#define NUM_SWITCHES_POSITIONS (NUM_SWITCHES * 3)
void keysInit(void);
uint8_t keyState(uint8_t index);