Update Arduboy2 library, boards.txt

boards.txt
add seperate Arduboy and Arduboy FX board support

Arduboy2.cpp, Arduboy2.h
change use of avr eeprom library instead of Arduino eeprom library.

Arduboy2core.cpp
fix SH1106 display code end timing
This commit is contained in:
Mr.Blinky 2022-06-11 19:09:48 +02:00
parent 95196a6a55
commit e73457dc75
4 changed files with 185 additions and 22 deletions

View File

@ -269,11 +269,173 @@ arduboy-homemade.menu.contrast.lowest.build.contrast=-DOLED_CONTRAST=0x00
arduboy-homemade.menu.contrast.highest=Highest arduboy-homemade.menu.contrast.highest=Highest
arduboy-homemade.menu.contrast.highest.build.contrast=-DOLED_CONTRAST=0xFF arduboy-homemade.menu.contrast.highest.build.contrast=-DOLED_CONTRAST=0xFF
################################################################################
# Arduboy FX board
################################################################################
arduboy-fx.name=Arduboy FX
#Arduino Leonardo
arduboy-fx.vid.0=0x2341
arduboy-fx.pid.0=0x0036
arduboy-fx.vid.1=0x2341
arduboy-fx.pid.1=0x8036
arduboy-fx.vid.2=0x2A03
arduboy-fx.pid.2=0x0036
arduboy-fx.vid.3=0x2A03
arduboy-fx.pid.3=0x8036
#Arduino Micro
arduboy-fx.vid.4=0x2341
arduboy-fx.pid.4=0x0037
arduboy-fx.vid.5=0x2341
arduboy-fx.pid.5=0x8037
arduboy-fx.vid.6=0x2A03
arduboy-fx.pid.6=0x0037
arduboy-fx.vid.7=0x2A03
arduboy-fx.pid.7=0x8037
#Genuino Micro
arduboy-fx.vid.8=0x2341
arduboy-fx.pid.8=0x8237
#Sparkfun Pro Micro 5V
arduboy-fx.vid.8=0x1b4f
arduboy-fx.pid.8=0x9205
arduboy-fx.vid.9=0x1b4f
arduboy-fx.pid.9=0x9206
arduboy-fx.upload.tool=arduino:avrdude
arduboy-fx.upload.protocol=avr109
arduboy-fx.upload.maximum_size=28672
arduboy-fx.upload.maximum_data_size=2560
arduboy-fx.upload.speed=57600
arduboy-fx.upload.disable_flushing=true
arduboy-fx.upload.use_1200bps_touch=true
arduboy-fx.upload.wait_for_upload_port=true
arduboy-fx.bootloader.tool=arduino:avrdude
arduboy-fx.bootloader.low_fuses=0xff
arduboy-fx.bootloader.high_fuses=0xd2
arduboy-fx.bootloader.extended_fuses=0xcb
arduboy-fx.bootloader.file=cathy3k/arduboy3k-bootloader-menu-sda.hex
arduboy-fx.bootloader.unlock_bits=0x3F
arduboy-fx.bootloader.lock_bits=0x2F
arduboy-fx.build.mcu=atmega32u4
arduboy-fx.build.f_cpu=16000000L
arduboy-fx.build.variant=arduboy
arduboy-fx.build.board=AVR_ARDUBOY
arduboy-fx.build.vid=0x2341
arduboy-fx.build.pid=0x8036
arduboy-fx.build.variant=arduboy
arduboy-fx.build.usb_product="Arduboy"
arduboy-fx.build.board=AVR_ARDUBOY
arduboy-fx.build.core=arduino:arduino
arduboy-fx.build.flash_cs=-DCART_CS_SDA
arduboy-fx.build.extra_flags=-DARDUBOY_10 {build.flash_cs} {build.usb_flags}
# Arduboy FX menu options ######################################################
arduboy-fx.menu.core.arduboy-core=Arduboy optimized core
arduboy-fx.menu.core.arduboy-core.build.core=arduboy
arduboy-fx.menu.core.arduino-core=Standard Arduino core
arduboy-fx.menu.core.arduino-core.build.core=arduino:arduino
arduboy-fx.menu.boot.cathy3k=Cathy3K (starts with menu)
arduboy-fx.menu.boot.cathy3k.upload.maximum_size=29696
arduboy-fx.menu.boot.cathy3k.bootloader.high_fuses=0xd2
arduboy-fx.menu.boot.cathy3k.bootloader.file=cathy3k/arduboy3k-bootloader-menu-sda.hex
arduboy-fx.menu.boot.cathy3kg=Cathy3K (starts with game)
arduboy-fx.menu.boot.cathy3kg.upload.maximum_size=29696
arduboy-fx.menu.boot.cathy3kg.bootloader.high_fuses=0xd2
arduboy-fx.menu.boot.cathy3kg.bootloader.file=cathy3k/arduboy3k-bootloader-game-sda.hex
################################################################################
# Arduboy FX DevKit board
################################################################################
arduboy-fx-devkit.name=Arduboy FX DevKit
#Arduino Leonardo
arduboy-fx-devkit.vid.0=0x2341
arduboy-fx-devkit.pid.0=0x0036
arduboy-fx-devkit.vid.1=0x2341
arduboy-fx-devkit.pid.1=0x8036
arduboy-fx-devkit.vid.2=0x2A03
arduboy-fx-devkit.pid.2=0x0036
arduboy-fx-devkit.vid.3=0x2A03
arduboy-fx-devkit.pid.3=0x8036
#Arduino Micro
arduboy-fx-devkit.vid.4=0x2341
arduboy-fx-devkit.pid.4=0x0037
arduboy-fx-devkit.vid.5=0x2341
arduboy-fx-devkit.pid.5=0x8037
arduboy-fx-devkit.vid.6=0x2A03
arduboy-fx-devkit.pid.6=0x0037
arduboy-fx-devkit.vid.7=0x2A03
arduboy-fx-devkit.pid.7=0x8037
#Genuino Micro
arduboy-fx-devkit.vid.8=0x2341
arduboy-fx-devkit.pid.8=0x8237
#Sparkfun Pro Micro 5V
arduboy-fx-devkit.vid.8=0x1b4f
arduboy-fx-devkit.pid.8=0x9205
arduboy-fx-devkit.vid.9=0x1b4f
arduboy-fx-devkit.pid.9=0x9206
arduboy-fx-devkit.upload.tool=arduino:avrdude
arduboy-fx-devkit.upload.protocol=avr109
arduboy-fx-devkit.upload.maximum_size=28672
arduboy-fx-devkit.upload.maximum_data_size=2560
arduboy-fx-devkit.upload.speed=57600
arduboy-fx-devkit.upload.disable_flushing=true
arduboy-fx-devkit.upload.use_1200bps_touch=true
arduboy-fx-devkit.upload.wait_for_upload_port=true
arduboy-fx-devkit.bootloader.tool=arduino:avrdude
arduboy-fx-devkit.bootloader.low_fuses=0xff
arduboy-fx-devkit.bootloader.high_fuses=0xd2
arduboy-fx-devkit.bootloader.extended_fuses=0xcb
arduboy-fx-devkit.bootloader.file=cathy3k/arduboy3k-bootloader-menu-sda.hex
arduboy-fx-devkit.bootloader.unlock_bits=0x3F
arduboy-fx-devkit.bootloader.lock_bits=0x2F
arduboy-fx-devkit.build.mcu=atmega32u4
arduboy-fx-devkit.build.f_cpu=16000000L
arduboy-fx-devkit.build.variant=arduboy
arduboy-fx-devkit.build.board=AVR_ARDUBOY
arduboy-fx-devkit.build.vid=0x2341
arduboy-fx-devkit.build.pid=0x8036
arduboy-fx-devkit.build.variant=arduboy
arduboy-fx-devkit.build.usb_product="Arduboy"
arduboy-fx-devkit.build.board=AVR_ARDUBOY
arduboy-fx-devkit.build.core=arduino:arduino
arduboy-fx-devkit.build.flash_cs=-DCART_CS_RX
arduboy-fx-devkit.build.extra_flags=-DARDUBOY_10 {build.flash_cs} {build.usb_flags}
# Arduboy FX DevKit menu options ###############################################
arduboy-fx-devkit.menu.core.arduboy-core=Arduboy optimized core
arduboy-fx-devkit.menu.core.arduboy-core.build.core=arduboy
arduboy-fx-devkit.menu.core.arduino-core=Standard Arduino core
arduboy-fx-devkit.menu.core.arduino-core.build.core=arduino:arduino
arduboy-fx-devkit.menu.boot.cathy3k=Cathy3K (starts with menu)
arduboy-fx-devkit.menu.boot.cathy3k.upload.maximum_size=29696
arduboy-fx-devkit.menu.boot.cathy3k.bootloader.high_fuses=0xd2
arduboy-fx-devkit.menu.boot.cathy3k.bootloader.file=cathy3k/arduboy3k-bootloader-menu-sda.hex
arduboy-fx-devkit.menu.boot.cathy3kg=Cathy3K (starts with game)
arduboy-fx-devkit.menu.boot.cathy3kg.upload.maximum_size=29696
arduboy-fx-devkit.menu.boot.cathy3kg.bootloader.high_fuses=0xd2
arduboy-fx-devkit.menu.boot.cathy3kg.bootloader.file=cathy3k/arduboy3k-bootloader-game-sda.hex
################################################################################ ################################################################################
# Arduboy board # Arduboy board
################################################################################ ################################################################################
arduboy.name=Arduboy (FX) arduboy.name=Arduboy
#Arduino Leonardo #Arduino Leonardo
arduboy.vid.0=0x2341 arduboy.vid.0=0x2341
@ -484,7 +646,7 @@ arduboy-devkit.menu.boot.cathy3kg.bootloader.file=cathy3k/arduboy3k-bootloader-g
8bitcadexl.build.flash_cs=-DCART_CS_RX 8bitcadexl.build.flash_cs=-DCART_CS_RX
8bitcadexl.build.extra_flags=-DARDUBOY_10 -DOLED_SSD1309 {build.flash_cs} {build.contrast} {build.usb_flags} 8bitcadexl.build.extra_flags=-DARDUBOY_10 -DOLED_SSD1309 {build.flash_cs} {build.contrast} {build.usb_flags}
# Arduboy menu options ######################################################### # 8BitCADE XL menu options #####################################################
#core select #core select
@ -567,7 +729,7 @@ arduboy-devkit.menu.boot.cathy3kg.bootloader.file=cathy3k/arduboy3k-bootloader-g
8bitcadexlup.build.flash_cs=-DCART_CS_RX 8bitcadexlup.build.flash_cs=-DCART_CS_RX
8bitcadexlup.build.extra_flags=-DARDUBOY_10 -DOLED_SSD1309 -DSUPPORT_XY_BUTTONS {build.flash_cs} {build.contrast} {build.usb_flags} 8bitcadexlup.build.extra_flags=-DARDUBOY_10 -DOLED_SSD1309 -DSUPPORT_XY_BUTTONS {build.flash_cs} {build.contrast} {build.usb_flags}
# Arduboy menu options ######################################################### # 8BitCADE XL Level UP menu options ############################################
#core select #core select

