diff --git a/Arduino/Esp32/Main/Main.ino b/Arduino/Esp32/Main/Main.ino index 6986102b..a657a82b 100644 --- a/Arduino/Esp32/Main/Main.ino +++ b/Arduino/Esp32/Main/Main.ino @@ -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 + @@ -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 @@ -682,6 +672,24 @@ void pedalUpdateTask( void * pvParameters ) semaphore_updateJoystick = xSemaphoreCreateMutex(); //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); @@ -876,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); } + + + } } diff --git a/SimHubPlugin/.vs/User.PluginSdkDemo/v17/.suo b/SimHubPlugin/.vs/User.PluginSdkDemo/v17/.suo index 53f12317..ba4dcfae 100644 Binary files a/SimHubPlugin/.vs/User.PluginSdkDemo/v17/.suo and b/SimHubPlugin/.vs/User.PluginSdkDemo/v17/.suo differ