Removed a few legacy timer limitations, fix non-working limit (fix #3301)
This commit is contained in:
@@ -1627,6 +1627,8 @@ class Firmware {
|
|||||||
|
|
||||||
virtual int getCapability(const Capability) = 0;
|
virtual int getCapability(const Capability) = 0;
|
||||||
|
|
||||||
|
virtual QTime getMaxTimerStart() = 0;
|
||||||
|
|
||||||
virtual bool isTelemetrySourceAvailable(int source) = 0;
|
virtual bool isTelemetrySourceAvailable(int source) = 0;
|
||||||
|
|
||||||
virtual int isAvailable(PulsesProtocol proto, int port=0) = 0;
|
virtual int isAvailable(PulsesProtocol proto, int port=0) = 0;
|
||||||
|
|||||||
@@ -813,6 +813,16 @@ int OpenTxFirmware::getCapability(const Capability capability)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTime OpenTxFirmware::getMaxTimerStart()
|
||||||
|
{
|
||||||
|
if (IS_TARANIS(board))
|
||||||
|
return QTime(23, 59, 59);
|
||||||
|
else if (IS_ARM(board))
|
||||||
|
return QTime(8, 59, 59);
|
||||||
|
else
|
||||||
|
return QTime(0, 59, 59);
|
||||||
|
}
|
||||||
|
|
||||||
bool OpenTxFirmware::isTelemetrySourceAvailable(int source)
|
bool OpenTxFirmware::isTelemetrySourceAvailable(int source)
|
||||||
{
|
{
|
||||||
if (IS_TARANIS(board) && (source == TELEMETRY_SOURCE_RSSI_TX))
|
if (IS_TARANIS(board) && (source == TELEMETRY_SOURCE_RSSI_TX))
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ class OpenTxFirmware: public Firmware {
|
|||||||
|
|
||||||
virtual int getCapability(const Capability);
|
virtual int getCapability(const Capability);
|
||||||
|
|
||||||
|
virtual QTime getMaxTimerStart();
|
||||||
|
|
||||||
virtual bool isTelemetrySourceAvailable(int source);
|
virtual bool isTelemetrySourceAvailable(int source);
|
||||||
|
|
||||||
virtual int isAvailable(PulsesProtocol proto, int port=0);
|
virtual int isAvailable(PulsesProtocol proto, int port=0);
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
|||||||
else if (func>=FuncSetTimer1 && func<=FuncSetTimer3) {
|
else if (func>=FuncSetTimer1 && func<=FuncSetTimer3) {
|
||||||
if (modified) cfn.param = QTimeS(fswtchParamTime[i]->time()).seconds();
|
if (modified) cfn.param = QTimeS(fswtchParamTime[i]->time()).seconds();
|
||||||
fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0));
|
fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0));
|
||||||
fswtchParamTime[i]->setMaximumTime(QTime(0, 59, 59));
|
fswtchParamTime[i]->setMaximumTime(firmware->getMaxTimerStart());
|
||||||
fswtchParamTime[i]->setTime(QTimeS(cfn.param));
|
fswtchParamTime[i]->setTime(QTimeS(cfn.param));
|
||||||
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
|||||||
ui->countdownBeep->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC);
|
ui->countdownBeep->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->value->setMaximumTime(firmware->getMaxTimerStart());
|
||||||
|
|
||||||
ui->persistent->setField(timer.persistent, this);
|
ui->persistent->setField(timer.persistent, this);
|
||||||
ui->persistent->addItem(tr("Not persistent"), 0);
|
ui->persistent->addItem(tr("Not persistent"), 0);
|
||||||
ui->persistent->addItem(tr("Persistent (flight)"), 1);
|
ui->persistent->addItem(tr("Persistent (flight)"), 1);
|
||||||
@@ -66,9 +68,11 @@ TimerPanel::~TimerPanel()
|
|||||||
|
|
||||||
void TimerPanel::update()
|
void TimerPanel::update()
|
||||||
{
|
{
|
||||||
int min = timer.val / 60;
|
int hour = timer.val / 3600;
|
||||||
int sec = timer.val % 60;
|
int min = (timer.val - (hour * 3600)) / 60;
|
||||||
ui->value->setTime(QTime(0, min, sec));
|
int sec = (timer.val - (hour * 3600)) % 60;
|
||||||
|
|
||||||
|
ui->value->setTime(QTime(hour, min, sec));
|
||||||
|
|
||||||
if (firmware->getCapability(PermTimers)) {
|
if (firmware->getCapability(PermTimers)) {
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
@@ -94,7 +98,7 @@ QWidget * TimerPanel::getLastFocus()
|
|||||||
|
|
||||||
void TimerPanel::on_value_editingFinished()
|
void TimerPanel::on_value_editingFinished()
|
||||||
{
|
{
|
||||||
timer.val = ui->value->time().minute()*60 + ui->value->time().second();
|
timer.val = ui->value->time().hour()*3600 + ui->value->time().minute()*60 + ui->value->time().second();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>-1</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@@ -39,10 +39,10 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentSection">
|
<property name="currentSection">
|
||||||
<enum>QDateTimeEdit::MinuteSection</enum>
|
<enum>QDateTimeEdit::HourSection</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="displayFormat">
|
<property name="displayFormat">
|
||||||
<string notr="true">mm:ss</string>
|
<string notr="true">hh:mm:ss</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2
|
|||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
char separator = ':';
|
char separator = ':';
|
||||||
if (tme >= 3600 && (~att & DBLSIZE)) {
|
if (tme >= 3600) {
|
||||||
qr = div(qr.quot, 60);
|
qr = div(qr.quot, 60);
|
||||||
separator = CHR_HOUR;
|
separator = CHR_HOUR;
|
||||||
}
|
}
|
||||||
@@ -617,6 +617,10 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2
|
|||||||
#define separator ':'
|
#define separator ':'
|
||||||
#endif
|
#endif
|
||||||
lcdDrawNumber(x, y, qr.quot, att|LEADING0|LEFT, 2);
|
lcdDrawNumber(x, y, qr.quot, att|LEADING0|LEFT, 2);
|
||||||
|
#if defined(CPUARM)
|
||||||
|
if (separator == CHR_HOUR)
|
||||||
|
att &= ~DBLSIZE;
|
||||||
|
#endif
|
||||||
#if defined(CPUARM) && defined(RTCLOCK)
|
#if defined(CPUARM) && defined(RTCLOCK)
|
||||||
if (att&TIMEBLINK)
|
if (att&TIMEBLINK)
|
||||||
lcdDrawChar(lcdLastPos, y, separator, BLINK);
|
lcdDrawChar(lcdLastPos, y, separator, BLINK);
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
|
|||||||
#endif
|
#endif
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
else if (func == FUNC_SET_TIMER) {
|
else if (func == FUNC_SET_TIMER) {
|
||||||
val_max = 59*60+59;
|
val_max = 539*60+59;
|
||||||
putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr);
|
putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -205,13 +205,14 @@ void menuModelSetup(uint8_t event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
|
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 539); // 8:59
|
||||||
timer->start = qr.rem + qr.quot*60;
|
timer->start = qr.rem + qr.quot*60;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
|
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
|
||||||
timer->start -= qr.rem ;
|
timer->start -= qr.rem ;
|
||||||
if ((int16_t)timer->start < 0) timer->start=0;
|
if ((int16_t)timer->start < 0) timer->start=0;
|
||||||
|
if ((int16_t)timer->start > 5999) timer->start=32399; // 8:59:59
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,6 +286,8 @@ void menuModelSetup(uint8_t event)
|
|||||||
case 2:
|
case 2:
|
||||||
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
|
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
|
||||||
timer->start -= qr.rem ;
|
timer->start -= qr.rem ;
|
||||||
|
if ((int16_t)timer->start < 0) timer->start=0;
|
||||||
|
if ((int32_t)timer->start > 3599) timer->start=3599; // 59:59
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
|
|||||||
lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr);
|
lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr);
|
||||||
}
|
}
|
||||||
else if (func == FUNC_SET_TIMER) {
|
else if (func == FUNC_SET_TIMER) {
|
||||||
val_max = 59*60+59;
|
val_max = 539*60+59; //8:59:59
|
||||||
putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT, attr);
|
putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT|TIMEHOUR, attr);
|
||||||
}
|
}
|
||||||
else if (func == FUNC_PLAY_SOUND) {
|
else if (func == FUNC_PLAY_SOUND) {
|
||||||
val_max = AU_SPECIAL_SOUND_LAST-AU_SPECIAL_SOUND_FIRST-1;
|
val_max = AU_SPECIAL_SOUND_LAST-AU_SPECIAL_SOUND_FIRST-1;
|
||||||
|
|||||||
@@ -122,9 +122,8 @@ void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
|
|||||||
TimerData * timer = &g_model.timers[timerIdx];
|
TimerData * timer = &g_model.timers[timerIdx];
|
||||||
drawStringWithIndex(0*FW, y, STR_TIMER, timerIdx+1);
|
drawStringWithIndex(0*FW, y, STR_TIMER, timerIdx+1);
|
||||||
putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, menuHorizontalPosition==0 ? attr : 0);
|
putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, menuHorizontalPosition==0 ? attr : 0);
|
||||||
|
putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, menuHorizontalPosition==1 ? attr|TIMEHOUR : TIMEHOUR, menuHorizontalPosition==2 ? attr|TIMEHOUR : TIMEHOUR);
|
||||||
putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, menuHorizontalPosition==1 ? attr : 0, menuHorizontalPosition==2 ? attr : 0);
|
if (attr && menuHorizontalPosition < 0) drawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, 11*FW, FH+1);
|
||||||
if (attr && menuHorizontalPosition < 0) lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH+1, FH+1);
|
|
||||||
if (attr && s_editMode>0) {
|
if (attr && s_editMode>0) {
|
||||||
div_t qr = div(timer->start, 60);
|
div_t qr = div(timer->start, 60);
|
||||||
switch (menuHorizontalPosition) {
|
switch (menuHorizontalPosition) {
|
||||||
@@ -148,13 +147,14 @@ void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
|
qr.quot = checkIncDec(event, qr.quot, 0, 1439, EE_MODEL | NO_INCDEC_MARKS); // 23h59
|
||||||
timer->start = qr.rem + qr.quot*60;
|
timer->start = qr.rem + qr.quot*60;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
|
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
|
||||||
timer->start -= qr.rem ;
|
timer->start -= qr.rem ;
|
||||||
if ((int16_t)timer->start < 0) timer->start=0;
|
if ((int16_t)timer->start < 0) timer->start=0;
|
||||||
|
if ((int32_t)timer->start > 86399) timer->start=86399; // 23h59:59
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user