Fix T-Beam 1W fan races and remove PWM controls

This commit is contained in:
agessaman
2026-09-04 16:51:53 -07:00
parent 8fd6893117
commit 6c1f4c09a6
3 changed files with 102 additions and 156 deletions
+10 -15
View File
@@ -32,39 +32,34 @@
class TBeam1WBoard : public ESP32Board {
public:
enum FanMode { FAN_ON, FAN_OFF, FAN_AUTO };
enum FanDrive { FAN_DRIVE_PWM, FAN_DRIVE_ONOFF };
private:
bool radio_powered = false;
bool _stopped = false;
bool _pwm_attached = false;
KeyValueStore* _prefs = nullptr;
FanMode _mode = FAN_AUTO;
FanDrive _drive = FAN_DRIVE_ONOFF;
int _lo_c = FAN_DEFAULT_LO_C;
int _hi_c = FAN_DEFAULT_HI_C;
int _manual_duty = -1; // -1 = follow mode; 0..100 = CLI override
bool _thermal_on = false; // onoff hysteresis; TX boost must not latch this
volatile float _temp_c = NAN;
volatile int _duty_pct = 100;
volatile bool _tx_active = false;
volatile bool _tx_cooldown_active = false;
volatile uint32_t _tx_until_ms = 0;
bool _fan_on = true;
float _temp_c = NAN;
bool _tx_active = false;
bool _tx_cooldown_active = false;
uint32_t _tx_until_ms = 0;
TaskHandle_t _fan_task = nullptr;
mutable portMUX_TYPE _fan_mux = portMUX_INITIALIZER_UNLOCKED;
void startFanTask();
void updateFan();
void applyDuty(int pct);
void setFanOutputLocked(bool enabled);
float readNtcTempC();
int rampDuty(float temp_c) const;
int cooldownSecs();
bool isTxCooling(uint32_t now);
int cooldownSecsLocked();
bool isTxCoolingLocked(uint32_t now);
bool ntcImplausible(float temp_c) const;
bool persistKey(const char* key, const char* value);
static bool parseIntArg(const char* text, int& value);
void loadFanPrefs();
const char* modeName() const;
const char* driveName() const;
const char* modeNameLocked() const;
static void fanTaskThunk(void* arg);
public: