From 7d6c2c8afbb79c8950b42d56561522788d8b2299 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Sat, 18 Jun 2022 13:58:46 +0100 Subject: [PATCH] smaller random Saves over 300 bytes of progmem on a uno by omitting the random library --- EXRAIL2.cpp | 4 ++-- objdump.bat | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index fa8d575..30b1b6d 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -706,7 +706,7 @@ void RMFT2::loop2() { break; case OPCODE_IFRANDOM: // do block on random percentage - skipIf=(int16_t)random(100)>=operand; + skipIf=(int16_t)(micros()%100) >= operand; break; case OPCODE_IFRESERVE: // do block if we successfully RERSERVE @@ -750,7 +750,7 @@ void RMFT2::loop2() { break; case OPCODE_RANDWAIT: - delayMe(random(operand)*100L); + delayMe((micros()%operand) *100L); break; case OPCODE_RED: diff --git a/objdump.bat b/objdump.bat index 94e19e8..26e3233 100644 --- a/objdump.bat +++ b/objdump.bat @@ -2,7 +2,7 @@ ECHO ON FOR /F "delims=" %%i IN ('dir %TMP%\arduino_build_* /b /ad-h /t:c /od') DO SET a=%%i echo Most recent subfolder: %a% >%TMP%\OBJDUMP_%a%.txt SET ELF=%TMP%\%a%\CommandStation-EX.ino.elf - +set PATH="C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\";%PATH% avr-objdump --private=mem-usage %ELF% >>%TMP%\OBJDUMP_%a%.txt ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt avr-objdump -x -C %ELF% | find ".text" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt