Merge pull request #745 from opentx/bsongis/Issue650_precise_logical_switches_delays_durations

Issue #650 fixed - 0.1s precision in durations/delays for logical
This commit is contained in:
Andre Bernet
2014-02-26 11:26:52 +01:00
8 changed files with 31 additions and 28 deletions
+2 -2
View File
@@ -471,8 +471,8 @@ void ConvertModel_215_to_216(ModelData &model)
if (sw.func >= LS_FUNC_STAY) sw.func += 1;
sw.v1 = oldModel.customSw[i].v1;
sw.v2 = oldModel.customSw[i].v2;
sw.delay = oldModel.customSw[i].delay;
sw.duration = oldModel.customSw[i].duration;
sw.delay = oldModel.customSw[i].delay * 5;
sw.duration = oldModel.customSw[i].duration * 5;
sw.andsw = ConvertSwitch_215_to_216(oldModel.customSw[i].andsw);
#if defined(PCBTARANIS)
uint8_t cstate = cswFamily(sw.func);
+4 -4
View File
@@ -4379,7 +4379,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
case LS_FIELD_DURATION:
lcd_putsLeft(y, STR_DURATION);
if (cs->duration > 0)
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->duration, attr|PREC1|LEFT);
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->duration, attr|PREC1|LEFT);
else
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION);
@@ -4387,7 +4387,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
case LS_FIELD_DELAY:
lcd_putsLeft(y, STR_DELAY);
if (cs->delay > 0)
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->delay, attr|PREC1|LEFT);
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->delay, attr|PREC1|LEFT);
else
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY);
@@ -4677,7 +4677,7 @@ void menuModelLogicalSwitches(uint8_t event)
#if defined(CPUARM)
// CSW duration
if (cs->duration > 0)
lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT);
lcd_outdezAtt(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT);
else
lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0);
@@ -4689,7 +4689,7 @@ void menuModelLogicalSwitches(uint8_t event)
}
}
else if (cs->delay > 0) {
lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT);
lcd_outdezAtt(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT);
}
else {
lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0);
+2 -2
View File
@@ -719,8 +719,8 @@ enum LogicalSwitchesFunctions {
};
#if defined(CPUARM)
#define MAX_LS_DURATION 120 /*60s*/
#define MAX_LS_DELAY 120 /*60s*/
#define MAX_LS_DURATION 250 /*25s*/
#define MAX_LS_DELAY 250 /*25s*/
#define MAX_LS_ANDSW SWSRC_LAST
typedef int16_t ls_telemetry_value_t;
PACK(typedef struct t_LogicalSwitchData { // Custom Switches data
+2 -2
View File
@@ -1634,13 +1634,13 @@ bool getSwitch(int8_t swtch)
result = false;
}
else {
cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50);
cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*10);
}
}
if (cs->duration) {
if (result && !cswStates[cs_idx]) {
cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*50);
cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*10);
}
cswStates[cs_idx] = result;