Add ampfactor to control final motor power
This commit is contained in:
parent
e8e8b2495d
commit
45db6670c9
|
|
@ -66,11 +66,12 @@ int arduino_simhaptic_update(SimDevice* this, SimData* simdata)
|
||||||
double play = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
|
double play = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
|
||||||
|
|
||||||
double rplay = play;
|
double rplay = play;
|
||||||
|
play = play * serialdevice->ampfactor;
|
||||||
if(play > 1.0)
|
if(play > 1.0)
|
||||||
{
|
{
|
||||||
play = 1.0;
|
play = 1.0;
|
||||||
}
|
}
|
||||||
int effectspeed = ceil( 255 * play );
|
int effectspeed = ceil(255 * play);
|
||||||
|
|
||||||
int motor = serialdevice->motorsposition;
|
int motor = serialdevice->motorsposition;
|
||||||
|
|
||||||
|
|
@ -161,6 +162,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms) {
|
||||||
this->u.simhapticdata.effect3 = 0;
|
this->u.simhapticdata.effect3 = 0;
|
||||||
this->u.simhapticdata.effect4 = 0;
|
this->u.simhapticdata.effect4 = 0;
|
||||||
this->state = 0;
|
this->state = 0;
|
||||||
|
this->ampfactor = ds->serialdevsettings.ampfactor;
|
||||||
slogi("Initializing arduino device for haptic effects.");
|
slogi("Initializing arduino device for haptic effects.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ typedef struct
|
||||||
SerialDeviceType devicetype;
|
SerialDeviceType devicetype;
|
||||||
// move these two they only apply to the haptic device
|
// move these two they only apply to the haptic device
|
||||||
int motorsposition;
|
int motorsposition;
|
||||||
|
double ampfactor;
|
||||||
double state;
|
double state;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,18 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
||||||
int motorposition = 8;
|
int motorposition = 8;
|
||||||
config_setting_lookup_int(device_settings, "motors", &motorposition);
|
config_setting_lookup_int(device_settings, "motors", &motorposition);
|
||||||
ds->serialdevsettings.motorsposition = motorposition;
|
ds->serialdevsettings.motorsposition = motorposition;
|
||||||
|
|
||||||
|
double ampfactor = 1.0;
|
||||||
|
ds->serialdevsettings.ampfactor = 1.0;
|
||||||
|
int found = config_setting_lookup_float(device_settings, "ampfactor", &factor);
|
||||||
|
if(found == 0)
|
||||||
|
{
|
||||||
|
ds->serialdevsettings.ampfactor = 1.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ds->serialdevsettings.ampfactor = ampfactor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
char* portdev;
|
char* portdev;
|
||||||
MotorPosition motorsposition;
|
MotorPosition motorsposition;
|
||||||
|
float ampfactor;
|
||||||
}
|
}
|
||||||
SerialDeviceSettings;
|
SerialDeviceSettings;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue