Update Arduboy2 library
Add support for microcade fix eeprom function warnings inlined setRGBled On/Off functions
This commit is contained in:
parent
fc95424467
commit
32e8b1d25c
|
@ -86,13 +86,22 @@ void Arduboy2Base::flashlight()
|
||||||
void Arduboy2Base::systemButtons()
|
void Arduboy2Base::systemButtons()
|
||||||
{
|
{
|
||||||
while (pressed(B_BUTTON)) {
|
while (pressed(B_BUTTON)) {
|
||||||
|
#if defined(MICROCADE)
|
||||||
|
setRGBledRedOff();
|
||||||
|
setRGBledGreenOff();
|
||||||
|
#endif
|
||||||
setRGBledBlueOn();
|
setRGBledBlueOn();
|
||||||
sysCtrlSound(UP_BUTTON + B_BUTTON, GREEN_LED, 0xff);
|
sysCtrlSound(UP_BUTTON + B_BUTTON, GREEN_LED, 0xff);
|
||||||
sysCtrlSound(DOWN_BUTTON + B_BUTTON, RED_LED, 0);
|
sysCtrlSound(DOWN_BUTTON + B_BUTTON, RED_LED, 0);
|
||||||
delayByte(200);
|
delayByte(200);
|
||||||
}
|
}
|
||||||
|
#if defined(MICROCADE)
|
||||||
|
setRGBledRedOn();
|
||||||
|
setRGBledGreenOn();
|
||||||
|
setRGBledBlueOn();
|
||||||
|
#else
|
||||||
setRGBledBlueOff();
|
setRGBledBlueOff();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::sysCtrlSound(uint8_t buttons, uint8_t led, uint8_t eeVal)
|
void Arduboy2Base::sysCtrlSound(uint8_t buttons, uint8_t led, uint8_t eeVal)
|
||||||
|
@ -101,7 +110,7 @@ void Arduboy2Base::sysCtrlSound(uint8_t buttons, uint8_t led, uint8_t eeVal)
|
||||||
setRGBledBlueOff();
|
setRGBledBlueOff();
|
||||||
delayByte(200);
|
delayByte(200);
|
||||||
digitalWriteRGB(led, RGB_ON); // turn on "acknowledge" LED
|
digitalWriteRGB(led, RGB_ON); // turn on "acknowledge" LED
|
||||||
eeprom_update_byte(eepromAudioOnOff, eeVal);
|
eeprom_update_byte((uint8_t*)eepromAudioOnOff, eeVal);
|
||||||
delayShort(500);
|
delayShort(500);
|
||||||
digitalWriteRGB(led, RGB_OFF); // turn off "acknowledge" LED
|
digitalWriteRGB(led, RGB_OFF); // turn off "acknowledge" LED
|
||||||
|
|
||||||
|
@ -181,13 +190,23 @@ bool Arduboy2Base::bootLogoShell(void (&drawLogo)(int16_t))
|
||||||
|
|
||||||
if (showLEDs) {
|
if (showLEDs) {
|
||||||
setRGBledRedOn();
|
setRGBledRedOn();
|
||||||
|
#if defined (MICROCADE)
|
||||||
|
setRGBledGreenOff();
|
||||||
|
setRGBledBlueOff();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int16_t y = -15; y <= 24; y++) {
|
for (int16_t y = -15; y <= 24; y++) {
|
||||||
if (pressed(RIGHT_BUTTON)) {
|
if (pressed(RIGHT_BUTTON)) {
|
||||||
|
#if defined(MICROCADE)
|
||||||
|
setRGBledRedOn();
|
||||||
|
setRGBledGreenOn();
|
||||||
|
setRGBledBlueOn();
|
||||||
|
#else
|
||||||
setRGBledRedOff();
|
setRGBledRedOff();
|
||||||
setRGBledGreenOff();
|
setRGBledGreenOff();
|
||||||
//setRGBledblueOff(); // Blue LED not turned on inside loop
|
//setRGBledblueOff(); // Blue LED not turned on inside loop
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +228,12 @@ bool Arduboy2Base::bootLogoShell(void (&drawLogo)(int16_t))
|
||||||
setRGBledBlueOn();
|
setRGBledBlueOn();
|
||||||
}
|
}
|
||||||
delayShort(400);
|
delayShort(400);
|
||||||
|
#if !defined (MICROCADE)
|
||||||
setRGBledBlueOff();
|
setRGBledBlueOff();
|
||||||
|
#else
|
||||||
|
setRGBledGreenOn();
|
||||||
|
setRGBledRedOn();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,21 +1096,21 @@ bool Arduboy2Base::collide(Rect rect1, Rect rect2)
|
||||||
|
|
||||||
uint16_t Arduboy2Base::readUnitID()
|
uint16_t Arduboy2Base::readUnitID()
|
||||||
{
|
{
|
||||||
return eeprom_read_byte(eepromUnitID) |
|
return eeprom_read_byte((uint8_t*)eepromUnitID) |
|
||||||
(((uint16_t)(eeprom_read_byte(eepromUnitID + 1))) << 8);
|
(((uint16_t)(eeprom_read_byte((uint8_t*)(eepromUnitID + 1)))) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::writeUnitID(uint16_t id)
|
void Arduboy2Base::writeUnitID(uint16_t id)
|
||||||
{
|
{
|
||||||
eeprom_update_byte(eepromUnitID, (uint8_t)(id & 0xff));
|
eeprom_update_byte((uint8_t*)eepromUnitID, (uint8_t)(id & 0xff));
|
||||||
eeprom_update_byte(eepromUnitID + 1, (uint8_t)(id >> 8));
|
eeprom_update_byte((uint8_t*)eepromUnitID + 1, (uint8_t)(id >> 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Arduboy2Base::readUnitName(char* name)
|
uint8_t Arduboy2Base::readUnitName(char* name)
|
||||||
{
|
{
|
||||||
char val;
|
char val;
|
||||||
uint8_t dest;
|
uint8_t dest;
|
||||||
uint8_t src = eepromUnitName;
|
uint8_t* src = (uint8_t*)eepromUnitName;
|
||||||
|
|
||||||
for (dest = 0; dest < ARDUBOY_UNIT_NAME_LEN; dest++)
|
for (dest = 0; dest < ARDUBOY_UNIT_NAME_LEN; dest++)
|
||||||
{
|
{
|
||||||
|
@ -1105,7 +1129,7 @@ uint8_t Arduboy2Base::readUnitName(char* name)
|
||||||
void Arduboy2Base::writeUnitName(const char* name)
|
void Arduboy2Base::writeUnitName(const char* name)
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
uint8_t dest = eepromUnitName;
|
uint8_t* dest = (uint8_t*)eepromUnitName;
|
||||||
|
|
||||||
for (uint8_t src = 0; src < ARDUBOY_UNIT_NAME_LEN; src++)
|
for (uint8_t src = 0; src < ARDUBOY_UNIT_NAME_LEN; src++)
|
||||||
{
|
{
|
||||||
|
@ -1120,41 +1144,41 @@ void Arduboy2Base::writeUnitName(const char* name)
|
||||||
|
|
||||||
bool Arduboy2Base::readShowBootLogoFlag()
|
bool Arduboy2Base::readShowBootLogoFlag()
|
||||||
{
|
{
|
||||||
return (eeprom_read_byte(eepromSysFlags) & sysFlagShowLogoMask);
|
return (eeprom_read_byte((uint8_t*)eepromSysFlags) & sysFlagShowLogoMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::writeShowBootLogoFlag(bool val)
|
void Arduboy2Base::writeShowBootLogoFlag(bool val)
|
||||||
{
|
{
|
||||||
uint8_t flags = eeprom_read_byte(eepromSysFlags);
|
uint8_t flags = eeprom_read_byte((uint8_t*)eepromSysFlags);
|
||||||
|
|
||||||
bitWrite(flags, sysFlagShowLogoBit, val);
|
bitWrite(flags, sysFlagShowLogoBit, val);
|
||||||
eeprom_update_byte(eepromSysFlags, flags);
|
eeprom_update_byte((uint8_t*)eepromSysFlags, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arduboy2Base::readShowUnitNameFlag()
|
bool Arduboy2Base::readShowUnitNameFlag()
|
||||||
{
|
{
|
||||||
return (eeprom_read_byte(eepromSysFlags) & sysFlagUnameMask);
|
return (eeprom_read_byte((uint8_t*)eepromSysFlags) & sysFlagUnameMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::writeShowUnitNameFlag(bool val)
|
void Arduboy2Base::writeShowUnitNameFlag(bool val)
|
||||||
{
|
{
|
||||||
uint8_t flags = eeprom_read_byte(eepromSysFlags);
|
uint8_t flags = eeprom_read_byte((uint8_t*)eepromSysFlags);
|
||||||
|
|
||||||
bitWrite(flags, sysFlagUnameBit, val);
|
bitWrite(flags, sysFlagUnameBit, val);
|
||||||
eeprom_update_byte(eepromSysFlags, flags);
|
eeprom_update_byte((uint8_t*)eepromSysFlags, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arduboy2Base::readShowBootLogoLEDsFlag()
|
bool Arduboy2Base::readShowBootLogoLEDsFlag()
|
||||||
{
|
{
|
||||||
return (eeprom_read_byte(eepromSysFlags) & sysFlagShowLogoLEDsMask);
|
return (eeprom_read_byte((uint8_t*)eepromSysFlags) & sysFlagShowLogoLEDsMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::writeShowBootLogoLEDsFlag(bool val)
|
void Arduboy2Base::writeShowBootLogoLEDsFlag(bool val)
|
||||||
{
|
{
|
||||||
uint8_t flags = eeprom_read_byte(eepromSysFlags);
|
uint8_t flags = eeprom_read_byte((uint8_t*)eepromSysFlags);
|
||||||
|
|
||||||
bitWrite(flags, sysFlagShowLogoLEDsBit, val);
|
bitWrite(flags, sysFlagShowLogoLEDsBit, val);
|
||||||
eeprom_update_byte(eepromSysFlags, flags);
|
eeprom_update_byte((uint8_t*)eepromSysFlags, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::swapInt16(int16_t& a, int16_t& b)
|
void Arduboy2Base::swapInt16(int16_t& a, int16_t& b)
|
||||||
|
@ -1305,11 +1329,11 @@ void Arduboy2::bootLogoExtra()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = eeprom_read_byte(eepromUnitName);
|
c = eeprom_read_byte((uint8_t*)eepromUnitName);
|
||||||
|
|
||||||
if (c != 0xFF && c != 0x00)
|
if (c != 0xFF && c != 0x00)
|
||||||
{
|
{
|
||||||
uint8_t i = eepromUnitName;
|
uint8_t* i = (uint8_t*)eepromUnitName;
|
||||||
cursor_x = 50 - (64 - WIDTH / 2);
|
cursor_x = 50 - (64 - WIDTH / 2);
|
||||||
cursor_y = 56;
|
cursor_y = 56;
|
||||||
|
|
||||||
|
@ -1318,7 +1342,7 @@ void Arduboy2::bootLogoExtra()
|
||||||
write(c);
|
write(c);
|
||||||
c = eeprom_read_byte(++i);
|
c = eeprom_read_byte(++i);
|
||||||
}
|
}
|
||||||
while (i < eepromUnitName + ARDUBOY_UNIT_NAME_LEN);
|
while ((uint16_t)i < eepromUnitName + ARDUBOY_UNIT_NAME_LEN);
|
||||||
|
|
||||||
display();
|
display();
|
||||||
delayShort(1000);
|
delayShort(1000);
|
||||||
|
|
|
@ -194,7 +194,10 @@ void Arduboy2Core::bootPins()
|
||||||
#ifdef ARDUBOY_10
|
#ifdef ARDUBOY_10
|
||||||
|
|
||||||
// Port B INPUT_PULLUP or HIGH
|
// Port B INPUT_PULLUP or HIGH
|
||||||
PORTB = (_BV(RED_LED_BIT) | _BV(BLUE_LED_BIT) //RGB LED off
|
PORTB = (0
|
||||||
|
#ifndef MICROCADE
|
||||||
|
| _BV(RED_LED_BIT) | _BV(BLUE_LED_BIT) //RGB LED off
|
||||||
|
#endif
|
||||||
#ifndef AB_ALTERNATE_WIRING
|
#ifndef AB_ALTERNATE_WIRING
|
||||||
| _BV(GREEN_LED_BIT)
|
| _BV(GREEN_LED_BIT)
|
||||||
#endif
|
#endif
|
||||||
|
@ -231,7 +234,7 @@ void Arduboy2Core::bootPins()
|
||||||
// Speaker: Not set here. Controlled by audio class
|
// Speaker: Not set here. Controlled by audio class
|
||||||
// Port D INPUT_PULLUP or HIGH
|
// Port D INPUT_PULLUP or HIGH
|
||||||
PORTD = (
|
PORTD = (
|
||||||
#if defined(AB_ALTERNATE_WIRING)
|
#if (defined(AB_ALTERNATE_WIRING) && !defined(MICROCADE))
|
||||||
_BV(GREEN_LED_BIT) |
|
_BV(GREEN_LED_BIT) |
|
||||||
#endif
|
#endif
|
||||||
#if !(defined(ARDUINO_AVR_MICRO))
|
#if !(defined(ARDUINO_AVR_MICRO))
|
||||||
|
@ -1182,63 +1185,9 @@ void Arduboy2Core::flipHorizontal(bool flipped)
|
||||||
|
|
||||||
/* RGB LED */
|
/* RGB LED */
|
||||||
|
|
||||||
void Arduboy2Core::setRGBledRedOn()
|
|
||||||
{
|
|
||||||
#ifndef LCD_ST7565
|
|
||||||
bitClear(RED_LED_PORT, RED_LED_BIT); // Red on
|
|
||||||
#else
|
|
||||||
bitSet(RED_LED_PORT, RED_LED_BIT); // Red on
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arduboy2Core::setRGBledRedOff()
|
|
||||||
{
|
|
||||||
#ifndef LCD_ST7565
|
|
||||||
bitSet(RED_LED_PORT, RED_LED_BIT); // Red off
|
|
||||||
#else
|
|
||||||
bitClear(RED_LED_PORT, RED_LED_BIT); // Red off
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arduboy2Core::setRGBledGreenOn()
|
|
||||||
{
|
|
||||||
#ifndef LCD_ST7565
|
|
||||||
bitClear(GREEN_LED_PORT, GREEN_LED_BIT); // Green on
|
|
||||||
#else
|
|
||||||
bitSet(GREEN_LED_PORT, GREEN_LED_BIT); // Green on
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arduboy2Core::setRGBledGreenOff()
|
|
||||||
{
|
|
||||||
#ifndef LCD_ST7565
|
|
||||||
bitSet(GREEN_LED_PORT, GREEN_LED_BIT); // Green off
|
|
||||||
#else
|
|
||||||
bitClear(GREEN_LED_PORT, GREEN_LED_BIT); // Green off
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arduboy2Core::setRGBledBlueOn()
|
|
||||||
{
|
|
||||||
#ifndef LCD_ST7565
|
|
||||||
bitClear(BLUE_LED_PORT, BLUE_LED_BIT); // Blue on
|
|
||||||
#else
|
|
||||||
bitSet(BLUE_LED_PORT, BLUE_LED_BIT); // Blue on
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arduboy2Core::setRGBledBlueOff()
|
|
||||||
{
|
|
||||||
#ifndef LCD_ST7565
|
|
||||||
bitSet(BLUE_LED_PORT, BLUE_LED_BIT); // Blue off
|
|
||||||
#else
|
|
||||||
bitClear(BLUE_LED_PORT, BLUE_LED_BIT); // Blue off
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Arduboy2Core::setRGBled(uint8_t red, uint8_t green, uint8_t blue)
|
void Arduboy2Core::setRGBled(uint8_t red, uint8_t green, uint8_t blue)
|
||||||
{
|
{
|
||||||
#ifdef LCD_ST7565
|
#if defined (LCD_ST7565) || (MICROCADE)
|
||||||
if ((red | green | blue) == 0) //prevent backlight off
|
if ((red | green | blue) == 0) //prevent backlight off
|
||||||
{
|
{
|
||||||
red = 255;
|
red = 255;
|
||||||
|
@ -1335,7 +1284,7 @@ void Arduboy2Core::freeRGBled()
|
||||||
|
|
||||||
void Arduboy2Core::digitalWriteRGB(uint8_t red, uint8_t green, uint8_t blue)
|
void Arduboy2Core::digitalWriteRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||||
{
|
{
|
||||||
#ifdef LCD_ST7565
|
#if defined (LCD_ST7565) || (MICROCADE)
|
||||||
if ((red & green & blue) == RGB_OFF) //prevent backlight off
|
if ((red & green & blue) == RGB_OFF) //prevent backlight off
|
||||||
{
|
{
|
||||||
red = RGB_ON;
|
red = RGB_ON;
|
||||||
|
|
|
@ -830,12 +830,59 @@ class Arduboy2Core : public Arduboy2NoUSB
|
||||||
*/
|
*/
|
||||||
static void sendLCDCommand(uint8_t command);
|
static void sendLCDCommand(uint8_t command);
|
||||||
|
|
||||||
static void setRGBledRedOn();
|
static void inline setRGBledRedOn()__attribute__((always_inline))
|
||||||
static void setRGBledRedOff();
|
{
|
||||||
static void setRGBledGreenOn();
|
#ifndef LCD_ST7565
|
||||||
static void setRGBledGreenOff();
|
bitClear(RED_LED_PORT, RED_LED_BIT); // Red on
|
||||||
static void setRGBledBlueOn();
|
#else
|
||||||
static void setRGBledBlueOff();
|
bitSet(RED_LED_PORT, RED_LED_BIT); // Red on
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void inline setRGBledRedOff()__attribute__((always_inline))
|
||||||
|
{
|
||||||
|
#ifndef LCD_ST7565
|
||||||
|
bitSet(RED_LED_PORT, RED_LED_BIT); // Red off
|
||||||
|
#else
|
||||||
|
bitClear(RED_LED_PORT, RED_LED_BIT); // Red off
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void inline setRGBledGreenOn()__attribute__((always_inline))
|
||||||
|
{
|
||||||
|
#ifndef LCD_ST7565
|
||||||
|
bitClear(GREEN_LED_PORT, GREEN_LED_BIT); // Green on
|
||||||
|
#else
|
||||||
|
bitSet(GREEN_LED_PORT, GREEN_LED_BIT); // Green on
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void inline setRGBledGreenOff()__attribute__((always_inline))
|
||||||
|
{
|
||||||
|
#ifndef LCD_ST7565
|
||||||
|
bitSet(GREEN_LED_PORT, GREEN_LED_BIT); // Green off
|
||||||
|
#else
|
||||||
|
bitClear(GREEN_LED_PORT, GREEN_LED_BIT); // Green off
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void inline setRGBledBlueOn()__attribute__((always_inline))
|
||||||
|
{
|
||||||
|
#ifndef LCD_ST7565
|
||||||
|
bitClear(BLUE_LED_PORT, BLUE_LED_BIT); // Blue on
|
||||||
|
#else
|
||||||
|
bitSet(BLUE_LED_PORT, BLUE_LED_BIT); // Blue on
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void inline setRGBledBlueOff()__attribute__((always_inline))
|
||||||
|
{
|
||||||
|
#ifndef LCD_ST7565
|
||||||
|
bitSet(BLUE_LED_PORT, BLUE_LED_BIT); // Blue off
|
||||||
|
#else
|
||||||
|
bitClear(BLUE_LED_PORT, BLUE_LED_BIT); // Blue off
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief
|
/** \brief
|
||||||
* Set the light output of the RGB LED.
|
* Set the light output of the RGB LED.
|
||||||
|
|
Loading…
Reference in New Issue