mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
Begin of pin mapping screen
This commit is contained in:
parent
c16d1bf2e9
commit
1baf2e740e
16 changed files with 119 additions and 18 deletions
51
radio/src/bitfield.h
Normal file
51
radio/src/bitfield.h
Normal 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
|
||||
*
|
||||
* This file is based on work published at http://www.coranac.com/documents/working-with-bits-and-bitfields
|
||||
*
|
||||
* 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 BITFIELD_H
|
||||
#define BITFIELD_H
|
||||
|
||||
// A set of bitfield handling macros
|
||||
#define BF_BIT(n) ( 1<<(n) )
|
||||
#define BF_BIT_GET(y, mask) ( y & (mask) )
|
||||
#define BF_BIT_SET(y, mask) ( y |= (mask) )
|
||||
#define BF_BIT_CLEAR(y, mask) ( y &= ~(mask) )
|
||||
#define BF_BIT_FLIP(y, mask) ( y ^= (mask) )
|
||||
#define BF_SINGLE_BIT_GET(y, i) BF_BIT_GET(y, BF_BIT(i))
|
||||
#define BF_SINGLE_BIT_SET(y, i) BF_BIT_SET(y, BF_BIT(i))
|
||||
|
||||
//! Create a bitmask of length 'len'.
|
||||
#define BF_BITMASK(len) ( BF_BIT(len)-1 )
|
||||
|
||||
//! Create a bitfield mask of length 'len' starting at bit 'start'.
|
||||
#define BF_MASK(start, len) ( BF_BITMASK(len)<<(start) )
|
||||
|
||||
//! Prepare a bitmask for insertion or combining.
|
||||
#define BF_PREP(x, start, len) ( ((x)&BF_BITMASK(len)) << (start) )
|
||||
|
||||
//! Extract a bitfield of length 'len' starting at bit 'start' from 'y'.
|
||||
#define BF_GET(y, start, len) ( ((y)>>(start)) & BF_BITMASK(len) )
|
||||
|
||||
//! Insert 'len' bits of 'x 'into 'y', starting at bit 'start' from 'y'.
|
||||
#define BF_SET(y, x, start, len) \
|
||||
( y= ((y) &~ BF_MASK(start, len)) | BF_PREP(x, start, len) )
|
||||
|
||||
#endif //BITFIELD_H
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
#include <opentx.h>
|
||||
|
||||
uint8_t g_moduleIdx;
|
||||
uint8_t g_moduleIdx, g_receiverIdx;
|
||||
void menuModelFailsafe(event_t event);
|
||||
void menuModelPinmap(event_t event);
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
uint8_t getSwitchWarningsCount()
|
||||
|
@ -83,11 +84,11 @@ enum MenuModelSetupItems {
|
|||
ITEM_MODEL_INTERNAL_MODULE_FAILSAFE,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RANGE_REGISTER,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_NUMBER,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_RANGE,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_PINMAP,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_TELEM,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_BIND_DEL,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_NUMBER,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_RANGE,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_PINMAP,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_TELEM,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_BIND_DEL,
|
||||
ITEM_MODEL_INTERNAL_MODULE_PXX2_ADD_RECEIVER,
|
||||
|
@ -1117,24 +1118,19 @@ void menuModelSetup(event_t event)
|
|||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_RANGE:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_RANGE:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_1_PINMAP:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_PXX2_RECEIVER_2_PINMAP:
|
||||
{
|
||||
// TODO have a proper channel assignement screen, section bellow is just for tests
|
||||
uint8_t useUpperChannels;
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(k);
|
||||
uint8_t moduleIdx = CURRENT_MODULE_EDITED(k);
|
||||
|
||||
if (memcmp(&g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[receiverIdx].channelMapping, DEFAULT_CHANNEL_MAPPING, sizeof(uint64_t)) == 0)
|
||||
useUpperChannels = 0;
|
||||
else
|
||||
useUpperChannels = 1;
|
||||
|
||||
useUpperChannels = editCheckBox(useUpperChannels, MODEL_SETUP_2ND_COLUMN, y, INDENT INDENT "Use CH9-16", attr, event);
|
||||
|
||||
if (useUpperChannels)
|
||||
memcpy(&g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[receiverIdx].channelMapping, CH9TO16_CHANNEL_MAPPING, sizeof(uint64_t));
|
||||
else
|
||||
memcpy(&g_model.moduleData[INTERNAL_MODULE].pxx2.receivers[receiverIdx].channelMapping, DEFAULT_CHANNEL_MAPPING, sizeof(uint64_t));
|
||||
lcdDrawTextAlignedLeft(y, INDENT INDENT "PinMap");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, "[set]", attr);
|
||||
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
g_receiverIdx = receiverIdx;
|
||||
g_moduleIdx = moduleIdx;
|
||||
pushMenu(menuModelPinmap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1744,3 +1740,39 @@ void menuModelFailsafe(event_t event)
|
|||
lcdDrawText(CENTER_OFS, LCD_H - (FH + 1), STR_OUTPUTS2FAILSAFE, INVERS);
|
||||
}
|
||||
}
|
||||
|
||||
void menuModelPinmap(event_t event)
|
||||
{
|
||||
SIMPLE_SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx) + 1);
|
||||
|
||||
lcdDrawTextAlignedCenter(0, PINMAPSET);
|
||||
lcdInvertLine(0);
|
||||
|
||||
//const coord_t x = 1;
|
||||
coord_t y = FH + 1;
|
||||
uint8_t line = (menuVerticalPosition >= sentModuleChannels(g_moduleIdx) ? 2 : 0);
|
||||
uint8_t pin = (menuVerticalPosition >= 8 ? 8 : 0) + line;
|
||||
|
||||
for (; line < 8; line++) {
|
||||
//Pin
|
||||
lcdDrawTextAlignedLeft(y, "Pin");
|
||||
lcdDrawNumber(lcdLastRightPos+5, y, pin);
|
||||
lcdDrawText(lcdLastRightPos+5, y, " -> ");
|
||||
|
||||
|
||||
//Channel
|
||||
LcdFlags flags = SMLSIZE;
|
||||
if (menuVerticalPosition == pin) {
|
||||
flags |= INVERS;
|
||||
if (s_editMode) {
|
||||
flags |= BLINK;
|
||||
}
|
||||
}
|
||||
lcdDrawNumber(lcdLastRightPos+5, y, getPinOuput(g_receiverIdx, g_moduleIdx, pin), flags);
|
||||
|
||||
y += FH;
|
||||
|
||||
if (++pin >= sentModuleChannels(g_moduleIdx))
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -200,6 +200,11 @@ static const int8_t maxChannelsXJT[] = { 0, 8, 0, 4 }; // relative to 8!
|
|||
constexpr int8_t MAX_TRAINER_CHANNELS_M8 = MAX_TRAINER_CHANNELS - 8;
|
||||
constexpr int8_t MAX_EXTRA_MODULE_CHANNELS_M8 = 8; // only 16ch PPM
|
||||
|
||||
inline uint8_t getPinOuput(uint8_t receiverIdx, uint8_t moduleIdx, uint8_t pin)
|
||||
{
|
||||
return ((g_model.moduleData[moduleIdx].pxx2.receivers[receiverIdx].channelMapping >> (pin + ((pin & 0x01) ? -1 : 1 )) * 4) & 0x0F);
|
||||
}
|
||||
|
||||
inline int8_t maxModuleChannels_M8(uint8_t idx)
|
||||
{
|
||||
if (isExtraModule(idx))
|
||||
|
|
|
@ -368,6 +368,7 @@ const char STR_USBMODE[] = TR_USBMODE;
|
|||
const char STR_JACKMODE[] = TR_JACKMODE;
|
||||
const char STR_FAILSAFE[] = TR_FAILSAFE;
|
||||
const char STR_FAILSAFESET[] = TR_FAILSAFESET;
|
||||
const char STR_PINMAPSET[] = TR_PINMAPSET;
|
||||
const char STR_HOLD[] = TR_HOLD;
|
||||
const char STR_NONE[] = TR_NONE;
|
||||
const char STR_MENUSENSOR[] = TR_MENUSENSOR;
|
||||
|
|
|
@ -581,6 +581,7 @@ extern const char STR_MODULE_TELEMETRY[];
|
|||
extern const char STR_MODULE_TELEM_ON[];
|
||||
extern const char STR_FAILSAFE[];
|
||||
extern const char STR_FAILSAFESET[];
|
||||
extern const char STR_PINMAPSET[];
|
||||
extern const char STR_HOLD[];
|
||||
extern const char STR_NONE[];
|
||||
extern const char STR_MENUSENSOR[];
|
||||
|
|
|
@ -921,6 +921,7 @@
|
|||
#define TR_EXTERNALRF "Externí RF modul"
|
||||
#define TR_FAILSAFE TR("Failsafe", "Mód Failsafe")
|
||||
#define TR_FAILSAFESET "NASTAVENÍ FAILSAFE"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENZOR"
|
||||
|
|
|
@ -926,6 +926,7 @@
|
|||
#define TR_EXTERNALRF "Externes HF-Modul"
|
||||
#define TR_FAILSAFE TR(INDENT "Failsafe", INDENT "Failsafe Mode")
|
||||
#define TR_FAILSAFESET "Failsafe setzen"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -925,6 +925,7 @@
|
|||
#define TR_EXTERNALRF "External RF"
|
||||
#define TR_FAILSAFE TR(INDENT "Failsafe", INDENT "Failsafe mode")
|
||||
#define TR_FAILSAFESET "FAILSAFE SETTINGS"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -932,6 +932,7 @@
|
|||
#define TR_EXTERNALRF "Externa RF"
|
||||
#define TR_FAILSAFE INDENT"Modo sgdad."
|
||||
#define TR_FAILSAFESET "AJUSTES SGDAD."
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -924,6 +924,7 @@
|
|||
#define TR_EXTERNALRF "External RF"
|
||||
#define TR_FAILSAFE INDENT "Failsafe mode"
|
||||
#define TR_FAILSAFESET "FAILSAFE SETTINGS"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -936,6 +936,7 @@
|
|||
#define TR_EXTERNALRF "HF externe"
|
||||
#define TR_FAILSAFE TR(INDENT "Failsafe", INDENT "Type failsafe")
|
||||
#define TR_FAILSAFESET "REGLAGES FAILSAFE"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "CAPTEUR"
|
||||
|
|
|
@ -926,6 +926,7 @@
|
|||
#define TR_EXTERNALRF "Modulo esterno"
|
||||
#define TR_FAILSAFE "Modo failsafe"
|
||||
#define TR_FAILSAFESET TR("FAILSAFE","IMPOSTAZIONI FAILSAFE")
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -927,6 +927,7 @@
|
|||
#define TR_EXTERNALRF "Externe RF"
|
||||
#define TR_FAILSAFE TR(INDENT "Failsafe", INDENT "Failsafe Modus")
|
||||
#define TR_FAILSAFESET "Failsafe instellen"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -927,6 +927,7 @@
|
|||
#define TR_EXTERNALRF "Zewn.Moduł RF"
|
||||
#define TR_FAILSAFE TR(INDENT"Failsafe",INDENT"Tryb Failsafe")
|
||||
#define TR_FAILSAFESET "USTAWIENIE FAILSAFE"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "CZUJNIK"
|
||||
|
|
|
@ -931,6 +931,7 @@
|
|||
#define TR_EXTERNALRF "External RF"
|
||||
#define TR_FAILSAFE "Failsafe mode"
|
||||
#define TR_FAILSAFESET "FAILSAFE SETTINGS"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
|
@ -940,6 +940,7 @@
|
|||
#define TR_EXTERNALRF "Extern Radiomodul"
|
||||
#define TR_FAILSAFE TR(INDENT "Failsafe", INDENT "Failsafeläge")
|
||||
#define TR_FAILSAFESET "FailsafeInställning"
|
||||
#define TR_PINMAPSET "Set PIN to CH map"
|
||||
#define TR_HOLD "HOLD"
|
||||
#define TR_NONE "NONE"
|
||||
#define TR_MENUSENSOR "SENSOR"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue