Exemplo n.º 1
0
unsigned int deserializeControllerMapFromFile(struct HWCONTROLINPUT *hwcontrol, struct CONTROLLER *controller)
{

    /* check for controller file -- if exists, dump into current hardware control structure */
    FILE *f;
    int i;
    f = fopen("controls.dat", "rb+");
    if (f) {
        fread(serializedControllerMap, sizeof(char), sizeof(serializedControllerMap), f);
        fclose(f);
        for (i = 0; i < CONTROLLER_INPUT_MAX; ++i) {
            if (serializedControllerMap[i][serializedKeyboard]) {
                controller->pressedInputs[i] = &hwcontrol->pressedKeys[serializedControllerMap[i][serializedKeyboard]];
            }
            if (serializedControllerMap[i][serializedJoystick]) {
                controller->pressedInputs[i] = &hwcontrol->pressedJS[serializedControllerMap[i][serializedJoystick]];
            }
        }
    } else {
        setControllerDefaults(hwcontrol, controller);
    }

}
Exemplo n.º 2
0
/* When enter is pressed, the command is excecuted here */
void executeSerialCommand(uint8_t string[])
{
	float numArg = 0;
	uint8_t tempBool = 0;

	/* Big help screen */
	if (compareCommand(string, CMD_HELP, &numArg))
	{
		print("\r\n Format is:");
		print("\r\n   command:number");
		print("\r\n number must be between:");
		print("\r\n   -1000 and 1000 for (permilli) commands");
		print("\r\n   1 or 0 for (boolean) commands\n");
		/* Because serial can be time consuming */
		#ifdef WATCHDOG_EN
				HAL_IWDG_Refresh(&hiwdg);
		#endif
		print("\r\n defaults - Sets defaults (no args)");
		print("\r\n print config - Prints out the current config (no args)");
		print("\r\n power bias - Sets front to rear power bias (permilli)");
		print("\r\n front slip - Sets front diff slip (permilli)");
		/* Because serial can be time consuming */
		#ifdef WATCHDOG_EN
				HAL_IWDG_Refresh(&hiwdg);
		#endif
		print("\r\n rear slip - Sets rear diff slip (permilli)");
		print("\r\n gyro gain - Sets steering correction gain (permilli)");
		print("\r\n steering trim - Trims the steering (permilli)");
		/* Because serial can be time consuming */
		#ifdef WATCHDOG_EN
				HAL_IWDG_Refresh(&hiwdg);
		#endif
		print("\r\n invert steering - Inverts the steering (boolean)");
		print("\r\n wheel feedback - Enables the wheel speed feedback (boolean)\n");

	}

	/* Prints current config */
	if (compareCommand(string, CMD_PRINT_CONFIG, &numArg))
	{
		uint8_t intString[10];

		print("\r\n Power bias: ");
		itoa(ControllerConfig.powerBias, &intString, 10);
		print(&intString);

		print("\r\n Front slip: ");
		itoa(ControllerConfig.frontSlip, &intString, 10);
		print(&intString);

		print("\r\n Rear slip: ");
		itoa(ControllerConfig.rearSlip, &intString, 10);
		print(&intString);

		print("\r\n Gyro gain: ");
		itoa(ControllerConfig.gyroGain, &intString, 10);
		print(&intString);

		print("\r\n Steering trim: ");
		itoa(ControllerConfig.steeringTrim, &intString, 10);
		print(&intString);

		print("\r\n Invert steering: ");
		itoa(ControllerConfig.invertSteering, &intString, 10);
		print(&intString);

		print("\r\n Wheel speed feedback: ");
		itoa(ControllerConfig.enableWheelSpeedFeedback, &intString, 10);
		print(&intString);
		print("\r\n");
	}

	/* Setting power bias etc */
	if (compareCommand(string, CMD_SET_POWERBIAS, &numArg))
	{
		print("\r\n Power bias ");
		setControllerConfig(powerBias, (int32_t)numArg);
	}

	if (compareCommand(string, CMD_SET_FRONTSLIP, &numArg))
	{
		print("\r\n Front slip ");
		setControllerConfig(frontSlip, (int32_t)numArg);
	}

	if (compareCommand(string, CMD_SET_REARSLIP, &numArg))
	{
		setControllerConfig(rearSlip, (int32_t)numArg);
		print("\r\n Rear slip ");
	}

	if (compareCommand(string, CMD_SET_GYROGAIN, &numArg))
	{
		setControllerConfig(gyroGain, (int32_t)numArg);
		print("\r\n Gyro gain ");
	}

	if (compareCommand(string, CMD_SET_STEERINGTRIM, &numArg))
	{
		setControllerConfig(steeringTrim, (int32_t)numArg);
		print("\r\n Steering trim ");
	}

	if (compareCommand(string, CMD_INVERT_STEERING, &numArg))
	{
		setControllerConfig(invertSteering, (int32_t)numArg);
		print("\r\n Steering invert ");
	}

	if (compareCommand(string, CMD_WHEELFEEDBACK, &numArg))
	{
		setControllerConfig(enableWheelSpeedFeedback, (int32_t)numArg);
		print("\r\n Wheel speed feedback ");
	}

	/* Restores default settings */
	if (compareCommand(string, CMD_DEFAULTS, &numArg))
	{
		/* Set defaults */
		setControllerDefaults();
	}

	/* Reboots CPU */
	if (compareCommand(string, CMD_REBOOT, &numArg))
	{
		/* Flag for reset */
		ResetPendingFlag = 1;
	}

	print("\r\nBrinir> ");
}
Exemplo n.º 3
0
CSVController::CSVController(QObject *parent) : QObject(parent)
{
    setControllerDefaults();
}