mirror of https://github.com/MLXXXp/Arduboy2.git
Add delayShort() function
Same as Arduino delay() except takes a 16 bit value. Mainly added to save some code in the library but can be used by sketches for the same purpose. Also changed a delay in bootLogoText() to match a previous change in bootLogo()
This commit is contained in:
parent
e96ae541d6
commit
142d85415c
|
@ -28,6 +28,7 @@ buttonsState KEYWORD2
|
|||
clear KEYWORD2
|
||||
collide KEYWORD2
|
||||
cpuLoad KEYWORD2
|
||||
delayShort KEYWORD2
|
||||
digitalWriteRGB KEYWORD2
|
||||
display KEYWORD2
|
||||
displayOff KEYWORD2
|
||||
|
|
|
@ -48,7 +48,7 @@ void Arduboy2Base::begin()
|
|||
|
||||
// wait for all buttons to be released
|
||||
do {
|
||||
delay(50);
|
||||
delayShort(50);
|
||||
} while (buttonsState());
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ void Arduboy2Base::systemButtons()
|
|||
digitalWriteRGB(BLUE_LED, RGB_ON); // turn on blue LED
|
||||
sysCtrlSound(UP_BUTTON + B_BUTTON, GREEN_LED, 0xff);
|
||||
sysCtrlSound(DOWN_BUTTON + B_BUTTON, RED_LED, 0);
|
||||
delay(200);
|
||||
delayShort(200);
|
||||
}
|
||||
|
||||
digitalWriteRGB(BLUE_LED, RGB_OFF); // turn off blue LED
|
||||
|
@ -87,10 +87,10 @@ void Arduboy2Base::sysCtrlSound(uint8_t buttons, uint8_t led, uint8_t eeVal)
|
|||
{
|
||||
if (pressed(buttons)) {
|
||||
digitalWriteRGB(BLUE_LED, RGB_OFF); // turn off blue LED
|
||||
delay(200);
|
||||
delayShort(200);
|
||||
digitalWriteRGB(led, RGB_ON); // turn on "acknowledge" LED
|
||||
EEPROM.update(EEPROM_AUDIO_ON_OFF, eeVal);
|
||||
delay(500);
|
||||
delayShort(500);
|
||||
digitalWriteRGB(led, RGB_OFF); // turn off "acknowledge" LED
|
||||
|
||||
while (pressed(buttons)) { } // Wait for button release
|
||||
|
@ -161,15 +161,15 @@ void Arduboy2Base::bootLogoShell(void (*drawLogo)(int16_t))
|
|||
clear();
|
||||
(*drawLogo)(y); // call the function that actually draws the logo
|
||||
display();
|
||||
delay(27);
|
||||
delayShort(27);
|
||||
// longer delay post boot, we put it inside the loop to
|
||||
// save the flash calling clear/delay again outside the loop
|
||||
if (y==-16) {
|
||||
delay(250);
|
||||
delayShort(250);
|
||||
}
|
||||
}
|
||||
|
||||
delay(700);
|
||||
delayShort(700);
|
||||
digitalWriteRGB(BLUE_LED, RGB_OFF);
|
||||
|
||||
bootLogoExtra();
|
||||
|
@ -1087,15 +1087,15 @@ void Arduboy2::bootLogoText()
|
|||
cursor_y = y;
|
||||
print("ARDUBOY");
|
||||
display();
|
||||
delay(27);
|
||||
delayShort(27);
|
||||
// longer delay post boot, we put it inside the loop to
|
||||
// save the flash calling clear/delay again outside the loop
|
||||
if (y==-16) {
|
||||
delay(250);
|
||||
delayShort(250);
|
||||
}
|
||||
}
|
||||
|
||||
delay(750);
|
||||
delayShort(700);
|
||||
digitalWriteRGB(BLUE_LED, RGB_OFF);
|
||||
textSize = 1;
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ void Arduboy2::bootLogoExtra()
|
|||
while (i < EEPROM_UNIT_NAME + ARDUBOY_UNIT_NAME_LEN);
|
||||
|
||||
display();
|
||||
delay(1000);
|
||||
delayShort(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,9 +194,9 @@ void Arduboy2Core::bootPins()
|
|||
void Arduboy2Core::bootOLED()
|
||||
{
|
||||
// reset the display
|
||||
delay(5); // reset pin should be low here. let it stay low a while
|
||||
delayShort(5); // reset pin should be low here. let it stay low a while
|
||||
bitSet(RST_PORT, RST_BIT); // set high to come out of reset
|
||||
delay(5); // wait a while
|
||||
delayShort(5); // wait a while
|
||||
|
||||
// select the display (permanently, since nothing else is using SPI)
|
||||
bitClear(CS_PORT, CS_BIT);
|
||||
|
@ -281,7 +281,7 @@ void Arduboy2Core::displayOff()
|
|||
SPItransfer(0xAE); // display off
|
||||
SPItransfer(0x8D); // charge pump:
|
||||
SPItransfer(0x10); // disable
|
||||
delay(250);
|
||||
delayShort(250);
|
||||
bitClear(RST_PORT, RST_BIT); // set display reset pin low (reset state)
|
||||
}
|
||||
|
||||
|
@ -469,3 +469,10 @@ uint8_t Arduboy2Core::buttonsState()
|
|||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
// delay in ms with 16 bit duration
|
||||
void Arduboy2Core::delayShort(uint16_t ms)
|
||||
{
|
||||
delay((unsigned long) ms);
|
||||
}
|
||||
|
||||
|
|
|
@ -676,6 +676,19 @@ class Arduboy2Core
|
|||
*/
|
||||
void static safeMode();
|
||||
|
||||
/** \brief
|
||||
* Delay for the number of milliseconds, specified as a 16 bit value.
|
||||
*
|
||||
* \param ms The delay in milliseconds.
|
||||
*
|
||||
* \details
|
||||
* This function works the same as the Arduino `delay()` function except
|
||||
* the provided value is 16 bits long, so the maximum delay allowed is
|
||||
* 65535 milliseconds (about 65.5 seconds). Using this function instead
|
||||
* of Arduino `delay()` will save a few bytes of code.
|
||||
*/
|
||||
void static delayShort(uint16_t ms) __attribute__ ((noinline));
|
||||
|
||||
protected:
|
||||
// internals
|
||||
void static setCPUSpeed8MHz();
|
||||
|
|
Loading…
Reference in New Issue