Rename Arduboy... classes to Arduboy2...

Change ArduboyCore to Arduboy2Core and ArduboyAudio to Arduboy2Audio
Rename files accordingly
Change version to 3.0.0
This commit is contained in:
Scott Allen 2016-10-27 14:59:56 -04:00
parent 0cb37455c6
commit 867f2d000c
7 changed files with 48 additions and 48 deletions

View File

@ -7,7 +7,7 @@
"type": "git", "type": "git",
"url": "https://github.com/MLXXXp/Arduboy2.git" "url": "https://github.com/MLXXXp/Arduboy2.git"
}, },
"version": "2.1.0", "version": "3.0.0",
"exclude": "extras", "exclude": "extras",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": "atmelavr" "platforms": "atmelavr"

View File

@ -1,5 +1,5 @@
name=Arduboy2 name=Arduboy2
version=2.1.0 version=3.0.0
author=Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen, Ross O. Shoger author=Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen, Ross O. Shoger
maintainer=Scott Allen saydisp-git@yahoo.ca maintainer=Scott Allen saydisp-git@yahoo.ca
sentence=An alternative library for use with the Arduboy game system. sentence=An alternative library for use with the Arduboy game system.

View File

@ -2,7 +2,7 @@
#define ARDUBOY2_H #define ARDUBOY2_H
#include <Arduino.h> #include <Arduino.h>
#include "ArduboyCore.h" #include "Arduboy2Core.h"
#include "Sprites.h" #include "Sprites.h"
#include <Print.h> #include <Print.h>
#include <limits.h> #include <limits.h>
@ -11,7 +11,7 @@
// For a version number in the form of x.y.z the value of the define will be // 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. // ((x * 10000) + (y * 100) + (z)) as a decimal number.
// So, it will read as xxxyyzz, with no leading zeros on x. // So, it will read as xxxyyzz, with no leading zeros on x.
#define ARDUBOY_LIB_VER 20100 #define ARDUBOY_LIB_VER 30000
// EEPROM settings // EEPROM settings
#define EEPROM_VERSION 0 #define EEPROM_VERSION 0
@ -22,7 +22,7 @@
#define EEPROM_STORAGE_SPACE_START 16 // and onward #define EEPROM_STORAGE_SPACE_START 16 // and onward
// eeprom settings above are neded for audio // eeprom settings above are neded for audio
#include "ArduboyAudio.h" #include "Arduboy2Audio.h"
#define PIXEL_SAFE_MODE #define PIXEL_SAFE_MODE
@ -57,14 +57,14 @@ struct Point
//========== Arduboy2Base ========== //========== Arduboy2Base ==========
//================================== //==================================
class Arduboy2Base : public ArduboyCore class Arduboy2Base : public Arduboy2Core
{ {
friend class Sprites; friend class Sprites;
public: public:
Arduboy2Base(); Arduboy2Base();
ArduboyAudio audio; Arduboy2Audio audio;
/// Initialize hardware, boot logo, boot utilities, etc. /// Initialize hardware, boot logo, boot utilities, etc.
/** /**

View File

@ -1,9 +1,9 @@
#include "Arduboy2.h" #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 // fire up audio pins
#ifdef ARDUBOY_10 #ifdef ARDUBOY_10
@ -15,7 +15,7 @@ void ArduboyAudio::on()
audio_enabled = true; audio_enabled = true;
} }
void ArduboyAudio::off() void Arduboy2Audio::off()
{ {
audio_enabled = false; audio_enabled = false;
// shut off audio pins // shut off audio pins
@ -27,18 +27,18 @@ void ArduboyAudio::off()
#endif #endif
} }
void ArduboyAudio::saveOnOff() void Arduboy2Audio::saveOnOff()
{ {
EEPROM.update(EEPROM_AUDIO_ON_OFF, audio_enabled); EEPROM.update(EEPROM_AUDIO_ON_OFF, audio_enabled);
} }
void ArduboyAudio::begin() void Arduboy2Audio::begin()
{ {
if (EEPROM.read(EEPROM_AUDIO_ON_OFF)) if (EEPROM.read(EEPROM_AUDIO_ON_OFF))
on(); on();
} }
bool ArduboyAudio::enabled() bool Arduboy2Audio::enabled()
{ {
return audio_enabled; return audio_enabled;
} }

View File

@ -1,10 +1,10 @@
#ifndef ARDUBOY_AUDIO_H #ifndef ARDUBOY2_AUDIO_H
#define ARDUBOY_AUDIO_H #define ARDUBOY2_AUDIO_H
#include <Arduino.h> #include <Arduino.h>
#include <EEPROM.h> #include <EEPROM.h>
class ArduboyAudio class Arduboy2Audio
{ {
public: public:
void static begin(); void static begin();

View File

@ -1,8 +1,8 @@
#include "ArduboyCore.h" #include "Arduboy2Core.h"
// need to redeclare these here since we declare them static in .h // need to redeclare these here since we declare them static in .h
volatile uint8_t *ArduboyCore::csport, *ArduboyCore::dcport; volatile uint8_t *Arduboy2Core::csport, *Arduboy2Core::dcport;
uint8_t ArduboyCore::cspinmask, ArduboyCore::dcpinmask; uint8_t Arduboy2Core::cspinmask, Arduboy2Core::dcpinmask;
const uint8_t PROGMEM pinBootProgram[] = { const uint8_t PROGMEM pinBootProgram[] = {
// buttons // 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 #ifdef ARDUBOY_SET_CPU_8MHZ
// ARDUBOY_SET_CPU_8MHZ will be set by the IDE using boards.txt // 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. // hardware clock on the Arduboy is 16MHz.
// We also need to readjust the PLL prescaler because the Arduino USB code // We also need to readjust the PLL prescaler because the Arduino USB code
// likely will have incorrectly set it for an 8MHz hardware clock. // likely will have incorrectly set it for an 8MHz hardware clock.
void ArduboyCore::setCPUSpeed8MHz() void Arduboy2Core::setCPUSpeed8MHz()
{ {
uint8_t oldSREG = SREG; uint8_t oldSREG = SREG;
cli(); // suspend interrupts cli(); // suspend interrupts
@ -137,7 +137,7 @@ void ArduboyCore::setCPUSpeed8MHz()
} }
#endif #endif
void ArduboyCore::bootPins() void Arduboy2Core::bootPins()
{ {
uint8_t pin, mode; uint8_t pin, mode;
const uint8_t *i = pinBootProgram; const uint8_t *i = pinBootProgram;
@ -156,7 +156,7 @@ void ArduboyCore::bootPins()
digitalWrite(RST, HIGH); // bring out of reset digitalWrite(RST, HIGH); // bring out of reset
} }
void ArduboyCore::bootOLED() void Arduboy2Core::bootOLED()
{ {
// setup the ports we need to talk to the OLED // setup the ports we need to talk to the OLED
csport = portOutputRegister(digitalPinToPort(CS)); csport = portOutputRegister(digitalPinToPort(CS));
@ -175,13 +175,13 @@ void ArduboyCore::bootOLED()
LCDDataMode(); LCDDataMode();
} }
void ArduboyCore::LCDDataMode() void Arduboy2Core::LCDDataMode()
{ {
*dcport |= dcpinmask; *dcport |= dcpinmask;
*csport &= ~cspinmask; *csport &= ~cspinmask;
} }
void ArduboyCore::LCDCommandMode() void Arduboy2Core::LCDCommandMode()
{ {
*csport |= cspinmask; *csport |= cspinmask;
*dcport &= ~dcpinmask; *dcport &= ~dcpinmask;
@ -190,7 +190,7 @@ void ArduboyCore::LCDCommandMode()
void ArduboyCore::safeMode() void Arduboy2Core::safeMode()
{ {
blank(); // too avoid random gibberish blank(); // too avoid random gibberish
while (true) { while (true) {
@ -201,13 +201,13 @@ void ArduboyCore::safeMode()
/* Power Management */ /* Power Management */
void ArduboyCore::idle() void Arduboy2Core::idle()
{ {
set_sleep_mode(SLEEP_MODE_IDLE); set_sleep_mode(SLEEP_MODE_IDLE);
sleep_mode(); sleep_mode();
} }
void ArduboyCore::bootPowerSaving() void Arduboy2Core::bootPowerSaving()
{ {
power_adc_disable(); power_adc_disable();
power_usart0_disable(); power_usart0_disable();
@ -220,19 +220,19 @@ void ArduboyCore::bootPowerSaving()
// power_usb_disable() // 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 */ /* Drawing */
void ArduboyCore::paint8Pixels(uint8_t pixels) void Arduboy2Core::paint8Pixels(uint8_t pixels)
{ {
SPI.transfer(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++) 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 // paint from a memory buffer, this should be FAST as it's likely what
// will be used by any buffer based subclass // will be used by any buffer based subclass
void ArduboyCore::paintScreen(uint8_t image[]) void Arduboy2Core::paintScreen(uint8_t image[])
{ {
uint8_t c; uint8_t c;
int i = 0; 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 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++) for (int i = 0; i < (HEIGHT*WIDTH)/8; i++)
SPI.transfer(0x00); SPI.transfer(0x00);
} }
void ArduboyCore::sendLCDCommand(uint8_t command) void Arduboy2Core::sendLCDCommand(uint8_t command)
{ {
LCDCommandMode(); LCDCommandMode();
SPI.transfer(command); SPI.transfer(command);
@ -281,33 +281,33 @@ void ArduboyCore::sendLCDCommand(uint8_t command)
// invert the display or set to normal // invert the display or set to normal
// when inverted, a pixel set to 0 will be on // 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); sendLCDCommand(inverse ? OLED_PIXELS_INVERTED : OLED_PIXELS_NORMAL);
} }
// turn all display pixels on, ignoring buffer contents // turn all display pixels on, ignoring buffer contents
// or set to normal buffer display // 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); sendLCDCommand(on ? OLED_ALL_PIXELS_ON : OLED_PIXELS_FROM_RAM);
} }
// flip the display vertically or set to normal // 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); sendLCDCommand(flipped ? OLED_VERTICAL_FLIPPED : OLED_VERTICAL_NORMAL);
} }
// flip the display horizontally or set to 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); sendLCDCommand(flipped ? OLED_HORIZ_FLIPPED : OLED_HORIZ_NORMAL);
} }
/* RGB LED */ /* 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 #ifdef ARDUBOY_10 // RGB, all the pretty colors
// inversion is necessary because these are common annode LEDs // 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 #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 #ifdef ARDUBOY_10
digitalWrite(RED_LED, red); digitalWrite(RED_LED, red);
@ -333,7 +333,7 @@ void ArduboyCore::setRGBled(uint8_t red, uint8_t green, uint8_t blue)
/* Buttons */ /* Buttons */
uint8_t ArduboyCore::buttonsState() uint8_t Arduboy2Core::buttonsState()
{ {
uint8_t buttons; uint8_t buttons;

View File

@ -1,5 +1,5 @@
#ifndef ARDUBOY_CORE_H #ifndef ARDUBOY2_CORE_H
#define ARDUBOY_CORE_H #define ARDUBOY2_CORE_H
#include <Arduino.h> #include <Arduino.h>
#include <avr/power.h> #include <avr/power.h>
@ -134,10 +134,10 @@
#define PAGE_ADDRESS_END ((HEIGHT/8)-1) & 7 // 8 pages high #define PAGE_ADDRESS_END ((HEIGHT/8)-1) & 7 // 8 pages high
class ArduboyCore class Arduboy2Core
{ {
public: public:
ArduboyCore(); Arduboy2Core();
/// allows the CPU to idle between frames /// allows the CPU to idle between frames
/** /**