1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

Reduce codesize of setOutputPower (#7572)

The logic can be simplified by using integer logic without a functional
change. Reduces code size by 40% (78 bytes -> 46 bytes) and silences
a Warith-conversion warning.
This commit is contained in:
Dirk Mueller 2020-09-02 17:47:48 +02:00 committed by GitHub
parent ca149a23c7
commit df01d19d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -369,17 +369,18 @@ WiFiPhyMode_t ESP8266WiFiGenericClass::getPhyMode() {
*/ */
void ESP8266WiFiGenericClass::setOutputPower(float dBm) { void ESP8266WiFiGenericClass::setOutputPower(float dBm) {
if(dBm > 20.5f) { int i_dBm = int(dBm * 4.0f);
dBm = 20.5f;
} else if(dBm < 0.0f) { // i_dBm 82 == 20.5 dBm
dBm = 0.0f; if(i_dBm > 82) {
i_dBm = 82;
} else if(i_dBm < 0) {
i_dBm = 0;
} }
uint8_t val = (dBm*4.0f); system_phy_set_max_tpw((uint8_t) i_dBm);
system_phy_set_max_tpw(val);
} }
/** /**
* store WiFi config in SDK flash area * store WiFi config in SDK flash area
* @param persistent * @param persistent