diff --git a/library.json b/library.json index 383d916..9f204ce 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/MLXXXp/Arduboy2.git" }, - "version": "2.1.0", + "version": "3.0.0", "exclude": "extras", "frameworks": "arduino", "platforms": "atmelavr" diff --git a/library.properties b/library.properties index 840e1a3..fb07125 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduboy2 -version=2.1.0 +version=3.0.0 author=Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen, Ross O. Shoger maintainer=Scott Allen saydisp-git@yahoo.ca sentence=An alternative library for use with the Arduboy game system. diff --git a/src/Arduboy2.h b/src/Arduboy2.h index 87f2211..cee024c 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -2,7 +2,7 @@ #define ARDUBOY2_H #include -#include "ArduboyCore.h" +#include "Arduboy2Core.h" #include "Sprites.h" #include #include @@ -11,7 +11,7 @@ // For a version number in the form of x.y.z the value of the define will be // ((x * 10000) + (y * 100) + (z)) as a decimal number. // So, it will read as xxxyyzz, with no leading zeros on x. -#define ARDUBOY_LIB_VER 20100 +#define ARDUBOY_LIB_VER 30000 // EEPROM settings #define EEPROM_VERSION 0 @@ -22,7 +22,7 @@ #define EEPROM_STORAGE_SPACE_START 16 // and onward // eeprom settings above are neded for audio -#include "ArduboyAudio.h" +#include "Arduboy2Audio.h" #define PIXEL_SAFE_MODE @@ -57,14 +57,14 @@ struct Point //========== Arduboy2Base ========== //================================== -class Arduboy2Base : public ArduboyCore +class Arduboy2Base : public Arduboy2Core { friend class Sprites; public: Arduboy2Base(); - ArduboyAudio audio; + Arduboy2Audio audio; /// Initialize hardware, boot logo, boot utilities, etc. /** diff --git a/src/ArduboyAudio.cpp b/src/Arduboy2Audio.cpp similarity index 71% rename from src/ArduboyAudio.cpp rename to src/Arduboy2Audio.cpp index 5e8db9e..12bd95b 100644 --- a/src/ArduboyAudio.cpp +++ b/src/Arduboy2Audio.cpp @@ -1,9 +1,9 @@ #include "Arduboy2.h" -#include "ArduboyAudio.h" +#include "Arduboy2Audio.h" -bool ArduboyAudio::audio_enabled = false; +bool Arduboy2Audio::audio_enabled = false; -void ArduboyAudio::on() +void Arduboy2Audio::on() { // fire up audio pins #ifdef ARDUBOY_10 @@ -15,7 +15,7 @@ void ArduboyAudio::on() audio_enabled = true; } -void ArduboyAudio::off() +void Arduboy2Audio::off() { audio_enabled = false; // shut off audio pins @@ -27,18 +27,18 @@ void ArduboyAudio::off() #endif } -void ArduboyAudio::saveOnOff() +void Arduboy2Audio::saveOnOff() { EEPROM.update(EEPROM_AUDIO_ON_OFF, audio_enabled); } -void ArduboyAudio::begin() +void Arduboy2Audio::begin() { if (EEPROM.read(EEPROM_AUDIO_ON_OFF)) on(); } -bool ArduboyAudio::enabled() +bool Arduboy2Audio::enabled() { return audio_enabled; } diff --git a/src/ArduboyAudio.h b/src/Arduboy2Audio.h similarity index 76% rename from src/ArduboyAudio.h rename to src/Arduboy2Audio.h index 0b8ae9b..14e8732 100644 --- a/src/ArduboyAudio.h +++ b/src/Arduboy2Audio.h @@ -1,10 +1,10 @@ -#ifndef ARDUBOY_AUDIO_H -#define ARDUBOY_AUDIO_H +#ifndef ARDUBOY2_AUDIO_H +#define ARDUBOY2_AUDIO_H #include #include -class ArduboyAudio +class Arduboy2Audio { public: void static begin(); diff --git a/src/ArduboyCore.cpp b/src/Arduboy2Core.cpp similarity index 86% rename from src/ArduboyCore.cpp rename to src/Arduboy2Core.cpp index a5dc51e..e83640d 100644 --- a/src/ArduboyCore.cpp +++ b/src/Arduboy2Core.cpp @@ -1,8 +1,8 @@ -#include "ArduboyCore.h" +#include "Arduboy2Core.h" // need to redeclare these here since we declare them static in .h -volatile uint8_t *ArduboyCore::csport, *ArduboyCore::dcport; -uint8_t ArduboyCore::cspinmask, ArduboyCore::dcpinmask; +volatile uint8_t *Arduboy2Core::csport, *Arduboy2Core::dcport; +uint8_t Arduboy2Core::cspinmask, Arduboy2Core::dcpinmask; const uint8_t PROGMEM pinBootProgram[] = { // buttons @@ -99,9 +99,9 @@ const uint8_t PROGMEM lcdBootProgram[] = { }; -ArduboyCore::ArduboyCore() {} +Arduboy2Core::Arduboy2Core() {} -void ArduboyCore::boot() +void Arduboy2Core::boot() { #ifdef ARDUBOY_SET_CPU_8MHZ // ARDUBOY_SET_CPU_8MHZ will be set by the IDE using boards.txt @@ -125,7 +125,7 @@ void ArduboyCore::boot() // hardware clock on the Arduboy is 16MHz. // We also need to readjust the PLL prescaler because the Arduino USB code // likely will have incorrectly set it for an 8MHz hardware clock. -void ArduboyCore::setCPUSpeed8MHz() +void Arduboy2Core::setCPUSpeed8MHz() { uint8_t oldSREG = SREG; cli(); // suspend interrupts @@ -137,7 +137,7 @@ void ArduboyCore::setCPUSpeed8MHz() } #endif -void ArduboyCore::bootPins() +void Arduboy2Core::bootPins() { uint8_t pin, mode; const uint8_t *i = pinBootProgram; @@ -156,7 +156,7 @@ void ArduboyCore::bootPins() digitalWrite(RST, HIGH); // bring out of reset } -void ArduboyCore::bootOLED() +void Arduboy2Core::bootOLED() { // setup the ports we need to talk to the OLED csport = portOutputRegister(digitalPinToPort(CS)); @@ -175,13 +175,13 @@ void ArduboyCore::bootOLED() LCDDataMode(); } -void ArduboyCore::LCDDataMode() +void Arduboy2Core::LCDDataMode() { *dcport |= dcpinmask; *csport &= ~cspinmask; } -void ArduboyCore::LCDCommandMode() +void Arduboy2Core::LCDCommandMode() { *csport |= cspinmask; *dcport &= ~dcpinmask; @@ -190,7 +190,7 @@ void ArduboyCore::LCDCommandMode() -void ArduboyCore::safeMode() +void Arduboy2Core::safeMode() { blank(); // too avoid random gibberish while (true) { @@ -201,13 +201,13 @@ void ArduboyCore::safeMode() /* Power Management */ -void ArduboyCore::idle() +void Arduboy2Core::idle() { set_sleep_mode(SLEEP_MODE_IDLE); sleep_mode(); } -void ArduboyCore::bootPowerSaving() +void Arduboy2Core::bootPowerSaving() { power_adc_disable(); power_usart0_disable(); @@ -220,19 +220,19 @@ void ArduboyCore::bootPowerSaving() // power_usb_disable() } -uint8_t ArduboyCore::width() { return WIDTH; } +uint8_t Arduboy2Core::width() { return WIDTH; } -uint8_t ArduboyCore::height() { return HEIGHT; } +uint8_t Arduboy2Core::height() { return HEIGHT; } /* Drawing */ -void ArduboyCore::paint8Pixels(uint8_t pixels) +void Arduboy2Core::paint8Pixels(uint8_t pixels) { SPI.transfer(pixels); } -void ArduboyCore::paintScreen(const uint8_t *image) +void Arduboy2Core::paintScreen(const uint8_t *image) { for (int i = 0; i < (HEIGHT*WIDTH)/8; i++) { @@ -242,7 +242,7 @@ void ArduboyCore::paintScreen(const uint8_t *image) // paint from a memory buffer, this should be FAST as it's likely what // will be used by any buffer based subclass -void ArduboyCore::paintScreen(uint8_t image[]) +void Arduboy2Core::paintScreen(uint8_t image[]) { uint8_t c; int i = 0; @@ -266,13 +266,13 @@ void ArduboyCore::paintScreen(uint8_t image[]) while (!(SPSR & _BV(SPIF))) { } // wait for the last byte to be sent } -void ArduboyCore::blank() +void Arduboy2Core::blank() { for (int i = 0; i < (HEIGHT*WIDTH)/8; i++) SPI.transfer(0x00); } -void ArduboyCore::sendLCDCommand(uint8_t command) +void Arduboy2Core::sendLCDCommand(uint8_t command) { LCDCommandMode(); SPI.transfer(command); @@ -281,33 +281,33 @@ void ArduboyCore::sendLCDCommand(uint8_t command) // invert the display or set to normal // when inverted, a pixel set to 0 will be on -void ArduboyCore::invert(bool inverse) +void Arduboy2Core::invert(bool inverse) { sendLCDCommand(inverse ? OLED_PIXELS_INVERTED : OLED_PIXELS_NORMAL); } // turn all display pixels on, ignoring buffer contents // or set to normal buffer display -void ArduboyCore::allPixelsOn(bool on) +void Arduboy2Core::allPixelsOn(bool on) { sendLCDCommand(on ? OLED_ALL_PIXELS_ON : OLED_PIXELS_FROM_RAM); } // flip the display vertically or set to normal -void ArduboyCore::flipVertical(bool flipped) +void Arduboy2Core::flipVertical(bool flipped) { sendLCDCommand(flipped ? OLED_VERTICAL_FLIPPED : OLED_VERTICAL_NORMAL); } // flip the display horizontally or set to normal -void ArduboyCore::flipHorizontal(bool flipped) +void Arduboy2Core::flipHorizontal(bool flipped) { sendLCDCommand(flipped ? OLED_HORIZ_FLIPPED : OLED_HORIZ_NORMAL); } /* RGB LED */ -void ArduboyCore::setRGBled(uint8_t red, uint8_t green, uint8_t blue) +void Arduboy2Core::setRGBled(uint8_t red, uint8_t green, uint8_t blue) { #ifdef ARDUBOY_10 // RGB, all the pretty colors // inversion is necessary because these are common annode LEDs @@ -320,7 +320,7 @@ void ArduboyCore::setRGBled(uint8_t red, uint8_t green, uint8_t blue) #endif } - void ArduboyCore::digitalWriteRGB(uint8_t red, uint8_t green, uint8_t blue) + void Arduboy2Core::digitalWriteRGB(uint8_t red, uint8_t green, uint8_t blue) { #ifdef ARDUBOY_10 digitalWrite(RED_LED, red); @@ -333,7 +333,7 @@ void ArduboyCore::setRGBled(uint8_t red, uint8_t green, uint8_t blue) /* Buttons */ -uint8_t ArduboyCore::buttonsState() +uint8_t Arduboy2Core::buttonsState() { uint8_t buttons; diff --git a/src/ArduboyCore.h b/src/Arduboy2Core.h similarity index 99% rename from src/ArduboyCore.h rename to src/Arduboy2Core.h index 0d68373..f110c6b 100644 --- a/src/ArduboyCore.h +++ b/src/Arduboy2Core.h @@ -1,5 +1,5 @@ -#ifndef ARDUBOY_CORE_H -#define ARDUBOY_CORE_H +#ifndef ARDUBOY2_CORE_H +#define ARDUBOY2_CORE_H #include #include @@ -134,10 +134,10 @@ #define PAGE_ADDRESS_END ((HEIGHT/8)-1) & 7 // 8 pages high -class ArduboyCore +class Arduboy2Core { public: - ArduboyCore(); + Arduboy2Core(); /// allows the CPU to idle between frames /**