1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +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) {
if(dBm > 20.5f) {
dBm = 20.5f;
} else if(dBm < 0.0f) {
dBm = 0.0f;
int i_dBm = int(dBm * 4.0f);
// i_dBm 82 == 20.5 dBm
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(val);
system_phy_set_max_tpw((uint8_t) i_dBm);
}
/**
* store WiFi config in SDK flash area
* @param persistent