Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer Backpack Updates #137

Merged
merged 12 commits into from
Aug 3, 2024
28 changes: 26 additions & 2 deletions hardware/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,18 @@
"firmware": "TIMER_ESP12F_Backpack",
"upload_methods": ["uart", "wifi"],
"platform": "esp8285"
},
"esp32c3": {
"product_name": "Backpack for Race Timer with ESP32C3",
"firmware": "TIMER_ESP32C3_Backpack",
"upload_methods": ["uart", "wifi"],
"platform": "esp32-c3"
},
"esp32s3": {
"product_name": "Backpack for Race Timer with ESP32S3",
"firmware": "TIMER_ESP32S3_Backpack",
"upload_methods": ["uart", "wifi"],
"platform": "esp32-s3"
}
}
},
Expand All @@ -479,10 +491,22 @@
},
"NuclearHazard": {
"product_name": "NuclearHazard",
"firmware": "TIMER_ESP32_Backpack",
"firmware": "NuclearHazard_Backpack",
"upload_methods": ["wifi"],
"platform": "esp32"
},
"esp32c3": {
"product_name": "ESP32C3 Module (DIY)",
"firmware": "TIMER_ESP32C3_Backpack",
"upload_methods": ["uart", "wifi"],
"platform": "esp32-c3"
},
"esp32s3": {
"product_name": "ESP32S3 Module (DIY)",
"firmware": "TIMER_ESP32S3_Backpack",
"upload_methods": ["uart", "wifi"],
"platform": "esp32-s3"
}
}
}
}
}
2 changes: 1 addition & 1 deletion html/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function updateConfig(data) {
mui.tabs.activate('pane-justified-2');
_('tx_tab').style.display = 'none';
}
if(config['product_name']) _('product_name').textContent = config['product_name'];
if(config['product_name'] && _('product-name')) _('product_name').textContent = config['product_name'];

updateAatConfig(config);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/WIFI/devWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <WiFi.h>
#include <ESPmDNS.h>
#include <Update.h>
#include <esp_wifi.h>
#else
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
Expand Down Expand Up @@ -646,6 +647,9 @@ static void HandleWebUpdate()
WiFi.softAP(wifi_ap_ssid, wifi_ap_password);
WiFi.scanNetworks(true);
startServices();
#if defined(PLATFORM_ESP32)
esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
#endif
break;
case WIFI_STA:
DBGLN("Connecting to home network '%s' '%s'", station_ssid, station_password);
Expand Down
6 changes: 3 additions & 3 deletions python/binary_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def upload_esp32_uart(args):
args.port = serials_find.get_serial_port()
try:
dir = os.path.dirname(args.file.name)
start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000'
start_addr = '0x0000' if args.platform.startswith('esp32-') else '0x1000'
esptool.main(['--chip', args.platform.replace('-', ''), '--port', args.port, '--baud', str(args.baud), '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', start_addr, os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
except:
return ElrsUploadResult.ErrorGeneral
Expand All @@ -104,7 +104,7 @@ def upload_esp32_etx(args):
args.port = serials_find.get_serial_port()
try:
dir = os.path.dirname(args.file.name)
start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000'
start_addr = '0x0000' if args.platform.startswith('esp32-') else '0x1000'
esptool.main(['--passthrough', '--chip', args.platform.replace('-', ''), '--port', args.port, '--baud', '460800', '--before', 'etx', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', start_addr, os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
except:
return ElrsUploadResult.ErrorGeneral
Expand All @@ -115,7 +115,7 @@ def upload_esp32_passthru(args):
args.port = serials_find.get_serial_port()
try:
dir = os.path.dirname(args.file.name)
start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000'
start_addr = '0x0000' if args.platform.startswith('esp32-') else '0x1000'
esptool.main(['--passthrough', '--chip', args.platform.replace('-', ''), '--port', args.port, '--baud', '230400', '--before', 'passthru', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', start_addr, os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
except:
return ElrsUploadResult.ErrorGeneral
Expand Down
10 changes: 8 additions & 2 deletions src/Timer_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ void SetSoftMACAddress()
firmwareOptions.uid[0] = firmwareOptions.uid[0] & ~0x01;

WiFi.mode(WIFI_STA);
#if defined(PLATFORM_ESP8266)
WiFi.setOutputPower(20.5);
#elif defined(PLATFORM_ESP32)
WiFi.setTxPower(WIFI_POWER_19_5dBm);
#endif
WiFi.begin("network-name", "pass-to-network", 1);
WiFi.disconnect();

Expand All @@ -350,6 +355,7 @@ void SetSoftMACAddress()
wifi_set_macaddr(STATION_IF, firmwareOptions.uid);
#elif defined(PLATFORM_ESP32)
esp_wifi_set_mac(WIFI_IF_STA, firmwareOptions.uid);
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR);
#endif
}

Expand Down Expand Up @@ -436,12 +442,12 @@ void setup()
}

esp_now_register_recv_cb(OnDataRecv);

#if defined(PLATFORM_ESP32)
esp_now_register_send_cb(OnDataSent);
xSemaphoreGive(semaphore);
#endif

registerPeer(firmwareOptions.uid);

memcpy(sendAddress, firmwareOptions.uid, 6);
Expand Down
1 change: 1 addition & 0 deletions src/Tx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ void SetSoftMACAddress()
WiFi.setOutputPower(20.5);
#elif defined(PLATFORM_ESP32)
WiFi.setTxPower(WIFI_POWER_19_5dBm);
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR);
#endif
WiFi.begin("network-name", "pass-to-network", 1);
WiFi.disconnect();
Expand Down
3 changes: 2 additions & 1 deletion src/Vrx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ void SetSoftMACAddress()
WiFi.setOutputPower(20.5);
#elif defined(PLATFORM_ESP32)
WiFi.setTxPower(WIFI_POWER_19_5dBm);
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR);
#endif
WiFi.begin("network-name", "pass-to-network", 1);
WiFi.disconnect();
Expand Down Expand Up @@ -485,7 +486,7 @@ void loop()
turnOffLED();
ESP.restart();
}
#endif
#endif

