public class KartSetup
extends java.lang.Object
Groups all kart settings together and allows a convenient kart setup.
Constructor and Description |
---|
KartSetup()
Creates a new, kart setup with all parameters set to their defaults.
|
Modifier and Type | Method and Description |
---|---|
KartSetup |
apply(KartSetup setup)
Applies all parameters of the given Kart setup to this setup.
|
KartSetup |
clearHwSetting(KartHardwareSettings setting)
Clears the given hardware setting flag.
|
int |
driveMaxSpeed()
Returns the maximal speed a kart is allowed to drive with.
|
KartSetup |
driveMaxSpeed(int speed)
Sets the maximal speed a kart is allowed to drive with.
|
int |
drivePwmPeriod()
Returns the drive motor control block PWM period.
|
KartSetup |
drivePwmPeriod(int period)
Sets the drive motor control block PWM period.
|
java.util.EnumSet<KartHardwareSettings> |
hardwareSettings()
Returns the Kart's actual hardware settings.
|
KartSetup |
hardwareSettings(java.util.EnumSet<KartHardwareSettings> hardwareSettings)
Changes all of the hardware settings flags to the given values.
|
static KartSetup |
load(java.lang.String identifier,
android.app.Activity activity)
Loads the kart settings from the given name.
|
void |
save(java.lang.String identifier,
android.app.Activity activity)
Saves the kart settings under the given identifier.
|
KartSetup |
setHwSetting(KartHardwareSettings setting)
Sets the given hardware setting flag.
|
KartSetup |
steeringCenterPosition(int position)
Sets the steering motor central position.
|
int |
steeringEndSwitchAddress()
Returns the steering end switch address from which emulated end switch the data is considered by the steering FSM.
|
KartSetup |
steeringEndSwitchAddress(int address)
Sets the steering end switch address from which emulated end switch the data is considered by the steering FSM.
|
int |
steeringMaxPosition()
Returns the maximal step count at the opposite site of the stepper end contact switch.
|
KartSetup |
steeringMaxPosition(int position)
Sets the maximal step count of the steering motor.
|
int |
steeringStepPeriod()
Returns the steering motor driver step period.
|
KartSetup |
steeringStepPeriod(int period)
Sets the steering motor driver step period.
|
float |
updateInterval()
Returns the update interval of the Kart in seconds.
|
KartSetup |
updateInterval(float interval)
Sets the update interval of the Kart in seconds.
|
public KartSetup()
Creates a new, kart setup with all parameters set to their defaults.
public int drivePwmPeriod()
Returns the drive motor control block PWM period. The period is defined as the value the main FPGA clock is divided by.
public KartSetup drivePwmPeriod(int period)
Sets the drive motor control block PWM period. The period is defined as the value the main FPGA clock is divided by. Defaults to 64.
period
- PWM period.public int driveMaxSpeed()
Returns the maximal speed a kart is allowed to drive with. Values are from 0 to 15.
public KartSetup driveMaxSpeed(int speed)
Sets the maximal speed a kart is allowed to drive with. Valid values are in 0...15.
speed
- Maximal allowed speed.public int steeringMaxPosition()
Returns the maximal step count at the opposite site of the stepper end contact switch.
public KartSetup steeringMaxPosition(int position)
Sets the maximal step count of the steering motor. Default value is defined by Kart VHDL.
design.position
- The value of the step counter at the opposite site of the end switch.public KartSetup steeringCenterPosition(int position)
Sets the steering motor central position. Note that this method actually calls the method steeringMaxPosition with 2 times the center position.
position
- The value of the step counter at the center.public int steeringStepPeriod()
Returns the steering motor driver step period. The period is defined as the value the main FPGA clock is divided by.
public KartSetup steeringStepPeriod(int period)
Sets the steering motor driver step period. The period is defined as the value the main FPGA clock is divided by. Defaults to 100.
period
- Steering motor step period.public int steeringEndSwitchAddress()
Returns the steering end switch address from which emulated end switch the data is considered by the steering FSM. This value can be ignored if the option to enable the emulated end contact is not set in the hardware settings.
public KartSetup steeringEndSwitchAddress(int address)
Sets the steering end switch address from which emulated end switch the data is considered by the steering FSM. This value will be ignored if the option to enable the emulated end contact is not set in the hardware settings. Defaults to 0.
address
- Steering end contact address.public java.util.EnumSet<KartHardwareSettings> hardwareSettings()
Returns the Kart's actual hardware settings. Default is all flags cleared.
public KartSetup hardwareSettings(java.util.EnumSet<KartHardwareSettings> hardwareSettings)
Changes all of the hardware settings flags to the given values.
hardwareSettings
- Hardware settings to apply.public KartSetup setHwSetting(KartHardwareSettings setting)
Sets the given hardware setting flag.
setting
- Hardware setting flag to set.public KartSetup clearHwSetting(KartHardwareSettings setting)
Clears the given hardware setting flag.
setting
- Hardware setting flag to clear.public float updateInterval()
Returns the update interval of the Kart in seconds. This interval is the time between each register update send from the Kart to the Android application.
public KartSetup updateInterval(float interval)
Sets the update interval of the Kart in seconds. This interval is the time between each register update send from the Kart to the Android application. Note that fractions of seconds is supported too. Defaults to 0.064.
interval
- Update interval in seconds.public KartSetup apply(KartSetup setup)
Applies all parameters of the given Kart setup to this setup.
setup
- Kart setup to apply to this kart setup object.public void save(java.lang.String identifier, android.app.Activity activity)
Saves the kart settings under the given identifier.
identifier
- Name for the saved setup.activity
- Activity is needed to access file system.public static KartSetup load(java.lang.String identifier, android.app.Activity activity)
Loads the kart settings from the given name.
identifier
- Identifier of the setup to load.activity
- Activity is needed to access file system.