1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Haptic strength will be selectable with a slider, with a default

position at center
This commit is contained in:
bsongis 2014-05-14 11:07:40 +02:00
parent cd42a7749e
commit 8f10bed8c1
12 changed files with 97 additions and 94 deletions

View file

@ -928,9 +928,9 @@ GeneralSettings::GeneralSettings()
byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16);
byte8=(int8_t)t_HapticSet.mid(2,2).toInt(&ok,16);
if (ok)
hapticStrength=byte8u;
hapticStrength=byte8;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
hapticLength=byte8;

View file

@ -506,7 +506,7 @@ class GeneralSettings {
bool hideNameOnSplash;
bool enablePpmsim;
unsigned int speakerPitch;
unsigned int hapticStrength;
int hapticStrength;
unsigned int speakerMode;
unsigned int lightOnStickMove; /* er9x / ersky9x only */
char ownerName[10+1];

View file

@ -124,7 +124,7 @@ Er9xGeneral::operator GeneralSettings ()
result.PPM_Multiplier = PPM_Multiplier;
getEEPROMString(result.ownerName, ownerName, sizeof(ownerName));
result.speakerPitch = speakerPitch;
result.hapticStrength = hapticStrength;
result.hapticStrength = hapticStrength - 3;
result.speakerMode = speakerMode;
result.switchWarningStates =switchWarningStates;
return result;

View file

@ -131,7 +131,7 @@ Ersky9xGeneral::operator GeneralSettings ()
getEEPROMString(result.ownerName, ownerName, sizeof(ownerName));
result.optrexDisplay = optrexDisplay;
result.speakerPitch = speakerPitch;
result.hapticStrength = hapticStrength;
result.hapticStrength = hapticStrength - 3;
result.speakerMode = speakerMode;
result.switchWarningStates = switchWarningStates;
result.speakerVolume = volume;

View file

@ -2664,7 +2664,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
}
internalField.Append(new SignedField<3>(generalData.beeperLength));
internalField.Append(new UnsignedField<3>(generalData.hapticStrength));
internalField.Append(new SignedField<3>(generalData.hapticStrength));
internalField.Append(new UnsignedField<1>(generalData.gpsFormat));
internalField.Append(new SpareBitsField<1>()); // unexpectedShutdown

View file

