DSM2 Bind Mode Fix -- Issue 98
Some DSM2 modules take longer than others to power up. Thus, sending a
single BIND packet is not sufficient in some cases. I have implemented
here an approimately 4 second period (after power-up) during which
time the trainer swtich can activate BIND mode.
This is in fact not strictly needed, since the DSM module will by
itself reject bind packets after a short time. (I have confirmed this
again with my DSM2 module today.) However, we like to be sure, so the
limited time window for BIND activation remains.
The word "BIND" also now appears as confirmation in upper-right of
the main view, whenever bind packets are being sent to the DSM module.
(I did not consider it important to add this "BIND" word to the
language files. Please feel free to do so though, if warranted.)
Gruvin.
This commit is contained in:
@@ -380,4 +380,8 @@ void menuMainView(uint8_t event)
|
||||
DISPLAY_PROGRESS_BAR(20*FW+1);
|
||||
#endif
|
||||
|
||||
#ifdef DSM2
|
||||
if (s_bind_mode)
|
||||
lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
+13
-6
@@ -418,20 +418,27 @@ normal:
|
||||
|
||||
*/
|
||||
|
||||
bool s_bind_allowed = true;
|
||||
bool s_bind_mode = false; // For confirmation display of "BIND" in upper-right of main view screen
|
||||
uint8_t s_bind_allowed = 255; // Counter allows trainer switch bind mode during 1st ~4 seconds, after power-on.
|
||||
// This is needed to give time for DSM module to repliably complete power up.
|
||||
|
||||
FORCEINLINE void setupPulsesDsm2()
|
||||
{
|
||||
uint16_t *ptr = (uint16_t *)pulses2MHz;
|
||||
if (s_bind_allowed) {
|
||||
*ptr++ = (keyState(SW_Trainer) ? BIND_BIT : 0x00);
|
||||
s_bind_allowed = false;
|
||||
if (s_bind_allowed) s_bind_allowed--;
|
||||
if (s_bind_allowed && keyState(SW_Trainer))
|
||||
{
|
||||
s_bind_mode = true;
|
||||
*ptr++ = BIND_BIT;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
s_bind_mode = false;
|
||||
*ptr++ = 0x00;
|
||||
}
|
||||
*ptr++ = g_model.modelId;
|
||||
for (uint8_t i=0; i<DSM2_CHANS; i++) {
|
||||
for (uint8_t i=0; i<DSM2_CHANS; i++)
|
||||
{
|
||||
uint16_t pulse = limit(0, ((g_chans512[i]*13)>>5)+512,1023);
|
||||
*ptr++ = (i<<2) | ((pulse>>8)&0x03);
|
||||
*ptr++ = pulse & 0xff;
|
||||
|
||||
Reference in New Issue
Block a user