Skip to content

Commit

Permalink
bugfix and rudder output change
Browse files Browse the repository at this point in the history
1. add ESPNow check for send to master function
2. remove BLE output for rudder, rudder only support ESPNow
  • Loading branch information
tcfshcrw committed Aug 5, 2024
1 parent 4000729 commit 7d8e5a1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
19 changes: 16 additions & 3 deletions ESP32/include/ESPNOW_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ uint16_t ESPNow_recieve=0;
bool ESPNOW_status =false;
bool ESPNow_initial_status=false;
bool ESPNow_update= false;
bool ESPNow_no_device=false;
//https://github.com/nickgammon/I2C_Anything/tree/master
struct ESPNow_Send_Struct
{
Expand Down Expand Up @@ -58,12 +59,24 @@ void sendMessageToMaster(int32_t controllerValue)
myData.pedal_status=0;
}
// Send message via ESP-NOW
esp_err_t result = esp_now_send(esp_master, (uint8_t *) &myData, sizeof(myData));
if(ESPNOW_status)
{
esp_err_t result = esp_now_send(esp_master, (uint8_t *) &myData, sizeof(myData));
}

//esp_now_send(esp_master, (uint8_t *) &myData, sizeof(myData));
/*
if (result != ESP_OK) {
Serial.println("Failed send data to ESP_Master");
if (result != ESP_OK)
{
ESPNow_no_device=true;
//Serial.println("Failed send data to ESP_Master");
}
else
{
ESPNow_no_device=false;
}
*/

/*if (result == ESP_OK) {
Serial.println("Sent with success");
}
Expand Down
22 changes: 17 additions & 5 deletions ESP32/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,12 @@ void serialCommunicationTask( void * pvParameters )

//Serial.print(" 4");
//Serial.print("\r\n");
if(dap_calculationVariables_st.Rudder_status==false)
{
//general output
SetControllerOutputValue(joystickNormalizedToInt32_local);
}
/*
if(dap_calculationVariables_st.Rudder_status)
{
if(dap_calculationVariables_st.rudder_brake_status)
Expand All @@ -1631,6 +1637,7 @@ void serialCommunicationTask( void * pvParameters )
//general output
SetControllerOutputValue(joystickNormalizedToInt32_local);
}
*/

}

Expand Down Expand Up @@ -1812,19 +1819,24 @@ void I2C_SyncTask( void * pvParameters )
int ESPNOW_count=0;
int error_count=0;
int print_count=0;
int ESPNow_no_device_count=0;
uint8_t error_out;
void ESPNOW_SyncTask( void * pvParameters )
{
for(;;)
{
//if(ESPNOW_count>10)
//if(ESPNOW_status)
{
//send the data to master
//if(dap_config_st.payLoadPedalConfig_.Joystick_ESPsync_to_ESP==1)
//always send message to ESP reciever
{
sendMessageToMaster(joystickNormalizedToInt32);
}
//{
sendMessageToMaster(joystickNormalizedToInt32);




//}

//rudder sync
if(dap_calculationVariables_st.Rudder_status)
Expand Down Expand Up @@ -1888,7 +1900,7 @@ void ESPNOW_SyncTask( void * pvParameters )


#endif
delay(1);
delay(2);
}
}
#endif
Expand Down

0 comments on commit 7d8e5a1

Please sign in to comment.