if (connectionState == wifiUpdate)
{
Expand Down
22 changes: 18 additions & 4 deletions targets/common.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ build_flags =

# ------------------------- COMMON ESP32 DEFINITIONS -----------------
[env_common_esp32]
platform = espressif32@5.2.0
platform = espressif32@6.7.0
board = esp32dev
; board_build.partitions = min_spiffs.csv
board_build.partitions = min_spiffs.csv
upload_speed = 460800
monitor_speed = 460800
upload_resetmethod = nodemcu
board_build.f_cpu = 240000000L
build_flags =
-D PLATFORM_ESP32=1
lib_ignore = STM32UPDATE

# ------------------------- COMMON ESP32 DEFINITIONS -----------------
# ------------------------- COMMON ESP32C3 DEFINITIONS -----------------
[env_common_esp32c3]
platform = espressif32@6.4.0
platform = espressif32@6.7.0
board = esp32-c3-devkitm-1
board_build.partitions = min_spiffs.csv
upload_speed = 460800
Expand All @@ -60,6 +61,19 @@ build_flags =
-D PLATFORM_ESP32=1
lib_ignore = STM32UPDATE

# ------------------------- COMMON ESP32S3 DEFINITIONS -----------------
[env_common_esp32s3]
platform = [email protected]
board = esp32-s3-devkitc-1
board_build.partitions = min_spiffs.csv
upload_speed = 460800
monitor_speed = 460800
upload_resetmethod = nodemcu
board_build.f_cpu = 240000000L
build_flags =
-D PLATFORM_ESP32=1
lib_ignore = STM32UPDATE

# ------------------------- COMMON TX-BACKPACK DEFINITIONS -----------------
[tx_backpack_common]
build_flags =
Expand Down
18 changes: 17 additions & 1 deletion targets/debug.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

[env:DEBUG_ESP_RX_Backpack_via_UART]
extends = env_common_esp8285, steadyview_vrx_backpack_common
upload_resetmethod = nodemcu
build_flags =
${env_common_esp8285.build_flags}
${steadyview_vrx_backpack_common.build_flags}
-D DEBUG_LOG
-D DEBUG_ELRS_WIFI
-D PIN_LED=16
-D PIN_MOSI=12 ;Some pin (not a UART)
-D PIN_CLK=0 ;Boot pad
Expand All @@ -17,6 +17,21 @@ build_flags =
[env:DEBUG_ESP_RX_Backpack_via_WIFI]
extends = env:DEBUG_ESP_RX_Backpack_via_UART

[env:DEBUG_ESP32_RX_Backpack_via_UART]
extends = env_common_esp32, steadyview_vrx_backpack_common
upload_resetmethod = nodemcu
build_flags =
${env_common_esp32.build_flags}
${steadyview_vrx_backpack_common.build_flags}
-D DEBUG_LOG
-D PIN_LED=2
-D PIN_MOSI=18 ;Some pin (not a UART)
-D PIN_CLK=19 ;Boot pad
-D PIN_CS=5 ;Some other pin (not a UART)

[env:DEBUG_ESP32_RX_Backpack_via_WIFI]
extends = env:DEBUG_ESP32_RX_Backpack_via_UART

# ********************************
# Transmitter backpack targets
# ********************************
Expand All @@ -41,6 +56,7 @@ extends = env_common_esp32, tx_backpack_common
build_flags =
${env_common_esp32.build_flags}
${tx_backpack_common.build_flags}
-D DEBUG_LOG
-D PIN_BUTTON=0
-D PIN_LED=4
lib_ignore = STM32UPDATE
Expand Down
35 changes: 34 additions & 1 deletion targets/timer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,37 @@ build_flags =
-D PIN_LED=2

[env:TIMER_ESP12F_Backpack_via_WIFI]
extends = env:TIMER_ESP12F_Backpack_via_UART
extends = env:TIMER_ESP12F_Backpack_via_UART

[env:TIMER_ESP32C3_Backpack_via_UART]
extends = env_common_esp32c3, timer_backpack_common
build_flags =
${env_common_esp32c3.build_flags}
${timer_backpack_common.build_flags}
-D PIN_BUTTON=9
-D PIN_LED=8

[env:TIMER_ESP32C3_Backpack_via_WIFI]
extends = env:TIMER_ESP32C3_Backpack_via_UART

[env:TIMER_ESP32S3_Backpack_via_UART]
extends = env_common_esp32s3, timer_backpack_common
build_flags =
${env_common_esp32s3.build_flags}
${timer_backpack_common.build_flags}
-D PIN_BUTTON=0
-D PIN_LED=21

[env:TIMER_ESP32S3_Backpack_via_WIFI]
extends = env:TIMER_ESP32S3_Backpack_via_UART

[env:NuclearHazard_Backpack_via_UART]
extends = env_common_esp32, timer_backpack_common
build_flags =
${env_common_esp32.build_flags}
${timer_backpack_common.build_flags}
-D PIN_BUTTON=0
-D PIN_LED=15

[env:NuclearHazard_Backpack_via_WIFI]
extends = env:NuclearHazard_Backpack_via_UART