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:
parent
ca149a23c7
commit
df01d19d29
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user