Optimizations
This commit is contained in:
parent
7b96ba2d19
commit
67a5277d2a
@ -19,24 +19,8 @@
|
|||||||
#define ENABLE_SAVE_STATUS
|
#define ENABLE_SAVE_STATUS
|
||||||
#define AUTO_SAVE_MINUTES 10 // Auto save for every 10 minutes
|
#define AUTO_SAVE_MINUTES 10 // Auto save for every 10 minutes
|
||||||
#define ENABLE_LOAD_STATE_FROM_EEPROM
|
#define ENABLE_LOAD_STATE_FROM_EEPROM
|
||||||
//#define ENABLE_DUMP_STATE_TO_SERIAL_WHEN_START
|
|
||||||
// #define ENABLE_SERIAL_DUMP
|
|
||||||
//#define ENABLE_SERIAL_DEBUG_INPUT
|
|
||||||
//#define ENABLE_LOAD_HARCODED_STATE_WHEN_START
|
|
||||||
/***************************/
|
|
||||||
|
|
||||||
/***** Time and clock *****/
|
|
||||||
// ESP8266 is not a very good time keeping device, each one of these little shits has a different clock oscilator.
|
|
||||||
// it also seems that the temperature also effects the clock frequency so time keeps on drifting and it get's noticable after some time.
|
|
||||||
// You can play around with these 2 to try and reduce the drift:
|
|
||||||
|
|
||||||
#define EMULATOR_CLOCK_SPEED 1000000
|
#define EMULATOR_CLOCK_SPEED 1000000
|
||||||
// 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 1
|
|
||||||
// If game time is going faster than it should, increase this value
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/***** Set display orientation, U8G2_MIRROR_VERTICAL is not supported *****/
|
/***** Set display orientation, U8G2_MIRROR_VERTICAL is not supported *****/
|
||||||
//#define U8G2_LAYOUT_NORMAL
|
//#define U8G2_LAYOUT_NORMAL
|
||||||
@ -59,7 +43,6 @@ U8G2_SSD1306_128X64_NONAME_2_HW_I2C display(U8G2_MIRROR);
|
|||||||
#define PIN_BTN_L 12 // D6
|
#define PIN_BTN_L 12 // D6
|
||||||
#define PIN_BTN_M 13 // D7
|
#define PIN_BTN_M 13 // D7
|
||||||
#define PIN_BTN_R 15 // D8
|
#define PIN_BTN_R 15 // D8
|
||||||
//define PIN_BTN_SAVE 3
|
|
||||||
#define PIN_BUZZER 0 // D5
|
#define PIN_BUZZER 0 // D5
|
||||||
|
|
||||||
/**** TamaLib Specific Variables ****/
|
/**** TamaLib Specific Variables ****/
|
||||||
@ -85,7 +68,6 @@ static void hal_sleep_until(timestamp_t ts) {
|
|||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
delayMicroseconds(remaining);
|
delayMicroseconds(remaining);
|
||||||
}
|
}
|
||||||
delayMicroseconds(FINE_TUNING_DELAY); // fixed delay to compensate for emulator time drifting
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +161,7 @@ static int hal_handler(void) {
|
|||||||
#ifdef ENABLE_SAVE_STATUS
|
#ifdef ENABLE_SAVE_STATUS
|
||||||
if (digitalRead(PIN_BTN_L) == HIGH && digitalRead(PIN_BTN_M) == HIGH && digitalRead(PIN_BTN_R) == HIGH) {
|
if (digitalRead(PIN_BTN_L) == HIGH && digitalRead(PIN_BTN_M) == HIGH && digitalRead(PIN_BTN_R) == HIGH) {
|
||||||
if (button4state==0) {
|
if (button4state==0) {
|
||||||
|
|
||||||
saveStateToEEPROM(&cpuState);
|
saveStateToEEPROM(&cpuState);
|
||||||
|
|
||||||
noTone(PIN_BUZZER);
|
noTone(PIN_BUZZER);
|
||||||
tone(PIN_BUZZER, 700, 100);
|
tone(PIN_BUZZER, 700, 100);
|
||||||
delay(120);
|
delay(120);
|
||||||
@ -198,7 +178,6 @@ static int hal_handler(void) {
|
|||||||
button4state = 0;
|
button4state = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -216,15 +195,6 @@ static hal_t hal = {
|
|||||||
.handler = &hal_handler,
|
.handler = &hal_handler,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
void drawTriangle(uint8_t x, uint8_t y) {
|
|
||||||
//display.drawLine(x,y,x+6,y);
|
|
||||||
display.drawLine(x+1,y+1,x+5,y+1);
|
|
||||||
display.drawLine(x+2,y+2,x+4,y+2);
|
|
||||||
display.drawLine(x+3,y+3,x+3,y+3);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void drawTamaRow(uint8_t tamaLCD_y, uint8_t ActualLCD_y, uint8_t thick) {
|
void drawTamaRow(uint8_t tamaLCD_y, uint8_t ActualLCD_y, uint8_t thick) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
for (i = 0; i < LCD_WIDTH; i++) {
|
for (i = 0; i < LCD_WIDTH; i++) {
|
||||||
@ -240,7 +210,6 @@ void drawTamaSelection(uint8_t y) {
|
|||||||
uint8_t i;
|
uint8_t i;
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
if (icon_buffer[i]) {
|
if (icon_buffer[i]) {
|
||||||
// drawTriangle(i*16+5,y);
|
|
||||||
display.drawXBMP(i * 16 + 4, y + 6, 8, 8, bitmaps + i * 8);
|
display.drawXBMP(i * 16 + 4, y + 6, 8, 8, bitmaps + i * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,15 +281,6 @@ void dumpStateToSerial() {
|
|||||||
if ((count % 16) == 15) Serial.println("");
|
if ((count % 16) == 15) Serial.println("");
|
||||||
}
|
}
|
||||||
Serial.println("};");
|
Serial.println("};");
|
||||||
/*
|
|
||||||
Serial.println("");
|
|
||||||
Serial.println("static const uint8_t bitmaps[] PROGMEM = {");
|
|
||||||
for(i=0;i<144;i++) {
|
|
||||||
sprintf(tmp, "0x%02X,", bitmaps_raw[i]);
|
|
||||||
Serial.print(tmp);
|
|
||||||
if ((i % 18)==17) Serial.println("");
|
|
||||||
}
|
|
||||||
Serial.println("};"); */
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -339,7 +299,6 @@ void setup() {
|
|||||||
pinMode(PIN_BTN_L, INPUT);
|
pinMode(PIN_BTN_L, INPUT);
|
||||||
pinMode(PIN_BTN_M, INPUT);
|
pinMode(PIN_BTN_M, INPUT);
|
||||||
pinMode(PIN_BTN_R, INPUT);
|
pinMode(PIN_BTN_R, INPUT);
|
||||||
//pinMode(PIN_BTN_SAVE, INPUT);
|
|
||||||
pinMode(PIN_BUZZER, OUTPUT);
|
pinMode(PIN_BUZZER, OUTPUT);
|
||||||
|
|
||||||
display.setI2CAddress(DISPLAY_I2C_ADDRESS * 2); // required if display does not use default address of 0x3C
|
display.setI2CAddress(DISPLAY_I2C_ADDRESS * 2); // required if display does not use default address of 0x3C
|
||||||
@ -355,8 +314,7 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_LOAD_STATE_FROM_EEPROM
|
#ifdef ENABLE_LOAD_STATE_FROM_EEPROM
|
||||||
if (validEEPROM())
|
if (validEEPROM()) {
|
||||||
{
|
|
||||||
loadStateFromEEPROM(&cpuState);
|
loadStateFromEEPROM(&cpuState);
|
||||||
} else {
|
} else {
|
||||||
Serial.println(F("No magic number in state, skipping state restore"));
|
Serial.println(F("No magic number in state, skipping state restore"));
|
||||||
@ -365,18 +323,11 @@ void setup() {
|
|||||||
loadHardcodedState(&cpuState);
|
loadHardcodedState(&cpuState);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
int i;
|
|
||||||
for(i=0;i<(18*8);i++) {
|
|
||||||
bitmaps_raw[i]= reverseBits(bitmaps_raw[i]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef ENABLE_DUMP_STATE_TO_SERIAL_WHEN_START
|
#ifdef ENABLE_DUMP_STATE_TO_SERIAL_WHEN_START
|
||||||
dumpStateToSerial();
|
dumpStateToSerial();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t middle_long_press_started = 0;
|
uint32_t middle_long_press_started = 0;
|
||||||
uint32_t right_long_press_started = 0;
|
uint32_t right_long_press_started = 0;
|
||||||
bool is_display_off = false;
|
bool is_display_off = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user