Arduboy2 Library
Arduboy2Core.h File Reference

The Arduboy2Core class for Arduboy hardware initilization and control. More...

#include <Arduino.h>
#include <avr/power.h>
#include <avr/sleep.h>
+ Include dependency graph for Arduboy2Core.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Arduboy2Core
 Lower level functions generally dealing directly with the hardware. More...
 

Macros

#define RGB_ON   LOW
 
#define RGB_OFF   HIGH
 
#define RED_LED   10
 
#define GREEN_LED   11
 
#define BLUE_LED   9
 
#define LEFT_BUTTON   _BV(5)
 
#define RIGHT_BUTTON   _BV(6)
 
#define UP_BUTTON   _BV(7)
 
#define DOWN_BUTTON   _BV(4)
 
#define A_BUTTON   _BV(3)
 
#define B_BUTTON   _BV(2)
 
#define PIN_SPEAKER_1   5
 
#define PIN_SPEAKER_2   13
 
#define WIDTH   128
 
#define HEIGHT   64
 
#define ARDUBOY_NO_USB
 Eliminate the USB stack to free up code space. More...
 

Detailed Description

The Arduboy2Core class for Arduboy hardware initilization and control.

Definition in file Arduboy2Core.h.

Macro Definition Documentation

#define A_BUTTON   _BV(3)

The A button value for functions requiring a bitmask

Definition at line 71 of file Arduboy2Core.h.

#define ARDUBOY_NO_USB
Value:
int main() __attribute__ ((OS_main)); \
int main() { \
Arduboy2Core::mainNoUSB(); \
return 0; \
}

Eliminate the USB stack to free up code space.

Note
WARNING: Removing the USB code will make it impossible for sketch uploader programs to automatically force a reset into the bootloader! This means that a user will manually have to invoke a reset in order to upload a new sketch, after one without USB has be been installed. Be aware that the timing for the point that a reset must be initiated can be tricky, which could lead to some frustration on the user's part.

This macro will cause the USB code, normally included in the sketch as part of the standard Arduino environment, to be eliminated. This will free up a fair amount of program space, and some RAM space as well, at the expense of disabling all USB functionality within the sketch (except as power input).

The macro should be placed before the setup() function definition:

#include <Arduboy2.h>
Arduboy2 arduboy;
// (Other variable declarations, etc.)
// Eliminate the USB stack
void setup() {
arduboy.begin();
// any additional setup code
}

As stated in the warning above, without the USB code an uploader program will be unable to automatically force a reset into the bootloader to upload a new sketch. The user will have to manually invoke a reset. In addition to eliminating the USB code, this macro will check if the DOWN button is held when the sketch first starts and, if so, will call exitToBootloader() to start the bootloader for uploading. This makes it easier for the user than having to press the reset button.

However, to make it even more convenient for a user to invoke the bootloader it is highly recommended that a sketch using this macro include a menu or prompt that allows the user to press the DOWN button within the sketch, which should cause exitToBootloader() to be called.

At a minimum, the documentation for the sketch should clearly state that a manual reset will be required, and give detailed instructions on what the user must do to upload a new sketch.

See also
Arduboy2Core::exitToBootloader()

Definition at line 310 of file Arduboy2Core.h.

#define B_BUTTON   _BV(2)

The B button value for functions requiring a bitmask

Definition at line 72 of file Arduboy2Core.h.

#define BLUE_LED   9

The pin number for the blue color in the RGB LED.

Definition at line 54 of file Arduboy2Core.h.

#define DOWN_BUTTON   _BV(4)

The Down button value for functions requiring a bitmask

Definition at line 70 of file Arduboy2Core.h.

#define GREEN_LED   11

The pin number for the greem color in the RGB LED.

Definition at line 53 of file Arduboy2Core.h.

#define HEIGHT   64

The height of the display in pixels

Definition at line 249 of file Arduboy2Core.h.

#define LEFT_BUTTON   _BV(5)

The Left button value for functions requiring a bitmask

Definition at line 67 of file Arduboy2Core.h.

#define PIN_SPEAKER_1   5

The pin number of the first lead of the speaker

Definition at line 110 of file Arduboy2Core.h.

#define PIN_SPEAKER_2   13

The pin number of the second lead of the speaker

Definition at line 111 of file Arduboy2Core.h.

#define RED_LED   10

The pin number for the red color in the RGB LED.

Definition at line 52 of file Arduboy2Core.h.

#define RGB_OFF   HIGH

For digitially setting an RGB LED off using digitalWriteRGB()

Definition at line 35 of file Arduboy2Core.h.

#define RGB_ON   LOW

For digitially setting an RGB LED on using digitalWriteRGB()

Definition at line 34 of file Arduboy2Core.h.

#define RIGHT_BUTTON   _BV(6)

The Right button value for functions requiring a bitmask

Definition at line 68 of file Arduboy2Core.h.

#define UP_BUTTON   _BV(7)

The Up button value for functions requiring a bitmask

Definition at line 69 of file Arduboy2Core.h.

#define WIDTH   128

The width of the display in pixels

Definition at line 248 of file Arduboy2Core.h.