-
-
Notifications
You must be signed in to change notification settings - Fork 814
Fix: Lillygo Tbeam 1W Fan Control and LNA Sequencing improvements #2418
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
Open
Robowarrior834
wants to merge
4
commits into
meshcore-dev:dev
Choose a base branch
from
Robowarrior834:Tbeam1W-Fix
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,4 +229,7 @@ void loop() { | |
| ui_task.loop(); | ||
| #endif | ||
| rtc_clock.tick(); | ||
| #ifdef P_FAN_CTRL | ||
| update_fan_control(); | ||
| #endif | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,4 +113,7 @@ void loop() { | |
| ui_task.loop(); | ||
| #endif | ||
| rtc_clock.tick(); | ||
| #ifdef P_FAN_CTRL | ||
| update_fan_control(); | ||
| #endif | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,30 +3,49 @@ | |
| void TBeam1WBoard::begin() { | ||
| ESP32Board::begin(); | ||
|
|
||
| // Power on radio module (must be done before radio init) | ||
| // Power on radio module (must be done before radio init). | ||
| // Drive LOW first to ensure a clean SX1262 reset — on soft reboot the ESP32 | ||
| // GPIO glitch may be too brief to drain module capacitors, leaving the SX1262 | ||
| // in a stuck state. Holding LOW for 50ms guarantees a full power cycle. | ||
| pinMode(SX126X_POWER_EN, OUTPUT); | ||
| digitalWrite(SX126X_POWER_EN, LOW); | ||
| delay(50); | ||
| digitalWrite(SX126X_POWER_EN, HIGH); | ||
| radio_powered = true; | ||
| delay(10); // Allow radio to power up | ||
|
|
||
| // RF switch RXEN pin handled by RadioLib via setRfSwitchPins() | ||
| // Explicitly drive RXEN HIGH (LNA on) from boot, before RadioLib takes over. | ||
| // Without this the pin floats until the first startReceive() call. | ||
| pinMode(SX126X_RXEN, OUTPUT); | ||
| digitalWrite(SX126X_RXEN, HIGH); | ||
|
|
||
| // Initialize LED | ||
| pinMode(LED_PIN, OUTPUT); | ||
| digitalWrite(LED_PIN, LOW); | ||
|
|
||
| // Initialize fan control (on by default - 1W PA can overheat) | ||
| // Fan starts off; onAfterTransmit() enables it with a 30s cooldown timer | ||
| pinMode(FAN_CTRL_PIN, OUTPUT); | ||
| digitalWrite(FAN_CTRL_PIN, HIGH); | ||
| digitalWrite(FAN_CTRL_PIN, LOW); | ||
| } | ||
|
|
||
| void TBeam1WBoard::onBeforeTransmit() { | ||
| // RF switching handled by RadioLib via SX126X_DIO2_AS_RF_SWITCH and setRfSwitchPins() | ||
| digitalWrite(LED_PIN, HIGH); // TX LED on | ||
| digitalWrite(SX126X_RXEN, LOW); // disconnect LNA before PA ramps up | ||
| digitalWrite(LED_PIN, HIGH); | ||
| } | ||
|
|
||
| void TBeam1WBoard::onAfterTransmit() { | ||
| digitalWrite(LED_PIN, LOW); // TX LED off | ||
| digitalWrite(SX126X_RXEN, HIGH); // re-enable LNA immediately after TX | ||
| digitalWrite(LED_PIN, LOW); | ||
| // Keep fan running for 10s after TX | ||
| setFanEnabled(true); | ||
| _fan_off_millis = millis() + 10000; | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ie. here make this the board's loop() method |
||
| void TBeam1WBoard::updateFan() { | ||
| if (_fan_off_millis > 0 && (long)(millis() - _fan_off_millis) >= 0) { | ||
| setFanEnabled(false); | ||
| _fan_off_millis = 0; | ||
| } | ||
| } | ||
|
|
||
| uint16_t TBeam1WBoard::getBattMilliVolts() { | ||
|
|
@@ -68,4 +87,4 @@ void TBeam1WBoard::setFanEnabled(bool enabled) { | |
|
|
||
| bool TBeam1WBoard::isFanEnabled() const { | ||
| return digitalRead(FAN_CTRL_PIN) == HIGH; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is probably time to introduce a new virtual MainBoard::loop(), and a no-op as default.
And have the TBeam1WBoard class override, and put the updateFan() logic there