Fonctionne avec l'USB déconnecté et l'esclave en mode minimal + moteur
This commit is contained in:
parent
9966f4745c
commit
7224acd615
|
|
@ -74,26 +74,29 @@ void motion_control_update(void)
|
|||
if(elapsed_time_ms >= MSG_DELAY_MS)
|
||||
{
|
||||
// Send motors speed via I2C
|
||||
union {
|
||||
struct {
|
||||
uint8_t motor1_speed;
|
||||
uint8_t motor2_speed;
|
||||
} hard;
|
||||
uint8_t data[5];
|
||||
|
||||
uint8_t raw[MSG_LEN];
|
||||
} data;
|
||||
data[0] = 0x00; /// registre
|
||||
|
||||
data.hard.motor1_speed = (uint8_t)abs((int)motor1_speed);
|
||||
data.hard.motor2_speed = (uint8_t)abs((int)motor2_speed);
|
||||
//data.motor1_speed = (uint8_t)abs((int)motor1_speed);
|
||||
//data.motor2_speed = (uint8_t)abs((int)motor2_speed);
|
||||
|
||||
data.hard.motor1_speed = (uint8_t)abs((int)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
data.hard.motor2_speed = (uint8_t)abs((int)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
//data.motor1_speed = (uint8_t)abs((int)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
//data.motor2_speed = (uint8_t)abs((int)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
|
||||
data[1] = (uint8_t)abs((int)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
data[2] = (uint8_t)abs((int)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
|
||||
motor_set_dir(MOTOR1, (int16_t)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
motor_set_dir(MOTOR2, (int16_t)robot.udp_client.data.hard.inputs.joystick_x);
|
||||
|
||||
uint8_t reg = 0x00;
|
||||
|
||||
if(i2c_write_blocking(I2C_MASTER_INSTANCE, I2C_MOTION_CONTROLLER_ADDRESS, data, 3, false) == PICO_ERROR_GENERIC)
|
||||
{
|
||||
puts("Motion controller not reachable");
|
||||
}
|
||||
/*
|
||||
if(i2c_write_blocking(I2C_MASTER_INSTANCE, I2C_MOTION_CONTROLLER_ADDRESS, ®, 1, true) == PICO_ERROR_GENERIC)
|
||||
{
|
||||
puts("Motion controller not reachable");
|
||||
|
|
@ -102,6 +105,6 @@ void motion_control_update(void)
|
|||
if(i2c_write_blocking(I2C_MASTER_INSTANCE, I2C_MOTION_CONTROLLER_ADDRESS, data.raw, MSG_LEN, false) == PICO_ERROR_GENERIC)
|
||||
{
|
||||
puts("Motion controller not reachable");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue