Optimise M0/M1 code size
Replace two bool variables with one. It's not obvious but (!hasP && !hasS) is equal to !(hasP || hasS) Note: expiration_time_set = hasP || hasS Truth table: |--------------------------------------------------| | hasP| hasS| (!hasP && !hasS)| !(hasP || hasS) | |------|-----|--------------------|-----------------| | 0 | 0 | 1 | 1 | | 0 | 1 | 0 | 0 | | 1 | 0 | 0 | 0 | | 1 | 1 | 0 | 0 | |--------------------------------------------------| Change in memory: Flash: -36 bytes SRAM: 0 bytes
This commit is contained in:
parent
91b913e997
commit
4ce3fa53a1
|
|
@ -5221,18 +5221,13 @@ void process_commands()
|
|||
case 1: {
|
||||
const char *src = strchr_pointer + 2;
|
||||
codenum = 0;
|
||||
bool hasP = false, hasS = false;
|
||||
if (code_seen('P')) {
|
||||
codenum = code_value_long(); // milliseconds to wait
|
||||
hasP = codenum > 0;
|
||||
}
|
||||
if (code_seen('S')) {
|
||||
codenum = code_value_long() * 1000; // seconds to wait
|
||||
hasS = codenum > 0;
|
||||
}
|
||||
if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait
|
||||
if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait
|
||||
bool expiration_time_set = bool(codenum);
|
||||
|
||||
while (*src == ' ') ++src;
|
||||
custom_message_type = CustomMsg::M0Wait;
|
||||
if (!hasP && !hasS && *src != '\0') {
|
||||
if (!expiration_time_set && *src != '\0') {
|
||||
lcd_setstatus(src);
|
||||
} else {
|
||||
// farmers want to abuse a bug from the previous firmware releases
|
||||
|
|
@ -5247,7 +5242,7 @@ void process_commands()
|
|||
st_synchronize();
|
||||
menu_set_block(MENU_BLOCK_STATUS_SCREEN_M0);
|
||||
previous_millis_cmd.start();
|
||||
if (codenum > 0 ) {
|
||||
if (expiration_time_set) {
|
||||
codenum += _millis(); // keep track of when we started waiting
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
while(_millis() < codenum && !lcd_clicked()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue