Skip to content

Commit

Permalink
Bugfix: No joystick output
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrGri committed Dec 25, 2023
1 parent 4d9a40f commit 3c3f2a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 53 deletions.
86 changes: 33 additions & 53 deletions Arduino/Esp32/Main/Main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ bool isv57LifeSignal_b = false;
int32_t servo_offset_compensation_steps_i32 = 0;
#endif

#ifdef Using_analog_output
int32_t Using_analog_output_ = 1;
#else
int32_t Using_analog_output_ = 0;
#endif




Expand Down Expand Up @@ -213,15 +209,9 @@ void setup()
Serial.println(" ");

// init controller
if(Using_analog_output_ !=1)
{
SetupController();
delay(2000);
}
else
{
delay(10000);
}
SetupController();
delay(2000);



// check whether iSV57 communication can be established
Expand Down Expand Up @@ -678,19 +668,6 @@ void pedalUpdateTask( void * pvParameters )
joystickNormalizedToInt32 = NormalizeControllerOutputValue(loadcellReading, dap_calculationVariables_st.Force_Min, dap_calculationVariables_st.Force_Max, dap_config_st.payLoadPedalConfig_.maxGameOutput);
//joystickNormalizedToInt32 = NormalizeControllerOutputValue(filteredReading, dap_calculationVariables_st.Force_Min, dap_calculationVariables_st.Force_Max, dap_config_st.payLoadPedalConfig_.maxGameOutput);
xSemaphoreGive(semaphore_updateJoystick);
if(Using_analog_output_ =1)
{
int dac_value=(int)(joystickNormalizedToInt32*255/10000);
dacWrite(D_O,dac_value);
}
if(dap_config_st.payLoadPedalConfig_.Simulate_ABS_trigger==1)
{
int32_t ABS_trigger_value=dap_config_st.payLoadPedalConfig_.Simulate_ABS_value*100;
if(joystickNormalizedToInt32 > ABS_trigger_value)
{
absOscillation.trigger();
}
}
}
}
else
Expand All @@ -699,6 +676,25 @@ void pedalUpdateTask( void * pvParameters )
//Serial.println("semaphore_updateJoystick == 0");
}

// provide joystick output on PIN
#ifdef Using_analog_output
int dac_value=(int)(joystickNormalizedToInt32*255/10000);
dacWrite(D_O,dac_value);
#endif


// simulate ABS trigger
if(dap_config_st.payLoadPedalConfig_.Simulate_ABS_trigger==1)
{
int32_t ABS_trigger_value=dap_config_st.payLoadPedalConfig_.Simulate_ABS_value*100;
if(joystickNormalizedToInt32 > ABS_trigger_value)
{
absOscillation.trigger();
}
}



#ifdef PRINT_USED_STACK_SIZE
unsigned int temp2 = uxTaskGetStackHighWaterMark(nullptr);
Serial.print("PU task stack size="); Serial.println(temp2);
Expand Down Expand Up @@ -888,41 +884,25 @@ void serialCommunicationTask( void * pvParameters )
}
}



// transmit controller output
if(Using_analog_output_ =1)
if (IsControllerReady())
{
if(semaphore_updateJoystick!=NULL)
{
if(xSemaphoreTake(semaphore_updateJoystick, (TickType_t)1)==pdTRUE)
{
joystickNormalizedToInt32_local = joystickNormalizedToInt32;
xSemaphoreGive(semaphore_updateJoystick);
}
//else
//{
//Serial.println("semaphore_updateJoystick == 0");
//}
}
}
else
{
if (IsControllerReady()) {
if(semaphore_updateJoystick!=NULL)
if(xSemaphoreTake(semaphore_updateJoystick, (TickType_t)1)==pdTRUE)
{
if(xSemaphoreTake(semaphore_updateJoystick, (TickType_t)1)==pdTRUE)
{
joystickNormalizedToInt32_local = joystickNormalizedToInt32;
xSemaphoreGive(semaphore_updateJoystick);
}
//else
//{
//Serial.println("semaphore_updateJoystick == 0");
//}
joystickNormalizedToInt32_local = joystickNormalizedToInt32;
xSemaphoreGive(semaphore_updateJoystick);
}
SetControllerOutputValue(joystickNormalizedToInt32_local);
}
SetControllerOutputValue(joystickNormalizedToInt32_local);
}




}
}

Expand Down
Binary file modified SimHubPlugin/.vs/User.PluginSdkDemo/v17/.suo
Binary file not shown.

0 comments on commit 3c3f2a2

Please sign in to comment.