1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +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); byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok) if (ok)
hapticMode=(BeeperMode)byte8; 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) if (ok)
hapticStrength=byte8u; hapticStrength=byte8;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16); byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok) if (ok)
hapticLength=byte8; hapticLength=byte8;

View file

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

View file

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

View file

@ -131,7 +131,7 @@ Ersky9xGeneral::operator GeneralSettings ()
getEEPROMString(result.ownerName, ownerName, sizeof(ownerName)); getEEPROMString(result.ownerName, ownerName, sizeof(ownerName));
result.optrexDisplay = optrexDisplay; result.optrexDisplay = optrexDisplay;
result.speakerPitch = speakerPitch; result.speakerPitch = speakerPitch;
result.hapticStrength = hapticStrength; result.hapticStrength = hapticStrength - 3;
result.speakerMode = speakerMode; result.speakerMode = speakerMode;
result.switchWarningStates = switchWarningStates; result.switchWarningStates = switchWarningStates;
result.speakerVolume = volume; 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 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 UnsignedField<1>(generalData.gpsFormat));
internalField.Append(new SpareBitsField<1>()); // unexpectedShutdown internalField.Append(new SpareBitsField<1>()); // unexpectedShutdown

View file

@ -200,7 +200,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
} }
if (!GetCurrentFirmware()->getCapability(Haptic)) { if (!GetCurrentFirmware()->getCapability(Haptic)) {
ui->hapticStrengthSB->setDisabled(true); ui->hapticStrength->setDisabled(true);
ui->hapticmodeCB->setDisabled(true); ui->hapticmodeCB->setDisabled(true);
} }
@ -375,7 +375,7 @@ void GeneralEdit::setValues()
ui->volume_SB->setValue(g_eeGeneral.speakerVolume); ui->volume_SB->setValue(g_eeGeneral.speakerVolume);
ui->beeperlenCB->setCurrentIndex(g_eeGeneral.beeperLength+2); ui->beeperlenCB->setCurrentIndex(g_eeGeneral.beeperLength+2);
ui->speakerPitchSB->setValue(g_eeGeneral.speakerPitch); 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->hapticmodeCB->setCurrentIndex(g_eeGeneral.hapticMode+2);
ui->battCalibDSB->setValue((double)g_eeGeneral.vBatCalib/10); ui->battCalibDSB->setValue((double)g_eeGeneral.vBatCalib/10);
ui->CurrentCalib_SB->setValue((double)g_eeGeneral.currentCalib); ui->CurrentCalib_SB->setValue((double)g_eeGeneral.currentCalib);
@ -914,9 +914,9 @@ void GeneralEdit::on_speakerPitchSB_editingFinished()
updateSettings(); updateSettings();
} }
void GeneralEdit::on_hapticStrengthSB_editingFinished() void GeneralEdit::on_hapticStrength_valueChanged()
{ {
g_eeGeneral.hapticStrength = ui->hapticStrengthSB->value(); g_eeGeneral.hapticStrength = ui->hapticStrength->value();
updateSettings(); updateSettings();
} }
@ -1018,9 +1018,9 @@ void GeneralEdit::on_calretrieve_PB_clicked()
byte8=(int8_t)HapticSet.mid(0,2).toUInt(&ok,16); byte8=(int8_t)HapticSet.mid(0,2).toUInt(&ok,16);
if (ok) if (ok)
g_eeGeneral.hapticMode=(BeeperMode)byte8; 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) if (ok)
g_eeGeneral.hapticStrength=byte8u; g_eeGeneral.hapticStrength=byte8;
byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16); byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16);
if (ok) if (ok)
g_eeGeneral.hapticLength=byte8; 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].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].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].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].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)); 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_faimode_CB_stateChanged(int );
void on_speakerPitchSB_editingFinished(); void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished(); void on_timezoneSB_editingFinished();
void on_hapticStrengthSB_editingFinished(); void on_hapticStrength_valueChanged();
void on_soundModeCB_currentIndexChanged(int index); void on_soundModeCB_currentIndexChanged(int index);
void on_beeperlenCB_currentIndexChanged(int index); void on_beeperlenCB_currentIndexChanged(int index);
void on_volume_SB_editingFinished(); 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> <string>Setup</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0"> <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"> <item row="3" column="1">
<widget class="QComboBox" name="hapticLengthCB"> <widget class="QComboBox" name="hapticLengthCB">
<item> <item>
@ -421,6 +437,20 @@ Mode 4:
</property> </property>
</widget> </widget>
</item> </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"> <item row="30" column="3" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
@ -1446,20 +1476,6 @@ Acceptable values are 5v..10v</string>
</property> </property>
</widget> </widget>
</item> </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"> <item row="9" column="0">
<widget class="QLabel" name="label_contrast"> <widget class="QLabel" name="label_contrast">
<property name="toolTip"> <property name="toolTip">
@ -1723,19 +1739,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </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"> <item row="12" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
@ -1836,6 +1839,51 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </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"> <item row="4" column="3" rowspan="2" colspan="2">
<layout class="QGridLayout" name="gridLayout_9" columnstretch="1,0,1,0"> <layout class="QGridLayout" name="gridLayout_9" columnstretch="1,0,1,0">
<item row="0" column="0"> <item row="0" column="0">
@ -1932,51 +1980,6 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </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> </layout>
</widget> </widget>
<widget class="QWidget" name="tabTrainer"> <widget class="QWidget" name="tabTrainer">

View file

@ -328,6 +328,8 @@ void ConvertGeneralSettings_215_to_216(EEGeneral &settings)
settings.chkSum = evalChkSum(); settings.chkSum = evalChkSum();
memcpy(&settings.currModel, &oldSettings.currModel, sizeof(GeneralSettings_v215)-offsetof(GeneralSettings_v215, currModel)); 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) int ConvertTelemetrySource_215_to_216(int source)

View file

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

View file

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

View file

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