View File

@ -101,7 +101,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(eepromAudioOnOff, eeVal); eeprom_update_byte(eepromAudioOnOff, eeVal);
delayShort(500); delayShort(500);
digitalWriteRGB(led, RGB_OFF); // turn off "acknowledge" LED digitalWriteRGB(led, RGB_OFF); // turn off "acknowledge" LED
@ -1072,14 +1072,14 @@ bool Arduboy2Base::collide(Rect rect1, Rect rect2)
uint16_t Arduboy2Base::readUnitID() uint16_t Arduboy2Base::readUnitID()
{ {
return EEPROM.read(eepromUnitID) | return eeprom_read_byte(eepromUnitID) |
(((uint16_t)(EEPROM.read(eepromUnitID + 1))) << 8); (((uint16_t)(eeprom_read_byte(eepromUnitID + 1))) << 8);
} }
void Arduboy2Base::writeUnitID(uint16_t id) void Arduboy2Base::writeUnitID(uint16_t id)
{ {
EEPROM.update(eepromUnitID, (uint8_t)(id & 0xff)); eeprom_update_byte(eepromUnitID, (uint8_t)(id & 0xff));
EEPROM.update(eepromUnitID + 1, (uint8_t)(id >> 8)); eeprom_update_byte(eepromUnitID + 1, (uint8_t)(id >> 8));
} }
uint8_t Arduboy2Base::readUnitName(char* name) uint8_t Arduboy2Base::readUnitName(char* name)
@ -1090,7 +1090,7 @@ uint8_t Arduboy2Base::readUnitName(char* name)
for (dest = 0; dest < ARDUBOY_UNIT_NAME_LEN; dest++) for (dest = 0; dest < ARDUBOY_UNIT_NAME_LEN; dest++)
{ {
val = EEPROM.read(src); val = eeprom_read_byte(src);
name[dest] = val; name[dest] = val;
src++; src++;
if (val == 0x00 || (byte)val == 0xFF) { if (val == 0x00 || (byte)val == 0xFF) {
@ -1113,48 +1113,48 @@ void Arduboy2Base::writeUnitName(const char* name)
done = true; done = true;
} }
// write character or 0 pad if finished // write character or 0 pad if finished
EEPROM.update(dest, done ? 0x00 : name[src]); eeprom_update_byte(dest, done ? 0x00 : name[src]);
dest++; dest++;
} }
} }
bool Arduboy2Base::readShowBootLogoFlag() bool Arduboy2Base::readShowBootLogoFlag()
{ {
return (EEPROM.read(eepromSysFlags) & sysFlagShowLogoMask); return (eeprom_read_byte(eepromSysFlags) & sysFlagShowLogoMask);
} }
void Arduboy2Base::writeShowBootLogoFlag(bool val) void Arduboy2Base::writeShowBootLogoFlag(bool val)
{ {
uint8_t flags = EEPROM.read(eepromSysFlags); uint8_t flags = eeprom_read_byte(eepromSysFlags);
bitWrite(flags, sysFlagShowLogoBit, val); bitWrite(flags, sysFlagShowLogoBit, val);
EEPROM.update(eepromSysFlags, flags); eeprom_update_byte(eepromSysFlags, flags);
} }
bool Arduboy2Base::readShowUnitNameFlag() bool Arduboy2Base::readShowUnitNameFlag()
{ {
return (EEPROM.read(eepromSysFlags) & sysFlagUnameMask); return (eeprom_read_byte(eepromSysFlags) & sysFlagUnameMask);
} }
void Arduboy2Base::writeShowUnitNameFlag(bool val) void Arduboy2Base::writeShowUnitNameFlag(bool val)
{ {
uint8_t flags = EEPROM.read(eepromSysFlags); uint8_t flags = eeprom_read_byte(eepromSysFlags);
bitWrite(flags, sysFlagUnameBit, val); bitWrite(flags, sysFlagUnameBit, val);
EEPROM.update(eepromSysFlags, flags); eeprom_update_byte(eepromSysFlags, flags);
} }
bool Arduboy2Base::readShowBootLogoLEDsFlag() bool Arduboy2Base::readShowBootLogoLEDsFlag()
{ {
return (EEPROM.read(eepromSysFlags) & sysFlagShowLogoLEDsMask); return (eeprom_read_byte(eepromSysFlags) & sysFlagShowLogoLEDsMask);
} }
void Arduboy2Base::writeShowBootLogoLEDsFlag(bool val) void Arduboy2Base::writeShowBootLogoLEDsFlag(bool val)
{ {
uint8_t flags = EEPROM.read(eepromSysFlags); uint8_t flags = eeprom_read_byte(eepromSysFlags);
bitWrite(flags, sysFlagShowLogoLEDsBit, val); bitWrite(flags, sysFlagShowLogoLEDsBit, val);
EEPROM.update(eepromSysFlags, flags); eeprom_update_byte(eepromSysFlags, flags);
} }
void Arduboy2Base::swapInt16(int16_t& a, int16_t& b) void Arduboy2Base::swapInt16(int16_t& a, int16_t& b)
@ -1305,7 +1305,7 @@ void Arduboy2::bootLogoExtra()
return; return;
} }
c = EEPROM.read(eepromUnitName); c = eeprom_read_byte(eepromUnitName);
if (c != 0xFF && c != 0x00) if (c != 0xFF && c != 0x00)
{ {
@ -1316,7 +1316,7 @@ void Arduboy2::bootLogoExtra()
do do
{ {
write(c); write(c);
c = EEPROM.read(++i); c = eeprom_read_byte(++i);
} }
while (i < eepromUnitName + ARDUBOY_UNIT_NAME_LEN); while (i < eepromUnitName + ARDUBOY_UNIT_NAME_LEN);

View File

@ -8,7 +8,7 @@
#define ARDUBOY2_H #define ARDUBOY2_H
#include <Arduino.h> #include <Arduino.h>
#include <EEPROM.h> #include <avr/eeprom.h>
#include "Arduboy2Core.h" #include "Arduboy2Core.h"
#include "Arduboy2Audio.h" #include "Arduboy2Audio.h"
#include "Arduboy2Beep.h" #include "Arduboy2Beep.h"

View File

@ -901,6 +901,7 @@ void Arduboy2Core::paintScreen(uint8_t image[], bool clear)
" inc r19 ;1 \n\t" " inc r19 ;1 \n\t"
" cpi r19,%[page_end] ;1 \n\t" " cpi r19,%[page_end] ;1 \n\t"
" brne 1b ;1/2 \n\t" " brne 1b ;1/2 \n\t"
" lpm r20, Z ;3 delay \n\t"
" in __tmp_reg__, %[spsr] \n\t" //read SPSR to clear SPIF " in __tmp_reg__, %[spsr] \n\t" //read SPSR to clear SPIF
: [ptr] "+&z" (image) : [ptr] "+&z" (image)
: :