mirror of https://github.com/MLXXXp/Arduboy2.git
Repackaged
This commit is contained in:
parent
e0ff80a803
commit
f2e6f4f9cb
|
|
@ -1 +0,0 @@
|
|||
doxygen/
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
version 2.1 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <Arduboy2.h>
|
||||
#include "Arduboy2.h"
|
||||
|
||||
// block in EEPROM to save high scores
|
||||
#define EE_FILE 2
|
||||
|
|
@ -19,7 +19,8 @@
|
|||
Arduboy2 arduboy;
|
||||
BeepPin1 beep;
|
||||
|
||||
const unsigned int FRAME_RATE = 40; // Frame rate in frames per second
|
||||
const unsigned int FRAME_RATE = 30; // Frame rate in frames per second
|
||||
const unsigned int MENU_FRAME_RATE = 2; // Frame rate in frames per second
|
||||
const unsigned int COLUMNS = 13; //Columns of bricks
|
||||
const unsigned int ROWS = 4; //Rows of bricks
|
||||
int dx = -1; //Initial movement of ball
|
||||
|
|
@ -56,6 +57,9 @@ byte bottomBrick;
|
|||
|
||||
byte tick;
|
||||
|
||||
uint8_t brightness = 0; // how bright the LEDs are
|
||||
int8_t fadeAmount = 1; // how many points to fade the LEDs by
|
||||
|
||||
void setup()
|
||||
{
|
||||
arduboy.begin();
|
||||
|
|
@ -102,7 +106,7 @@ void loop()
|
|||
drawPaddle();
|
||||
|
||||
//Pause game if FIRE pressed
|
||||
pad = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
|
||||
pad = arduboy.pressed(DOWN_BUTTON);
|
||||
|
||||
if(pad == true && oldpad == false && released)
|
||||
{
|
||||
|
|
@ -142,18 +146,18 @@ void movePaddle()
|
|||
//Move right
|
||||
if(xPaddle < WIDTH - 12)
|
||||
{
|
||||
if (arduboy.pressed(RIGHT_BUTTON))
|
||||
if (arduboy.pressed(UP_BUTTON))
|
||||
{
|
||||
xPaddle+=2;
|
||||
xPaddle+=3;
|
||||
}
|
||||
}
|
||||
|
||||
//Move left
|
||||
if(xPaddle > 0)
|
||||
{
|
||||
if (arduboy.pressed(LEFT_BUTTON))
|
||||
if (arduboy.pressed(B_BUTTON))
|
||||
{
|
||||
xPaddle-=2;
|
||||
xPaddle-=3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -295,7 +299,7 @@ void moveBall()
|
|||
xb=xPaddle + 5;
|
||||
|
||||
//Release ball if FIRE pressed
|
||||
pad3 = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
|
||||
pad3 = arduboy.pressed(DOWN_BUTTON);
|
||||
if (pad3 == true && oldpad3 == false)
|
||||
{
|
||||
released = true;
|
||||
|
|
@ -367,7 +371,7 @@ void pause()
|
|||
{
|
||||
arduboy.delayShort(150);
|
||||
//Unpause if FIRE is pressed
|
||||
pad2 = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
|
||||
pad2 = arduboy.pressed(DOWN_BUTTON);
|
||||
if (pad2 == true && oldpad2 == false && released)
|
||||
{
|
||||
arduboy.fillRect(52, 45, 30, 11, 0);
|
||||
|
|
@ -383,8 +387,7 @@ void Score()
|
|||
score += (level*10);
|
||||
}
|
||||
|
||||
void newLevel()
|
||||
{
|
||||
void newLevel(){
|
||||
//Undraw paddle
|
||||
arduboy.drawRect(xPaddle, 63, 11, 1, 0);
|
||||
|
||||
|
|
@ -418,10 +421,23 @@ boolean pollFireButton(int n)
|
|||
{
|
||||
for(int i = 0; i < n; i++)
|
||||
{
|
||||
arduboy.delayShort(15);
|
||||
pad = arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON);
|
||||
// set the brightness of the LEDs
|
||||
arduboy.setRGBled(brightness, 255 - brightness, 0);
|
||||
|
||||
// change the brightness for next time through the loop
|
||||
brightness = brightness + fadeAmount;
|
||||
|
||||
// reverse the direction of the fading at the ends of the fade
|
||||
if (brightness == 0 || brightness == 255) fadeAmount = -fadeAmount;
|
||||
|
||||
arduboy.delayShort(10);
|
||||
pad = arduboy.pressed(DOWN_BUTTON);
|
||||
if(pad == true && oldpad == false)
|
||||
{
|
||||
brightness = 0; // how bright the LEDs are
|
||||
fadeAmount = 1; // how many points to fade the LEDs by
|
||||
arduboy.setRGBled(0, 0, 0); // set the brightness of the LEDs
|
||||
|
||||
oldpad3 = true; //Forces pad loop 3 to run once
|
||||
return true;
|
||||
}
|
||||
|
|
@ -528,6 +544,9 @@ void enterInitials()
|
|||
{
|
||||
byte index = 0;
|
||||
|
||||
// Lower the frame rate otherwise the intials input is too fast
|
||||
arduboy.setFrameRate(MENU_FRAME_RATE);
|
||||
|
||||
arduboy.clear();
|
||||
|
||||
initials[0] = ' ';
|
||||
|
|
@ -558,7 +577,7 @@ void enterInitials()
|
|||
arduboy.drawLine(56 + (index*8), 28, 56 + (index*8) + 6, 28, 1);
|
||||
arduboy.delayShort(70);
|
||||
|
||||
if (arduboy.pressed(LEFT_BUTTON) || arduboy.pressed(B_BUTTON))
|
||||
if (arduboy.pressed(LEFT_BUTTON))
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
|
|
@ -617,13 +636,16 @@ void enterInitials()
|
|||
}
|
||||
}
|
||||
|
||||
if (arduboy.pressed(A_BUTTON))
|
||||
if (arduboy.pressed(B_BUTTON))
|
||||
{
|
||||
playToneTimed(1046, 80);
|
||||
if (index < 2)
|
||||
{
|
||||
index++;
|
||||
} else {
|
||||
// Go back to standard frame rate
|
||||
arduboy.setFrameRate(FRAME_RATE);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -715,3 +737,4 @@ void playToneTimed(unsigned int frequency, unsigned int duration)
|
|||
arduboy.delayShort(duration);
|
||||
beep.noTone();
|
||||
}
|
||||
|
||||
|
|
@ -33,23 +33,24 @@ void Arduboy2Base::begin()
|
|||
|
||||
display(); // blank the display (sBuffer is global, so cleared automatically)
|
||||
|
||||
flashlight(); // light the RGB LED and screen if UP button is being held.
|
||||
// flashlight(); // light the RGB LED and screen if UP button is being held.
|
||||
|
||||
// check for and handle buttons held during start up for system control
|
||||
systemButtons();
|
||||
// systemButtons();
|
||||
|
||||
audio.begin();
|
||||
audio.on(); // changed from audio.begin() because EEPROM state may
|
||||
// not necessarily follow Arduboy rules on a watchX!
|
||||
|
||||
bootLogo();
|
||||
// alternative logo functions. Work the same as bootLogo() but may reduce
|
||||
// memory size if the sketch uses the same bitmap drawing function
|
||||
// bootLogo();
|
||||
// bootLogoCompressed();
|
||||
// bootLogoSpritesSelfMasked();
|
||||
// bootLogoSpritesOverwrite();
|
||||
// bootLogoSpritesBSelfMasked();
|
||||
// bootLogoSpritesBOverwrite();
|
||||
|
||||
waitNoButtons(); // wait for all buttons to be released
|
||||
// waitNoButtons(); // wait for all buttons to be released
|
||||
}
|
||||
|
||||
void Arduboy2Base::flashlight()
|
||||
|
|
@ -279,7 +280,7 @@ unsigned long Arduboy2Base::generateRandomSeed()
|
|||
{
|
||||
unsigned long seed;
|
||||
|
||||
power_adc_enable(); // ADC on
|
||||
// power_adc_enable(); // ADC on
|
||||
|
||||
// do an ADC read from an unconnected input pin
|
||||
ADCSRA |= _BV(ADSC); // start conversion (ADMUX has been pre-set in boot())
|
||||
|
|
@ -287,7 +288,7 @@ unsigned long Arduboy2Base::generateRandomSeed()
|
|||
|
||||
seed = ((unsigned long)ADC << 16) + micros();
|
||||
|
||||
power_adc_disable(); // ADC off
|
||||
// power_adc_disable(); // ADC off
|
||||
|
||||
return seed;
|
||||
}
|
||||
|
|
@ -12,12 +12,7 @@ bool Arduboy2Audio::audio_enabled = false;
|
|||
void Arduboy2Audio::on()
|
||||
{
|
||||
// fire up audio pins by seting them as outputs
|
||||
#ifdef ARDUBOY_10
|
||||
bitSet(SPEAKER_1_DDR, SPEAKER_1_BIT);
|
||||
bitSet(SPEAKER_2_DDR, SPEAKER_2_BIT);
|
||||
#else
|
||||
bitSet(SPEAKER_1_DDR, SPEAKER_1_BIT);
|
||||
#endif
|
||||
bitSet(SPEAKER_DDR, SPEAKER_BIT);
|
||||
audio_enabled = true;
|
||||
}
|
||||
|
||||
|
|
@ -25,12 +20,7 @@ void Arduboy2Audio::off()
|
|||
{
|
||||
audio_enabled = false;
|
||||
// shut off audio pins by setting them as inputs
|
||||
#ifdef ARDUBOY_10
|
||||
bitClear(SPEAKER_1_DDR, SPEAKER_1_BIT);
|
||||
bitClear(SPEAKER_2_DDR, SPEAKER_2_BIT);
|
||||
#else
|
||||
bitClear(SPEAKER_1_DDR, SPEAKER_1_BIT);
|
||||
#endif
|
||||
bitClear(SPEAKER_DDR, SPEAKER_BIT);
|
||||
}
|
||||
|
||||
void Arduboy2Audio::toggle()
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* @file Arduboy2Beep.cpp
|
||||
* \brief
|
||||
* Classes to generate simple square wave tones on the Arduboy speaker pins.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Arduboy2Beep.h"
|
||||
|
||||
// Speaker pin, Timer 1A, Port B bit 5, Arduino pin 9
|
||||
|
||||
uint8_t BeepPin1::duration = 0;
|
||||
|
||||
void BeepPin1::begin()
|
||||
{
|
||||
TCCR1A = 0;
|
||||
TCCR1B = (bit(WGM32) | bit(CS31)); // CTC mode. Divide by 8 clock prescale
|
||||
}
|
||||
|
||||
void BeepPin1::tone(uint16_t count)
|
||||
{
|
||||
tone(count, 0);
|
||||
}
|
||||
|
||||
void BeepPin1::tone(uint16_t count, uint8_t dur)
|
||||
{
|
||||
duration = dur;
|
||||
TCCR1A = bit(COM1A0); // set toggle on compare mode (which connects the pin)
|
||||
OCR1A = count; // load the count (16 bits), which determines the frequency
|
||||
}
|
||||
|
||||
void BeepPin1::timer()
|
||||
{
|
||||
if (duration && (--duration == 0)) {
|
||||
TCCR1A = 0; // set normal mode (which disconnects the pin)
|
||||
}
|
||||
}
|
||||
|
||||
void BeepPin1::noTone()
|
||||
{
|
||||
duration = 0;
|
||||
TCCR1A = 0; // set normal mode (which disconnects the pin)
|
||||
}
|
||||
|
||||
// The following "dummy" function will compile and
|
||||
// operate properly but no sound will be produced
|
||||
|
||||
uint8_t BeepPin2::duration = 0;
|
||||
|
||||
void BeepPin2::begin()
|
||||
{
|
||||
}
|
||||
|
||||
void BeepPin2::tone(uint16_t count)
|
||||
{
|
||||
tone(count, 0);
|
||||
}
|
||||
|
||||
void BeepPin2::tone(uint16_t count, uint8_t dur)
|
||||
{
|
||||
(void) count; // parameter not used
|
||||
|
||||
duration = dur;
|
||||
}
|
||||
|
||||
void BeepPin2::timer()
|
||||
{
|
||||
if (duration) {
|
||||
--duration;
|
||||
}
|
||||
}
|
||||
|
||||
void BeepPin2::noTone()
|
||||
{
|
||||
duration = 0;
|
||||
}
|
||||
|
||||
|
|
@ -110,87 +110,52 @@ void Arduboy2Core::setCPUSpeed8MHz()
|
|||
// This routine must be modified if any pins are moved to a different port
|
||||
void Arduboy2Core::bootPins()
|
||||
{
|
||||
#ifdef ARDUBOY_10
|
||||
|
||||
// Port B INPUT_PULLUP or HIGH
|
||||
PORTB |= _BV(RED_LED_BIT) | _BV(GREEN_LED_BIT) | _BV(BLUE_LED_BIT) |
|
||||
_BV(B_BUTTON_BIT);
|
||||
// Port B INPUT or LOW (none)
|
||||
PORTB |= _BV(B_BUTTON_BIT) | _BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT);
|
||||
// Port B INPUT or LOW
|
||||
PORTB &= ~(_BV(SPEAKER_BIT));
|
||||
// Port B inputs
|
||||
DDRB &= ~(_BV(B_BUTTON_BIT) | _BV(SPI_MISO_BIT));
|
||||
// Port B outputs
|
||||
DDRB |= _BV(RED_LED_BIT) | _BV(GREEN_LED_BIT) | _BV(BLUE_LED_BIT) |
|
||||
_BV(SPI_MOSI_BIT) | _BV(SPI_SCK_BIT) | _BV(SPI_SS_BIT);
|
||||
|
||||
// Port C
|
||||
// Speaker: Not set here. Controlled by audio class
|
||||
|
||||
// Port D INPUT_PULLUP or HIGH
|
||||
PORTD |= _BV(CS_BIT);
|
||||
// Port D INPUT or LOW
|
||||
PORTD &= ~(_BV(RST_BIT));
|
||||
// Port D inputs (none)
|
||||
// Port D outputs
|
||||
DDRD |= _BV(RST_BIT) | _BV(CS_BIT) | _BV(DC_BIT);
|
||||
|
||||
// Port E INPUT_PULLUP or HIGH
|
||||
PORTE |= _BV(A_BUTTON_BIT);
|
||||
// Port E INPUT or LOW (none)
|
||||
// Port E inputs
|
||||
DDRE &= ~(_BV(A_BUTTON_BIT));
|
||||
// Port E outputs (none)
|
||||
|
||||
// Port F INPUT_PULLUP or HIGH
|
||||
PORTF |= _BV(LEFT_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) |
|
||||
_BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT);
|
||||
// Port F INPUT or LOW
|
||||
PORTF &= ~(_BV(RAND_SEED_IN_BIT));
|
||||
// Port F inputs
|
||||
DDRF &= ~(_BV(LEFT_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) |
|
||||
_BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) |
|
||||
_BV(RAND_SEED_IN_BIT));
|
||||
// Port F outputs (none)
|
||||
|
||||
#elif defined(AB_DEVKIT)
|
||||
|
||||
// Port B INPUT_PULLUP or HIGH
|
||||
PORTB |= _BV(LEFT_BUTTON_BIT) | _BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) |
|
||||
_BV(BLUE_LED_BIT);
|
||||
// Port B INPUT or LOW (none)
|
||||
// Port B inputs
|
||||
DDRB &= ~(_BV(LEFT_BUTTON_BIT) | _BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) |
|
||||
DDRB &= ~(_BV(B_BUTTON_BIT) | _BV(UP_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT) |
|
||||
_BV(SPI_MISO_BIT));
|
||||
// Port B outputs
|
||||
DDRB |= _BV(SPI_MOSI_BIT) | _BV(SPI_SCK_BIT) | _BV(SPI_SS_BIT) |
|
||||
_BV(BLUE_LED_BIT);
|
||||
_BV(SPEAKER_BIT);
|
||||
|
||||
// Port C INPUT_PULLUP or HIGH
|
||||
PORTC |= _BV(RIGHT_BUTTON_BIT);
|
||||
// Port C INPUT or LOW (none)
|
||||
// Port C INPUT_PULLUP or HIGH (none)
|
||||
// Port C INPUT or LOW
|
||||
PORTC &= ~(_BV(BATT_STAT_BIT) | _BV(LEDL_BIT));
|
||||
// Port C inputs
|
||||
DDRC &= ~(_BV(RIGHT_BUTTON_BIT));
|
||||
// Port C outputs (none)
|
||||
DDRC &= ~(_BV(BATT_STAT_BIT));
|
||||
// Port C outputs
|
||||
DDRC |= _BV(LEDL_BIT);
|
||||
|
||||
// Port D INPUT_PULLUP or HIGH
|
||||
PORTD |= _BV(CS_BIT);
|
||||
// Port D INPUT_PULLUP or HIGH (none)
|
||||
// Port D INPUT or LOW
|
||||
PORTD &= ~(_BV(RST_BIT));
|
||||
// Port D inputs (none)
|
||||
PORTD &= ~(_BV(I2C_SCL_BIT) | _BV(I2C_SDA_BIT) | _BV(BLE_IRQ_BIT) |
|
||||
_BV(RTC_INT_BIT) | _BV(BATT_EN_BIT) | _BV(BATT_LVL_BIT) |
|
||||
_BV(LEDR_BIT));
|
||||
// Port D inputs
|
||||
DDRD &= ~(_BV(I2C_SCL_BIT) | _BV(I2C_SDA_BIT) | _BV(BLE_IRQ_BIT) |
|
||||
_BV(RTC_INT_BIT) | _BV(BATT_LVL_BIT));
|
||||
// Port D outputs
|
||||
DDRD |= _BV(RST_BIT) | _BV(CS_BIT) | _BV(DC_BIT);
|
||||
DDRD |= _BV(BATT_EN_BIT) | _BV(LEDR_BIT);
|
||||
|
||||
// Port E (none)
|
||||
// Port E INPUT_PULLUP or HIGH (none)
|
||||
// Port E INPUT or LOW
|
||||
PORTE &= ~(_BV(MPU_INT_BIT));
|
||||
// Port E inputs
|
||||
DDRE &= ~(_BV(MPU_INT_BIT));
|
||||
// Port E outputs (none)
|
||||
|
||||
// Port F INPUT_PULLUP or HIGH
|
||||
PORTF |= _BV(A_BUTTON_BIT) | _BV(B_BUTTON_BIT);
|
||||
PORTF |= _BV(CS_BIT) | _BV(BLE_CS_BIT) | _BV(BLE_RST_BIT);
|
||||
// Port F INPUT or LOW
|
||||
PORTF &= ~(_BV(RAND_SEED_IN_BIT));
|
||||
PORTF &= ~(_BV(RAND_SEED_IN_BIT) | _BV(RST_BIT));
|
||||
// Port F inputs
|
||||
DDRF &= ~(_BV(A_BUTTON_BIT) | _BV(B_BUTTON_BIT) | _BV(RAND_SEED_IN_BIT));
|
||||
// Port F outputs (none)
|
||||
// Speaker: Not set here. Controlled by audio class
|
||||
|
||||
#endif
|
||||
DDRF &= ~(_BV(RAND_SEED_IN_BIT));
|
||||
// Port F outputs
|
||||
DDRF |= _BV(CS_BIT) | _BV(RST_BIT) | _BV(DC_BIT) |
|
||||
_BV(BLE_CS_BIT) | _BV(BLE_RST_BIT);
|
||||
}
|
||||
|
||||
void Arduboy2Core::bootOLED()
|
||||
|
|
@ -272,9 +237,6 @@ void Arduboy2Core::idle()
|
|||
|
||||
void Arduboy2Core::bootPowerSaving()
|
||||
{
|
||||
// disable Two Wire Interface (I2C) and the ADC
|
||||
// All other bits will be written with 0 so will be enabled
|
||||
PRR0 = _BV(PRTWI) | _BV(PRADC);
|
||||
// disable USART1
|
||||
PRR1 |= _BV(PRUSART1);
|
||||
}
|
||||
|
|
@ -432,95 +394,60 @@ void Arduboy2Core::flipHorizontal(bool flipped)
|
|||
|
||||
void Arduboy2Core::setRGBled(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
#ifdef ARDUBOY_10 // RGB, all the pretty colors
|
||||
// timer 0: Fast PWM, OC0A clear on compare / set at top
|
||||
// We must stay in Fast PWM mode because timer 0 is used for system timing.
|
||||
// We can't use "inverted" mode because it won't allow full shut off.
|
||||
TCCR0A = _BV(COM0A1) | _BV(WGM01) | _BV(WGM00);
|
||||
OCR0A = 255 - green;
|
||||
// timer 1: Phase correct PWM 8 bit
|
||||
// OC1A and OC1B set on up-counting / clear on down-counting (inverted). This
|
||||
// allows the value to be directly loaded into the OCR with common anode LED.
|
||||
TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(COM1B1) | _BV(COM1B0) | _BV(WGM10);
|
||||
OCR1AL = blue;
|
||||
OCR1BL = red;
|
||||
#elif defined(AB_DEVKIT)
|
||||
// only blue on DevKit, which is not PWM capable
|
||||
(void)red; // parameter unused
|
||||
(void)green; // parameter unused
|
||||
bitWrite(BLUE_LED_PORT, BLUE_LED_BIT, blue ? RGB_ON : RGB_OFF);
|
||||
#endif
|
||||
(void) blue; // parameter not used
|
||||
|
||||
// from http://r6500.blogspot.com/2014/12/fast-pwm-on-arduino-leonardo.html
|
||||
TCCR4D = 0; // timer 4, Fast PWM
|
||||
TCCR4B = _BV(CS41); // 187500Hz
|
||||
PLLFRQ = (PLLFRQ & 0xCF) | _BV(PLLTM1) | _BV(PLLTM0); // 96MHz/2 = 48MHz
|
||||
OCR4C = 255; // terminal count for timer 4 PWM
|
||||
|
||||
// timer 4A (LEDL / Arduino pin 13)
|
||||
TCCR4A |= _BV(COM4A1) | _BV(PWM4A);
|
||||
OCR4A = red;
|
||||
|
||||
// timer 4D (LEDR / Arduino pin 6)
|
||||
TCCR4C |= _BV(COM4D1) | _BV(PWM4D);
|
||||
OCR4D = green;
|
||||
}
|
||||
|
||||
void Arduboy2Core::setRGBled(uint8_t color, uint8_t val)
|
||||
{
|
||||
#ifdef ARDUBOY_10
|
||||
if (color == RED_LED)
|
||||
{
|
||||
OCR1BL = val;
|
||||
OCR4A = val; // (LEDL / Arduino pin 13)
|
||||
}
|
||||
else if (color == GREEN_LED)
|
||||
{
|
||||
OCR0A = 255 - val;
|
||||
OCR4D = val; // (LEDR / Arduino pin 6)
|
||||
}
|
||||
else if (color == BLUE_LED)
|
||||
{
|
||||
OCR1AL = val;
|
||||
}
|
||||
#elif defined(AB_DEVKIT)
|
||||
// only blue on DevKit, which is not PWM capable
|
||||
if (color == BLUE_LED)
|
||||
{
|
||||
bitWrite(BLUE_LED_PORT, BLUE_LED_BIT, val ? RGB_ON : RGB_OFF);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Arduboy2Core::freeRGBled()
|
||||
{
|
||||
#ifdef ARDUBOY_10
|
||||
// clear the COM bits to return the pins to normal I/O mode
|
||||
TCCR0A = _BV(WGM01) | _BV(WGM00);
|
||||
TCCR1A = _BV(WGM10);
|
||||
#endif
|
||||
TCCR4A = 0;
|
||||
TCCR4C = 0;
|
||||
}
|
||||
|
||||
void Arduboy2Core::digitalWriteRGB(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
#ifdef ARDUBOY_10
|
||||
bitWrite(RED_LED_PORT, RED_LED_BIT, red);
|
||||
bitWrite(GREEN_LED_PORT, GREEN_LED_BIT, green);
|
||||
bitWrite(BLUE_LED_PORT, BLUE_LED_BIT, blue);
|
||||
#elif defined(AB_DEVKIT)
|
||||
// only blue on DevKit
|
||||
(void)red; // parameter unused
|
||||
(void)green; // parameter unused
|
||||
bitWrite(BLUE_LED_PORT, BLUE_LED_BIT, blue);
|
||||
#endif
|
||||
(void) blue; // parameter not used
|
||||
|
||||
bitWrite(LEDL_PORT, LEDL_BIT, red);
|
||||
bitWrite(LEDR_PORT, LEDR_BIT, green);
|
||||
}
|
||||
|
||||
void Arduboy2Core::digitalWriteRGB(uint8_t color, uint8_t val)
|
||||
{
|
||||
#ifdef ARDUBOY_10
|
||||
if (color == RED_LED)
|
||||
{
|
||||
bitWrite(RED_LED_PORT, RED_LED_BIT, val);
|
||||
bitWrite(LEDL_PORT, LEDL_BIT, val);
|
||||
}
|
||||
else if (color == GREEN_LED)
|
||||
{
|
||||
bitWrite(GREEN_LED_PORT, GREEN_LED_BIT, val);
|
||||
bitWrite(LEDR_PORT, LEDR_BIT, val);
|
||||
}
|
||||
else if (color == BLUE_LED)
|
||||
{
|
||||
bitWrite(BLUE_LED_PORT, BLUE_LED_BIT, val);
|
||||
}
|
||||
#elif defined(AB_DEVKIT)
|
||||
// only blue on DevKit
|
||||
if (color == BLUE_LED)
|
||||
{
|
||||
bitWrite(BLUE_LED_PORT, BLUE_LED_BIT, val);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
|
|
@ -529,26 +456,9 @@ uint8_t Arduboy2Core::buttonsState()
|
|||
{
|
||||
uint8_t buttons;
|
||||
|
||||
#ifdef ARDUBOY_10
|
||||
// up, right, left, down
|
||||
buttons = ((~PINF) &
|
||||
(_BV(UP_BUTTON_BIT) | _BV(RIGHT_BUTTON_BIT) |
|
||||
_BV(LEFT_BUTTON_BIT) | _BV(DOWN_BUTTON_BIT)));
|
||||
// A
|
||||
if (bitRead(A_BUTTON_PORTIN, A_BUTTON_BIT) == 0) { buttons |= A_BUTTON; }
|
||||
// B
|
||||
if (bitRead(B_BUTTON_PORTIN, B_BUTTON_BIT) == 0) { buttons |= B_BUTTON; }
|
||||
#elif defined(AB_DEVKIT)
|
||||
// down, left, up
|
||||
buttons = ((~PINB) &
|
||||
(_BV(DOWN_BUTTON_BIT) | _BV(LEFT_BUTTON_BIT) | _BV(UP_BUTTON_BIT)));
|
||||
// right
|
||||
if (bitRead(RIGHT_BUTTON_PORTIN, RIGHT_BUTTON_BIT) == 0) { buttons |= RIGHT_BUTTON; }
|
||||
// A
|
||||
if (bitRead(A_BUTTON_PORTIN, A_BUTTON_BIT) == 0) { buttons |= A_BUTTON; }
|
||||
// B
|
||||
if (bitRead(B_BUTTON_PORTIN, B_BUTTON_BIT) == 0) { buttons |= B_BUTTON; }
|
||||
#endif
|
||||
// up, down, B
|
||||
buttons = ((~PINB) & (_BV(UP_BUTTON_BIT) | _BV(B_BUTTON_BIT) |
|
||||
_BV(DOWN_BUTTON_BIT)));
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
|
@ -13,66 +13,83 @@
|
|||
#include <avr/wdt.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define RGB_ON HIGH /**< For digitially setting an LED on using digitalWriteRGB() */
|
||||
#define RGB_OFF LOW /**< For digitially setting an LED off using digitalWriteRGB() */
|
||||
|
||||
// main hardware compile flags
|
||||
#define PIN_BLE_CS A2 // Bluetooth CS Arduino pin number
|
||||
#define BLE_CS_PORT PORTF // Bluetooth CS port
|
||||
#define BLE_CS_BIT PORTF5 // Bluetooth CS physical bit number
|
||||
|
||||
#if !defined(ARDUBOY_10) && !defined(AB_DEVKIT)
|
||||
/* defaults to Arduboy Release 1.0 if not using a boards.txt file
|
||||
*
|
||||
* we default to Arduboy Release 1.0 if a compile flag has not been
|
||||
* passed to us from a boards.txt file
|
||||
*
|
||||
* if you wish to compile for the devkit without using a boards.txt
|
||||
* file simply comment out the ARDUBOY_10 define and uncomment
|
||||
* the AB_DEVKIT define like this:
|
||||
*
|
||||
* // #define ARDUBOY_10
|
||||
* #define AB_DEVKIT
|
||||
*/
|
||||
#define ARDUBOY_10 //< compile for the production Arduboy v1.0
|
||||
// #define AB_DEVKIT //< compile for the official dev kit
|
||||
#endif
|
||||
#define PIN_BLE_IRQ 0 // Bluetooth IRQ Arduino pin number
|
||||
#define BLE_IRQ_PORT PORTD // Bluetooth IRQ port
|
||||
#define BLE_IRQ_BIT PORTD2 // Bluetooth IRQ physical bit number
|
||||
|
||||
#define RGB_ON LOW /**< For digitially setting an RGB LED on using digitalWriteRGB() */
|
||||
#define RGB_OFF HIGH /**< For digitially setting an RGB LED off using digitalWriteRGB() */
|
||||
#define PIN_BLE_RST A1 // Bluetooth reset Arduino pin number
|
||||
#define BLE_RST_PORT PORTF // Bluetooth reset port
|
||||
#define BLE_RST_BIT PORTF6 // Bluetooth reset physical bit number
|
||||
|
||||
// ----- Arduboy pins -----
|
||||
#ifdef ARDUBOY_10
|
||||
#define PIN_BATT_LVL 12 // Battery Level Arduino pin number
|
||||
#define BATT_LVL_PORT PORTD // Battery Level port
|
||||
#define BATT_LVL_BIT PORTD6 // Battery Level physical bit number
|
||||
|
||||
#define PIN_CS 12 // Display CS Arduino pin number
|
||||
#define CS_PORT PORTD // Display CS port
|
||||
#define CS_BIT PORTD6 // Display CS physical bit number
|
||||
#define PIN_BATT_EN 4 // Battery Enable Arduino pin number
|
||||
#define BATT_EN_PORT PORTD // Battery Enable port
|
||||
#define BATT_EN_BIT PORTD4 // Battery Enable physical bit number
|
||||
|
||||
#define PIN_DC 4 // Display D/C Arduino pin number
|
||||
#define DC_PORT PORTD // Display D/C port
|
||||
#define DC_BIT PORTD4 // Display D/C physical bit number
|
||||
#define PIN_BATT_STAT 5 // Battery State Arduino pin number
|
||||
#define BATT_STAT_PORT PORTC // Battery State port
|
||||
#define BATT_STAT_BIT PORTC6 // Battery State physical bit number
|
||||
|
||||
#define PIN_RST 6 // Display reset Arduino pin number
|
||||
#define RST_PORT PORTD // Display reset port
|
||||
#define RST_BIT PORTD7 // Display reset physical bit number
|
||||
#define PIN_MPU_INT 7 // MPU6050 interrupt Arduino pin number
|
||||
#define MPU_INT_PORT PORTE // MPU6050 interrupt port
|
||||
#define MPU_INT_BIT PORTE6 // MPU6050 interrupt physical bit number
|
||||
|
||||
#define RED_LED 10 /**< The pin number for the red color in the RGB LED. */
|
||||
#define GREEN_LED 11 /**< The pin number for the greem color in the RGB LED. */
|
||||
#define BLUE_LED 9 /**< The pin number for the blue color in the RGB LED. */
|
||||
#define PIN_RTC_INT 1 // Real Time Clock interrupt Arduino pin number
|
||||
#define RTC_INT_PORT PORTD // Real Time Clock interrupt port
|
||||
#define RTC_INT_BIT PORTD3 // Real Time Clock interrupt physical bit number
|
||||
|
||||
#define RED_LED_PORT PORTB
|
||||
#define RED_LED_BIT PORTB6
|
||||
#define PIN_I2C_SDA 2 // I2C SDA Arduino pin number
|
||||
#define I2C_SDA_PORT PORTD // I2C SDA port
|
||||
#define I2C_SDA_BIT PORTD1 // I2C SDA physical bit number
|
||||
|
||||
#define GREEN_LED_PORT PORTB
|
||||
#define GREEN_LED_BIT PORTB7
|
||||
#define PIN_I2C_SCL 3 // I2C SCL Arduino pin number
|
||||
#define I2C_SCL_PORT PORTD // I2C SCL port
|
||||
#define I2C_SCL_BIT PORTD0 // I2C SCL physical bit number
|
||||
|
||||
#define BLUE_LED_PORT PORTB
|
||||
#define BLUE_LED_BIT PORTB5
|
||||
#define PIN_CS A5 // Display CS Arduino pin number
|
||||
#define CS_PORT PORTF // Display CS port
|
||||
#define CS_BIT PORTF0 // Display CS physical bit number
|
||||
|
||||
#define PIN_DC A3 // Display D/C Arduino pin number
|
||||
#define DC_PORT PORTF // Display D/C port
|
||||
#define DC_BIT PORTF4 // Display D/C physical bit number
|
||||
|
||||
#define PIN_RST A4 // Display reset Arduino pin number
|
||||
#define RST_PORT PORTF // Display reset port
|
||||
#define RST_BIT PORTF1 // Display reset physical bit number
|
||||
|
||||
#define LEDL 13 /**< The pin number for LEDL. */
|
||||
#define LEDL_PORT PORTC
|
||||
#define LEDL_BIT PORTC7
|
||||
|
||||
#define LEDR 6 /**< The pin number for LEDR. */
|
||||
#define LEDR_PORT PORTD
|
||||
#define LEDR_BIT PORTD7
|
||||
|
||||
#define RED_LED 13 /**< The pin number for the red color in the RGB LED. */
|
||||
#define GREEN_LED 6 /**< The pin number for the greem color in the RGB LED. */
|
||||
#define BLUE_LED 13 /**< The pin number for the blue color in the RGB LED. */
|
||||
|
||||
// bit values for button states
|
||||
// these are determined by the buttonsState() function
|
||||
#define LEFT_BUTTON _BV(5) /**< The Left button value for functions requiring a bitmask */
|
||||
#define RIGHT_BUTTON _BV(6) /**< The Right button value for functions requiring a bitmask */
|
||||
#define LEFT_BUTTON _BV(0) /**< The Left button value for functions requiring a bitmask */
|
||||
#define RIGHT_BUTTON _BV(0) /**< The Right button value for functions requiring a bitmask */
|
||||
#define UP_BUTTON _BV(7) /**< The Up button value for functions requiring a bitmask */
|
||||
#define DOWN_BUTTON _BV(4) /**< The Down button value for functions requiring a bitmask */
|
||||
#define A_BUTTON _BV(3) /**< The A button value for functions requiring a bitmask */
|
||||
#define B_BUTTON _BV(2) /**< The B button value for functions requiring a bitmask */
|
||||
#define DOWN_BUTTON _BV(6) /**< The Down button value for functions requiring a bitmask */
|
||||
#define A_BUTTON _BV(0) /**< The A button value for functions requiring a bitmask */
|
||||
#define B_BUTTON _BV(4) /**< The B button value for functions requiring a bitmask */
|
||||
|
||||
/*
|
||||
#define PIN_LEFT_BUTTON A2
|
||||
#define LEFT_BUTTON_PORT PORTF
|
||||
#define LEFT_BUTTON_PORTIN PINF
|
||||
|
|
@ -84,99 +101,13 @@
|
|||
#define RIGHT_BUTTON_PORTIN PINF
|
||||
#define RIGHT_BUTTON_DDR DDRF
|
||||
#define RIGHT_BUTTON_BIT PORTF6
|
||||
*/
|
||||
|
||||
#define PIN_UP_BUTTON A0
|
||||
#define UP_BUTTON_PORT PORTF
|
||||
#define UP_BUTTON_PORTIN PINF
|
||||
#define UP_BUTTON_DDR DDRF
|
||||
#define UP_BUTTON_BIT PORTF7
|
||||
|
||||
#define PIN_DOWN_BUTTON A3
|
||||
#define DOWN_BUTTON_PORT PORTF
|
||||
#define DOWN_BUTTON_PORTIN PINF
|
||||
#define DOWN_BUTTON_DDR DDRF
|
||||
#define DOWN_BUTTON_BIT PORTF4
|
||||
|
||||
#define PIN_A_BUTTON 7
|
||||
#define A_BUTTON_PORT PORTE
|
||||
#define A_BUTTON_PORTIN PINE
|
||||
#define A_BUTTON_DDR DDRE
|
||||
#define A_BUTTON_BIT PORTE6
|
||||
|
||||
#define PIN_B_BUTTON 8
|
||||
#define B_BUTTON_PORT PORTB
|
||||
#define B_BUTTON_PORTIN PINB
|
||||
#define B_BUTTON_DDR DDRB
|
||||
#define B_BUTTON_BIT PORTB4
|
||||
|
||||
#define PIN_SPEAKER_1 5 /**< The pin number of the first lead of the speaker */
|
||||
#define PIN_SPEAKER_2 13 /**< The pin number of the second lead of the speaker */
|
||||
|
||||
#define SPEAKER_1_PORT PORTC
|
||||
#define SPEAKER_1_DDR DDRC
|
||||
#define SPEAKER_1_BIT PORTC6
|
||||
|
||||
#define SPEAKER_2_PORT PORTC
|
||||
#define SPEAKER_2_DDR DDRC
|
||||
#define SPEAKER_2_BIT PORTC7
|
||||
// -----------------------
|
||||
|
||||
// ----- DevKit pins -----
|
||||
#elif defined(AB_DEVKIT)
|
||||
|
||||
#define PIN_CS 6 // Display CS Arduino pin number
|
||||
#define CS_PORT PORTD // Display CS port
|
||||
#define CS_BIT PORTD7 // Display CS physical bit number
|
||||
|
||||
#define PIN_DC 4 // Display D/C Arduino pin number
|
||||
#define DC_PORT PORTD // Display D/C port
|
||||
#define DC_BIT PORTD4 // Display D/C physical bit number
|
||||
|
||||
#define PIN_RST 12 // Display reset Arduino pin number
|
||||
#define RST_PORT PORTD // Display reset port
|
||||
#define RST_BIT PORTD6 // Display reset physical bit number
|
||||
|
||||
#define SPI_MOSI_PORT PORTB
|
||||
#define SPI_MOSI_BIT PORTB2
|
||||
|
||||
#define SPI_SCK_PORT PORTB
|
||||
#define SPI_SCK_BIT PORTB1
|
||||
|
||||
// map all LEDs to the single TX LED on DEVKIT
|
||||
#define RED_LED 17
|
||||
#define GREEN_LED 17
|
||||
#define BLUE_LED 17
|
||||
|
||||
#define BLUE_LED_PORT PORTB
|
||||
#define BLUE_LED_BIT PORTB0
|
||||
|
||||
// bit values for button states
|
||||
// these are determined by the buttonsState() function
|
||||
#define LEFT_BUTTON _BV(5)
|
||||
#define RIGHT_BUTTON _BV(2)
|
||||
#define UP_BUTTON _BV(4)
|
||||
#define DOWN_BUTTON _BV(6)
|
||||
#define A_BUTTON _BV(1)
|
||||
#define B_BUTTON _BV(0)
|
||||
|
||||
// pin values for buttons, probably shouldn't use these
|
||||
#define PIN_LEFT_BUTTON 9
|
||||
#define LEFT_BUTTON_PORT PORTB
|
||||
#define LEFT_BUTTON_PORTIN PINB
|
||||
#define LEFT_BUTTON_DDR DDRB
|
||||
#define LEFT_BUTTON_BIT PORTB5
|
||||
|
||||
#define PIN_RIGHT_BUTTON 5
|
||||
#define RIGHT_BUTTON_PORT PORTC
|
||||
#define RIGHT_BUTTON_PORTIN PINC
|
||||
#define RIGHT_BUTTON_DDR DDRC
|
||||
#define RIGHT_BUTTON_BIT PORTC6
|
||||
|
||||
#define PIN_UP_BUTTON 8
|
||||
#define PIN_UP_BUTTON 11
|
||||
#define UP_BUTTON_PORT PORTB
|
||||
#define UP_BUTTON_PORTIN PINB
|
||||
#define UP_BUTTON_DDR DDRB
|
||||
#define UP_BUTTON_BIT PORTB4
|
||||
#define UP_BUTTON_BIT PORTB7
|
||||
|
||||
#define PIN_DOWN_BUTTON 10
|
||||
#define DOWN_BUTTON_PORT PORTB
|
||||
|
|
@ -184,38 +115,31 @@
|
|||
#define DOWN_BUTTON_DDR DDRB
|
||||
#define DOWN_BUTTON_BIT PORTB6
|
||||
|
||||
#define PIN_A_BUTTON A0
|
||||
#define A_BUTTON_PORT PORTF
|
||||
#define A_BUTTON_PORTIN PINF
|
||||
#define A_BUTTON_DDR DDRF
|
||||
#define A_BUTTON_BIT PORTF7
|
||||
/*
|
||||
#define PIN_A_BUTTON 7
|
||||
#define A_BUTTON_PORT PORTE
|
||||
#define A_BUTTON_PORTIN PINE
|
||||
#define A_BUTTON_DDR DDRE
|
||||
#define A_BUTTON_BIT PORTE6
|
||||
*/
|
||||
|
||||
#define PIN_B_BUTTON A1
|
||||
#define B_BUTTON_PORT PORTF
|
||||
#define B_BUTTON_PORTIN PINF
|
||||
#define B_BUTTON_DDR DDRF
|
||||
#define B_BUTTON_BIT PORTF6
|
||||
#define PIN_B_BUTTON 8
|
||||
#define B_BUTTON_PORT PORTB
|
||||
#define B_BUTTON_PORTIN PINB
|
||||
#define B_BUTTON_DDR DDRB
|
||||
#define B_BUTTON_BIT PORTB4
|
||||
|
||||
#define PIN_SPEAKER_1 A2
|
||||
#define SPEAKER_1_PORT PORTF
|
||||
#define SPEAKER_1_DDR DDRF
|
||||
#define SPEAKER_1_BIT PORTF5
|
||||
// SPEAKER_2 is purposely not defined for DEVKIT as it could potentially
|
||||
// be dangerous and fry your hardware (because of the devkit wiring).
|
||||
//
|
||||
// Reference: https://github.com/Arduboy/Arduboy/issues/108
|
||||
|
||||
#endif
|
||||
// --------------------
|
||||
|
||||
// ----- Pins common on Arduboy and DevKit -----
|
||||
#define PIN_SPEAKER 9 /**< The pin number of the speaker */
|
||||
#define SPEAKER_PORT PORTB
|
||||
#define SPEAKER_DDR DDRB
|
||||
#define SPEAKER_BIT PORTB5
|
||||
|
||||
// Unconnected analog input used for noise by initRandomSeed()
|
||||
#define RAND_SEED_IN A4
|
||||
#define RAND_SEED_IN A0
|
||||
#define RAND_SEED_IN_PORT PORTF
|
||||
#define RAND_SEED_IN_BIT PORTF1
|
||||
// Value for ADMUX to read the random seed pin: 2.56V reference, ADC1
|
||||
#define RAND_SEED_IN_ADMUX (_BV(REFS0) | _BV(REFS1) | _BV(MUX0))
|
||||
#define RAND_SEED_IN_BIT PORTF7
|
||||
// Value for ADMUX to read the random seed pin: 2.56V reference, ADC7
|
||||
#define RAND_SEED_IN_ADMUX (_BV(REFS1) | _BV(REFS0) | _BV(MUX2) | _BV(MUX1) | _BV(MUX0))
|
||||
|
||||
// SPI interface
|
||||
#define SPI_MISO_PORT PORTB
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# watchX-Arduboy2
|
||||
|
||||
This is a modification of the [Arduboy2](https://github.com/MLXXXp/Arduboy2) library, made to work with the pin-mappings and PWM/Timer allocations of the [watchX](http://watchx.io/). Packaged together with the *ArduBreakout.ino* example sketch for demonstration purposes.
|
||||
|
||||
## Things to note:
|
||||
|
||||
- we only have 3 buttons, these are mapped to **UP_BUTTON / DOWN_BUTTON / B_BUTTON**
|
||||
- we only have 2 LEDs, these are mapped to **RED_LED / GREEN_LED**
|
||||
- we only have 1 speaker pin, this is mapped to **BeepPin1** used by **Arduboy2Beep**
|
||||
|
||||
For the time being, I have commented out the extra start-up functions (flashlight / systemButtons / bootLogo...) because in their current state they rely on having more than just our 3 buttons and 2 LEDs, and also because the state of the EEPROM may not necessarily follow Arduboy2 rules on a watchX!
|
||||
148
LICENSE.txt
148
LICENSE.txt
|
|
@ -1,148 +0,0 @@
|
|||
/**
|
||||
\page licenses Software License Agreements
|
||||
\verbatim
|
||||
|
||||
Software License Agreements
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Licensed under the BSD 3-clause license:
|
||||
|
||||
Arduboy2 library:
|
||||
Copyright (c) 2016-2018, Scott Allen
|
||||
All rights reserved.
|
||||
|
||||
The Arduboy2 library was forked from the Arduboy library:
|
||||
https://github.com/Arduboy/Arduboy
|
||||
Copyright (c) 2016, Kevin "Arduboy" Bates
|
||||
Copyright (c) 2016, Chris Martinez
|
||||
Copyright (c) 2016, Josh Goebel
|
||||
Copyright (c) 2016, Scott Allen
|
||||
All rights reserved.
|
||||
which is in turn partially based on the Adafruit_SSD1306 library
|
||||
https://github.com/adafruit/Adafruit_SSD1306
|
||||
Copyright (c) 2012, Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
SetSystemEEPROM example sketch:
|
||||
Copyright (c) 2018, Scott Allen
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Licensed under the BSD 2-clause license:
|
||||
|
||||
Portions of the Arduboy library, and thus portions of the Arduboy2 library,
|
||||
based on the Adafruit-GFX library:
|
||||
https://github.com/adafruit/Adafruit-GFX-Library
|
||||
Copyright (c) 2012 Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Licensed under the MIT license:
|
||||
|
||||
Code from ArduboyExtra:
|
||||
https://github.com/yyyc514/ArduboyExtra
|
||||
Copyright (c) 2015 Josh Goebel
|
||||
|
||||
Code for drawing compressed bitmaps:
|
||||
https://github.com/TEAMarg/drawCompressed
|
||||
Copyright (c) 2016 TEAM a.r.g.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Licensed under the GNU LGPL license:
|
||||
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
|
||||
|
||||
ArduBreakout example sketch:
|
||||
Original work:
|
||||
Copyright (c) 2011 Sebastian Goscik
|
||||
All rights reserved.
|
||||
Modified work:
|
||||
Copyright (c) 2016 Scott Allen
|
||||
All rights reserved.
|
||||
|
||||
Buttons and HelloWorld example sketches:
|
||||
Copyright (c) 2015 David Martinez
|
||||
All rights reserved.
|
||||
|
||||
This work is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Placed in the public domain:
|
||||
|
||||
BeepDemo example sketch:
|
||||
By Scott Allen
|
||||
|
||||
RGBled example sketch:
|
||||
By Scott Allen
|
||||
|
||||
===============================================================================
|
||||
\endverbatim
|
||||
*/
|
||||
437
README.md
437
README.md
|
|
@ -1,437 +0,0 @@
|
|||
# Arduboy2 Library
|
||||
|
||||
The Arduboy2 library is maintained in a git repository hosted on [GitHub](https://github.com/) at:
|
||||
|
||||
https://github.com/MLXXXp/Arduboy2
|
||||
|
||||
The **Arduboy2** library is a fork of the [Arduboy library](https://github.com/Arduboy/Arduboy), which provides a standard *application programming interface* (API) to the display, buttons and other hardware of the Arduino based [Arduboy miniature game system](https://www.arduboy.com/).
|
||||
|
||||
The name *Arduboy2* doesn't indicate that it's for a new "next generation" of the Arduboy hardware. The name was changed so it can coexist in the Arduino IDE with the current *Arduboy* library, without conflict. This way, existing sketches can continue to use the *Arduboy* library and class, without changes, while new sketches can be written (or old ones modified) to use and take advantage of the capabilities of the *Arduboy2* class and library.
|
||||
|
||||
For notes on the differences between the *Arduboy2* library and the original *Arduboy* library, and for information on migrating a sketch currently using the *Arduboy* library, see the sections at the end of this document.
|
||||
|
||||
## Library documentation
|
||||
|
||||
Comments in the library header files are formatted for the [Doxygen](http://www.doxygen.org) document generation system. The HTML files generated using the configuration file _extras/Doxyfile_ can be found at:
|
||||
|
||||
https://MLXXXp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/html/index.html
|
||||
|
||||
A generated PDF file can be found at:
|
||||
|
||||
https://MLXXXp.github.io/documents/Arduino/libraries/Arduboy2/Doxygen/pdf/Arduboy2.pdf
|
||||
|
||||
## Installation
|
||||
|
||||
The Arduboy2 library can be installed using the Arduino IDE Library Manager:
|
||||
|
||||
- In the Arduino IDE select from the menus: `Sketch > Include Library > Manage Libraries...`
|
||||
- In the Library Manager *Filter your search...* field enter *arduboy2*.
|
||||
- Click somewhere within the Arduboy2 entry.
|
||||
- Click on the *Install* button.
|
||||
|
||||
For more library installation information see
|
||||
|
||||
[Installing Additional Arduino Libraries - Using the Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3)
|
||||
|
||||
## Start up features
|
||||
|
||||
The *begin()* function, used to initialize the library, includes features that are intended to be available to all sketches using the library (unless the sketch developer has chosen to disable one or more of them to free up some code space):
|
||||
|
||||
### The boot logo
|
||||
|
||||
At the start of the sketch, the **ARDUBOY** logo scrolls down from the top of the screen to the center.
|
||||
|
||||
The RGB LED lights red then green then blue while the logo is scrolling. (If your Arduboy is one of those that has the RGB LED installed incorrectly, then it will light blue then off then red). For users who do not wish to have the RGB LED flash during the boot logo sequence, a flag can be set in system EEPROM to have it remain off. The included *SetSystemEEPROM* example sketch can be used to set this flag.
|
||||
|
||||
A user settable *unit name* of up to 6 characters can be saved in system EEPROM memory. If set, this name will be briefly displayed at the bottom of the boot logo screen, after the logo stops scrolling down. This feature is only available if the *Arduboy2* class is used, not the *Arduboy2Base* class. This is because it requires the text display functions, which are only available in the *Arduboy2* class. A flag in system EEPROM controls whether or not the *unit name* is displayed on the boot logo screen, regardless of whether the *unit name* itself has been set. The included *SetSystemEEPROM* example sketch can be used to set both the *unit name* and this flag.
|
||||
|
||||
Once the logo display sequence completes, the sketch continues.
|
||||
|
||||
For developers who wish to quickly begin testing, or impatient users who want to go strait to playing their game, the boot logo sequence can be bypassed by holding the *RIGHT* button while powering up, and then releasing it. Alternatively, the *RIGHT* button can be pressed while the logo is scrolling down.
|
||||
|
||||
For users who wish to always disable the displaying of the boot logo sequence on boot up, a flag in system EEPROM is available for this. The included *SetSystemEEPROM* example sketch can be used to set this flag.
|
||||
|
||||
### "Flashlight" mode
|
||||
|
||||
If the *UP* button is pressed and held when the Arduboy is powered on, it enters *flashlight* mode. This turns the RGB LED fully on, and all the pixels of the screen are lit, resulting in a bright white light suitable as a small flashlight. (For an incorrect RGB LED, only the screen will light). To exit *flashlight* mode the Arduboy must be restarted.
|
||||
|
||||
*Flashlight* mode is also sometimes useful to allow uploading of new sketches, in case the sketch currently loaded uses a large amount of RAM which creates a bootloader problem.
|
||||
|
||||
### Audio mute control
|
||||
|
||||
Pressing and holding the *B* button when powering on will enter *System Control* mode. The RGB LED will light blue (red for an incorrect LED) to indicate that you are in *system control* mode. You must continue to hold the *B* button to remain in this mode. The only *system control* function currently implemented is *audio mute control*.
|
||||
|
||||
Pressing the *UP* button (while still holding *B*) will set a flag in system EEPROM indicating *audio enabled*. The RGB LED will flash green once (off for an incorrect LED) to indicate this action.
|
||||
|
||||
Pressing the *DOWN* button (while still holding *B*) will set the flag to *audio disabled* (muted). The RGB LED will flash red once (blue for an incorrect LED) to indicate this action.
|
||||
|
||||
Releasing the *B* button will exit *system control* mode and the sketch will continue.
|
||||
|
||||
Note that the audio control feature only sets a flag in EEPROM. Whatever code actually produces the sound must use the *audio.enabled()* function to check and honor the mute state. Audio libraries written with the Arduboy system in mind, such as the available *ArduboyPlaytune* and *ArduboyTones*, should do this. However, be aware that for some sketches, which don't use the Arduboy2 or other compliant library and generate sounds in their own way, this method of muting sound may not work.
|
||||
|
||||
## Using the library in a sketch
|
||||
|
||||
As with most libraries, to use Arduboy2 in your sketch you must include its header file at the start:
|
||||
|
||||
```cpp
|
||||
#include <Arduboy2.h>
|
||||
```
|
||||
|
||||
You must then create an Arduboy2 class object:
|
||||
|
||||
```cpp
|
||||
Arduboy2 arduboy;
|
||||
```
|
||||
|
||||
Naming the object *arduboy* has become somewhat of a standard, but you can use a different name if you wish.
|
||||
|
||||
To initialize the library, you must call its *begin()* function. This is usually done at the start of the sketch's *setup()* function:
|
||||
|
||||
```cpp
|
||||
void setup()
|
||||
{
|
||||
arduboy.begin();
|
||||
// more setup code follows, if required
|
||||
}
|
||||
```
|
||||
|
||||
The rest of the Arduboy2 functions will now be available for use.
|
||||
|
||||
If you wish to use the Sprites class functions you must create a Sprites object:
|
||||
|
||||
```cpp
|
||||
Sprites sprites;
|
||||
```
|
||||
|
||||
Sample sketches have been included with the library as examples of how to use it. To load an example, for examination and uploading to the Arduboy, using the Arduino IDE menus select:
|
||||
|
||||
`File > Examples > Arduboy2`
|
||||
|
||||
More information on writing sketches for the Arduboy can be found in the [Arduboy Community Forum](http://community.arduboy.com/).
|
||||
|
||||
### Using EEPROM in a sketch
|
||||
|
||||
The Arduboy2 library reserves an area at the start of EEPROM for storing system information, such as the current audio mute state and the Unit Name and Unit ID. A sketch **must not** use this reserved area for its own purposes. A sketch may use any EEPROM past this reserved area. The first EEPROM address available for sketch use is given as the defined value *EEPROM_STORAGE_SPACE_START*
|
||||
|
||||
### Audio control functions
|
||||
|
||||
The library includes an Arduboy2Audio class. This class provides functions to enable and disable (mute) sound and also save the current mute state so that it remains in effect over power cycles and after loading a different sketch. It doesn't contain anything to actually produce sound.
|
||||
|
||||
The Arduboy2Base class, and thus the Arduboy2 class, creates an Arduboy2Audio class object named *audio*, so a sketch doesn't need to create its own Arduboy2Audio object.
|
||||
|
||||
Example:
|
||||
|
||||
```cpp
|
||||
#include <Arduboy2.h>
|
||||
|
||||
Arduboy2 arduboy;
|
||||
|
||||
// Arduboy2Audio functions can be called as follows:
|
||||
arduboy.audio.on();
|
||||
arduboy.audio.off();
|
||||
```
|
||||
|
||||
### Simple tone generation
|
||||
|
||||
The *BeepPin1* and *BeepPin2* classes are available to generate simple square wave tones using speaker pin 1 and speaker pin 2 respectively. These classes are documented in file *Arduboy2Beep.h*. Also, *BeepDemo* is included as one of the example sketches, which demonstrates basic use.
|
||||
|
||||
NOTE: These functions will not work with a DevKit Arduboy because the speaker pins used cannot be directly controlled by a timer/counter. "Dummy" functions are provided so a sketch will compile and work properly but no sound will be produced.
|
||||
|
||||
### Ways to make more code space available to sketches
|
||||
|
||||
#### Sound effects and music
|
||||
|
||||
If all you want is to play single tones, using the built in *BeepPin1* or *BeepPin2* classes will be very efficient.
|
||||
|
||||
If you want to be able to play sequences of tones or background music, using the [*ArduboyTones*](https://github.com/MLXXXp/ArduboyTones) library will be more code efficient than using [*ArduboyPlaytune*](https://github.com/Arduboy/ArduboyPlayTune) or most other sound libraries compatible with the Arduboy. *ArduboyTones* even produces less code than the [Arduino built in *tone()* function](https://www.arduino.cc/en/Reference/Tone). You'll have to decide on the appropriate library or functions you use to generate sound, based on the features required and how much memory you want it to use.
|
||||
|
||||
#### Remove the text functions
|
||||
|
||||
If your sketch doesn't use any of the functions for displaying text, such as *setCursor()* and *print()*, you can remove them. You could do this if your sketch generates whatever text it requires by some other means. Removing the text functions frees up code by not including the font table and some code that is always pulled in by inheriting the [Arduino *Print* class](http://playground.arduino.cc/Code/Printclass).
|
||||
|
||||
To eliminate text capability in your sketch, when creating the library object simply use the *Arduboy2Base* class instead of *Arduboy2*:
|
||||
|
||||
For example, if the object will be named *arduboy*:
|
||||
|
||||
Replace
|
||||
|
||||
```cpp
|
||||
Arduboy2 arduboy;
|
||||
```
|
||||
|
||||
with
|
||||
|
||||
```cpp
|
||||
Arduboy2Base arduboy;
|
||||
```
|
||||
|
||||
#### Remove boot up features
|
||||
|
||||
As previously described, the *begin()* function includes features that are intended to be available to all sketches during boot up. However, if you're looking to gain some code space, you can call *boot()* instead of *begin()*. This will initialize the system but not include any of the extra boot up features. If desired, you can then add back in any of these features by calling the functions that perform them. You will have to trade off between the desirability of having a feature and how much memory you can recover by not including it.
|
||||
|
||||
A good way to use *boot()* instead of *begin()* is to copy the code from the body of the *begin()* function, in file *Arduboy2.cpp*, into your sketch and then edit it to retain the *boot()* call and any feature calls desired.
|
||||
|
||||
As of this writing, the begin function is:
|
||||
|
||||
```cpp
|
||||
void Arduboy2Base::begin()
|
||||
{
|
||||
boot(); // raw hardware
|
||||
|
||||
display(); // blank the display (sBuffer is global, so cleared automatically)
|
||||
|
||||
flashlight(); // light the RGB LED and screen if UP button is being held.
|
||||
|
||||
// check for and handle buttons held during start up for system control
|
||||
systemButtons();
|
||||
|
||||
audio.begin();
|
||||
|
||||
bootLogo();
|
||||
|
||||
waitNoButtons(); // wait for all buttons to be released
|
||||
}
|
||||
```
|
||||
|
||||
To incorporate it into your sketch just keep *boot()* and whatever feature calls are desired, if any. Comment out or delete the rest. Remember to add the class object name in front of each function call, since they're now being called from outside the class itself. If your sketch uses sound, it's a good idea to keep the call to *audio.begin()*.
|
||||
|
||||
For example: Let's say a sketch has its own code to enable, disable and save the *audio on/off* setting, and wants to keep the *flashlight* function. In *setup()* it could replace *begin()* with:
|
||||
|
||||
```cpp
|
||||
arduboy.boot(); // raw hardware
|
||||
|
||||
// *** This particular sketch clears the display soon, so it doesn't need this:
|
||||
// display(); // blank the display (sBuffer is global, so cleared automatically)
|
||||
|
||||
arduboy.flashlight(); // light the RGB LED and screen if UP button is being held.
|
||||
|
||||
// check for and handle buttons held during start up for system control
|
||||
// systemButtons();
|
||||
|
||||
arduboy.audio.begin();
|
||||
|
||||
// bootLogo();
|
||||
|
||||
// waitNoButtons(); // wait for all buttons to be released
|
||||
```
|
||||
|
||||
This saves whatever code *display()*, *systemButtons()*, *bootLogo()* and *waitNoButtons()* would use.
|
||||
|
||||
There are a few functions provided that are roughly equivalent to the standard functions used by *begin()* but which use less code space.
|
||||
|
||||
- *bootLogoCompressed()*, *bootLogoSpritesSelfMasked()*, *bootLogoSpritesOverwrite()*, *bootLogoSpritesBSelfMasked()* and *bootLogoSpritesBOverwrite()* will do the same as *bootLogo()* but will use *drawCompressed()*, or *Sprites* / *SpritesB* class *drawSelfMasked()* or *drawOverwrite()* functions respectively, instead of *drawBitmask()*, to render the logo. If the sketch uses one of these functions, then using the boot logo function that also uses it may reduce code size. It's best to try each of them to see which one produces the smallest size.
|
||||
- *bootLogoText()* can be used in place *bootLogo()* in the case where the sketch uses text functions. It renders the logo as text instead of as a bitmap (so doesn't look as good).
|
||||
- *safeMode()* can be used in place of *flashlight()* for cases where it's needed to allow uploading a new sketch when the bootloader "magic key" problem is an issue. It only lights the red RGB LED, so you don't get the bright light that is the primary purpose of *flashlight()*.
|
||||
|
||||
#### Use the SpritesB class instead of Sprites
|
||||
|
||||
The *SpritesB* class has functions identical to the *Sprites* class. The difference is that *SpritesB* is optimized for small code size rather than execution speed. If you want to use the sprites functions, and the slower speed of *SpritesB* doesn't affect your sketch, you may be able to use it to gain some code space.
|
||||
|
||||
Even if the speed is acceptable when using *SpritesB*, you should still try using *Sprites*. In some cases *Sprites* will produce less code than *SpritesB*, notably when only one of the functions is used.
|
||||
|
||||
You can easily switch between using *Sprites* or *SpritesB* by using one or the other to create an object instance:
|
||||
|
||||
```cpp
|
||||
Sprites sprites; // Use this to optimize for execution speed
|
||||
SpritesB sprites; // Use this to (likely) optimize for code size
|
||||
```
|
||||
|
||||
#### Eliminate the USB stack code
|
||||
|
||||
**Warning:** Although this will free up a fair amount of code and some RAM space, without an active USB interface uploader programs will be unable to automatically force a reset to invoke the bootloader. This means the user will have to manually initiate a reset in order to upload a new sketch. This can be an inconvenience or even frustrating for a user, due to the fact that timing the sequence can sometimes be tricky. Therefore, using this technique should be considered as a last resort. If it is used, the sketch documentation should state clearly what will be involved to upload a new sketch.
|
||||
|
||||
The *ARDUBOY_NO_USB* macro is used to eliminate the USB code. The *exitToBootloader()* function is available to make it easier for a user to invoke the bootloader. For more details, see the documentation provided for these.
|
||||
|
||||
----------
|
||||
|
||||
## What's different from Arduboy library V1.1
|
||||
|
||||
A main goal of Arduboy2 is to provide ways in which more code space can be freed for use by large sketches. Another goal is to allow methods other than the *tunes* functions to be used to produce sounds. Arduboy2 remains substantially compatible with [Arduboy library V1.1](https://github.com/Arduboy/Arduboy/releases/tag/v1.1), which was the latest stable release at the time of the fork. Arduboy2 is based on the code targeted for Arduboy library V1.2, which was still in development and unreleased at the time it was forked.
|
||||
|
||||
Main differences between Arduboy2 and Arduboy V1.1 are:
|
||||
|
||||
- The *ArduboyTunes* subclass, which provided the *tunes.xxx()* functions, has been removed. It's functionality is available in a separate [*ArduboyPlaytune* library](https://github.com/Arduboy/ArduboyPlayTune). By removing these functions, more code space may become available because interrupt routines and other support code was being compiled in even if a sketch didn't make use them. Another benefit is that without the automatic installation of timer interrupt service routines, other audio generating functions and libraries, that need access to the same interrupts, can now be used. Removal of the *tunes* functions is the main API incompatibility with Arduboy V1.1. Sketches written to use *tunes* functions will need some minor modifications in order to make them work with Arduboy2 plus ArduboyPlaytune, [ArduboyTones](https://github.com/MLXXXp/ArduboyTones), or some other audio library.
|
||||
- Arduboy library V1.1 uses timer 1 for the *tunes* functions. This causes problems when attempting to control the Arduboy's RGB LED using PWM, such as with *setRGBled()*, because it also requires timer 1. Since the *tunes* functionality has been removed from Arduboy2, there are no problems with using the RGB LED (except those caused by the RGB LED being incorrectly installed). Of course, using an external library that uses timer 1, such as *ArduboyPlaytune*, may reintroduce the problems. However, using a library that doesn't use timer 1, such as *ArduboyTones*, is now an option.
|
||||
- The code to generate text output, using *setCursor()*, *print()*, etc., can be removed to free up code space, if a sketch doesn't use any text functions. The *Arduboy2* class includes the text functions but using the *Arduboy2Base* class instead will eliminate them. With text functions included, the font table and some support functions are always compiled in even if not used. The API for using text functions is the same as Arduboy V1.1 with some additional functions added:
|
||||
- *setTextColor()* and *setTextBackground()* allow for printing black text on a white background.
|
||||
- *getCursorX()* and *getCursorY()* allow for determining the current text cursor position.
|
||||
- The *clear()* function will now reset the text cursor to home position 0, 0.
|
||||
- A new feature has been added which allows the *audio on/off* flag in system EEPROM to be configured by the user when the sketch starts. The flag is used by the Arduboy and Arduboy2 *audio* subclass, along with external sound functions and libraries, to provide a standardized sound mute capability. See the information above, under the heading *Audio mute control*, for more details.
|
||||
- The *color* parameter, which is the last parameter for most of the drawing functions, has been made optional and will default to WHITE if not included in the call. This doesn't save any code but has been added as a convenience, since most drawing functions are called with WHITE specified.
|
||||
- A new function *digitalWriteRGB()* has been added to control the RGB LED digitally instead of using PWM. This uses less code if just turning the RGB LEDs fully on or off is all that's required.
|
||||
- The *beginNoLogo()* function is not included. This function could be used in Arduboy V1.1 in place of *begin()* to suppress the displaying of the ARDUBOY logo and thus free up the code that it required. Instead, Arduboy2 allows a sketch to call *boot()* and then add in any extra features that *begin()* provides by calling their functions directly after *boot()*, if desired.
|
||||
- The *ArduboyCore* and *ArduboyAudio* base classes, previously only available to, and used to derive, the *Arduboy* class, have been made publicly available for the benefit of developers who may wish to use them as the base of an entirely new library. This change doesn't affect the existing API.
|
||||
|
||||
As of version 2.1.0 functionality from the [Team A.R.G.](http://www.team-arg.org/) *Arglib* library has been added:
|
||||
|
||||
- The sprite drawing functions, collision detection functions, and button handling functions that Team A.R.G. incorporated from the [ArduboyExtra](https://github.com/yyyc514/ArduboyExtra) project. The *poll()* function was renamed *pollButtons()* for clarity. The *Sprites* class doesn't require a parameter for the constructor, whereas in *Arglib* a pointer to an Arduboy class object is required.
|
||||
- The *drawCompressed()* function, which allows compressed bitmaps to be drawn. Saving bitmaps in compressed form may reduce overall sketch size.
|
||||
|
||||
Team A.R.G. has now migrated all of their games and demos to use the Arduboy2 library.
|
||||
|
||||
## Migrating a sketch from Arduboy library V1.1 to Arduboy2
|
||||
|
||||
Since the Arduboy2 library can coexist in the Arduino IDE alongside the Arduboy library V1.1, a currently working sketch that uses Arduboy V1.1 doesn't have to be migrated to Arduboy2. However, if you want to switch a sketch to Arduboy2 for further development, in order to take advantage of any of the changes and enhancements, it's generally relatively easy.
|
||||
|
||||
The Arduboy2 library, for the most part, is compatible with Arduboy library V1.1 but migrating a sketch to Arduboy2 will require some small changes, and more so if it uses the *tunes* functions, such as *tunes.tone()* or *tunes.playScore()*.
|
||||
|
||||
### Required changes
|
||||
|
||||
The first thing to do is change the `include` for the library header file:
|
||||
|
||||
```cpp
|
||||
#include <Arduboy.h>
|
||||
```
|
||||
|
||||
becomes
|
||||
|
||||
```cpp
|
||||
#include <Arduboy2.h>
|
||||
```
|
||||
|
||||
If it was "Arduboy.h" (in quotes), it's still better to change it to <Arduboy2.h> (in angle brackets).
|
||||
|
||||
The same thing has to be done with creating the library object. (If the object name isn't *arduboy*, keep whatever name is used.):
|
||||
|
||||
```cpp
|
||||
Arduboy arduboy;
|
||||
```
|
||||
|
||||
becomes
|
||||
|
||||
```cpp
|
||||
Arduboy2 arduboy;
|
||||
```
|
||||
|
||||
If the sketch doesn't use any *tunes* functions, there's a good chance this is all that has to be done to make it compile.
|
||||
|
||||
### Sketch uses only *tunes.tone()* for sound
|
||||
|
||||
If the sketch has sound but only uses *tunes.tone()*, solutions are:
|
||||
|
||||
#### Solution 1: Switch to using Arduino *tone()*
|
||||
|
||||
An easy change is to use the Arduino built in *tone()* function. You can add a function to the sketch that wraps *tone()* so that it works like *tunes.tone()*, like so:
|
||||
|
||||
```cpp
|
||||
// Wrap the Arduino tone() function so that the pin doesn't have to be
|
||||
// specified each time. Also, don't play if audio is set to off.
|
||||
void playTone(unsigned int frequency, unsigned long duration)
|
||||
{
|
||||
if (arduboy.audio.enabled() == true)
|
||||
{
|
||||
tone(PIN_SPEAKER_1, frequency, duration);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You then change all *tunes.tone()* calls to *playTone()* calls using the same parameter values. For example:
|
||||
|
||||
```cpp
|
||||
arduboy.tunes.tone(1000, 250);
|
||||
```
|
||||
|
||||
becomes
|
||||
|
||||
```cpp
|
||||
playTone(1000, 250);
|
||||
```
|
||||
|
||||
#### Solution 2: Switch to using the ArduboyTones library
|
||||
|
||||
Changing to the *ArduboyTones* library is slightly more complicated. The advantage is that it will generate less code than using *tone()* and will also allow you to easily enhance the sketch to play tone sequences instead of just single tones. ArduboyTones can also play each tone at either normal or a higher volume.
|
||||
|
||||
You have to add an include for the ArduboyTones header file:
|
||||
|
||||
```cpp
|
||||
#include <ArduboyTones.h>
|
||||
```
|
||||
|
||||
You then have to create an object for the *ArduboyTones* class and pass it a pointer to the Arduboy2 *audio.enabled()* function. This must go after the creation of the Arduboy2 object, like so:
|
||||
|
||||
```cpp
|
||||
Arduboy2 arduboy;
|
||||
ArduboyTones sound(arduboy.audio.enabled);
|
||||
```
|
||||
|
||||
You then change all Arduboy *tunes.tone()* calls to ArduboyTones *tone()* calls using the same parameter values. For example:
|
||||
|
||||
```cpp
|
||||
arduboy.tunes.tone(1000, 250);
|
||||
```
|
||||
|
||||
becomes
|
||||
|
||||
```cpp
|
||||
sound.tone(1000, 250);
|
||||
```
|
||||
|
||||
See the [ArduboyTones](https://github.com/MLXXXp/ArduboyTones) README file for more information on installing and using it.
|
||||
|
||||
#### Solution 3: Switch to using the ArduboyPlaytune library.
|
||||
|
||||
See the following for how to do this:
|
||||
|
||||
### Sketch uses *tunes.playScore()*
|
||||
|
||||
If the sketch uses *tunes.playScore()*, probably the easiest solution is to use the *ArduboyPlaytune* library. *ArduboyPlaytune* is essentially the code that was in the Arduboy V1.1 *tunes* subclass, which has been removed from Arduboy2. It's been cleaned up and a few enhancements have been added, but all the Arduboy V1.1 *tunes* functions are available.
|
||||
|
||||
You have to add an include for the ArduboyPlaytune header file:
|
||||
|
||||
```cpp
|
||||
#include <ArduboyPlaytune.h>
|
||||
```
|
||||
|
||||
You then have to create an object for the *ArduboyPlaytune* class and pass it a pointer to the Arduboy2 *audio.enabled()* function. This must go after the creation of the Arduboy2 object, like so:
|
||||
|
||||
```cpp
|
||||
Arduboy2 arduboy;
|
||||
ArduboyPlaytune tunes(arduboy.audio.enabled);
|
||||
```
|
||||
|
||||
The sound channels must then be initialzed and assigned to the speaker pins. This code would go in the *setup()* function:
|
||||
|
||||
```cpp
|
||||
// audio setup
|
||||
tunes.initChannel(PIN_SPEAKER_1);
|
||||
#ifndef AB_DEVKIT
|
||||
// if not a DevKit
|
||||
tunes.initChannel(PIN_SPEAKER_2);
|
||||
#else
|
||||
// if it's a DevKit
|
||||
tunes.initChannel(PIN_SPEAKER_1); // use the same pin for both channels
|
||||
tunes.toneMutesScore(true); // mute the score when a tone is sounding
|
||||
#endif
|
||||
```
|
||||
|
||||
If you name the ArduboyPlaytune object *tunes* as shown above, then you just have to remove the Arduboy object name from any *tunes* calls. For example:
|
||||
|
||||
```cpp
|
||||
arduboy.tunes.playScore(mySong);
|
||||
```
|
||||
|
||||
becomes
|
||||
|
||||
```cpp
|
||||
tunes.playScore(mySong);
|
||||
```
|
||||
|
||||
See the [*ArduboyPlaytune* library](https://github.com/Arduboy/ArduboyPlayTune) documentation for more information.
|
||||
|
||||
If you don't need to play scores containing two parts, and don't require tones to be played in parallel with a score that's playing, then as an alternative to using *ArduboyPlaytune* you may wish to consider switching to *ArduboyTones*. This may require a bit of work because any *ArduboyPlaytune* scores would have to be converted to *ArduboyTones* format. It would involve changing note numbers to frequencies. This could be simplified by using the provided *NOTE_* defines. Also, durations would have to be converted, including adding silent "rest" tones as necessary.
|
||||
|
||||
The benefit of using *ArduboyTones* would be reduced code size and possibly easier addition of new sequences without the need of a MIDI to Playtune format converter.
|
||||
|
||||
### Sketch uses the *beginNoLogo()* function instead of *begin()*
|
||||
|
||||
The *beginNoLogo()* function has been removed. Instead, *boot()* can be used with additional functions following it to add back in desired boot functionality. See the information above, under the heading *Remove boot up features*, for more details. Assuming the object is named *arduboy*, a direct replacement for *beginNoLogo()* would be:
|
||||
|
||||
```cpp
|
||||
arduboy.boot();
|
||||
arduboy.display();
|
||||
arduboy.flashlight();
|
||||
arduboy.audio.begin();
|
||||
```
|
||||
|
||||
----------
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# ArduBreakout
|
||||
|
||||
Brick breaking game in the vein of Atari's *Breakout*.
|
||||
|
||||
Control the paddle with the directional keys to keep a ball bouncing against a brick wall until all of the bricks are broken.
|
||||
|
||||
High scores are saved to EEPROM and can be saved through Arduboy restarts.
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
This sketch provides an example of using the Arduboy2 library's BeepPin1 class
|
||||
to play simple tones.
|
||||
*/
|
||||
|
||||
/*
|
||||
To the extent possible under law, Scott Allen has waived all copyright and
|
||||
related or neighboring rights to this BeepDemo program.
|
||||
*/
|
||||
|
||||
// Comments are only provided for code dealing with tone generation or control.
|
||||
|
||||
#include <Arduboy2.h>
|
||||
// There's no need to #include <Arduboy2Beep.h>
|
||||
// It will be included in Arduboy2.h
|
||||
|
||||
Arduboy2 arduboy;
|
||||
|
||||
BeepPin1 beep; // Create a class instance for speaker pin 1
|
||||
//BeepPin2 beep; // For speaker pin 2, use this line instead of the line above
|
||||
|
||||
int objectX = 0;
|
||||
|
||||
char displayText[60];
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
arduboy.setFrameRate(25);
|
||||
|
||||
beep.begin(); // Set up the hardware for playing tones
|
||||
|
||||
commandText("none - Press buttons");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!arduboy.nextFrame()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The timer() function is called once per frame, so duration values will be
|
||||
// the number of frames that the tone plays for.
|
||||
// At 25 frames per second each frame will be 40ms.
|
||||
beep.timer(); // handle tone duration
|
||||
|
||||
arduboy.pollButtons();
|
||||
|
||||
if (arduboy.justPressed(LEFT_BUTTON)) {
|
||||
// Play a 523.251Hz tone (piano note C5) for 5 frames (200ms at 25 FPS)
|
||||
// beep.freq(523.251) is used to convert 523.251Hz to the required count
|
||||
beep.tone(beep.freq(523.251), 5);
|
||||
|
||||
commandText("beep.tone(\n beep.freq(523.251),\n 5)");
|
||||
}
|
||||
|
||||
if (arduboy.justPressed(UP_BUTTON)) {
|
||||
// Play a 587.330Hz tone (piano note D5) for 15 frames (600ms at 25 FPS)
|
||||
beep.tone(beep.freq(587.330), 15);
|
||||
|
||||
commandText("beep.tone(\n beep.freq(587.330),\n 15)");
|
||||
}
|
||||
|
||||
if (arduboy.justPressed(RIGHT_BUTTON)) {
|
||||
// Play a 659.255Hz tone (piano note E5) for 50 frames (2s at 25 FPS)
|
||||
beep.tone(beep.freq(659.255), 50);
|
||||
|
||||
commandText("beep.tone(\n beep.freq(659.255),\n 50)");
|
||||
}
|
||||
|
||||
if (arduboy.justPressed(DOWN_BUTTON)) {
|
||||
// Play a 698.456Hz tone (piano note F5) until stopped
|
||||
// or replaced by another tone
|
||||
beep.tone(beep.freq(698.456));
|
||||
|
||||
commandText("beep.tone(\n beep.freq(698.456))");
|
||||
}
|
||||
|
||||
if (arduboy.justPressed(A_BUTTON)) {
|
||||
// For short tones with a duration less than a frame time,
|
||||
// or when timer() isn't being used, such as in a menu,
|
||||
// a continuous tone can be played and then stopped after a delay
|
||||
// but note that no other work will be done during the delay.
|
||||
beep.tone(beep.freq(1000)); // Play a 1000Hz tone until stopped
|
||||
arduboy.delayShort(30); // Delay for 30ms
|
||||
beep.noTone(); // Stop the tone
|
||||
|
||||
commandText("beep.tone(\n beep.freq(1000))\n(delay 30ms)\nbeep.noTone()");
|
||||
}
|
||||
|
||||
if (arduboy.justPressed(B_BUTTON)) {
|
||||
beep.noTone(); // Stop the tone if one is playing
|
||||
|
||||
commandText("beep.noTone()");
|
||||
}
|
||||
|
||||
arduboy.println(F("Last command:"));
|
||||
arduboy.print(displayText);
|
||||
|
||||
// The Arduboy2 class's audio subclass controls sound muting.
|
||||
// For this sketch, mute or unmute can be set using the "System Control"
|
||||
// start up feature. (Hold B while powering up then, while still holding B,
|
||||
// press UP to enable sound or DOWN for mute.)
|
||||
if (!arduboy.audio.enabled()) {
|
||||
arduboy.setCursor(22, 40);
|
||||
arduboy.print(F("Sound is MUTED"));
|
||||
}
|
||||
|
||||
arduboy.setCursor(0, 48);
|
||||
// The "duration" variable can be tested for non-zero to determine if a
|
||||
// timed tone is currently playing.
|
||||
if (beep.duration != 0) {
|
||||
arduboy.print(F("A tone is playing"));
|
||||
}
|
||||
else {
|
||||
arduboy.print(F("Continuous tone or\nno tone playing"));
|
||||
}
|
||||
|
||||
arduboy.drawRect(objectX, 40, 6, 6);
|
||||
if (++objectX == WIDTH - 6) {
|
||||
objectX = 0;
|
||||
}
|
||||
|
||||
arduboy.display(CLEAR_BUFFER);
|
||||
}
|
||||
|
||||
void commandText(const char* text) {
|
||||
strncpy(displayText, text, sizeof displayText);
|
||||
displayText[sizeof displayText - 1] = '\0';
|
||||
}
|
||||
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
Buttons example
|
||||
June 11, 2015
|
||||
Copyright (C) 2015 David Martinez
|
||||
All rights reserved.
|
||||
This code is the most basic barebones code for showing how to use buttons in
|
||||
Arduboy.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <Arduboy2.h>
|
||||
|
||||
// Make an instance of arduboy used for many functions
|
||||
Arduboy2 arduboy;
|
||||
|
||||
// Variables for your game go here.
|
||||
char title[] = "Press Buttons!";
|
||||
byte x;
|
||||
byte y;
|
||||
|
||||
// Width of each charcter including inter-character space
|
||||
#define CHAR_WIDTH 6
|
||||
|
||||
// Height of each charater
|
||||
#define CHAR_HEIGHT 8
|
||||
|
||||
// To get the number of characters, we subtract 1 from the length of
|
||||
// the array because there will be a NULL terminator at the end.
|
||||
#define NUM_CHARS (sizeof(title) - 1)
|
||||
|
||||
// This is the highest value that x can be without the end of the text
|
||||
// going farther than the right side of the screen. We add one because
|
||||
// there will be a 1 pixel space at the end of the last character.
|
||||
// WIDTH and HEIGHT are defined in the Arduboy library.
|
||||
#define X_MAX (WIDTH - (NUM_CHARS * CHAR_WIDTH) + 1)
|
||||
|
||||
// This is the highest value that y can be without the text going below
|
||||
// the bottom of the screen.
|
||||
#define Y_MAX (HEIGHT - CHAR_HEIGHT)
|
||||
|
||||
|
||||
// This function runs once in your game.
|
||||
// use it for anything that needs to be set only once in your game.
|
||||
void setup() {
|
||||
//initiate arduboy instance
|
||||
arduboy.begin();
|
||||
|
||||
// here we set the framerate to 30, we do not need to run at default 60 and
|
||||
// it saves us battery life.
|
||||
arduboy.setFrameRate(30);
|
||||
|
||||
// set x and y to the middle of the screen
|
||||
x = (WIDTH / 2) - (NUM_CHARS * CHAR_WIDTH / 2);
|
||||
y = (HEIGHT / 2) - (CHAR_HEIGHT / 2);
|
||||
}
|
||||
|
||||
|
||||
// our main game loop, this runs once every cycle/frame.
|
||||
// this is where our game logic goes.
|
||||
void loop() {
|
||||
// pause render until it's time for the next frame
|
||||
if (!(arduboy.nextFrame()))
|
||||
return;
|
||||
|
||||
// the next couple of lines will deal with checking if the D-pad buttons
|
||||
// are pressed and move our text accordingly.
|
||||
// We check to make sure that x and y stay within a range that keeps the
|
||||
// text on the screen.
|
||||
|
||||
// if the right button is pressed move 1 pixel to the right every frame
|
||||
if(arduboy.pressed(RIGHT_BUTTON) && (x < X_MAX)) {
|
||||
x++;
|
||||
}
|
||||
|
||||
// if the left button is pressed move 1 pixel to the left every frame
|
||||
if(arduboy.pressed(LEFT_BUTTON) && (x > 0)) {
|
||||
x--;
|
||||
}
|
||||
|
||||
// if the up button or B button is pressed move 1 pixel up every frame
|
||||
if((arduboy.pressed(UP_BUTTON) || arduboy.pressed(B_BUTTON)) && (y > 0)) {
|
||||
y--;
|
||||
}
|
||||
|
||||
// if the down button or A button is pressed move 1 pixel down every frame
|
||||
if((arduboy.pressed(DOWN_BUTTON) || arduboy.pressed(A_BUTTON)) && (y < Y_MAX)) {
|
||||
y++;
|
||||
}
|
||||
|
||||
|
||||
// we clear our screen to black
|
||||
arduboy.clear();
|
||||
|
||||
// we set our cursor x pixels to the right and y down from the top
|
||||
arduboy.setCursor(x, y);
|
||||
|
||||
// then we print to screen what is stored in our title variable we declared earlier
|
||||
arduboy.print(title);
|
||||
|
||||
// then we finaly we tell the arduboy to display what we just wrote to the display.
|
||||
arduboy.display();
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
Buttons
|
||||
=======
|
||||
|
||||
A an example that demonstrates how to capture input from the buttons.
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Hello, World! example
|
||||
June 11, 2015
|
||||
Copyright (C) 2015 David Martinez
|
||||
All rights reserved.
|
||||
This code is the most basic barebones code for writing a program for Arduboy.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <Arduboy2.h>
|
||||
|
||||
// make an instance of arduboy used for many functions
|
||||
Arduboy2 arduboy;
|
||||
|
||||
|
||||
// This function runs once in your game.
|
||||
// use it for anything that needs to be set only once in your game.
|
||||
void setup() {
|
||||
// initiate arduboy instance
|
||||
arduboy.begin();
|
||||
|
||||
// here we set the framerate to 15, we do not need to run at
|
||||
// default 60 and it saves us battery life
|
||||
arduboy.setFrameRate(15);
|
||||
}
|
||||
|
||||
|
||||
// our main game loop, this runs once every cycle/frame.
|
||||
// this is where our game logic goes.
|
||||
void loop() {
|
||||
// pause render until it's time for the next frame
|
||||
if (!(arduboy.nextFrame()))
|
||||
return;
|
||||
|
||||
// first we clear our screen to black
|
||||
arduboy.clear();
|
||||
|
||||
// we set our cursor 5 pixels to the right and 10 down from the top
|
||||
// (positions start at 0, 0)
|
||||
arduboy.setCursor(4, 9);
|
||||
|
||||
// then we print to screen what is in the Quotation marks ""
|
||||
arduboy.print(F("Hello, world!"));
|
||||
|
||||
// then we finaly we tell the arduboy to display what we just wrote to the display
|
||||
arduboy.display();
|
||||
}
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
/***************************************************************
|
||||
Play a musical composition in the background while
|
||||
the main sketch code runs in the foreground.
|
||||
|
||||
The ArduboyPlaytune library must be installed to use this sketch
|
||||
https://github.com/Arduboy/ArduboyPlayTune
|
||||
|
||||
The D-Pad buttons will move the text and play a tone.
|
||||
|
||||
The A button mutes the sound.
|
||||
The screen is inverted when sound is muted.
|
||||
|
||||
The B button will turn sound back on if it's muted.
|
||||
|
||||
The score that is played contains two parts.
|
||||
With the DevKit only one part is played.
|
||||
***************************************************************/
|
||||
|
||||
#include <Arduboy2.h>
|
||||
#include <ArduboyPlaytune.h>
|
||||
|
||||
// 2 Part Inventions No. 3 - J.S. Bach
|
||||
const byte score[] PROGMEM = {
|
||||
2,154, 0x90,62, 0,166, 0x90,64, 0,166, 0x90,66, 0,166, 0x90,64, 0,166,
|
||||
0x90,67, 0,166, 0x90,66, 0,166, 0x90,64, 0,166, 0x90,62, 0,166, 0x90,69,
|
||||
0,166, 0x90,67, 0,166, 0x90,66, 0,166, 0x90,64, 0,166, 0x91,50, 0x90,66,
|
||||
0,166, 0x91,52, 0x90,62, 0,166, 0x91,54, 0x90,69, 0,166, 0x91,52, 0,166,
|
||||
0x90,71, 0x91,55, 0,166, 0x91,54, 0,166, 0x90,73, 0x91,52, 0,55, 0x90,71,
|
||||
0,55, 0x90,73, 0,55, 0x91,50, 0x90,74, 0,166, 0x91,57, 0x90,73, 0,83,
|
||||
0x90,74, 0,83, 0x91,55, 0x90,73, 0,166, 0x91,54, 0x90,71, 0,83, 0x90,69,
|
||||
0,83, 0x91,52, 0,125, 0x80, 0,41, 0x90,73, 0x91,54, 0,166, 0x90,74, 0x91,50,
|
||||
0,166, 0x90,76, 0x91,57, 0,166, 0x90,73, 0,166, 0x91,45, 0x90,78, 0,166,
|
||||
0x90,74, 0,166, 0x91,57, 0x90,73, 0,166, 0x90,71, 0,138, 0x81, 0,27, 0x91,57,
|
||||
0x90,76, 0,166, 0x90,73, 0,166, 0x91,45, 0x90,74, 0,166, 0x90,71, 0,166,
|
||||
0x91,57, 0x90,69, 0,166, 0x90,68, 0,138, 0x81, 0,27, 0x91,57, 0x90,76, 0,166,
|
||||
0x90,73, 0,166, 0x91,45, 0x90,78, 0,166, 0x90,74, 0,166, 0x91,57, 0x90,73,
|
||||
0,166, 0x90,71, 0,138, 0x81, 0,27, 0x91,57, 0x90,76, 0,166, 0x90,73, 0,166,
|
||||
0x91,45, 0x90,74, 0,166, 0x90,71, 0,166, 0x91,57, 0x90,69, 0,166, 0x90,68,
|
||||
0,138, 0x81, 0,27, 0x91,57, 0x90,73, 0,166, 0x90,71, 0,166, 0x91,59, 0x90,74,
|
||||
0,166, 0x90,73, 0,166, 0x91,61, 0x90,71, 0,166, 0x90,69, 0,166, 0x91,62,
|
||||
0x90,78, 0,166, 0x91,61, 0,166, 0x90,68, 0x91,64, 0,166, 0x91,62, 0,166,
|
||||
0x90,69, 0x91,61, 0,166, 0x91,59, 0,166, 0x91,61, 0,27, 0x80, 0,27, 0x90,71,
|
||||
0,55, 0x90,69, 0,55, 0x91,62, 0x90,68, 0,55, 0x90,69, 0,55, 0x90,71,
|
||||
0,27, 0x80, 0,27, 0x90,71, 0x91,64, 1,77, 0x91,52, 0,166, 0x90,69, 0,166,
|
||||
0x91,57, 0x90,69, 0,166, 0x91,52, 0,166, 0x91,54, 0,166, 0x91,56, 0,166,
|
||||
0x91,57, 0x80, 0,166, 0x91,59, 0,166, 0x91,61, 0,166, 0x91,59, 0,166, 0x90,76,
|
||||
0x91,62, 0,166, 0x91,61, 0,166, 0x90,81, 0x91,59, 0,166, 0x91,57, 0,166,
|
||||
0x91,64, 0,166, 0x90,71, 0,166, 0x91,52, 0x90,73, 0,166, 0x90,75, 0,166,
|
||||
0x90,76, 0x81, 0,166, 0x90,78, 0,166, 0x90,79, 0,166, 0x90,78, 0,166, 0x91,59,
|
||||
0x90,81, 0,166, 0x90,79, 0,166, 0x91,64, 0x90,78, 0,166, 0x90,76, 0,166,
|
||||
0x90,83, 0,166, 0x91,54, 0,166, 0x90,71, 0x91,56, 0,166, 0x91,58, 0,166,
|
||||
0x91,59, 0x80, 0,166, 0x91,61, 0,166, 0x91,62, 0,166, 0x91,61, 0,166, 0x90,66,
|
||||
0x91,64, 0,166, 0x91,62, 0,166, 0x90,71, 0x91,61, 0,166, 0x91,59, 0,166,
|
||||
0x91,66, 0,166, 0x90,70, 0,166, 0x91,54, 0x90,71, 0,166, 0x90,73, 0,166,
|
||||
0x91,64, 0x90,74, 0,166, 0x90,76, 0,166, 0x91,62, 0x90,78, 0,166, 0x90,76,
|
||||
0,166, 0x91,71, 0x90,79, 0,166, 0x91,70, 0x90,78, 0,166, 0x91,71, 0x90,76,
|
||||
0,166, 0x90,74, 0,166, 0x91,61, 0x90,76, 0,166, 0x90,74, 0,166, 0x91,70,
|
||||
0x90,78, 0,166, 0x91,68, 0x90,76, 0,166, 0x91,70, 0x90,74, 0,166, 0x90,73,
|
||||
0,166, 0x91,71, 0x90,74, 0,166, 0x91,69, 0x90,73, 0,166, 0x91,67, 0x90,76,
|
||||
0,166, 0x91,66, 0x90,74, 0,166, 0x91,64, 0x90,73, 0,166, 0x91,62, 0x90,71,
|
||||
0,166, 0x91,64, 0x90,73, 0,166, 0x91,62, 0,166, 0x90,70, 0x91,66, 0,83,
|
||||
0x90,68, 0,83, 0x91,64, 0x90,70, 0,166, 0x91,62, 0x90,71, 0,166, 0x91,61,
|
||||
0,166, 0x91,62, 0,166, 0x90,73, 0x91,64, 0,138, 0x80, 0,27, 0x90,73, 0x91,66,
|
||||
0,83, 0x90,74, 0,83, 0x90,73, 0,166, 0x91,54, 0,166, 0x90,71, 0,166,
|
||||
0x91,59, 0,166, 0x90,66, 0,166, 0x91,54, 0x90,68, 0,166, 0x90,70, 0,166,
|
||||
0x91,50, 0x90,71, 0,166, 0x90,73, 0,166, 0x91,47, 0x90,74, 0,166, 0x90,73,
|
||||
0,166, 0x90,76, 0,166, 0x90,74, 0,166, 0x90,73, 0x81, 0,166, 0x90,71, 0,166,
|
||||
0x90,79, 0,166, 0x91,47, 0,166, 0x91,49, 0,166, 0x91,51, 0,166, 0x91,52,
|
||||
0,166, 0x91,54, 0,166, 0x91,55, 0,166, 0x91,54, 0,166, 0x91,57, 0,166,
|
||||
0x91,55, 0,166, 0x91,54, 0,166, 0x91,52, 0,166, 0x91,57, 0,138, 0x80, 0,27,
|
||||
0x90,64, 0,166, 0x90,66, 0,166, 0x90,68, 0,166, 0x90,69, 0,166, 0x90,71,
|
||||
0,166, 0x90,73, 0,166, 0x90,71, 0,166, 0x90,74, 0,166, 0x90,73, 0,166,
|
||||
0x90,71, 0,166, 0x90,69, 0,166, 0x90,78, 0,138, 0x81, 0,27, 0x91,45, 0,166,
|
||||
0x91,47, 0,166, 0x91,49, 0,166, 0x91,50, 0,166, 0x91,52, 0,166, 0x91,54,
|
||||
0,166, 0x91,52, 0,166, 0x91,55, 0,166, 0x91,54, 0,166, 0x91,52, 0,166,
|
||||
0x91,50, 0,166, 0x91,56, 0,138, 0x80, 0,27, 0x90,71, 0,166, 0x90,76, 0,166,
|
||||
0x91,52, 0x90,74, 0,166, 0x91,54, 0x90,73, 0,166, 0x91,56, 0x90,71, 0,166,
|
||||
0x91,57, 0x90,73, 0,166, 0x91,56, 0x90,71, 0,166, 0x91,54, 0x90,74, 0,166,
|
||||
0x91,52, 0x90,73, 0,166, 0x91,50, 0x90,71, 0,166, 0x91,54, 0x90,69, 0,166,
|
||||
0x91,52, 0x90,68, 0,83, 0x90,69, 0,83, 0x91,50, 0x90,68, 0,166, 0x91,49,
|
||||
0x90,64, 0,166, 0x91,47, 0,166, 0x90,69, 0x91,49, 0,166, 0x90,71, 0x91,45,
|
||||
0,166, 0x90,73, 0x91,57, 0,166, 0x90,71, 0,166, 0x91,54, 0x90,74, 0,166,
|
||||
0x90,73, 0,166, 0x91,49, 0x90,71, 0,166, 0x90,69, 0,166, 0x91,50, 0x90,78,
|
||||
0,166, 0x91,49, 0,166, 0x91,52, 0,166, 0x90,68, 0x91,50, 0,166, 0x90,69,
|
||||
0x91,49, 0,166, 0x90,68, 0x91,47, 0,166, 0x90,69, 0x91,49, 0,166, 0x90,74,
|
||||
0x91,50, 0,166, 0x90,71, 0x91,52, 1,77, 0x91,40, 0,166, 0x90,69, 0,138,
|
||||
0x80, 0,27, 0x90,69, 0x91,45, 0,166, 0x91,49, 0,166, 0x91,50, 0,166, 0x90,73,
|
||||
0x91,52, 0,166, 0x90,74, 0x91,54, 0,166, 0x90,76, 0x91,55, 0,166, 0x90,66,
|
||||
0x91,57, 0,166, 0x91,55, 0,166, 0x90,67, 0x91,59, 0,166, 0x91,57, 0,166,
|
||||
0x90,71, 0x91,55, 0,83, 0x90,69, 0,83, 0x91,54, 0x90,67, 0,83, 0x90,69,
|
||||
0,83, 0x91,55, 0x90,71, 0,166, 0x91,54, 0,166, 0x90,74, 0x91,57, 0,83,
|
||||
0x90,73, 0,83, 0x91,55, 0x90,71, 0,83, 0x90,73, 0,83, 0x91,54, 0x90,74,
|
||||
0,166, 0x91,52, 0,166, 0x91,54, 0,166, 0x90,73, 0x91,52, 0,166, 0x90,76,
|
||||
0x91,55, 0,166, 0x90,74, 0x91,54, 0,166, 0x90,73, 0x91,52, 0,166, 0x90,74,
|
||||
0x91,50, 0,166, 0x90,76, 0x91,57, 0,166, 0x90,74, 0,166, 0x91,45, 0x90,73,
|
||||
0,166, 0x90,71, 0,166, 0x90,69, 0x81, 0,166, 0x90,67, 0,166, 0x90,66, 0,166,
|
||||
0x90,64, 0,166, 0x90,67, 0,166, 0x90,66, 0,166, 0x90,64, 0,166, 0x90,62,
|
||||
0,166, 0x90,69, 0,166, 0x90,67, 0,166, 0x90,66, 0,166, 0x90,64, 0,166,
|
||||
0x91,50, 0x90,66, 0,166, 0x91,52, 0x90,62, 0,166, 0x91,54, 0x90,69, 0,166,
|
||||
0x91,52, 0,166, 0x90,71, 0x91,55, 0,166, 0x91,54, 0,166, 0x90,73, 0x91,52,
|
||||
0,55, 0x90,71, 0,55, 0x90,73, 0,55, 0x91,50, 0x90,74, 0,166, 0x91,57,
|
||||
0x90,73, 0,83, 0x90,74, 0,83, 0x91,55, 0x90,73, 0,166, 0x91,54, 0x90,71,
|
||||
0,83, 0x90,69, 0,83, 0x91,52, 0,125, 0x80, 0,41, 0x90,74, 0x91,54, 0,166,
|
||||
0x91,50, 0,138, 0x80, 0,27, 0x90,74, 0x91,57, 0,166, 0x91,54, 0,166, 0x90,62,
|
||||
0x91,59, 0,166, 0x91,55, 0,166, 0x90,74, 0x91,54, 0,166, 0x91,52, 0,138,
|
||||
0x80, 0,27, 0x90,74, 0x91,57, 0,166, 0x91,54, 0,166, 0x90,62, 0x91,55, 0,166,
|
||||
0x91,52, 0,166, 0x90,74, 0x91,50, 0,166, 0x91,49, 0,138, 0x80, 0,27, 0x90,74,
|
||||
0x91,57, 0,166, 0x91,54, 0,166, 0x90,62, 0x91,59, 0,166, 0x91,55, 0,166,
|
||||
0x90,74, 0x91,54, 0,166, 0x91,52, 0,138, 0x80, 0,27, 0x90,74, 0x91,57, 0,166,
|
||||
0x91,54, 0,166, 0x90,62, 0x91,55, 0,166, 0x91,52, 0,166, 0x90,74, 0x91,50,
|
||||
0,166, 0x90,76, 0x91,49, 0,166, 0x90,78, 0x91,50, 0,166, 0x90,76, 0,166,
|
||||
0x91,52, 0x90,79, 0,166, 0x90,78, 0,166, 0x91,54, 0x90,76, 0,166, 0x90,74,
|
||||
0,166, 0x91,55, 0x90,83, 0,166, 0x91,54, 0,166, 0x90,73, 0x91,57, 0,166,
|
||||
0x91,55, 0,166, 0x90,74, 0x91,54, 0,166, 0x91,52, 0,166, 0x91,54, 0,27,
|
||||
0x80, 0,27, 0x90,76, 0,55, 0x90,74, 0,55, 0x91,55, 0x90,73, 0,55, 0x90,74,
|
||||
0,55, 0x90,76, 0,41, 0x80, 0,13, 0x90,76, 0x91,57, 1,77, 0x91,45, 0,166,
|
||||
0x90,74, 0,138, 0x80, 0,27, 0x90,74, 0x91,47, 0,166, 0x91,45, 0,166, 0x90,62,
|
||||
0x91,48, 0,166, 0x91,47, 0,166, 0x90,67, 0x91,45, 0,166, 0x91,43, 0,166,
|
||||
0x91,50, 0,166, 0x90,57, 0,166, 0x90,59, 0,166, 0x90,61, 0,166, 0x90,62,
|
||||
0,166, 0x90,64, 0,166, 0x90,66, 0,138, 0x81, 0,27, 0x91,49, 0x90,64, 0,166,
|
||||
0x91,47, 0x90,67, 0,166, 0x91,45, 0x90,66, 0,166, 0x91,43, 0x90,64, 0,166,
|
||||
0x91,42, 0x90,62, 0,166, 0x91,43, 0x90,71, 0,166, 0x91,42, 0,166, 0x91,45,
|
||||
0,166, 0x90,61, 0x91,43, 0,166, 0x90,62, 0x91,42, 0,166, 0x90,61, 0x91,40,
|
||||
0,166, 0x90,62, 0x91,42, 0,166, 0x90,67, 0x91,43, 0,166, 0x90,64, 0x91,45,
|
||||
1,244, 0x90,62, 0,138, 0x80, 0,27, 0x90,62, 0x91,38, 7,208, 0x80, 0x81,
|
||||
0xf0
|
||||
};
|
||||
|
||||
Arduboy2 arduboy;
|
||||
ArduboyPlaytune tunes(arduboy.audio.enabled);
|
||||
|
||||
void setup()
|
||||
{
|
||||
arduboy.begin();
|
||||
|
||||
arduboy.setFrameRate(25);
|
||||
arduboy.setTextSize(3);
|
||||
|
||||
// audio setup
|
||||
tunes.initChannel(PIN_SPEAKER_1);
|
||||
#ifndef AB_DEVKIT
|
||||
// if not a DevKit
|
||||
tunes.initChannel(PIN_SPEAKER_2);
|
||||
#else
|
||||
// if it's a DevKit
|
||||
tunes.initChannel(PIN_SPEAKER_1); // use the same pin for both channels
|
||||
tunes.toneMutesScore(true); // mute the score when a tone is sounding
|
||||
#endif
|
||||
|
||||
arduboy.invert(!arduboy.audio.enabled()); // invert display if sound muted
|
||||
}
|
||||
|
||||
|
||||
int x = 20, y = 10; // initial text position
|
||||
|
||||
void loop()
|
||||
{
|
||||
// pause render until it's time for the next frame
|
||||
if (!(arduboy.nextFrame()))
|
||||
return;
|
||||
|
||||
if (arduboy.pressed(UP_BUTTON)) {
|
||||
y-=1;
|
||||
tunes.tone(1175,300);
|
||||
} else if (arduboy.pressed(DOWN_BUTTON)) {
|
||||
y+=1;
|
||||
tunes.tone(1397,300);
|
||||
} else if (arduboy.pressed(LEFT_BUTTON)) {
|
||||
x-=1;
|
||||
tunes.tone(1047,300);
|
||||
} else if (arduboy.pressed(RIGHT_BUTTON)) {
|
||||
x+=1;
|
||||
tunes.tone(1319,300);
|
||||
}
|
||||
|
||||
if (arduboy.pressed(A_BUTTON)) {
|
||||
arduboy.invert(true);
|
||||
arduboy.audio.off();
|
||||
} else if (arduboy.pressed(B_BUTTON)) {
|
||||
arduboy.invert(false);
|
||||
arduboy.audio.on();
|
||||
}
|
||||
|
||||
arduboy.clear();
|
||||
arduboy.setCursor(x,y);
|
||||
arduboy.print("Music");
|
||||
arduboy.setCursor(x+8,y+24);
|
||||
arduboy.print("Demo");
|
||||
arduboy.display();
|
||||
|
||||
// play the tune if we aren't already
|
||||
if (!tunes.playing())
|
||||
tunes.playScore(score);
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# PlayTune
|
||||
|
||||
Play a musical composition using the Arduboy.
|
||||
|
||||
Demonstrates playing music in the background while the "real" sketch code runs in the foreground.
|
||||
|
||||
The ArduboyPlaytune library must be installed to use this sketch
|
||||
|
||||
https://github.com/Arduboy/ArduboyPlayTune
|
||||
|
||||
A small composition is stored by `byte PROGMEM score`. The score is started in the sketch loop using `playScore(score)`.
|
||||
|
||||
D-Pad buttons will move the text and play a tone.
|
||||
|
||||
The A button mutes the sound. The screen is inverted when sound is muted.
|
||||
|
||||
The B button will turn sound back on if it's muted.
|
||||
|
||||
|
|
@ -1,354 +0,0 @@
|
|||
/*
|
||||
This sketch demonstrates controlling the Arduboy's RGB LED,
|
||||
in both analog and digital modes.
|
||||
*/
|
||||
|
||||
/*
|
||||
To the extent possible under law, Scott Allen has waived all copyright and
|
||||
related or neighboring rights to this BeepDemo program.
|
||||
*/
|
||||
|
||||
#include <Arduboy2.h>
|
||||
|
||||
// The frame rate determines the button auto-repeat rate
|
||||
#define FRAME_RATE 25
|
||||
|
||||
// The increment/decrement amount when auto-repeating
|
||||
#define REPEAT_AMOUNT 3
|
||||
|
||||
// Delay time before button auto-repeat starts, in milliseconds
|
||||
#define REPEAT_DELAY 700
|
||||
|
||||
// Calculation of the number of frames to wait before button auto-repeat starts
|
||||
#define DELAY_FRAMES (REPEAT_DELAY / (1000 / FRAME_RATE))
|
||||
|
||||
#define ANALOG false
|
||||
#define DIGITAL true
|
||||
|
||||
#define ANALOG_MAX 255
|
||||
|
||||
// Color array index
|
||||
enum class Color {
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE,
|
||||
COUNT
|
||||
};
|
||||
|
||||
// Map LED color index to LED name
|
||||
const byte LEDpin[(byte)(Color::COUNT)] = {
|
||||
RED_LED,
|
||||
GREEN_LED,
|
||||
BLUE_LED
|
||||
};
|
||||
|
||||
Arduboy2 arduboy;
|
||||
|
||||
// Analog LED values
|
||||
byte analogValue[3] = { 0, 0, 0};
|
||||
// Digital LED states
|
||||
byte digitalState[3] = { RGB_OFF, RGB_OFF, RGB_OFF };
|
||||
|
||||
byte analogSelected = (byte)(Color::RED);
|
||||
byte digitalSelected = (byte)(Color::RED);
|
||||
|
||||
boolean controlMode = ANALOG;
|
||||
|
||||
// Button repeat handling
|
||||
unsigned int delayCount = 0;
|
||||
boolean repeating = false;
|
||||
|
||||
// ============================= SETUP ===================================
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
arduboy.setFrameRate(FRAME_RATE);
|
||||
analogSet();
|
||||
}
|
||||
// =======================================================================
|
||||
|
||||
|
||||
// =========================== MAIN LOOP =================================
|
||||
void loop() {
|
||||
if (!arduboy.nextFrame()) {
|
||||
return;
|
||||
}
|
||||
|
||||
arduboy.pollButtons();
|
||||
|
||||
// Toggle analog/digital control mode
|
||||
if (arduboy.justPressed(A_BUTTON)) {
|
||||
if ((controlMode = !controlMode) == DIGITAL) {
|
||||
arduboy.freeRGBled();
|
||||
digitalSet();
|
||||
}
|
||||
else {
|
||||
analogSet();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset to Analog mode and all LEDs off
|
||||
if (arduboy.justPressed(B_BUTTON)) {
|
||||
reset();
|
||||
}
|
||||
|
||||
// Handle D-pad buttons for current mode
|
||||
if (controlMode == ANALOG) {
|
||||
modeAnalog();
|
||||
}
|
||||
else {
|
||||
modeDigital();
|
||||
}
|
||||
|
||||
// Handle delay before button auto-repeat starts
|
||||
if ((delayCount != 0) && (--delayCount == 0)) {
|
||||
repeating = true;
|
||||
}
|
||||
|
||||
renderScreen(); // Render and display the entire screen
|
||||
}
|
||||
// =======================================================================
|
||||
|
||||
|
||||
// Analog control
|
||||
void modeAnalog() {
|
||||
if (arduboy.justPressed(RIGHT_BUTTON)) {
|
||||
valueInc(1);
|
||||
startButtonDelay();
|
||||
}
|
||||
else if (arduboy.justPressed(LEFT_BUTTON)) {
|
||||
valueDec(1);
|
||||
startButtonDelay();
|
||||
}
|
||||
else if (repeating && arduboy.pressed(RIGHT_BUTTON)) {
|
||||
valueInc(REPEAT_AMOUNT);
|
||||
}
|
||||
else if (repeating && arduboy.pressed(LEFT_BUTTON)) {
|
||||
valueDec(REPEAT_AMOUNT);
|
||||
}
|
||||
else if (arduboy.justPressed(DOWN_BUTTON)) {
|
||||
analogSelectInc();
|
||||
}
|
||||
else if (arduboy.justPressed(UP_BUTTON)) {
|
||||
analogSelectDec();
|
||||
}
|
||||
else if (repeating) {
|
||||
stopButtonRepeat();
|
||||
}
|
||||
}
|
||||
|
||||
// Digital control
|
||||
void modeDigital() {
|
||||
if (arduboy.justPressed(RIGHT_BUTTON) || arduboy.justPressed(LEFT_BUTTON)) {
|
||||
digitalState[digitalSelected] = (digitalState[digitalSelected] == RGB_ON) ?
|
||||
RGB_OFF : RGB_ON;
|
||||
arduboy.digitalWriteRGB(LEDpin[digitalSelected],
|
||||
digitalState[digitalSelected]);
|
||||
}
|
||||
else if (arduboy.justPressed(DOWN_BUTTON)) {
|
||||
digitalSelectInc();
|
||||
}
|
||||
else if (arduboy.justPressed(UP_BUTTON)) {
|
||||
digitalSelectDec();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset to analog mode and turn all LEDs off
|
||||
void reset() {
|
||||
digitalState[(byte)(Color::RED)] = RGB_OFF;
|
||||
digitalState[(byte)(Color::GREEN)] = RGB_OFF;
|
||||
digitalState[(byte)(Color::BLUE)] = RGB_OFF;
|
||||
digitalSet();
|
||||
|
||||
analogValue[(byte)(Color::RED)] = 0;
|
||||
analogValue[(byte)(Color::GREEN)] = 0;
|
||||
analogValue[(byte)(Color::BLUE)] = 0;
|
||||
analogSet();
|
||||
|
||||
digitalSelected = (byte)(Color::RED);
|
||||
analogSelected = (byte)(Color::RED);
|
||||
|
||||
controlMode = ANALOG;
|
||||
}
|
||||
|
||||
// Increment the selected analog LED value by the specified amount
|
||||
// and update the LED
|
||||
void valueInc(byte amount) {
|
||||
if ((ANALOG_MAX - analogValue[analogSelected]) <= amount) {
|
||||
analogValue[analogSelected] = ANALOG_MAX;
|
||||
}
|
||||
else {
|
||||
analogValue[analogSelected] += amount;
|
||||
}
|
||||
|
||||
arduboy.setRGBled(LEDpin[analogSelected], analogValue[analogSelected]);
|
||||
}
|
||||
|
||||
// Decrement the selected analog LED value by the specified amount
|
||||
// and update the LED
|
||||
void valueDec(byte amount) {
|
||||
if (analogValue[analogSelected] <= amount) {
|
||||
analogValue[analogSelected] = 0;
|
||||
}
|
||||
else {
|
||||
analogValue[analogSelected] -= amount;
|
||||
}
|
||||
|
||||
arduboy.setRGBled(LEDpin[analogSelected], analogValue[analogSelected]);
|
||||
}
|
||||
|
||||
// Select the next analog color index with wrap
|
||||
void analogSelectInc() {
|
||||
selectInc(analogSelected);
|
||||
}
|
||||
|
||||
// Select the previous analog color index with wrap
|
||||
void analogSelectDec() {
|
||||
selectDec(analogSelected);
|
||||
}
|
||||
|
||||
// Select the next digital color index with wrap
|
||||
void digitalSelectInc() {
|
||||
selectInc(digitalSelected);
|
||||
}
|
||||
|
||||
// Select the previous digital color index with wrap
|
||||
void digitalSelectDec() {
|
||||
selectDec(digitalSelected);
|
||||
}
|
||||
|
||||
// Select the next color index with wrap
|
||||
void selectInc(byte &index) {
|
||||
if (++index == (byte)(Color::COUNT)) {
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Select the previous color index with wrap
|
||||
void selectDec(byte &index) {
|
||||
if (index == 0) {
|
||||
index = ((byte)(Color::COUNT) - 1);
|
||||
}
|
||||
else {
|
||||
index--;
|
||||
}
|
||||
}
|
||||
|
||||
// Update all LEDs in analog mode
|
||||
void analogSet() {
|
||||
arduboy.setRGBled(analogValue[(byte)(Color::RED)],
|
||||
analogValue[(byte)(Color::GREEN)],
|
||||
analogValue[(byte)(Color::BLUE)]);
|
||||
}
|
||||
|
||||
// Update all LEDs in digital mode
|
||||
void digitalSet() {
|
||||
arduboy.digitalWriteRGB(digitalState[(byte)(Color::RED)],
|
||||
digitalState[(byte)(Color::GREEN)],
|
||||
digitalState[(byte)(Color::BLUE)]);
|
||||
}
|
||||
|
||||
// Start the button auto-repeat delay
|
||||
void startButtonDelay() {
|
||||
delayCount = DELAY_FRAMES;
|
||||
repeating = false;
|
||||
}
|
||||
|
||||
// Stop the button auto-repeat or delay
|
||||
void stopButtonRepeat() {
|
||||
delayCount = 0;
|
||||
repeating = false;
|
||||
}
|
||||
|
||||
// Render and display the screen
|
||||
void renderScreen() {
|
||||
arduboy.setCursor(12, 0);
|
||||
arduboy.print(F("RGB LED"));
|
||||
arduboy.setCursor(15, 56);
|
||||
arduboy.print(F("A:Mode B:Reset"));
|
||||
arduboy.setCursor(74, 0);
|
||||
|
||||
if (controlMode == ANALOG) {
|
||||
arduboy.print(F(" Analog"));
|
||||
drawAnalog(9, Color::RED, "Red:");
|
||||
drawAnalog(25, Color::GREEN, "Green:");
|
||||
drawAnalog(41, Color::BLUE, "Blue:");
|
||||
}
|
||||
else { // Digital
|
||||
arduboy.print(F("Digital"));
|
||||
drawDigital(9, Color::RED, "Red:");
|
||||
drawDigital(25, Color::GREEN, "Green:");
|
||||
drawDigital(41, Color::BLUE, "Blue:");
|
||||
}
|
||||
|
||||
arduboy.display(CLEAR_BUFFER);
|
||||
}
|
||||
|
||||
// Draw the information for one analog color
|
||||
void drawAnalog(int y, Color color, const char* name) {
|
||||
byte value = analogValue[(byte)color];
|
||||
|
||||
arduboy.setCursor(0, y);
|
||||
arduboy.print(name);
|
||||
arduboy.setCursor(42, y);
|
||||
printValue(value);
|
||||
if (analogSelected == (byte)color) {
|
||||
arduboy.print(F(" <--"));
|
||||
}
|
||||
drawBar(y + 8, color, value);
|
||||
}
|
||||
|
||||
// Draw the value bar for an analog color
|
||||
void drawBar(int y, Color color, byte value) {
|
||||
byte barLength = value / 2;
|
||||
|
||||
if (barLength == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (analogSelected == (byte)color) {
|
||||
arduboy.fillRect(0, y, barLength, 5);
|
||||
}
|
||||
else {
|
||||
arduboy.drawRect(0, y, barLength, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the informaton for one digital color
|
||||
void drawDigital(int y, Color color, const char* name) {
|
||||
byte state = digitalState[(byte)color];
|
||||
|
||||
arduboy.setCursor(34, y + 3);
|
||||
arduboy.print(name);
|
||||
arduboy.setCursor(76, y + 3);
|
||||
if (state == RGB_ON) {
|
||||
arduboy.print(F("ON "));
|
||||
arduboy.fillCircle(22, y + 6, 4);
|
||||
}
|
||||
else {
|
||||
arduboy.print(F("OFF"));
|
||||
arduboy.drawCircle(22, y + 6, 4);
|
||||
}
|
||||
|
||||
if (digitalSelected == (byte)color) {
|
||||
arduboy.print(F(" <--"));
|
||||
arduboy.drawRect(16, y, 13, 13);
|
||||
}
|
||||
}
|
||||
|
||||
// Print a byte in decimal and hex
|
||||
void printValue(byte val) {
|
||||
if (val < 100) {
|
||||
arduboy.print(' ');
|
||||
}
|
||||
if (val < 10) {
|
||||
arduboy.print(' ');
|
||||
}
|
||||
arduboy.print(val);
|
||||
|
||||
arduboy.print(F(" 0x"));
|
||||
if (val < 0x10) {
|
||||
arduboy.print('0');
|
||||
}
|
||||
arduboy.print(val, HEX);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
329
extras/Doxyfile
329
extras/Doxyfile
|
|
@ -1,329 +0,0 @@
|
|||
# Doxyfile 1.8.11
|
||||
|
||||
# This file describes the settings to be used by the documentation system
|
||||
# doxygen (www.doxygen.org) for a project.
|
||||
#
|
||||
# All text after a double hash (##) is considered a comment and is placed in
|
||||
# front of the TAG it is preceding.
|
||||
#
|
||||
# All text after a single hash (#) is considered a comment and will be ignored.
|
||||
# The format is:
|
||||
# TAG = value [value, ...]
|
||||
# For lists, items can also be appended using:
|
||||
# TAG += value [value, ...]
|
||||
# Values that contain spaces should be placed between quotes (\" \").
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "Arduboy2 Library"
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = ./doxygen
|
||||
CREATE_SUBDIRS = NO
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = YES
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 2
|
||||
ALIASES =
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING = ino=C++
|
||||
MARKDOWN_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = NO
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = YES
|
||||
HIDE_UNDOC_CLASSES = YES
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
CITE_BIB_FILES =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ./src ./README.md ./LICENSE.txt
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.c *.cc *.cxx *.cpp *.c++ *.h *.hh *.hxx *.hpp *.h++
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
USE_MDFILE_AS_MAINPAGE = ./README.md
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
CLANG_OPTIONS =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_EXTRA_STYLESHEET =
|
||||
HTML_EXTRA_FILES =
|
||||
HTML_COLORSTYLE_HUE = 245
|
||||
HTML_COLORSTYLE_SAT = 90
|
||||
HTML_COLORSTYLE_GAMMA = 95
|
||||
HTML_TIMESTAMP = YES
|
||||
HTML_DYNAMIC_SECTIONS = YES
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||
DOCSET_PUBLISHER_NAME = Publisher
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
CHM_INDEX_ENCODING =
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
GENERATE_QHP = NO
|
||||
QCH_FILE =
|
||||
QHP_NAMESPACE = org.doxygen.Project
|
||||
QHP_VIRTUAL_FOLDER = doc
|
||||
QHP_CUST_FILTER_NAME =
|
||||
QHP_CUST_FILTER_ATTRS =
|
||||
QHP_SECT_FILTER_ATTRS =
|
||||
QHG_LOCATION =
|
||||
GENERATE_ECLIPSEHELP = NO
|
||||
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
DISABLE_INDEX = NO
|
||||
GENERATE_TREEVIEW = YES
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
MATHJAX_EXTENSIONS =
|
||||
MATHJAX_CODEFILE =
|
||||
SEARCHENGINE = YES
|
||||
SERVER_BASED_SEARCH = NO
|
||||
EXTERNAL_SEARCH = NO
|
||||
SEARCHENGINE_URL =
|
||||
SEARCHDATA_FILE = searchdata.xml
|
||||
EXTERNAL_SEARCH_ID =
|
||||
EXTRA_SEARCH_MAPPINGS =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
LATEX_FOOTER =
|
||||
LATEX_EXTRA_STYLESHEET =
|
||||
LATEX_EXTRA_FILES =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
RTF_SOURCE_CODE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_SUBDIR =
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the DOCBOOK output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_DOCBOOK = NO
|
||||
DOCBOOK_OUTPUT = docbook
|
||||
DOCBOOK_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
DIA_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
DOT_NUM_THREADS = 0
|
||||
DOT_FONTNAME = Helvetica
|
||||
DOT_FONTSIZE = 10
|
||||
DOT_FONTPATH =
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = YES
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
INTERACTIVE_SVG = NO
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MSCFILE_DIRS =
|
||||
DIAFILE_DIRS =
|
||||
PLANTUML_JAR_PATH =
|
||||
PLANTUML_INCLUDE_PATH =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = YES
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 434 B |
|
|
@ -1,26 +0,0 @@
|
|||
# File Descriptions
|
||||
|
||||
Documentation for files contained in this repository which aren't self explanatory.
|
||||
|
||||
### /library.properties
|
||||
|
||||
Provides information so that this library can be installed and updated in the Arduino IDE using the [Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3).
|
||||
|
||||
The value of *version* must be set to the latest stable tagged release. This should be changed and commited just before tagging the new release.
|
||||
|
||||
See the [Arduino IDE 1.5: Library specification](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification) for details.
|
||||
|
||||
### /library.json
|
||||
|
||||
This JSON file is a manifest used by the [PlatformIO IDE](http://platformio.org/) to make this library available in its [Library Manager](http://docs.platformio.org/en/latest/librarymanager/index.html).
|
||||
|
||||
The value of *version* must be set to the latest stable tagged release. This should be changed and commited just before tagging the new release.
|
||||
|
||||
See the [PlatformIO library.json](http://docs.platformio.org/en/latest/librarymanager/config.html) documentation for details.
|
||||
|
||||
### /extras/assets/arduboy_logo.png<br>/extras/assets/arduboy_screen.png
|
||||
|
||||
Templates used to create the ARDUBOY logo used in the *bootLogo()* function.
|
||||
|
||||
----------
|
||||
|
||||
167
keywords.txt
167
keywords.txt
|
|
@ -1,167 +0,0 @@
|
|||
#######################################
|
||||
# Syntax Coloring Map For Arduboy2
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
Arduboy2 KEYWORD1
|
||||
Arduboy2Base KEYWORD1
|
||||
BeepPin1 KEYWORD1
|
||||
BeepPin2 KEYWORD1
|
||||
Point KEYWORD1
|
||||
Rect KEYWORD1
|
||||
Sprites KEYWORD1
|
||||
SpritesB KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
allPixelsOn KEYWORD2
|
||||
begin KEYWORD2
|
||||
blank KEYWORD2
|
||||
boot KEYWORD2
|
||||
bootLogo KEYWORD2
|
||||
bootLogoCompressed KEYWORD2
|
||||
bootLogoShell KEYWORD2
|
||||
bootLogoSpritesBOverwrite KEYWORD2
|
||||
bootLogoSpritesBSelfMasked KEYWORD2
|
||||
bootLogoSpritesOverwrite KEYWORD2
|
||||
bootLogoSpritesSelfMasked KEYWORD2
|
||||
bootLogoText KEYWORD2
|
||||
buttonsState KEYWORD2
|
||||
clear KEYWORD2
|
||||
collide KEYWORD2
|
||||
cpuLoad KEYWORD2
|
||||
delayShort KEYWORD2
|
||||
digitalWriteRGB KEYWORD2
|
||||
display KEYWORD2
|
||||
displayOff KEYWORD2
|
||||
displayOn KEYWORD2
|
||||
drawBitmap KEYWORD2
|
||||
drawChar KEYWORD2
|
||||
drawCircle KEYWORD2
|
||||
drawCompressed KEYWORD2
|
||||
drawFastHLine KEYWORD2
|
||||
drawFastVLine KEYWORD2
|
||||
drawLine KEYWORD2
|
||||
drawPixel KEYWORD2
|
||||
drawRect KEYWORD2
|
||||
drawRoundRect KEYWORD2
|
||||
drawSlowXYBitmap KEYWORD2
|
||||
drawTriangle KEYWORD2
|
||||
enabled KEYWORD2
|
||||
everyXFrames KEYWORD2
|
||||
exitToBootloader KEYWORD2
|
||||
fillCircle KEYWORD2
|
||||
fillRect KEYWORD2
|
||||
fillRoundRect KEYWORD2
|
||||
fillScreen KEYWORD2
|
||||
fillTriangle KEYWORD2
|
||||
flashlight KEYWORD2
|
||||
flipVertical KEYWORD2
|
||||
flipHorizontal KEYWORD2
|
||||
freeRGBled KEYWORD2
|
||||
generateRandomSeed KEYWORD2
|
||||
getBuffer KEYWORD2
|
||||
getCursorX KEYWORD2
|
||||
getCursorY KEYWORD2
|
||||
getPixel KEYWORD2
|
||||
getTextBackground KEYWORD2
|
||||
getTextColor KEYWORD2
|
||||
getTextSize KEYWORD2
|
||||
getTextWrap KEYWORD2
|
||||
height KEYWORD2
|
||||
idle KEYWORD2
|
||||
initRandomSeed KEYWORD2
|
||||
invert KEYWORD2
|
||||
justPressed KEYWORD2
|
||||
justReleased KEYWORD2
|
||||
nextFrame KEYWORD2
|
||||
nextFrameDEV KEYWORD2
|
||||
notPressed KEYWORD2
|
||||
off KEYWORD2
|
||||
on KEYWORD2
|
||||
paint8Pixels KEYWORD2
|
||||
paintScreen KEYWORD2
|
||||
pollButtons KEYWORD2
|
||||
pressed KEYWORD2
|
||||
readShowBootLogoFlag KEYWORD2
|
||||
readShowBootLogoLEDsFlag KEYWORD2
|
||||
readShowUnitNameFlag KEYWORD2
|
||||
readUnitID KEYWORD2
|
||||
readUnitName KEYWORD2
|
||||
safeMode KEYWORD2
|
||||
saveOnOff KEYWORD2
|
||||
setCursor KEYWORD2
|
||||
setFrameDuration KEYWORD2
|
||||
setFrameRate KEYWORD2
|
||||
setRGBled KEYWORD2
|
||||
setTextBackground KEYWORD2
|
||||
setTextColor KEYWORD2
|
||||
setTextSize KEYWORD2
|
||||
setTextWrap KEYWORD2
|
||||
SPItransfer KEYWORD2
|
||||
systemButtons KEYWORD2
|
||||
toggle KEYWORD2
|
||||
waitNoButtons KEYWORD2
|
||||
width KEYWORD2
|
||||
writeShowBootLogoFlag KEYWORD2
|
||||
writeShowBootLogoLEDsFlag KEYWORD2
|
||||
writeShowUnitNameFlag KEYWORD2
|
||||
writeUnitID KEYWORD2
|
||||
writeUnitName KEYWORD2
|
||||
|
||||
# Arduboy2Beep classes
|
||||
freq KEYWORD2
|
||||
noTone KEYWORD2
|
||||
timer KEYWORD2
|
||||
tone KEYWORD2
|
||||
|
||||
# Sprites class
|
||||
drawErase KEYWORD2
|
||||
drawExternalMask KEYWORD2
|
||||
drawOverwrite KEYWORD2
|
||||
drawPlusMask KEYWORD2
|
||||
drawSelfMasked KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
ARDUBOY_LIB_VER LITERAL1
|
||||
|
||||
ARDUBOY_UNIT_NAME_LEN LITERAL1
|
||||
|
||||
EEPROM_STORAGE_SPACE_START LITERAL1
|
||||
|
||||
HEIGHT LITERAL1
|
||||
WIDTH LITERAL1
|
||||
|
||||
BLACK LITERAL1
|
||||
WHITE LITERAL1
|
||||
INVERT LITERAL1
|
||||
|
||||
CLEAR_BUFFER LITERAL1
|
||||
|
||||
A_BUTTON LITERAL1
|
||||
B_BUTTON LITERAL1
|
||||
DOWN_BUTTON LITERAL1
|
||||
LEFT_BUTTON LITERAL1
|
||||
RIGHT_BUTTON LITERAL1
|
||||
UP_BUTTON LITERAL1
|
||||
|
||||
PIN_SPEAKER_1 LITERAL1
|
||||
PIN_SPEAKER_2 LITERAL1
|
||||
|
||||
BLUE_LED LITERAL1
|
||||
GREEN_LED LITERAL1
|
||||
RED_LED LITERAL1
|
||||
|
||||
RGB_OFF LITERAL1
|
||||
RGB_ON LITERAL1
|
||||
|
||||
ARDUBOY_NO_USB LITERAL1
|
||||
|
||||
17
library.json
17
library.json
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"name": "Arduboy2",
|
||||
"keywords": "arduboy, game",
|
||||
"description": "An alternative library for content creation on the Arduboy miniature gaming platform",
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/MLXXXp/Arduboy2.git"
|
||||
},
|
||||
"version": "5.1.0",
|
||||
"export":
|
||||
{
|
||||
"exclude": "extras"
|
||||
},
|
||||
"frameworks": "arduino",
|
||||
"platforms": "atmelavr"
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
name=Arduboy2
|
||||
version=5.1.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.
|
||||
paragraph=This is a fork of the Arduboy library, with a main goal of providing ways in which more code space can be freed for use by large sketches. It remains substantially compatible with Arduboy library V1.1, with the main API difference being that the "tones" subclass has been removed and its functionality made available in a separate ArduboyPlaytune library. Removal of "tones" also allows other audio functions and libraries to be used, such as ArduboyTones.
|
||||
category=Other
|
||||
url=https://github.com/MLXXXp/Arduboy2
|
||||
architectures=avr
|
||||
includes=Arduboy2.h
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/**
|
||||
* @file Arduboy2Beep.cpp
|
||||
* \brief
|
||||
* Classes to generate simple square wave tones on the Arduboy speaker pins.
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "Arduboy2Beep.h"
|
||||
|
||||
#ifndef AB_DEVKIT
|
||||
|
||||
// Speaker pin 1, Timer 3A, Port C bit 6, Arduino pin 5
|
||||
|
||||
uint8_t BeepPin1::duration = 0;
|
||||
|
||||
void BeepPin1::begin()
|
||||
{
|
||||
TCCR3A = 0;
|
||||
TCCR3B = (bit(WGM32) | bit(CS31)); // CTC mode. Divide by 8 clock prescale
|
||||
}
|
||||
|
||||
void BeepPin1::tone(uint16_t count)
|
||||
{
|
||||
tone(count, 0);
|
||||
}
|
||||
|
||||
void BeepPin1::tone(uint16_t count, uint8_t dur)
|
||||
{
|
||||
duration = dur;
|
||||
TCCR3A = bit(COM3A0); // set toggle on compare mode (which connects the pin)
|
||||
OCR3A = count; // load the count (16 bits), which determines the frequency
|
||||
}
|
||||
|
||||
void BeepPin1::timer()
|
||||
{
|
||||
if (duration && (--duration == 0)) {
|
||||
TCCR3A = 0; // set normal mode (which disconnects the pin)
|
||||
}
|
||||
}
|
||||
|
||||
void BeepPin1::noTone()
|
||||
{
|
||||
duration = 0;
|
||||
TCCR3A = 0; // set normal mode (which disconnects the pin)
|
||||
}
|
||||
|
||||
|
||||
// Speaker pin 2, Timer 4A, Port C bit 7, Arduino pin 13
|
||||
|
||||
uint8_t BeepPin2::duration = 0;
|
||||
|
||||
void BeepPin2::begin()
|
||||
{
|
||||
TCCR4A = 0; // normal mode. Disable PWM
|
||||
TCCR4B = bit(CS43); // divide by 128 clock prescale
|
||||
TCCR4D = 0; // normal mode
|
||||
TC4H = 0; // toggle pin at count = 0
|
||||
OCR4A = 0; // "
|
||||
}
|
||||
|
||||
void BeepPin2::tone(uint16_t count)
|
||||
{
|
||||
tone(count, 0);
|
||||
}
|
||||
|
||||
void BeepPin2::tone(uint16_t count, uint8_t dur)
|
||||
{
|
||||
duration = dur;
|
||||
TCCR4A = bit(COM4A0); // set toggle on compare mode (which connects the pin)
|
||||
TC4H = highByte(count); // load the count (10 bits),
|
||||
OCR4C = lowByte(count); // which determines the frequency
|
||||
}
|
||||
|
||||
void BeepPin2::timer()
|
||||
{
|
||||
if (duration && (--duration == 0)) {
|
||||
TCCR4A = 0; // set normal mode (which disconnects the pin)
|
||||
}
|
||||
}
|
||||
|
||||
void BeepPin2::noTone()
|
||||
{
|
||||
duration = 0;
|
||||
TCCR4A = 0; // set normal mode (which disconnects the pin)
|
||||
}
|
||||
|
||||
|
||||
#else /* AB_DEVKIT */
|
||||
|
||||
// *** The pins used for the speaker on the DevKit cannot be directly
|
||||
// controlled by a timer/counter. The following "dummy" functions will
|
||||
// compile and operate properly but no sound will be produced
|
||||
|
||||
uint8_t BeepPin1::duration = 0;
|
||||
|
||||
void BeepPin1::begin()
|
||||
{
|
||||
}
|
||||
|
||||
void BeepPin1::tone(uint16_t count)
|
||||
{
|
||||
tone(count, 0);
|
||||
}
|
||||
|
||||
void BeepPin1::tone(uint16_t count, uint8_t dur)
|
||||
{
|
||||
(void) count; // parameter not used
|
||||
|
||||
duration = dur;
|
||||
}
|
||||
|
||||
void BeepPin1::timer()
|
||||
{
|
||||
if (duration) {
|
||||
--duration;
|
||||
}
|
||||
}
|
||||
|
||||
void BeepPin1::noTone()
|
||||
{
|
||||
duration = 0;
|
||||
}
|
||||
|
||||
|
||||
uint8_t BeepPin2::duration = 0;
|
||||
|
||||
void BeepPin2::begin()
|
||||
{
|
||||
}
|
||||
|
||||
void BeepPin2::tone(uint16_t count)
|
||||
{
|
||||
tone(count, 0);
|
||||
}
|
||||
|
||||
void BeepPin2::tone(uint16_t count, uint8_t dur)
|
||||
{
|
||||
(void) count; // parameter not used
|
||||
|
||||
duration = dur;
|
||||
}
|
||||
|
||||
void BeepPin2::timer()
|
||||
{
|
||||
if (duration) {
|
||||
--duration;
|
||||
}
|
||||
}
|
||||
|
||||
void BeepPin2::noTone()
|
||||
{
|
||||
duration = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue