22-08-24 VE
latest code used during Best2024
This commit is contained in:
12
main/bsp.c
12
main/bsp.c
@@ -197,6 +197,7 @@ void boardInit(void)
|
||||
|
||||
void setMotor(uint32_t speedA, bool directionA,uint32_t speedB, bool directionB)
|
||||
{
|
||||
/*
|
||||
if(QUISUISJE==BATEAU){
|
||||
if(speedA<SEUIL_MOTEUR){
|
||||
gpio_set_level(M1A,0);
|
||||
@@ -225,6 +226,7 @@ void setMotor(uint32_t speedA, bool directionA,uint32_t speedB, bool directionB)
|
||||
}
|
||||
}
|
||||
else{
|
||||
*/
|
||||
if(directionA){
|
||||
ledc_set_duty(ledc_channel[0].speed_mode, ledc_channel[0].channel, speedA);
|
||||
ledc_update_duty(ledc_channel[0].speed_mode, ledc_channel[0].channel);
|
||||
@@ -250,14 +252,15 @@ void setMotor(uint32_t speedA, bool directionA,uint32_t speedB, bool directionB)
|
||||
ledc_set_duty(ledc_channel[3].speed_mode, ledc_channel[3].channel, speedB);
|
||||
ledc_update_duty(ledc_channel[3].speed_mode, ledc_channel[3].channel);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void initMotor(void)
|
||||
{
|
||||
int ch;
|
||||
|
||||
if(QUISUISJE==VOITURE){ /*
|
||||
// if(QUISUISJE==VOITURE){
|
||||
/*
|
||||
* Prepare and set configuration of timers
|
||||
* that will be used by LED Controller
|
||||
*/
|
||||
@@ -300,7 +303,7 @@ void initMotor(void)
|
||||
for (ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
|
||||
ledc_channel_config(&ledc_channel[ch]);
|
||||
}
|
||||
}
|
||||
/*}
|
||||
else{
|
||||
gpio_reset_pin(M1A);
|
||||
gpio_set_direction(M1A, GPIO_MODE_OUTPUT);
|
||||
@@ -311,6 +314,7 @@ gpio_set_direction(M2A, GPIO_MODE_OUTPUT);
|
||||
gpio_reset_pin(M2B);
|
||||
gpio_set_direction(M2B, GPIO_MODE_OUTPUT);
|
||||
}
|
||||
//*/
|
||||
setMotor(0,true,0,true);
|
||||
|
||||
}
|
||||
@@ -377,7 +381,7 @@ void getThrRaw(int *value){
|
||||
void getBatt(int *value){
|
||||
int rawValue;
|
||||
getBattRaw( &rawValue);
|
||||
*value=(int)(rawValue*3.5);//scale TBD
|
||||
*value=(int)(rawValue*4);//scale TBD
|
||||
}
|
||||
// Normalized value between -100 and +100
|
||||
void getDir(int *value){
|
||||
|
@@ -119,6 +119,8 @@ extern uint8_t led_strip_pixels[EXAMPLE_LED_NUMBERS * 3];
|
||||
#define TRANSMIT_PERIOD_INTERVAL 100 // 100 millisecondes entre les trames
|
||||
#define SIZE_TOPIC 25 // longueur des noms des topic
|
||||
|
||||
//#define BATEAU_MODE_TOR
|
||||
|
||||
#define TOPIC_TIMER_BATEAU "/B/timer"
|
||||
|
||||
|
||||
|
14
main/loop.c
14
main/loop.c
@@ -122,10 +122,10 @@ void loop_bateau(void ){
|
||||
dir=dirReceived;
|
||||
thr=gazReceived;
|
||||
dataReceived=0;
|
||||
M1=(-thr+dir)*5;
|
||||
M1=(2*thr-2*dir)*5;
|
||||
if(M1>MOTOR_MAX_VALUE)M1=MOTOR_MAX_VALUE;
|
||||
if(M1<-MOTOR_MAX_VALUE)M1=-MOTOR_MAX_VALUE;
|
||||
M2=-(-thr-dir)*5;
|
||||
M2=-(2*thr+2*dir)*5;
|
||||
if(M2>MOTOR_MAX_VALUE)M2=MOTOR_MAX_VALUE;
|
||||
if(M2<-MOTOR_MAX_VALUE)M2=-MOTOR_MAX_VALUE;
|
||||
if(M1>0){
|
||||
@@ -150,7 +150,7 @@ void loop_bateau(void ){
|
||||
}
|
||||
else{
|
||||
if(timer++>10){// timeout de 1 seconde
|
||||
esp_wifi_set_ps(WIFI_PS_MIN_MODEM);//minimise la conso, augmente la latence
|
||||
// VE DEBUG esp_wifi_set_ps(WIFI_PS_MIN_MODEM);//minimise la conso, augmente la latence
|
||||
state_bateau=BATEAU_SLEEP;
|
||||
setMotor(0,dirM1,0,dirM2);
|
||||
vTaskDelay(TRANSMIT_PERIOD_INTERVAL / portTICK_PERIOD_MS);
|
||||
@@ -198,7 +198,7 @@ void loop_radio_bateau(void ){
|
||||
vTaskDelay(TRANSMIT_PERIOD_INTERVAL / portTICK_PERIOD_MS);
|
||||
}
|
||||
else{
|
||||
esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
|
||||
// VE DEBUG esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
|
||||
state_radio_bateau=RADIO_BATEAU_SLEEP;
|
||||
getBatt(&batt);
|
||||
sprintf(battStr,"%04d",batt);
|
||||
@@ -238,7 +238,7 @@ void loop_starter_bateau(void){
|
||||
timer--;
|
||||
}
|
||||
else{
|
||||
//esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
data='0';
|
||||
msg_id = esp_mqtt_client_publish(clientMqtt, topicGo, &data, 0, 1, 1);
|
||||
state_radio_bateau=RADIO_BATEAU_SLEEP;
|
||||
@@ -286,10 +286,10 @@ void loop_voiture(void ){
|
||||
dir=dirReceived;
|
||||
thr=gazReceived;
|
||||
dataReceived=0;
|
||||
M1=(-thr+dir)*5;
|
||||
M1=(thr+dir)*5;
|
||||
if(M1>MOTOR_MAX_VALUE)M1=MOTOR_MAX_VALUE;
|
||||
if(M1<-MOTOR_MAX_VALUE)M1=-MOTOR_MAX_VALUE;
|
||||
M2=-(-thr-dir)*5;
|
||||
M2=-(thr-dir)*5;
|
||||
if(M2>MOTOR_MAX_VALUE)M2=MOTOR_MAX_VALUE;
|
||||
if(M2<-MOTOR_MAX_VALUE)M2=-MOTOR_MAX_VALUE;
|
||||
if(M1>0){
|
||||
|
Reference in New Issue
Block a user