Merge branch 'bsongis/x-lites' of https://github.com/kilrah/opentx_xlites into bsongis/x-lites
# Conflicts: # radio/src/gui/128x64/model_setup.cpp
This commit is contained in:
@@ -283,7 +283,7 @@ void menuModelSetup(event_t event)
|
||||
POT_WARN_ITEMS(), // Pot warning
|
||||
NUM_STICKS + NUM_POTS + NUM_SLIDERS + NUM_ROTARY_ENCODERS - 1, // Center beeps
|
||||
0, // Global functions
|
||||
4, // Registration ID
|
||||
PXX2_LEN_REGISTRATION_ID - 1, // Registration ID
|
||||
LABEL(InternalModule),
|
||||
INTERNAL_MODULE_MODE_ROWS,
|
||||
IF_INTERNAL_MODULE_ON((uint8_t)0), // Model Number
|
||||
@@ -1013,12 +1013,11 @@ void menuModelSetup(event_t event)
|
||||
#if defined(PCBTARANIS)
|
||||
case ITEM_MODEL_REGISTRATION_ID:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, "Regis. ID");
|
||||
for(uint8_t pos=0; pos<PXX2_LEN_REGISTRATION_ID; pos++)
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, "Reg. ID");
|
||||
for (uint8_t pos=0; pos<PXX2_LEN_REGISTRATION_ID; pos++) {
|
||||
lcdDrawHexChar(MODEL_SETUP_2ND_COLUMN + pos*FW*2,y, g_model.modelRegistrationID[pos], menuHorizontalPosition==pos ? attr : 0);
|
||||
lcdDrawChar(lcdLastRightPos, y, ':');
|
||||
if (attr && menuHorizontalPosition==pos) {
|
||||
if (attr && menuHorizontalPosition == pos) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.modelRegistrationID[pos], 0xff);
|
||||
}
|
||||
}
|
||||
@@ -1027,7 +1026,6 @@ void menuModelSetup(event_t event)
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_MODEL_NUM:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_RECEIVER_NUM);
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[INTERNAL_MODULE], attr | LEADING0|LEFT, 2);
|
||||
if (attr) {
|
||||
@@ -1036,9 +1034,11 @@ void menuModelSetup(event_t event)
|
||||
modelHeaders[g_eeGeneral.currModel].modelId[INTERNAL_MODULE] = g_model.header.modelId[INTERNAL_MODULE];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_RANGE:
|
||||
lcdDrawTextAlignedLeft(y, STR_RANGE);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_MODULE_RANGE, attr);
|
||||
case ITEM_MODEL_INTERNAL_MODULE_RANGE_REG:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, INDENT "Module");
|
||||
@@ -1053,11 +1053,9 @@ void menuModelSetup(event_t event)
|
||||
if (attr && s_editMode==0) {
|
||||
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_ADD_RECEIVER:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, "Receiver");
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, "[Add]", attr);
|
||||
if (attr && s_editMode>0) {
|
||||
@@ -1071,8 +1069,7 @@ void menuModelSetup(event_t event)
|
||||
}
|
||||
s_editMode = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ITEM_MODEL_INTERNAL_MODULE_RECEIVER_1_NUMBER:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_RECEIVER_2_NUMBER:
|
||||
@@ -1086,7 +1083,7 @@ void menuModelSetup(event_t event)
|
||||
case ITEM_MODEL_INTERNAL_MODULE_RECEIVER_1_RANGE:
|
||||
case ITEM_MODEL_INTERNAL_MODULE_RECEIVER_2_RANGE:
|
||||
{
|
||||
//TODO have a proper channel assignement screen, section bellow is just for tests
|
||||
// TODO have a proper channel assignement screen, section bellow is just for tests
|
||||
uint8_t useUpperChannels;
|
||||
uint8_t receiverIdx = CURRENT_RECEIVER_EDITED(k);
|
||||
|
||||
|
||||
+5
-2
@@ -1096,6 +1096,7 @@ void opentxResume();
|
||||
#else
|
||||
#define SD_SCREEN_FILE_LENGTH 64
|
||||
#endif
|
||||
|
||||
union ReusableBuffer
|
||||
{
|
||||
// ARM 334 bytes
|
||||
@@ -1116,8 +1117,10 @@ union ReusableBuffer
|
||||
struct {
|
||||
char msg[64];
|
||||
uint8_t r9mPower;
|
||||
char pxx2_candidate_receivers[5][8];
|
||||
uint8_t pxx2_candidate_receivers_count;
|
||||
uint8_t pxx2_register_or_bind_step;
|
||||
char pxx2_bind_candidate_receivers[5][8];
|
||||
uint8_t pxx2_bind_candidate_receivers_count;
|
||||
uint8_t pxx2_bind_receiver_index;
|
||||
} modelsetup;
|
||||
|
||||
// 103 bytes
|
||||
|
||||
@@ -57,11 +57,9 @@ void Pxx2Pulses::setupChannelsFrame(uint8_t module)
|
||||
|
||||
void Pxx2Pulses::setupRegisterFrame(uint8_t module)
|
||||
{
|
||||
unsigned counter = moduleSettings[module].counter;
|
||||
|
||||
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_REGISTER);
|
||||
|
||||
if (counter == REGISTER_COUNTER_ID_RECEIVED) {
|
||||
if (reusableBuffer.modelsetup.pxx2_register_or_bind_step == REGISTER_COUNTER_ID_RECEIVED) {
|
||||
Pxx2Transport::addByte(0x01);
|
||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
||||
@@ -76,9 +74,17 @@ void Pxx2Pulses::setupBindFrame(uint8_t module)
|
||||
{
|
||||
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_BIND);
|
||||
|
||||
Pxx2Transport::addByte(0x00);
|
||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
||||
if (reusableBuffer.modelsetup.pxx2_register_or_bind_step == BIND_RX_ID_SELECTED) {
|
||||
Pxx2Transport::addByte(0x00);
|
||||
for (uint8_t i=0; i<PXX2_LEN_RX_ID; i++) {
|
||||
Pxx2Transport::addByte(g_model.moduleData[module].pxx2.receivers[reusableBuffer.modelsetup.pxx2_bind_receiver_index].rxID[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Pxx2Transport::addByte(0x00);
|
||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-4
@@ -26,8 +26,6 @@
|
||||
|
||||
#define PXX2_TYPE_C_MODULE 0x01
|
||||
#define PXX2_TYPE_ID_REGISTER 0x01
|
||||
#define REGISTER_COUNTER_ID_RECEIVED 1001
|
||||
#define REGISTER_COUNTER_PASSWORD_RECEIVED 1002
|
||||
#define PXX2_TYPE_ID_BIND 0x02
|
||||
#define PXX2_TYPE_ID_CHANNELS 0x03
|
||||
#define PXX2_TYPE_ID_SPORT 0xFE
|
||||
@@ -38,8 +36,21 @@
|
||||
|
||||
#define PXX2_FLAG0_FAILSAFE (1 << 6)
|
||||
|
||||
const uint8_t DEFAULT_CHANNEL_MAPPING[] = {0x12, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
const uint8_t CH9TO16_CHANNEL_MAPPING[] = {0x89, 0xAB, 0xCD, 0xEF, 0x12, 0x23, 0x45, 0x67};
|
||||
const uint8_t DEFAULT_CHANNEL_MAPPING[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
|
||||
const uint8_t CH9TO16_CHANNEL_MAPPING[] = {0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67};
|
||||
|
||||
enum PXX2RegisterSteps {
|
||||
REGISTER_START,
|
||||
REGISTER_COUNTER_ID_RECEIVED,
|
||||
REGISTER_OK
|
||||
};
|
||||
|
||||
enum PXX2BindSteps {
|
||||
BIND_START,
|
||||
BIND_RX_ID_RECEIVED,
|
||||
BIND_RX_ID_SELECTED,
|
||||
BIND_OK
|
||||
};
|
||||
|
||||
class ModuleFifo : public Fifo<uint8_t, 32> {
|
||||
public:
|
||||
|
||||
@@ -76,12 +76,13 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
|
||||
{
|
||||
if (frame[3] == 0x00) {
|
||||
// RX_ID follows, we discard it for now
|
||||
moduleSettings[module].counter = REGISTER_COUNTER_ID_RECEIVED;
|
||||
reusableBuffer.modelsetup.pxx2_register_or_bind_step = REGISTER_COUNTER_ID_RECEIVED;
|
||||
}
|
||||
else if (frame[3] == 0x01) {
|
||||
// PASSWORD follows, we check it is good
|
||||
if (memcmp(&frame[4], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0) {
|
||||
moduleSettings[module].counter = REGISTER_COUNTER_PASSWORD_RECEIVED;
|
||||
reusableBuffer.modelsetup.pxx2_register_or_bind_step = REGISTER_OK;
|
||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,15 +91,22 @@ void processBindFrame(uint8_t module, uint8_t * frame)
|
||||
{
|
||||
if (frame[3] == 0x00) {
|
||||
bool found = false;
|
||||
for (uint8_t i=0; i<reusableBuffer.modelsetup.pxx2_candidate_receivers_count; i++) {
|
||||
if (memcmp(reusableBuffer.modelsetup.pxx2_candidate_receivers[i], &frame[4], PXX2_LEN_RX_ID) == 0) {
|
||||
for (uint8_t i=0; i<reusableBuffer.modelsetup.pxx2_bind_candidate_receivers_count; i++) {
|
||||
if (memcmp(reusableBuffer.modelsetup.pxx2_bind_candidate_receivers[i], &frame[4], PXX2_LEN_RX_ID) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found && reusableBuffer.modelsetup.pxx2_candidate_receivers_count < PXX2_MAX_RECEIVERS_PER_MODULE) {
|
||||
memcpy(reusableBuffer.modelsetup.pxx2_candidate_receivers[reusableBuffer.modelsetup.pxx2_candidate_receivers_count], &frame[4], PXX2_LEN_RX_ID);
|
||||
++reusableBuffer.modelsetup.pxx2_candidate_receivers_count;
|
||||
if (!found && reusableBuffer.modelsetup.pxx2_bind_candidate_receivers_count < PXX2_MAX_RECEIVERS_PER_MODULE) {
|
||||
memcpy(reusableBuffer.modelsetup.pxx2_bind_candidate_receivers[reusableBuffer.modelsetup.pxx2_bind_candidate_receivers_count], &frame[4], PXX2_LEN_RX_ID);
|
||||
++reusableBuffer.modelsetup.pxx2_bind_candidate_receivers_count;
|
||||
reusableBuffer.modelsetup.pxx2_register_or_bind_step = BIND_RX_ID_RECEIVED;
|
||||
}
|
||||
}
|
||||
else if (frame[3] == 0x01) {
|
||||
if (memcmp(g_model.moduleData[module].pxx2.receivers[reusableBuffer.modelsetup.pxx2_bind_receiver_index].rxID, &frame[4], PXX2_LEN_RX_ID) == 0) {
|
||||
reusableBuffer.modelsetup.pxx2_register_or_bind_step = BIND_OK;
|
||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user