Skip to content

Commit 595759b

Browse files
committed
Show how to take CPU/overclock setting into account
1 parent 06b9013 commit 595759b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/Wasm_PyBadge_Dino/Wasm_PyBadge_Dino.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ void display_info()
123123
arcada.display->setTextColor(ARCADA_BLACK);
124124
arcada.display->setTextWrap(true);
125125
arcada.display->setCursor(0, 5);
126-
arcada.display->println(" Wasm3 v" M3_VERSION " (" M3_ARCH ")");
127-
arcada.display->println();
126+
arcada.display->println(" Wasm3 v" M3_VERSION " (" M3_ARCH "@" + String(F_CPU/1000000) + "MHz)\n");
128127
arcada.display->println(" Dino game");
129128
arcada.display->println(" by Ben Smith (binji)");
130129
}
@@ -186,8 +185,10 @@ void setup()
186185

187186
//Serial.print("FPS: "); Serial.println(1000/(millis() - framestart));
188187

189-
// Limit to 40 fps
190-
while (millis() - framestart < (1000/40)) { delay(1); }
188+
// Limit to 40..70 fps, depending on CPU/overclock setting (120..200MHz)
189+
//const int target_fps = map(F_CPU/1000000, 120, 200, 40, 70);
190+
const int target_fps = 40;
191+
while (millis() - framestart < (1000/target_fps)) { delay(1); }
191192
}
192193

193194
if (result != m3Err_none) {

0 commit comments

Comments
 (0)