diff --git a/.github/workflows/PreRelease_task.yml b/.github/workflows/PreRelease_task.yml index d22cde7f..c3e5c12a 100644 --- a/.github/workflows/PreRelease_task.yml +++ b/.github/workflows/PreRelease_task.yml @@ -7,7 +7,7 @@ on: push: branches: [ develop ] #pull_request: - # branches: [ main ] + # branches: [ main ] # This is the list of jobs that will be run concurrently. # Since we use a build matrix, the actual number of jobs @@ -40,6 +40,7 @@ jobs: tag_name: ${{ steps.output_version_date.outputs.Version_date }} release_name: ${{ steps.output_version_date.outputs.Version_date }} prerelease: true + BuildFirmware: #runs-on: ubuntu-latest @@ -70,6 +71,7 @@ jobs: pio run --environment esp32 pio run --environment esp32s3usbotg pio run --environment esp32-speedcrafter + pio run --environment esp32s3usbotg-gilphilbert @@ -90,7 +92,9 @@ jobs: copy ${{ github.workspace }}/ESP32/.pio/build/esp32-speedcrafter/firmware.bin ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4 copy ${{ github.workspace }}/ESP32/.pio/build/esp32-speedcrafter/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4 copy ${{ github.workspace }}/ESP32/.pio/build/esp32-speedcrafter/partitions.bin ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4 - + copy ${{ github.workspace }}/ESP32/.pio/build/esp32s3usbotg-gilphilbert/firmware.bin ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert + copy ${{ github.workspace }}/ESP32/.pio/build/esp32s3usbotg-gilphilbert/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert + copy ${{ github.workspace }}/ESP32/.pio/build/esp32s3usbotg-gilphilbert/partitions.bin ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert @@ -113,6 +117,7 @@ jobs: 7z a ${{ github.workspace }}/Helper/zip/esp32.zip ${{ github.workspace }}/Helper/bins/esp32/ 7z a ${{ github.workspace }}/Helper/zip/esp32s3.zip ${{ github.workspace }}/Helper/bins/esp32s3/ 7z a ${{ github.workspace }}/Helper/zip/esp32_speedcrafter.zip ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4/ + 7z a ${{ github.workspace }}/Helper/zip/esp32s3-gilphilbert.zip ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert/ # 7z a ./Helper/zip/esp32.zip @./Helper/zip/filelist_esp32.txt # 7z a ./Helper/zip/esp32s3.zip @Helper/zip/filelist_esp32s3.txt # 7z a./Helper/zip/esp32_speedcrafter.zip @Helper/zip/filelist_esp32_speedcrafter.txt @@ -125,23 +130,28 @@ jobs: ./Helper/zip/esp32.zip ./Helper/zip/esp32s3.zip ./Helper/zip/esp32_speedcrafter.zip + ./Helper/zip/esp32s3-gilphilbert.zip # Build ESP code for esp32_master - name: Build PlatformIO Project ESP32 working-directory: ./ESP32_master run: | pio system info - pio run --environment esp32s3usbotg + pio run --environment esp32s3usbotg + pio run --environment esp32 # copy files to dir - name: Copy files to packing dir run: | copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32s3usbotg/firmware.bin ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32s3usbotg/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32s3usbotg/partitions.bin ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver + copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32/firmware.bin ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15 + copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15 + copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32/partitions.bin ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15 # zip plugin binaries - name: ZIP files run: | 7z a ${{ github.workspace }}/Helper/zip/esp32s3_joystickreceiver.zip ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver/ - + 7z a ${{ github.workspace }}/Helper/zip/esp32_analogout_SC_D15.zip ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15/ # Build ESP code for esp32_bridge - name: Build PlatformIO Project ESP_bridge working-directory: ./ESP_bridge @@ -197,6 +207,17 @@ jobs: asset_path: ./Helper/zip/esp32_speedcrafter.zip asset_name: esp32_speedcrafter.zip asset_content_type: application/zip + - name: Upload ESP release assets gilphilbert + id: upload-release-asset-esp32s3-gilphilbert + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + url: ${{needs.Build-date.outputs.Upload_URL}} + with: + upload_url: ${{ env.url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./Helper/zip/esp32s3-gilphilbert.zip + asset_name: esp32s3-gilphilbert.zip + asset_content_type: application/zip - name: Upload ESP release assets esp32s3 espmaster id: upload-release-asset-ESP32S3-ESPmaster @@ -210,6 +231,19 @@ jobs: asset_name: esp32s3_joystickreceiver.zip asset_content_type: application/zip + - name: Upload ESP release assets esp32s3 espmaster + id: upload-release-asset-esp32_analogout_SC_D15 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + url: ${{needs.Build-date.outputs.Upload_URL}} + with: + upload_url: ${{ env.url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./Helper/zip/esp32_analogout_SC_D15.zip + asset_name: esp32_analogout_SC_D15.zip + asset_content_type: application/zip + + - name: Upload ESP release assets esp32s3 espmaster id: upload-release-asset-esp32_bridge uses: actions/upload-release-asset@v1 @@ -268,6 +302,8 @@ jobs: #- name: List files in dir 2 # run: | # ls ${{ github.workspace }} + #- name: Edit version + #run: sed -i "s/\(AssemblyVersion(""\([0-9]\+\.\)\{3\}\)\([0-9]\+\)/\1${{github.run_number}}/" "SimHubPlugin/Properties/AssemblyInfo.cs" - name: Restore Packages run: nuget restore "SimHubPlugin/User.PluginSdkDemo.sln" @@ -333,7 +369,7 @@ jobs: # allowUpdates: true # name: ${{ env.DATE }} # tag: ${{ env.DATE }} - - name: Upload ESP release assets speedcrafter PCB V1p4 + - name: Upload Simhub plugin id: upload-release-asset-simhub_plugin uses: actions/upload-release-asset@v1 env: diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index b942b90c..219b8536 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -70,6 +70,7 @@ jobs: pio run --environment esp32 pio run --environment esp32s3usbotg pio run --environment esp32-speedcrafter + pio run --environment esp32s3usbotg-gilphilbert @@ -90,7 +91,9 @@ jobs: copy ${{ github.workspace }}/ESP32/.pio/build/esp32-speedcrafter/firmware.bin ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4 copy ${{ github.workspace }}/ESP32/.pio/build/esp32-speedcrafter/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4 copy ${{ github.workspace }}/ESP32/.pio/build/esp32-speedcrafter/partitions.bin ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4 - + copy ${{ github.workspace }}/ESP32/.pio/build/esp32s3usbotg-gilphilbert/firmware.bin ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert + copy ${{ github.workspace }}/ESP32/.pio/build/esp32s3usbotg-gilphilbert/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert + copy ${{ github.workspace }}/ESP32/.pio/build/esp32s3usbotg-gilphilbert/partitions.bin ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert @@ -113,6 +116,7 @@ jobs: 7z a ${{ github.workspace }}/Helper/zip/esp32.zip ${{ github.workspace }}/Helper/bins/esp32/ 7z a ${{ github.workspace }}/Helper/zip/esp32s3.zip ${{ github.workspace }}/Helper/bins/esp32s3/ 7z a ${{ github.workspace }}/Helper/zip/esp32_speedcrafter.zip ${{ github.workspace }}/Helper/bins/esp32_speedcrafter_PCB_V1p4/ + 7z a ${{ github.workspace }}/Helper/zip/esp32s3-gilphilbert.zip ${{ github.workspace }}/Helper/bins/esp32s3_esp32s3usbotg-gilphilbert/ # 7z a ./Helper/zip/esp32.zip @./Helper/zip/filelist_esp32.txt # 7z a ./Helper/zip/esp32s3.zip @Helper/zip/filelist_esp32s3.txt # 7z a./Helper/zip/esp32_speedcrafter.zip @Helper/zip/filelist_esp32_speedcrafter.txt @@ -125,22 +129,29 @@ jobs: ./Helper/zip/esp32.zip ./Helper/zip/esp32s3.zip ./Helper/zip/esp32_speedcrafter.zip + ./Helper/zip/esp32s3-gilphilbert.zip # Build ESP code for esp32_master - name: Build PlatformIO Project ESP32 working-directory: ./ESP32_master run: | pio system info - pio run --environment esp32s3usbotg + pio run --environment esp32s3usbotg + pio run --environment esp32 # copy files to dir - name: Copy files to packing dir run: | copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32s3usbotg/firmware.bin ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32s3usbotg/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32s3usbotg/partitions.bin ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver + copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32/firmware.bin ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15 + copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32/bootloader.bin ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15 + copy ${{ github.workspace }}/ESP32_master/.pio/build/esp32/partitions.bin ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15 + # zip plugin binaries - name: ZIP files run: | 7z a ${{ github.workspace }}/Helper/zip/esp32s3_joystickreceiver.zip ${{ github.workspace }}/Helper/bins/esp32s3_joystickreceiver/ + 7z a ${{ github.workspace }}/Helper/zip/esp32_analogout_SC_D15.zip ${{ github.workspace }}/Helper/bins/esp32_analogout_SC_D15/ # Build ESP code for esp32_bridge - name: Build PlatformIO Project ESP_bridge @@ -197,6 +208,17 @@ jobs: asset_path: ./Helper/zip/esp32_speedcrafter.zip asset_name: esp32_speedcrafter.zip asset_content_type: application/zip + - name: Upload ESP release assets gilphilbert + id: upload-release-asset-esp32s3-gilphilbert + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + url: ${{needs.Build-date.outputs.Upload_URL}} + with: + upload_url: ${{ env.url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./Helper/zip/esp32s3-gilphilbert.zip + asset_name: esp32s3-gilphilbert.zip + asset_content_type: application/zip - name: Upload ESP release assets esp32s3 espmaster id: upload-release-asset-ESP32S3-ESPmaster @@ -210,6 +232,18 @@ jobs: asset_name: esp32s3_joystickreceiver.zip asset_content_type: application/zip + - name: Upload ESP release assets esp32_analogout_SC_D15 + id: upload-release-asset-esp32_analogout_SC_D15 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + url: ${{needs.Build-date.outputs.Upload_URL}} + with: + upload_url: ${{ env.url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./Helper/zip/esp32_analogout_SC_D15.zip + asset_name: esp32_analogout_SC_D15.zip + asset_content_type: application/zip + - name: Upload ESP release assets esp32s3 espmaster id: upload-release-asset-esp32_bridge uses: actions/upload-release-asset@v1 @@ -335,7 +369,7 @@ jobs: # allowUpdates: true # name: ${{ env.DATE }} # tag: ${{ env.DATE }} - - name: Upload ESP release assets speedcrafter PCB V1p4 + - name: Upload Simhub plugin id: upload-release-asset-simhub_plugin uses: actions/upload-release-asset@v1 env: diff --git a/ESP32_master/include/Main.h b/ESP32_master/include/Main.h index 2344f74e..1625e686 100644 --- a/ESP32_master/include/Main.h +++ b/ESP32_master/include/Main.h @@ -61,61 +61,6 @@ -/********************************************************************/ -/* PIN defines */ -/********************************************************************/ -// initial version of dev PCB for regular ESP32 -#if PCB_VERSION == 1 - // ADC defines - #define PIN_DRDY 17// 17 --> DRDY - #define PIN_RST 16 // X --> X - #define PIN_SCK 18 // 18 -->SCLK - #define PIN_MISO 19 // 19 --> DOUT - #define PIN_MOSI 23 // 23 --> DIN - #define PIN_CS 5 // 5 --> CS - - // stepper pins - #define dirPinStepper 0 - #define stepPinStepper 4 - - // endstop pins - #define minPin 34 - #define maxPin 35 - - // level shifter not present on this PCB design - #define SENSORLESS_HOMING false - - #define BLUETOOTH_GAMEPAD - //#define USB_JOYSTICK - #define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 1 -#endif - - -// initial version of dev PCB for ESP32 S2 mini -#if PCB_VERSION == 2 - // ADC defines - #define PIN_DRDY 37// 37 --> DRDY - #define PIN_RST 16 // X --> X - #define PIN_SCK 18 // 18 -->SCLK - #define PIN_MISO 35 // 35 --> DOUT - #define PIN_MOSI 33 // 33 --> DIN - #define PIN_CS 39 // 39 --> CS - - // stepper pins - #define dirPinStepper 8 - #define stepPinStepper 9 - - // endstop pins - #define minPin 11 - #define maxPin 10 - - // level shifter not present on this PCB design - #define SENSORLESS_HOMING false - - //#define BLUETOOTH_GAMEPAD - #define USB_JOYSTICK - #define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 1 -#endif @@ -147,76 +92,24 @@ #define ISV57_TXPIN 27 //17 #define ISV57_RXPIN 26 // 16 +//MCP4728 IIC + #define MCP_SDA 21 + #define MCP_SCL 22 + #define Using_analog_output + #define Using_ESP32 //#define Using_I2C_Sync #define ESPNOW_Enable #define I2C_slave_address 0x15 - #define BLUETOOTH_GAMEPAD - //#define USB_JOYSTICK - #define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 1 -#endif - - - -// speedcrafter PCB V1.3 -#if PCB_VERSION == 4 - // ADC defines - #define PIN_DRDY 27// 19 --> DRDY - #define PIN_RST 5 // X --> X - #define PIN_SCK 14 // 16 -->SCLK - #define PIN_MISO 12 // 18 --> DOUT - #define PIN_MOSI 13 // 17 --> DIN - #define PIN_CS 15 // 21 --> CS - - // stepper pins - #define dirPinStepper 32 - #define stepPinStepper 33 - - // endstop pins - #define minPin 35 - #define maxPin 34 - - // level shifter is present on this PCB design - #define SENSORLESS_HOMING true - #define ISV57_TXPIN 27 //17 - #define ISV57_RXPIN 26 // 16 - - #define BLUETOOTH_GAMEPAD + //#define BLUETOOTH_GAMEPAD + #define Using_MCP4728 //#define USB_JOYSTICK - #define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 1 #endif -// Speedcrafters PCB V1.4 -#if PCB_VERSION == 5 - // ADC defines - #define PIN_DRDY 19// 19 --> DRDY - #define PIN_RST 34 // X --> X - #define PIN_SCK 15 // 16 -->SCLK - #define PIN_MISO 18 // 18 --> DOUT - #define PIN_MOSI 13 // 17 --> DIN - #define PIN_CS 21 // 21 --> CS - - // stepper pins - #define dirPinStepper 22 - #define stepPinStepper 23 - - // endstop pins - #define minPin 35 - #define maxPin 34 - - // level shifter is present on this PCB design - #define SENSORLESS_HOMING true - #define ISV57_TXPIN 26 //17 - #define ISV57_RXPIN 27 // 16 - - #define BLUETOOTH_GAMEPAD - //#define USB_JOYSTICK - #define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 1 -#endif @@ -254,10 +147,10 @@ #define ISV57_RXPIN 9//26 // 16 #define Using_analog_output_ESP32_S3 - + #define Using_ESP32S3 //#define BLUETOOTH_GAMEPAD #define USB_JOYSTICK - + #define ACTIVATE_JOYSTICK_OUTPUT #define SERIAL_COOMUNICATION_TASK_DELAY_IN_MS 5 #endif diff --git a/ESP32_master/platformio.ini b/ESP32_master/platformio.ini index 33798668..07880995 100644 --- a/ESP32_master/platformio.ini +++ b/ESP32_master/platformio.ini @@ -19,10 +19,6 @@ platform_packages = platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1 monitor_speed = 921600 -[common] -lib_deps_external = - schnoog/Joystick_ESP32S2 @ ^0.9.4 - [env:esp32s3usbotg] board = esp32-s3-devkitc-1 board_build.f_cpu = 240000000L @@ -42,10 +38,11 @@ board_upload.use_1200bps_touch = yes board_upload.wait_for_upload_port = yes board_upload.require_upload_port = yes lib_deps = - ${common.lib_deps_external} + regenbogencode/ESPNowW@^1.0.2 adafruit/Adafruit MCP4728@^1.0.9 adafruit/Adafruit BusIO@^1.16.1 + schnoog/Joystick_ESP32S2 @ ^0.9.4 [env:esp32s2mini] board = lolin_s2_mini @@ -54,7 +51,19 @@ board_build.f_cpu = 240000000L build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 lib_deps = - ${common.lib_deps_external} + regenbogencode/ESPNowW@^1.0.2 adafruit/Adafruit MCP4728@^1.0.9 - adafruit/Adafruit BusIO@^1.16.1 \ No newline at end of file + adafruit/Adafruit BusIO@^1.16.1 + +[env:esp32] +board = esp32dev +lib_deps = + + regenbogencode/ESPNowW@^1.0.2 + adafruit/Adafruit MCP4728@^1.0.9 + adafruit/Adafruit BusIO@^1.16.1 +build_unflags = + -D PCB_VERSION=6 +build_flags = + -D PCB_VERSION=3 \ No newline at end of file diff --git a/ESP32_master/src/Controller.cpp b/ESP32_master/src/Controller.cpp index b4b18344..e4cba496 100644 --- a/ESP32_master/src/Controller.cpp +++ b/ESP32_master/src/Controller.cpp @@ -4,7 +4,7 @@ -#define USB_JOYSTICK +//#define USB_JOYSTICK #ifdef USB_JOYSTICK #include diff --git a/ESP32_master/src/Main.cpp b/ESP32_master/src/Main.cpp index 8546d250..ca1ec368 100644 --- a/ESP32_master/src/Main.cpp +++ b/ESP32_master/src/Main.cpp @@ -43,10 +43,10 @@ /* controller definitions */ /* */ /**********************************************************************************************/ -#define ACTIVATE_JOYSTICK_OUTPUT -#ifdef ACTIVATE_JOYSTICK_OUTPUT + + #include "Controller.h" -#endif + /**********************************************************************************************/ /* */ @@ -54,12 +54,12 @@ /* */ /**********************************************************************************************/ //#include -#define Using_MCP4728 #include #include #include #include "Wire.h" #include "SPI.h" +//#define ESPNow_debug #ifdef Using_MCP4728 #include Adafruit_MCP4728 mcp; @@ -80,6 +80,7 @@ uint16_t pedal_throttle_rudder_value=0; uint8_t pedal_status=0; bool joystick_update=false; uint16_t Joystick_value[]={0,0,0}; + typedef struct struct_message { uint64_t cycleCnt_u64; int64_t timeSinceBoot_i64; @@ -98,7 +99,7 @@ void OnDataRecv(const uint8_t *mac_addr, const uint8_t *incomingData, int len) { { memcpy(&myData, incomingData, sizeof(myData)); pedal_status=myData.pedal_status; - #ifdef ACTIVATE_JOYSTICK_OUTPUT + //#ifdef ACTIVATE_JOYSTICK_OUTPUT // normalize controller output int32_t joystickNormalizedToInt32 = NormalizeControllerOutputValue(myData.controllerValue_i32, 0, 10000, 100); if(mac_addr[5]==Clu_mac[5]) @@ -119,7 +120,7 @@ void OnDataRecv(const uint8_t *mac_addr, const uint8_t *incomingData, int len) { Joystick_value[2]=myData.controllerValue_i32; //joystick_update=true; } - #else + #ifdef ESPNow_debug Serial.print("Bytes received: "); Serial.println(len); Serial.print("CycleCnt: "); @@ -173,7 +174,13 @@ void setup() delay(300); ESPNow.init(); Serial.println("wait 10s for ESPNOW initialized"); +#ifdef Using_ESP32S3 + esp_wifi_config_espnow_rate(WIFI_IF_STA, WIFI_PHY_RATE_54M); +#endif + +#ifdef Using_ESP32 esp_wifi_config_espnow_rate(WIFI_IF_STA, WIFI_PHY_RATE_MCS0_LGI); +#endif delay(3000); ESPNow.add_peer(Clu_mac); ESPNow.add_peer(Brk_mac); @@ -186,7 +193,7 @@ void setup() ESPNow.reg_recv_cb(OnDataRecv); Serial.println("ESPNow Comunication Starting"); #ifdef Using_MCP4728 - MCP4728_I2C.begin(MCP_SDA,MCP_SCL,400000); + MCP4728_I2C.begin(MCP_SDA,MCP_SCL,100000); uint8_t i2c_address[8]={0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67}; int index_address=0; int found_address=0; @@ -194,11 +201,13 @@ void setup() for(index_address=0;index_address<8;index_address++) { MCP4728_I2C.beginTransmission(i2c_address[index_address]); + //MCP4728_I2C.beginTransmission(index_address); error = MCP4728_I2C.endTransmission(); if (error == 0) { Serial.print("I2C device found at address"); Serial.print(i2c_address[index_address]); + //Serial.print(index_address); Serial.println(" !"); found_address=index_address; break; @@ -208,6 +217,7 @@ void setup() { Serial.print("try address"); Serial.println(i2c_address[index_address]); + //Serial.println(index_address); } } @@ -215,6 +225,8 @@ void setup() { Serial.println("Couldn't find MCP4728, will not have analog output"); MCP_status=false; + delay(10000); + ESP.restart(); } else { @@ -248,7 +260,7 @@ void loop() { cycleCntr_u64++; //Serial.println(cycleCntr_u64); - +#ifdef USB_JOYSTICK if(IsControllerReady()) { if(pedal_status==0) @@ -292,12 +304,13 @@ void loop() { joystickSendState(); } +#endif #ifdef Using_MCP4728 -if(MCP_status) + if(MCP_status) { - mcp.setChannelValue(MCP4728_CHANNEL_A, (uint16_t)((float)Joystick_value[0]/(float)JOYSTICK_RANGE*4096)); - mcp.setChannelValue(MCP4728_CHANNEL_B, (uint16_t)((float)Joystick_value[1]/(float)JOYSTICK_RANGE*4096)); - mcp.setChannelValue(MCP4728_CHANNEL_C, (uint16_t)((float)Joystick_value[2]/(float)JOYSTICK_RANGE*4096)); + mcp.setChannelValue(MCP4728_CHANNEL_A, (uint16_t)((float)Joystick_value[0]/(float)JOYSTICK_RANGE*0.8f*4096)); + mcp.setChannelValue(MCP4728_CHANNEL_B, (uint16_t)((float)Joystick_value[1]/(float)JOYSTICK_RANGE*0.8f*4096)); + mcp.setChannelValue(MCP4728_CHANNEL_C, (uint16_t)((float)Joystick_value[2]/(float)JOYSTICK_RANGE*0.8f*4096)); } #endif diff --git a/ESP_bridge/.vscode/settings.json b/ESP_bridge/.vscode/settings.json deleted file mode 100644 index 45203bcc..00000000 --- a/ESP_bridge/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "string": "cpp", - "string_view": "cpp" - } -} \ No newline at end of file