fix servo scaling
This commit is contained in:
parent
b9f8e90dd7
commit
43b23ec1ad
@ -90,8 +90,9 @@
|
||||
}
|
||||
|
||||
function send(x,y,angle){
|
||||
x = Math.round((x + 200) * 81.92);
|
||||
y = Math.round((y + 200) * 81.92);
|
||||
factor = (2**16-1)/400
|
||||
x = Math.round((x + 200) * factor);
|
||||
y = Math.round((y + 200) * factor);
|
||||
var data = clientId + ";d;" + x.toString() + "," + y.toString();
|
||||
connection.send(data);
|
||||
}
|
||||
|
||||
@ -59,8 +59,8 @@ int cmd_contrl(char* line, void* cli)
|
||||
{
|
||||
readInt(arg, &ch_d[1]);
|
||||
|
||||
servo_set(0, (int16_t)ch_d[0]);
|
||||
servo_set(1, (int16_t)ch_d[1]);
|
||||
servo_set(0, (uint16_t)ch_d[0]);
|
||||
servo_set(1, (uint16_t)ch_d[1]);
|
||||
snprintf(&msg[0], 40, "channel data: 0:%lu, 1:%lu\n", ch_d[0], ch_d[1]);
|
||||
CLI_stringOut((CLI_t*)cli, &msg[0]);
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ static uint8_t BoatId = 1;
|
||||
|
||||
#define HISTORY // enable cli history
|
||||
|
||||
#define SERVOS_CH0 {LEDC_CHANNEL_0, 5},
|
||||
#define SERVOS_CH1 {LEDC_CHANNEL_1, 6}
|
||||
#define SERVOS_CH0 {LEDC_CHANNEL_0, 7},
|
||||
#define SERVOS_CH1 {LEDC_CHANNEL_1, 21}
|
||||
#define SERVOS_CH2
|
||||
#define SERVOS_CH3
|
||||
#define SERVOS_CH4
|
||||
|
||||
@ -70,7 +70,7 @@ void servo_deinit(void)
|
||||
}
|
||||
}
|
||||
|
||||
void servo_set(uint8_t ch, int16_t pos)
|
||||
void servo_set(uint8_t ch, uint16_t pos)
|
||||
{
|
||||
uint32_t duty = (uint32_t) ((double)pos * (double)SERVO_DUTY_DIFF/(double)INT16_MAX);
|
||||
duty += (SERVO_DUTY_MIN + SERVO_DUTY_DIFF/2);
|
||||
|
||||
@ -5,6 +5,6 @@
|
||||
|
||||
void servo_init(void);
|
||||
void servo_deinit(void);
|
||||
void servo_set(uint8_t ch, int16_t pos);
|
||||
void servo_set(uint8_t ch, uint16_t pos);
|
||||
|
||||
#endif // SERVOS_H
|
||||
@ -121,18 +121,6 @@ ws_client_t ws_connect(char *url)
|
||||
|
||||
const esp_websocket_client_config_t ws_conf = {
|
||||
.uri = url
|
||||
// .disable_pingpong_discon = false,
|
||||
// .ping_interval_sec = 2,
|
||||
// .pingpong_timeout_sec = 1
|
||||
|
||||
// bool disable_auto_reconnect; /*!< Disable the automatic reconnect function when disconnected */
|
||||
// int buffer_size; /*!< Websocket buffer size */
|
||||
// bool keep_alive_enable; /*!< Enable keep-alive timeout */
|
||||
// int keep_alive_idle; /*!< Keep-alive idle time. Default is 5 (second) */
|
||||
// int keep_alive_interval; /*!< Keep-alive interval time. Default is 5 (second) */
|
||||
// int keep_alive_count; /*!< Keep-alive packet retry send count. Default is 3 counts */
|
||||
// int reconnect_timeout_ms; /*!< Reconnect after this value in miliseconds if disable_auto_reconnect is not enabled (defaults to 10s) */
|
||||
// int network_timeout_ms; /*!< Abort network operation if it is not completed after this value, in milliseconds (defaults to 10s) */
|
||||
};
|
||||
client->handle = esp_websocket_client_init(&ws_conf);
|
||||
esp_websocket_register_events(client->handle, WEBSOCKET_EVENT_ANY, ws_event_handler, (void *)client);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user