Optimize for performance and percision
This commit is contained in:
parent
e022c33a5c
commit
3eac4d03fa
@ -34,7 +34,7 @@
|
||||
// If game time is going faster than it should, increase this value by 1 to slow it down.
|
||||
|
||||
// fixed microsecond sleep between each cycle used to fine tune the emulator time drift even more
|
||||
#define FINE_TUNING_DELAY 22
|
||||
#define FINE_TUNING_DELAY 16
|
||||
// If game time is going faster than it should, increase this value
|
||||
/**************************************************************************/
|
||||
|
||||
@ -380,37 +380,45 @@ void setup() {
|
||||
uint32_t middle_long_press_started = 0;
|
||||
uint32_t right_long_press_started = 0;
|
||||
bool is_display_off = false;
|
||||
const uint32_t AUTO_SAVE_INTERVAL = AUTO_SAVE_MINUTES * 60 * 1000;
|
||||
|
||||
void loop() {
|
||||
tamalib_mainloop_step_by_step();
|
||||
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
#ifdef AUTO_SAVE_MINUTES
|
||||
if ((millis() - lastSaveTimestamp) > (AUTO_SAVE_MINUTES * 60 * 1000)) {
|
||||
lastSaveTimestamp = millis();
|
||||
if ((currentMillis - lastSaveTimestamp) > AUTO_SAVE_INTERVAL) {
|
||||
lastSaveTimestamp = currentMillis;
|
||||
saveStateToEEPROM(&cpuState);
|
||||
}
|
||||
#endif
|
||||
if (digitalRead(PIN_BTN_M) == HIGH && digitalRead(PIN_BTN_L) == HIGH) {
|
||||
if (millis() - middle_long_press_started > 2000) {
|
||||
|
||||
bool middleLeftPressed = (digitalRead(PIN_BTN_M) == HIGH) && (digitalRead(PIN_BTN_L) == HIGH);
|
||||
bool rightPressed = (digitalRead(PIN_BTN_R) == HIGH);
|
||||
|
||||
if (middleLeftPressed) {
|
||||
if ((currentMillis - middle_long_press_started) > 2000) {
|
||||
eraseStateFromEEPROM();
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
ESP.restart();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
middle_long_press_started = currentMillis;
|
||||
}
|
||||
else {
|
||||
middle_long_press_started = millis();
|
||||
}
|
||||
if (digitalRead(PIN_BTN_R) == HIGH) {
|
||||
if (millis() - right_long_press_started > 2000) {
|
||||
|
||||
if (rightPressed) {
|
||||
if ((currentMillis - right_long_press_started) > 2000) {
|
||||
if (!is_display_off) {
|
||||
display.sleepOn();
|
||||
is_display_off = true;
|
||||
}
|
||||
else if (is_display_off) {
|
||||
} else if (is_display_off) {
|
||||
display.sleepOff();
|
||||
is_display_off = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
right_long_press_started = millis();
|
||||
} else {
|
||||
right_long_press_started = currentMillis;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user