@ -200,7 +200,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
}
if (!GetCurrentFirmware()->getCapability(Haptic)) {
ui->hapticStrengthSB->setDisabled(true);
ui->hapticStrength->setDisabled(true);
ui->hapticmodeCB->setDisabled(true);
}
@ -375,7 +375,7 @@ void GeneralEdit::setValues()
ui->volume_SB->setValue(g_eeGeneral.speakerVolume);
ui->beeperlenCB->setCurrentIndex(g_eeGeneral.beeperLength+2);
ui->speakerPitchSB->setValue(g_eeGeneral.speakerPitch);
ui->hapticStrengthSB->setValue(g_eeGeneral.hapticStrength);
ui->hapticStrength->setValue(g_eeGeneral.hapticStrength);
ui->hapticmodeCB->setCurrentIndex(g_eeGeneral.hapticMode+2);
ui->battCalibDSB->setValue((double)g_eeGeneral.vBatCalib/10);
ui->CurrentCalib_SB->setValue((double)g_eeGeneral.currentCalib);
@ -914,9 +914,9 @@ void GeneralEdit::on_speakerPitchSB_editingFinished()
updateSettings();
}
void GeneralEdit::on_hapticStrengthSB_editingFinished()
void GeneralEdit::on_hapticStrength_valueChanged()
{
g_eeGeneral.hapticStrength = ui->hapticStrengthSB->value();
g_eeGeneral.hapticStrength = ui->hapticStrength->value();
updateSettings();
}
@ -1018,9 +1018,9 @@ void GeneralEdit::on_calretrieve_PB_clicked()
byte8=(int8_t)HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
g_eeGeneral.hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)HapticSet.mid(2,2).toUInt(&ok,16);
byte8=(int8_t)HapticSet.mid(2,2).toInt(&ok,16);
if (ok)
g_eeGeneral.hapticStrength=byte8u;
g_eeGeneral.hapticStrength=byte8;
byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
g_eeGeneral.hapticLength=byte8;
@ -1090,7 +1090,7 @@ void GeneralEdit::on_calstore_PB_clicked()
g.profile[profile_id].gsStickMode( g_eeGeneral.stickMode );
g.profile[profile_id].display( QString("%1%2%3").arg((g_eeGeneral.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.contrast, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.backlightBright, 2, 16, QChar('0')) );
g.profile[profile_id].beeper( QString("%1%2").arg(((uint8_t)g_eeGeneral.beeperMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.beeperLength, 2, 16, QChar('0')));
g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0')));
g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((int8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0')));
g.profile[profile_id].speaker( QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0')));
g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage));

View file

@ -36,7 +36,7 @@ private slots:
void on_faimode_CB_stateChanged(int );
void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished();
void on_hapticStrengthSB_editingFinished();
void on_hapticStrength_valueChanged();
void on_soundModeCB_currentIndexChanged(int index);
void on_beeperlenCB_currentIndexChanged(int index);
void on_volume_SB_editingFinished();

View file

@ -113,6 +113,22 @@ These will be relevant for all models in the same EEPROM.</string>
<string>Setup</string>
</attribute>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0">
<item row="4" column="1">
<widget class="QSlider" name="hapticStrength">
<property name="minimum">
<number>-2</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="hapticLengthCB">
<item>
@ -421,6 +437,20 @@ Mode 4:
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="displayTypeCB">
<item>
<property name="text">
<string>Standard</string>
</property>
</item>
<item>
<property name="text">
<string>Optrex</string>
</property>
</item>
</widget>
</item>
<item row="30" column="3" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
@ -1446,20 +1476,6 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="displayTypeCB">
<item>
<property name="text">
<string>Standard</string>
</property>
</item>
<item>
<property name="text">
<string>Optrex</string>
</property>
</item>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_contrast">
<property name="toolTip">
@ -1723,19 +1739,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="hapticStrengthSB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>5</number>
</property>
</widget>
</item>
<item row="12" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -1836,6 +1839,51 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="31" column="0">
<widget class="QLabel" name="stickReverseLB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Stick reverse (order as above)</string>
</property>
</widget>
</item>
<item row="31" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="stickReverse1">
<property name="text">
<string notr="true">1</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="stickReverse2">
<property name="text">
<string notr="true">2</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="stickReverse3">
<property name="text">
<string notr="true">3</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="stickReverse4">
<property name="text">
<string notr="true">4</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="3" rowspan="2" colspan="2">
<layout class="QGridLayout" name="gridLayout_9" columnstretch="1,0,1,0">
<item row="0" column="0">
@ -1932,51 +1980,6 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="31" column="0">
<widget class="QLabel" name="stickReverseLB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Stick reverse (order as above)</string>
</property>
</widget>
</item>
<item row="31" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="stickReverse1">
<property name="text">
<string notr="true">1</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="stickReverse2">
<property name="text">
<string notr="true">2</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="stickReverse3">
<property name="text">
<string notr="true">3</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="stickReverse4">
<property name="text">
<string notr="true">4</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTrainer">

View file

@ -328,6 +328,8 @@ void ConvertGeneralSettings_215_to_216(EEGeneral &settings)
settings.chkSum = evalChkSum();
memcpy(&settings.currModel, &oldSettings.currModel, sizeof(GeneralSettings_v215)-offsetof(GeneralSettings_v215, currModel));
settings.hapticStrength = 0; // Haptic strength reset
}
int ConvertTelemetrySource_215_to_216(int source)

View file

@ -418,11 +418,7 @@ void menuGeneralSetup(uint8_t event)
break;
case ITEM_SETUP_HAPTIC_STRENGTH:
lcd_putsLeft( y, STR_HAPTICSTRENGTH);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.hapticStrength, attr|LEFT);
if (attr) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.hapticStrength, 0, 5);
}
SLIDER_5POS(y, g_eeGeneral.hapticStrength, STR_HAPTICSTRENGTH, event, attr);
break;
#endif

View file

@ -55,14 +55,14 @@ void hapticQueue::heartbeat()
if (buzzTimeLeft > 0) {
buzzTimeLeft--; // time gets counted down
#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS))
hapticOn(g_eeGeneral.hapticStrength * 20);
hapticOn(HAPTIC_STRENGTH() * 20);
#else
if (hapticTick-- > 0) {
HAPTIC_ON();
}
else {
HAPTIC_OFF();
hapticTick = g_eeGeneral.hapticStrength;
hapticTick = HAPTIC_STRENGTH();
}
#endif
}

View file

@ -411,7 +411,7 @@ PACK(typedef struct t_EEGeneral {
N_PCBSTD_FIELD( uint8_t reNavigation)
N_TARANIS_FIELD(uint8_t stickReverse)
int8_t beepLength:3;
uint8_t hapticStrength:3;
int8_t hapticStrength:3;
uint8_t gpsFormat:1;
uint8_t unexpectedShutdown:1;
uint8_t speakerPitch;
@ -425,6 +425,8 @@ PACK(typedef struct t_EEGeneral {
}) EEGeneral;
#define HAPTIC_STRENGTH() (3+g_eeGeneral.hapticStrength)
#if defined(PCBTARANIS)
#define LEN_MODEL_NAME 12
#define LEN_BITMAP_NAME 10