mirror of https://github.com/MLXXXp/Arduboy2.git
Compare commits
29 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
bc460a2cff | |
|
|
ca1c3ae024 | |
|
|
031e9164aa | |
|
|
7f456cff69 | |
|
|
2374247788 | |
|
|
98afc7229f | |
|
|
4f0d802d50 | |
|
|
ccedf84434 | |
|
|
279fd9d0f4 | |
|
|
36cbdc734c | |
|
|
ab4df7c77a | |
|
|
b4b4d45009 | |
|
|
7dc88bed30 | |
|
|
191e9a2e45 | |
|
|
014e6e0a8b | |
|
|
500d81abb7 | |
|
|
2baca75689 | |
|
|
2f1c515672 | |
|
|
98f03773b2 | |
|
|
4698dd276e | |
|
|
e78e7c9d55 | |
|
|
1264edc748 | |
|
|
aaf4159274 | |
|
|
86169a0027 | |
|
|
58a35e2ad9 | |
|
|
bbebec346d | |
|
|
350a6ee629 | |
|
|
7fcbd35266 | |
|
|
5d154f817a |
|
|
@ -1,7 +1,30 @@
|
||||||
|
# Commit message style
|
||||||
When submitting changes via a pull request, or any other means, please format commit messages using ["50/72" guidelines, as suggested by Tim Pope](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
When submitting changes via a pull request, or any other means, please format commit messages using ["50/72" guidelines, as suggested by Tim Pope](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
||||||
|
|
||||||
Summary:
|
## Summary:
|
||||||
- Maximum 50 character first "title" line, written as a capitalized [imperative sentence](http://examples.yourdictionary.com/imperative-sentence-examples.html).
|
- Maximum 50 character first "title" line, written as a capitalized [imperative sentence](http://examples.yourdictionary.com/imperative-sentence-examples.html).
|
||||||
- If necessary, more detailed explanatory paragraphs following a blank line, with lines wrapped at maximum 72 characters.
|
- If necessary, more detailed explanatory paragraphs following a blank line, with lines wrapped at maximum 72 characters.
|
||||||
- If used, bullet points have a "hanging indent".
|
- If used, bullet points have a "hanging indent".
|
||||||
|
|
||||||
|
## Example 1:
|
||||||
|
```
|
||||||
|
Make state variables used by pollButtons() public
|
||||||
|
|
||||||
|
The variables currentButtonState and previousButtonState used by
|
||||||
|
pollButtons(), justPressed() and justReleased() have been made public.
|
||||||
|
This allows them to be manipulated if circumstances require it.
|
||||||
|
|
||||||
|
The documentation added for previousButtonState includes an example.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example 2:
|
||||||
|
```
|
||||||
|
Refactor text code and add char size functions
|
||||||
|
|
||||||
|
- Functions write() and drawChar() were refactored for smaller code
|
||||||
|
size and to make text wrapping operate more like what would normally
|
||||||
|
be expected.
|
||||||
|
|
||||||
|
- A new flag variable, textRaw, has been added, along with functions
|
||||||
|
setTextRawMode() and getTextRawMode() to set and read it.
|
||||||
|
```
|
||||||
10
LICENSE.txt
10
LICENSE.txt
|
|
@ -8,7 +8,7 @@ Software License Agreements
|
||||||
Licensed under the BSD 3-clause license:
|
Licensed under the BSD 3-clause license:
|
||||||
|
|
||||||
Arduboy2 library:
|
Arduboy2 library:
|
||||||
Copyright (c) 2016-2020, Scott Allen
|
Copyright (c) 2016-2021, Scott Allen
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
The Arduboy2 library was forked from the Arduboy library:
|
The Arduboy2 library was forked from the Arduboy library:
|
||||||
|
|
@ -18,13 +18,14 @@ Copyright (c) 2016, Chris Martinez
|
||||||
Copyright (c) 2016, Josh Goebel
|
Copyright (c) 2016, Josh Goebel
|
||||||
Copyright (c) 2016, Scott Allen
|
Copyright (c) 2016, Scott Allen
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
which is in turn partially based on the Adafruit_SSD1306 library
|
|
||||||
|
- which is in turn partially based on the Adafruit_SSD1306 library
|
||||||
https://github.com/adafruit/Adafruit_SSD1306
|
https://github.com/adafruit/Adafruit_SSD1306
|
||||||
Copyright (c) 2012, Adafruit Industries
|
Copyright (c) 2012, Adafruit Industries
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
SetSystemEEPROM example sketch:
|
SetSystemEEPROM example sketch:
|
||||||
Copyright (c) 2018, Scott Allen
|
Copyright (c) 2018-2020, Scott Allen
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -164,6 +165,9 @@ https://creativecommons.org/publicdomain/zero/1.0/
|
||||||
BeepDemo example sketch:
|
BeepDemo example sketch:
|
||||||
By Scott Allen
|
By Scott Allen
|
||||||
|
|
||||||
|
FontDemo example sketch:
|
||||||
|
By Scott Allen
|
||||||
|
|
||||||
RGBled example sketch:
|
RGBled example sketch:
|
||||||
By Scott Allen
|
By Scott Allen
|
||||||
|
|
||||||
|
|
|
||||||
135
README.md
135
README.md
|
|
@ -4,7 +4,7 @@ The Arduboy2 library is maintained in a git repository hosted on [GitHub](https:
|
||||||
|
|
||||||
https://github.com/MLXXXp/Arduboy2
|
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 **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 original *Arduboy* library is no longer being maintained.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
|
@ -47,9 +47,10 @@ A user settable *unit name* can be saved in system EEPROM memory. If set, this n
|
||||||
|
|
||||||
Once the logo display sequence completes, the sketch continues.
|
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.
|
**Note:**
|
||||||
|
|
||||||
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.
|
- 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
|
### "Flashlight" mode
|
||||||
|
|
||||||
|
|
@ -165,63 +166,99 @@ with
|
||||||
Arduboy2Base arduboy;
|
Arduboy2Base arduboy;
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Remove boot up features
|
#### Substitute or 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.
|
As previously described in the _Start up features_ section, 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. 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.
|
You should at least call either *flashlight()* or *safeMode()* as a safeguard to allow uploading a new sketch when the bootloader "magic key" problem is an issue.
|
||||||
|
|
||||||
As of this writing, the begin function is:
|
Here is a template that provides the equivalent of *begin()*
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
void Arduboy2Base::begin()
|
void setup()
|
||||||
{
|
{
|
||||||
boot(); // raw hardware
|
// Required to initialize the hardware.
|
||||||
|
arduboy.boot();
|
||||||
|
|
||||||
display(); // blank the display (sBuffer is global, so cleared automatically)
|
// This clears the display. (The screen buffer will be all zeros)
|
||||||
|
// It may not be needed if something clears the display later on but
|
||||||
|
// "garbage" will be displayed if systemButtons() is used without it.
|
||||||
|
arduboy.display();
|
||||||
|
|
||||||
flashlight(); // light the RGB LED and screen if UP button is being held.
|
// flashlight() or safeMode() should always be included to provide
|
||||||
|
// a method of recovering from the bootloader "magic key" problem.
|
||||||
|
arduboy.flashlight();
|
||||||
|
// arduboy.safeMode();
|
||||||
|
|
||||||
// check for and handle buttons held during start up for system control
|
// This allows sound to be turned on or muted. If the sketch provides
|
||||||
systemButtons();
|
// its own way of toggling sound, or doesn't produce any sound, this
|
||||||
|
// function may not be required.
|
||||||
|
arduboy.systemButtons();
|
||||||
|
|
||||||
audio.begin();
|
// This is required to initialize the speaker. It's not needed if
|
||||||
|
// the sketch doesn't produce any sounds.
|
||||||
|
arduboy.audio.begin();
|
||||||
|
|
||||||
bootLogo();
|
// This displays the boot logo sequence but note that the logo can
|
||||||
|
// be suppressed by the user, by pressing the RIGHT button or using
|
||||||
|
// a system EEPROM setting. If not removed entirely, an alternative
|
||||||
|
// bootLogo...() function may save some memory.
|
||||||
|
arduboy.bootLogo();
|
||||||
|
// arduboy.bootLogoCompressed();
|
||||||
|
// arduboy.bootLogoSpritesSelfMasked();
|
||||||
|
// arduboy.bootLogoSpritesOverwrite();
|
||||||
|
// arduboy.bootLogoSpritesBSelfMasked();
|
||||||
|
// arduboy.bootLogoSpritesBOverwrite();
|
||||||
|
// arduboy.bootLogoText();
|
||||||
|
|
||||||
|
// Wait for all buttons to be released, in case a pressed one might
|
||||||
|
// cause problems by being acted upon when the actual sketch code
|
||||||
|
// starts. If neither systemButtons() nor bootLogo() is kept, this
|
||||||
|
// function isn't required.
|
||||||
|
arduboy.waitNoButtons();
|
||||||
|
|
||||||
|
// Additional setup code...
|
||||||
|
|
||||||
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.
|
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.
|
- *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 *drawBitmap()*, 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).
|
- *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()*.
|
- *safeMode()* can be used in place of *flashlight()* as a safeguard 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()*.
|
||||||
|
|
||||||
|
It is also possible to replace the boot logo drawing function with one that uses a different bitmap rendering function used elsewhere in your sketch. This may save memory by using this bitmap function for the logo, instead of the logo using a separate function that only ends up being used once. For example, if you use the *ArdBitmap* library's *drawCompressed()* function in your sketch, you could convert the **ARDUBOY** logo to *Ardbitmap* compressed format, and create *drawLogoArdCompressed()* and *bootLogoArdCompressed()* functions:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
void drawLogoArdCompressed(int16_t y)
|
||||||
|
{
|
||||||
|
ardbitmap.drawCompressed(20, y, arduboy_logo_ardbitmap,
|
||||||
|
WHITE, ALIGN_CENTER, MIRROR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootLogoArdCompressed()
|
||||||
|
{
|
||||||
|
if (arduboy.bootLogoShell(drawLogoArdCompressed))
|
||||||
|
{
|
||||||
|
arduboy.bootLogoExtra();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
arduboy.beginDoFirst();
|
||||||
|
bootLogoArdCompressed();
|
||||||
|
arduboy.waitNoButtons();
|
||||||
|
|
||||||
|
// Additional setup code...
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The **ARDUBOY** logo, in PNG format, is included in the library repository as file:
|
||||||
|
|
||||||
|
`extras/assets/arduboy_logo.png`
|
||||||
|
|
||||||
#### Use the SpritesB class instead of Sprites
|
#### Use the SpritesB class instead of Sprites
|
||||||
|
|
||||||
|
|
@ -246,6 +283,8 @@ The *ARDUBOY_NO_USB* macro is used to eliminate the USB code. The *exitToBootloa
|
||||||
|
|
||||||
## What's different from Arduboy library V1.1
|
## What's different from Arduboy library V1.1
|
||||||
|
|
||||||
|
(These notes apply to when the *Arduboy2* library was first released. There will have been many additional changes, enhancements and features added to *Arduboy2* since then.)
|
||||||
|
|
||||||
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.
|
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:
|
Main differences between Arduboy2 and Arduboy V1.1 are:
|
||||||
|
|
@ -389,7 +428,7 @@ Arduboy2 arduboy;
|
||||||
ArduboyPlaytune tunes(arduboy.audio.enabled);
|
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:
|
The sound channels must then be initialized and assigned to the speaker pins. This code would go in the *setup()* function:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
// audio setup
|
// audio setup
|
||||||
|
|
@ -424,13 +463,13 @@ The benefit of using *ArduboyTones* would be reduced code size and possibly easi
|
||||||
|
|
||||||
### Sketch uses the beginNoLogo() function instead of begin()
|
### 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:
|
The *beginNoLogo()* function has been removed. *beginNoLogo()* can be replaced with *begin()*, since users can choose to suppress the logo sequence using the *RIGHT* button or by setting a flag in system EEPROM.
|
||||||
|
|
||||||
|
If using *begin()* results in the sketch program memory size being too large, *beginDoFirst()* or *boot()* can be used with additional functions following it to add back in desired boot functionality. See the information above, under the heading *Substitute or remove boot up features*, for more details. Assuming the object is named *arduboy*, an equivalent replacement for *beginNoLogo()* would be:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
arduboy.boot();
|
arduboy.beginDoFirst();
|
||||||
arduboy.display();
|
arduboy.waitNoButtons();
|
||||||
arduboy.flashlight();
|
|
||||||
arduboy.audio.begin();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ void moveBall()
|
||||||
topBrick = 6 * row + 1;
|
topBrick = 6 * row + 1;
|
||||||
bottomBrick = 6 * row + 7;
|
bottomBrick = 6 * row + 7;
|
||||||
|
|
||||||
//If A collison has occured
|
//If A collision has occurred
|
||||||
if (topBall <= bottomBrick && bottomBall >= topBrick &&
|
if (topBall <= bottomBrick && bottomBall >= topBrick &&
|
||||||
leftBall <= rightBrick && rightBall >= leftBrick)
|
leftBall <= rightBrick && rightBall >= leftBrick)
|
||||||
{
|
{
|
||||||
|
|
@ -293,7 +293,7 @@ void moveBall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Hoizontal collision
|
//Horizontal collision
|
||||||
if (leftBall < leftBrick || rightBall > rightBrick)
|
if (leftBall < leftBrick || rightBall > rightBrick)
|
||||||
{
|
{
|
||||||
//Only bounce once brick each ball move
|
//Only bounce once brick each ball move
|
||||||
|
|
@ -736,14 +736,14 @@ void enterHighScore(byte file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play a tone at a frequency coresponding to the specified precomputed count,
|
// Play a tone at a frequency corresponding to the specified precomputed count,
|
||||||
// for the specified number of frames.
|
// for the specified number of frames.
|
||||||
void playTone(uint16_t count, uint8_t frames)
|
void playTone(uint16_t count, uint8_t frames)
|
||||||
{
|
{
|
||||||
beep.tone(count, frames);
|
beep.tone(count, frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play a tone at a frequency coresponding to the specified precomputed count,
|
// Play a tone at a frequency corresponding to the specified precomputed count,
|
||||||
// for the specified duration in milliseconds, using a delay.
|
// for the specified duration in milliseconds, using a delay.
|
||||||
// Used when beep.timer() isn't being called.
|
// Used when beep.timer() isn't being called.
|
||||||
void playToneTimed(uint16_t count, uint16_t duration)
|
void playToneTimed(uint16_t count, uint16_t duration)
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ void loop() {
|
||||||
|
|
||||||
arduboy.pollButtons();
|
arduboy.pollButtons();
|
||||||
|
|
||||||
|
arduboy.clear();
|
||||||
|
|
||||||
if (arduboy.justPressed(LEFT_BUTTON)) {
|
if (arduboy.justPressed(LEFT_BUTTON)) {
|
||||||
// Play a 523.251Hz tone (piano note C5) for 5 frames (200ms at 25 FPS)
|
// 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.freq(523.251) is used to convert 523.251Hz to the required count
|
||||||
|
|
@ -127,7 +129,7 @@ void loop() {
|
||||||
objectX = 0;
|
objectX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
arduboy.display(CLEAR_BUFFER);
|
arduboy.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void commandText(const char* text) {
|
void commandText(const char* text) {
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ char title[] = "Press Buttons!";
|
||||||
byte x;
|
byte x;
|
||||||
byte y;
|
byte y;
|
||||||
|
|
||||||
// Width of each charcter including inter-character space
|
// Width of each character including inter-character space
|
||||||
#define CHAR_WIDTH 6
|
#define CHAR_WIDTH 6
|
||||||
|
|
||||||
// Height of each charater
|
// Height of each character
|
||||||
#define CHAR_HEIGHT 8
|
#define CHAR_HEIGHT 8
|
||||||
|
|
||||||
// To get the number of characters, we subtract 1 from the length of
|
// To get the number of characters, we subtract 1 from the length of
|
||||||
|
|
@ -101,6 +101,6 @@ void loop() {
|
||||||
// then we print to screen what is stored in our title variable we declared earlier
|
// then we print to screen what is stored in our title variable we declared earlier
|
||||||
arduboy.print(title);
|
arduboy.print(title);
|
||||||
|
|
||||||
// then we finaly we tell the arduboy to display what we just wrote to the display.
|
// then we finally we tell the arduboy to display what we just wrote to the display.
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
Buttons
|
Buttons
|
||||||
=======
|
=======
|
||||||
|
|
||||||
A an example that demonstrates how to capture input from the buttons.
|
An example that demonstrates how to capture input from the buttons.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
Creative Commons Legal Code
|
||||||
|
|
||||||
|
CC0 1.0 Universal
|
||||||
|
|
||||||
|
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||||
|
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||||
|
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||||
|
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||||
|
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||||
|
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||||
|
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||||
|
HEREUNDER.
|
||||||
|
|
||||||
|
Statement of Purpose
|
||||||
|
|
||||||
|
The laws of most jurisdictions throughout the world automatically confer
|
||||||
|
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||||
|
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||||
|
authorship and/or a database (each, a "Work").
|
||||||
|
|
||||||
|
Certain owners wish to permanently relinquish those rights to a Work for
|
||||||
|
the purpose of contributing to a commons of creative, cultural and
|
||||||
|
scientific works ("Commons") that the public can reliably and without fear
|
||||||
|
of later claims of infringement build upon, modify, incorporate in other
|
||||||
|
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||||
|
and for any purposes, including without limitation commercial purposes.
|
||||||
|
These owners may contribute to the Commons to promote the ideal of a free
|
||||||
|
culture and the further production of creative, cultural and scientific
|
||||||
|
works, or to gain reputation or greater distribution for their Work in
|
||||||
|
part through the use and efforts of others.
|
||||||
|
|
||||||
|
For these and/or other purposes and motivations, and without any
|
||||||
|
expectation of additional consideration or compensation, the person
|
||||||
|
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||||
|
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||||
|
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||||
|
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||||
|
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||||
|
|
||||||
|
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||||
|
protected by copyright and related or neighboring rights ("Copyright and
|
||||||
|
Related Rights"). Copyright and Related Rights include, but are not
|
||||||
|
limited to, the following:
|
||||||
|
|
||||||
|
i. the right to reproduce, adapt, distribute, perform, display,
|
||||||
|
communicate, and translate a Work;
|
||||||
|
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||||
|
iii. publicity and privacy rights pertaining to a person's image or
|
||||||
|
likeness depicted in a Work;
|
||||||
|
iv. rights protecting against unfair competition in regards to a Work,
|
||||||
|
subject to the limitations in paragraph 4(a), below;
|
||||||
|
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||||
|
in a Work;
|
||||||
|
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||||
|
European Parliament and of the Council of 11 March 1996 on the legal
|
||||||
|
protection of databases, and under any national implementation
|
||||||
|
thereof, including any amended or successor version of such
|
||||||
|
directive); and
|
||||||
|
vii. other similar, equivalent or corresponding rights throughout the
|
||||||
|
world based on applicable law or treaty, and any national
|
||||||
|
implementations thereof.
|
||||||
|
|
||||||
|
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||||
|
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||||
|
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||||
|
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||||
|
of action, whether now known or unknown (including existing as well as
|
||||||
|
future claims and causes of action), in the Work (i) in all territories
|
||||||
|
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||||
|
treaty (including future time extensions), (iii) in any current or future
|
||||||
|
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||||
|
including without limitation commercial, advertising or promotional
|
||||||
|
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||||
|
member of the public at large and to the detriment of Affirmer's heirs and
|
||||||
|
successors, fully intending that such Waiver shall not be subject to
|
||||||
|
revocation, rescission, cancellation, termination, or any other legal or
|
||||||
|
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||||
|
as contemplated by Affirmer's express Statement of Purpose.
|
||||||
|
|
||||||
|
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||||
|
be judged legally invalid or ineffective under applicable law, then the
|
||||||
|
Waiver shall be preserved to the maximum extent permitted taking into
|
||||||
|
account Affirmer's express Statement of Purpose. In addition, to the
|
||||||
|
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||||
|
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||||
|
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||||
|
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||||
|
maximum duration provided by applicable law or treaty (including future
|
||||||
|
time extensions), (iii) in any current or future medium and for any number
|
||||||
|
of copies, and (iv) for any purpose whatsoever, including without
|
||||||
|
limitation commercial, advertising or promotional purposes (the
|
||||||
|
"License"). The License shall be deemed effective as of the date CC0 was
|
||||||
|
applied by Affirmer to the Work. Should any part of the License for any
|
||||||
|
reason be judged legally invalid or ineffective under applicable law, such
|
||||||
|
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||||
|
of the License, and in such case Affirmer hereby affirms that he or she
|
||||||
|
will not (i) exercise any of his or her remaining Copyright and Related
|
||||||
|
Rights in the Work or (ii) assert any associated claims and causes of
|
||||||
|
action with respect to the Work, in either case contrary to Affirmer's
|
||||||
|
express Statement of Purpose.
|
||||||
|
|
||||||
|
4. Limitations and Disclaimers.
|
||||||
|
|
||||||
|
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||||
|
surrendered, licensed or otherwise affected by this document.
|
||||||
|
b. Affirmer offers the Work as-is and makes no representations or
|
||||||
|
warranties of any kind concerning the Work, express, implied,
|
||||||
|
statutory or otherwise, including without limitation warranties of
|
||||||
|
title, merchantability, fitness for a particular purpose, non
|
||||||
|
infringement, or the absence of latent or other defects, accuracy, or
|
||||||
|
the present or absence of errors, whether or not discoverable, all to
|
||||||
|
the greatest extent permissible under applicable law.
|
||||||
|
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||||
|
that may apply to the Work or any use thereof, including without
|
||||||
|
limitation any person's Copyright and Related Rights in the Work.
|
||||||
|
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||||
|
consents, permissions or other rights required for any use of the
|
||||||
|
Work.
|
||||||
|
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||||
|
party to this document and has no duty or obligation with respect to
|
||||||
|
this CC0 or use of the Work.
|
||||||
|
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
FontDemo.ino
|
||||||
|
|
||||||
|
This sketch draws all the characters of the library's font as a 16 x 16 block.
|
||||||
|
The bottom half of the block will be initially off screen. An information
|
||||||
|
overlay will be drawn on top of the block showing the X and Y cursor position
|
||||||
|
of the start of the block, the current text wrap state and the current text
|
||||||
|
raw mode state.
|
||||||
|
|
||||||
|
The block can be moved around and off the screen using the direction buttons,
|
||||||
|
to view all the characters and show how the wrap and raw modes behave.
|
||||||
|
|
||||||
|
Controls:
|
||||||
|
Direction Buttons: Move the block 1 pixel.
|
||||||
|
Hold A with Direction Buttons: Continuously move the block.
|
||||||
|
B Button: Toggle text raw mode on and off.
|
||||||
|
Hold A, press B: Toggle text wrap mode on and off.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Written in September 2020 by Scott Allen saydisp-git@yahoo.ca
|
||||||
|
|
||||||
|
To the extent possible under law, the author(s) have dedicated all copyright
|
||||||
|
and related and neighboring rights to this software to the public domain
|
||||||
|
worldwide. This software is distributed without any warranty.
|
||||||
|
|
||||||
|
You should have received a copy of the CC0 Public Domain Dedication along with
|
||||||
|
this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduboy2.h>
|
||||||
|
|
||||||
|
Arduboy2 arduboy;
|
||||||
|
|
||||||
|
constexpr uint8_t charWidth = arduboy.getCharacterWidth() + arduboy.getCharacterSpacing();
|
||||||
|
constexpr uint8_t charHeight = arduboy.getCharacterHeight() + arduboy.getLineSpacing();
|
||||||
|
constexpr uint16_t infoX = charWidth * 8;
|
||||||
|
constexpr uint16_t infoY = charHeight * 2;
|
||||||
|
constexpr uint8_t infoWidth = charWidth * 5;
|
||||||
|
constexpr uint8_t infoBorder = 1;
|
||||||
|
|
||||||
|
int16_t xPos = 0;
|
||||||
|
int16_t yPos = 0;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
arduboy.begin();
|
||||||
|
arduboy.setFrameRate(20);
|
||||||
|
|
||||||
|
arduboy.clear();
|
||||||
|
arduboy.print(F("DISPLAY AND MOVE FONT\n\n"
|
||||||
|
" Dpad: move 1\n"
|
||||||
|
"A + Dpad: repeat move\n"
|
||||||
|
" B: toggle raw\n"
|
||||||
|
" A + B: toggle wrap\n\n"
|
||||||
|
" Press A to start"));
|
||||||
|
arduboy.display();
|
||||||
|
|
||||||
|
while (!arduboy.pressed(A_BUTTON)) {
|
||||||
|
arduboy.idle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (!arduboy.nextFrame()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
arduboy.pollButtons();
|
||||||
|
|
||||||
|
if (arduboy.justPressed(B_BUTTON)) {
|
||||||
|
if (arduboy.pressed(A_BUTTON)) {
|
||||||
|
arduboy.setTextWrap(!arduboy.getTextWrap());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
arduboy.setTextRawMode(!arduboy.getTextRawMode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arduboy.justPressed(UP_BUTTON) ||
|
||||||
|
arduboy.pressed(UP_BUTTON + A_BUTTON)) {
|
||||||
|
--yPos;
|
||||||
|
}
|
||||||
|
if (arduboy.justPressed(DOWN_BUTTON) ||
|
||||||
|
arduboy.pressed(DOWN_BUTTON + A_BUTTON)) {
|
||||||
|
++yPos;
|
||||||
|
}
|
||||||
|
if (arduboy.justPressed(LEFT_BUTTON) ||
|
||||||
|
arduboy.pressed(LEFT_BUTTON | A_BUTTON)) {
|
||||||
|
--xPos;
|
||||||
|
}
|
||||||
|
if (arduboy.justPressed(RIGHT_BUTTON) ||
|
||||||
|
arduboy.pressed(RIGHT_BUTTON | A_BUTTON)) {
|
||||||
|
++xPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
arduboy.clear();
|
||||||
|
|
||||||
|
char code = 0;
|
||||||
|
for (uint8_t i = 0; i < 16; ++i) {
|
||||||
|
arduboy.setCursor(xPos, yPos + (charHeight * i));
|
||||||
|
for (uint8_t j = 0; j < 16; ++j) {
|
||||||
|
arduboy.print(code);
|
||||||
|
++code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arduboy.fillRect(infoX - infoBorder, infoY - infoBorder,
|
||||||
|
infoWidth + infoBorder, charHeight * 4 + infoBorder);
|
||||||
|
arduboy.setTextColor(BLACK);
|
||||||
|
arduboy.setTextBackground(WHITE);
|
||||||
|
arduboy.setCursor(infoX, infoY);
|
||||||
|
arduboy.print(F("X:"));
|
||||||
|
arduboy.print(xPos);
|
||||||
|
arduboy.setCursor(infoX, infoY + charHeight);
|
||||||
|
arduboy.print(F("Y:"));
|
||||||
|
arduboy.print(yPos);
|
||||||
|
arduboy.setCursor(infoX, infoY + (charHeight * 2));
|
||||||
|
arduboy.print(F("W:"));
|
||||||
|
arduboy.print(arduboy.getTextWrap() ? F("Yes") : F("No"));
|
||||||
|
arduboy.setCursor(infoX, infoY + (charHeight * 3));
|
||||||
|
arduboy.print(F("R:"));
|
||||||
|
arduboy.print(arduboy.getTextRawMode() ? F("Yes") : F("No"));
|
||||||
|
arduboy.setTextColor(WHITE);
|
||||||
|
arduboy.setTextBackground(BLACK);
|
||||||
|
|
||||||
|
arduboy.display();
|
||||||
|
}
|
||||||
|
|
@ -46,6 +46,6 @@ void loop() {
|
||||||
// then we print to screen what is in the Quotation marks ""
|
// then we print to screen what is in the Quotation marks ""
|
||||||
arduboy.print(F("Hello, world!"));
|
arduboy.print(F("Hello, world!"));
|
||||||
|
|
||||||
// then we finaly we tell the arduboy to display what we just wrote to the display
|
// then we finally we tell the arduboy to display what we just wrote to the display
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ void drawBar(int y, Color color, byte value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the informaton for one digital color
|
// Draw the information for one digital color
|
||||||
void drawDigital(int y, Color color, const char* name) {
|
void drawDigital(int y, Color color, const char* name) {
|
||||||
byte state = digitalState[(byte)color];
|
byte state = digitalState[(byte)color];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ This sketch also allows:
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Version 2.0
|
// Version 2.2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
Copyright (c) 2018, Scott Allen
|
Copyright (c) 2018-2020, Scott Allen
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -69,14 +69,14 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|
||||||
// The frame rate determines the button auto-repeat rate for unit name entry
|
// The frame rate determines the button auto-repeat rate for unit name entry
|
||||||
#define FRAME_RATE 10
|
constexpr uint8_t frameRate = 10;
|
||||||
|
|
||||||
// The unit ID auto-repeat rate is slowed, compared to the unit name rate, by
|
// The unit ID auto-repeat rate is slowed, compared to the unit name rate, by
|
||||||
// repeating only once per the defined number of frames
|
// repeating only once per the defined number of frames
|
||||||
#define ID_REPEAT_FRAMES 3
|
constexpr unsigned int idRepeatFrames = 3;
|
||||||
|
|
||||||
// Delay time before button auto-repeat starts, in milliseconds
|
// Delay time before button auto-repeat starts, in milliseconds
|
||||||
#define REPEAT_DELAY 700
|
constexpr unsigned int repeatDelay = 700;
|
||||||
|
|
||||||
// All the constant stings
|
// All the constant stings
|
||||||
const char StrName[] PROGMEM = "NAME";
|
const char StrName[] PROGMEM = "NAME";
|
||||||
|
|
@ -119,24 +119,20 @@ const char StrReset[] PROGMEM = "RESET";
|
||||||
const char StrHex[] PROGMEM = "hex";
|
const char StrHex[] PROGMEM = "hex";
|
||||||
const char StrDecimal[] PROGMEM = "decimal";
|
const char StrDecimal[] PROGMEM = "decimal";
|
||||||
|
|
||||||
#define CHAR_WIDTH 6
|
|
||||||
#define CHAR_HEIGHT 8
|
|
||||||
#define SMALL_SPACE 4 // The number of pixels for a small space between groups
|
|
||||||
|
|
||||||
// Defines for text and field locations
|
// Defines for text and field locations
|
||||||
#define MENU_BTN_CHANGE_NAME_X centerStr_P(StrBtnChangeName)
|
#define MENU_BTN_CHANGE_NAME_X centerStr_P(StrBtnChangeName)
|
||||||
#define MENU_BTN_CHANGE_NAME_Y 0
|
#define MENU_BTN_CHANGE_NAME_Y 0
|
||||||
#define MENU_NAME_X centerStrLen(ARDUBOY_UNIT_NAME_LEN)
|
#define MENU_NAME_X centerStrLen(ARDUBOY_UNIT_NAME_LEN)
|
||||||
#define MENU_NAME_Y (MENU_BTN_CHANGE_NAME_Y + CHAR_HEIGHT + 3)
|
#define MENU_NAME_Y (MENU_BTN_CHANGE_NAME_Y + charHeight + 3)
|
||||||
|
|
||||||
#define MENU_BTN_CHANGE_ID_X centerStr_P(StrBtnChangeID)
|
#define MENU_BTN_CHANGE_ID_X centerStr_P(StrBtnChangeID)
|
||||||
#define MENU_BTN_CHANGE_ID_Y 26
|
#define MENU_BTN_CHANGE_ID_Y 26
|
||||||
#define MENU_HEADING_HEX_X (centerStr_P(StrHex) - (WIDTH / 4))
|
#define MENU_HEADING_HEX_X (centerStr_P(StrHex) - (WIDTH / 4))
|
||||||
#define MENU_HEADING_DECIMAL_X (centerStr_P(StrDecimal) + (WIDTH / 4))
|
#define MENU_HEADING_DECIMAL_X (centerStr_P(StrDecimal) + (WIDTH / 4))
|
||||||
#define MENU_HEADINGS_Y (MENU_BTN_CHANGE_ID_Y + CHAR_HEIGHT + 1)
|
#define MENU_HEADINGS_Y (MENU_BTN_CHANGE_ID_Y + charHeight + 1)
|
||||||
#define MENU_ID_HEX_X (centerStrLen(5) - (WIDTH / 4))
|
#define MENU_ID_HEX_X (centerStrLen(5) - (WIDTH / 4))
|
||||||
#define MENU_ID_DECIMAL_X (centerStrLen(5) + (WIDTH / 4))
|
#define MENU_ID_DECIMAL_X (centerStrLen(5) + (WIDTH / 4))
|
||||||
#define MENU_ID_Y (MENU_HEADINGS_Y + CHAR_HEIGHT + 1)
|
#define MENU_ID_Y (MENU_HEADINGS_Y + charHeight + 1)
|
||||||
|
|
||||||
#define MENU_BTN_FLAGS_X 0
|
#define MENU_BTN_FLAGS_X 0
|
||||||
#define MENU_BTN_FLAGS_Y 56
|
#define MENU_BTN_FLAGS_Y 56
|
||||||
|
|
@ -165,9 +161,9 @@ const char StrDecimal[] PROGMEM = "decimal";
|
||||||
#define NAME_BTN_NO_X rightStr_P(StrBtnNo)
|
#define NAME_BTN_NO_X rightStr_P(StrBtnNo)
|
||||||
#define NAME_BTN_NO_Y NAME_BTN_YES_Y
|
#define NAME_BTN_NO_Y NAME_BTN_YES_Y
|
||||||
|
|
||||||
#define NAME_SAVE_Q_X (centerStr_P(StrSaveQ) - ((6 * CHAR_WIDTH) + (CHAR_WIDTH / 2)))
|
#define NAME_SAVE_Q_X (centerStr_P(StrSaveQ) - ((6 * charWidth) + (charWidth / 2)))
|
||||||
#define NAME_SAVE_Q_Y (NAME_LARGE_Y + (CHAR_HEIGHT / 2) + 3)
|
#define NAME_SAVE_Q_Y (NAME_LARGE_Y + (charHeight / 2) + 3)
|
||||||
#define NAME_SAVE_X (NAME_SAVE_Q_X + ((strlen_P(StrSaveQ) * CHAR_WIDTH) + CHAR_WIDTH))
|
#define NAME_SAVE_X (NAME_SAVE_Q_X + ((strlen_P(StrSaveQ) * charWidth) + charWidth))
|
||||||
#define NAME_SAVE_Y (NAME_LARGE_Y + 3)
|
#define NAME_SAVE_Y (NAME_LARGE_Y + 3)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -184,7 +180,7 @@ const char StrDecimal[] PROGMEM = "decimal";
|
||||||
|
|
||||||
#define ID_2_DECIMAL_X 12
|
#define ID_2_DECIMAL_X 12
|
||||||
#define ID_2_DECIMAL_Y 38
|
#define ID_2_DECIMAL_Y 38
|
||||||
#define ID_DECIMAL_X (WIDTH - (CHAR_WIDTH * 5 + 12))
|
#define ID_DECIMAL_X (WIDTH - (charWidth * 5 + 12))
|
||||||
#define ID_DECIMAL_Y ID_2_DECIMAL_Y
|
#define ID_DECIMAL_Y ID_2_DECIMAL_Y
|
||||||
|
|
||||||
#define ID_BINARY_X 0
|
#define ID_BINARY_X 0
|
||||||
|
|
@ -195,9 +191,9 @@ const char StrDecimal[] PROGMEM = "decimal";
|
||||||
#define ID_BTN_NO_X rightStr_P(StrBtnNo)
|
#define ID_BTN_NO_X rightStr_P(StrBtnNo)
|
||||||
#define ID_BTN_NO_Y ID_BTN_YES_Y
|
#define ID_BTN_NO_Y ID_BTN_YES_Y
|
||||||
|
|
||||||
#define ID_SAVE_Q_X (centerStr_P(StrSaveQ) - ((5 * CHAR_WIDTH) + (CHAR_WIDTH / 2)))
|
#define ID_SAVE_Q_X (centerStr_P(StrSaveQ) - ((5 * charWidth) + (charWidth / 2)))
|
||||||
#define ID_SAVE_Q_Y (ID_LARGE_Y + (CHAR_HEIGHT / 2) + 1)
|
#define ID_SAVE_Q_Y (ID_LARGE_Y + (charHeight / 2) + 1)
|
||||||
#define ID_SAVE_X (ID_SAVE_Q_X + ((strlen_P(StrSaveQ) * CHAR_WIDTH) + CHAR_WIDTH))
|
#define ID_SAVE_X (ID_SAVE_Q_X + ((strlen_P(StrSaveQ) * charWidth) + charWidth))
|
||||||
#define ID_SAVE_Y (ID_LARGE_Y + 1)
|
#define ID_SAVE_Y (ID_LARGE_Y + 1)
|
||||||
|
|
||||||
#define FLAGS_TITLE_X centerStr_P(StrFlags)
|
#define FLAGS_TITLE_X centerStr_P(StrFlags)
|
||||||
|
|
@ -212,7 +208,7 @@ const char StrDecimal[] PROGMEM = "decimal";
|
||||||
#define FLAGS_LEDS_Y 27
|
#define FLAGS_LEDS_Y 27
|
||||||
#define FLAGS_NAME_Y 40
|
#define FLAGS_NAME_Y 40
|
||||||
|
|
||||||
#define FLAGS_Q_X (CHAR_WIDTH * 2)
|
#define FLAGS_Q_X (charWidth * 2)
|
||||||
#define FLAGS_SET_X rightStr_P(StrYes)
|
#define FLAGS_SET_X rightStr_P(StrYes)
|
||||||
#define FLAGS_CURSOR_X 0
|
#define FLAGS_CURSOR_X 0
|
||||||
|
|
||||||
|
|
@ -220,74 +216,74 @@ const char StrDecimal[] PROGMEM = "decimal";
|
||||||
#define FLAGS_TEST_Y 56
|
#define FLAGS_TEST_Y 56
|
||||||
|
|
||||||
#define FLAGS_SAVED_X centerStr2_P(StrSaved)
|
#define FLAGS_SAVED_X centerStr2_P(StrSaved)
|
||||||
#define FLAGS_SAVED_Y ((HEIGHT / 2) - CHAR_HEIGHT)
|
#define FLAGS_SAVED_Y ((HEIGHT / 2) - (char2Height / 2))
|
||||||
|
|
||||||
#define FLAGS_NO_LOGO_1_X centerStr_P(StrNoLogo1)
|
#define FLAGS_NO_LOGO_1_X centerStr_P(StrNoLogo1)
|
||||||
#define FLAGS_NO_LOGO_1_Y ((HEIGHT / 2) - CHAR_HEIGHT - 1)
|
#define FLAGS_NO_LOGO_1_Y ((HEIGHT / 2) - charHeight - 1)
|
||||||
#define FLAGS_NO_LOGO_2_X centerStr_P(StrNoLogo2)
|
#define FLAGS_NO_LOGO_2_X centerStr_P(StrNoLogo2)
|
||||||
#define FLAGS_NO_LOGO_2_Y (FLAGS_NO_LOGO_1_Y + CHAR_HEIGHT + 2)
|
#define FLAGS_NO_LOGO_2_Y (FLAGS_NO_LOGO_1_Y + charHeight + 2)
|
||||||
|
|
||||||
#define RESET_BTN_MENU_X centerStr_P(StrBtnMenu)
|
#define RESET_BTN_MENU_X centerStr_P(StrBtnMenu)
|
||||||
#define RESET_BTN_MENU_Y 0
|
#define RESET_BTN_MENU_Y 0
|
||||||
#define RESET_BTN_SYS_X centerStr_P(StrBtnResetSys)
|
#define RESET_BTN_SYS_X centerStr_P(StrBtnResetSys)
|
||||||
#define RESET_BTN_SYS_Y 16
|
#define RESET_BTN_SYS_Y 16
|
||||||
#define RESET_BTN_SYS_EEPROM_X centerStr_P(StrEEPROM)
|
#define RESET_BTN_SYS_EEPROM_X centerStr_P(StrEEPROM)
|
||||||
#define RESET_BTN_SYS_EEPROM_Y (RESET_BTN_SYS_Y + CHAR_HEIGHT)
|
#define RESET_BTN_SYS_EEPROM_Y (RESET_BTN_SYS_Y + charHeight)
|
||||||
#define RESET_BTN_USER_X centerStr_P(StrBtnResetUser)
|
#define RESET_BTN_USER_X centerStr_P(StrBtnResetUser)
|
||||||
#define RESET_BTN_USER_Y 40
|
#define RESET_BTN_USER_Y 40
|
||||||
#define RESET_BTN_USER_EEPROM_X centerStr_P(StrEEPROM)
|
#define RESET_BTN_USER_EEPROM_X centerStr_P(StrEEPROM)
|
||||||
#define RESET_BTN_USER_EEPROM_Y (RESET_BTN_USER_Y + CHAR_HEIGHT)
|
#define RESET_BTN_USER_EEPROM_Y (RESET_BTN_USER_Y + charHeight)
|
||||||
|
|
||||||
#define RESET_SYS_TEXT_1_X centerStr_P(StrResetSys1)
|
#define RESET_SYS_TEXT_1_X centerStr_P(StrResetSys1)
|
||||||
#define RESET_SYS_TEXT_1_Y 0
|
#define RESET_SYS_TEXT_1_Y 0
|
||||||
#define RESET_SYS_TEXT_2_X centerStr_P(StrResetSys2)
|
#define RESET_SYS_TEXT_2_X centerStr_P(StrResetSys2)
|
||||||
#define RESET_SYS_TEXT_2_Y (RESET_SYS_TEXT_1_Y + CHAR_HEIGHT)
|
#define RESET_SYS_TEXT_2_Y (RESET_SYS_TEXT_1_Y + charHeight)
|
||||||
#define RESET_SYS_TEXT_3_X centerStr_P(StrResetSys3)
|
#define RESET_SYS_TEXT_3_X centerStr_P(StrResetSys3)
|
||||||
#define RESET_SYS_TEXT_3_Y (RESET_SYS_TEXT_2_Y + CHAR_HEIGHT)
|
#define RESET_SYS_TEXT_3_Y (RESET_SYS_TEXT_2_Y + charHeight)
|
||||||
#define RESET_SYS_SURE_Q_X centerStr_P(StrAreYouSureQ)
|
#define RESET_SYS_SURE_Q_X centerStr_P(StrAreYouSureQ)
|
||||||
#define RESET_SYS_SURE_Q_Y 32
|
#define RESET_SYS_SURE_Q_Y 32
|
||||||
#define RESET_SYS_BTN_YES_X centerStr_P(StrBtnResetYes)
|
#define RESET_SYS_BTN_YES_X centerStr_P(StrBtnResetYes)
|
||||||
#define RESET_SYS_BTN_YES_Y 48
|
#define RESET_SYS_BTN_YES_Y 48
|
||||||
#define RESET_SYS_BTN_NO_X centerStr_P(StrBtnResetYes)
|
#define RESET_SYS_BTN_NO_X centerStr_P(StrBtnResetYes)
|
||||||
#define RESET_SYS_BTN_NO_Y (RESET_SYS_BTN_YES_Y + CHAR_HEIGHT)
|
#define RESET_SYS_BTN_NO_Y (RESET_SYS_BTN_YES_Y + charHeight)
|
||||||
|
|
||||||
#define RESET_SYS_CONFIRMED_1_X centerStr2_P(StrSystem)
|
#define RESET_SYS_CONFIRMED_1_X centerStr2_P(StrSystem)
|
||||||
#define RESET_SYS_CONFIRMED_1_Y 7
|
#define RESET_SYS_CONFIRMED_1_Y 7
|
||||||
#define RESET_SYS_CONFIRMED_2_X centerStr2_P(StrEEPROM)
|
#define RESET_SYS_CONFIRMED_2_X centerStr2_P(StrEEPROM)
|
||||||
#define RESET_SYS_CONFIRMED_2_Y (RESET_SYS_CONFIRMED_1_Y + (CHAR_HEIGHT * 2) + 2)
|
#define RESET_SYS_CONFIRMED_2_Y (RESET_SYS_CONFIRMED_1_Y + char2Height + 2)
|
||||||
#define RESET_SYS_CONFIRMED_3_X centerStr2_P(StrReset)
|
#define RESET_SYS_CONFIRMED_3_X centerStr2_P(StrReset)
|
||||||
#define RESET_SYS_CONFIRMED_3_Y (RESET_SYS_CONFIRMED_2_Y + (CHAR_HEIGHT * 2) + 2)
|
#define RESET_SYS_CONFIRMED_3_Y (RESET_SYS_CONFIRMED_2_Y + char2Height + 2)
|
||||||
|
|
||||||
#define RESET_USER_TEXT_1_X centerStr_P(StrResetUser1)
|
#define RESET_USER_TEXT_1_X centerStr_P(StrResetUser1)
|
||||||
#define RESET_USER_TEXT_1_Y 0
|
#define RESET_USER_TEXT_1_Y 0
|
||||||
#define RESET_USER_TEXT_2_X centerStr_P(StrResetUser2)
|
#define RESET_USER_TEXT_2_X centerStr_P(StrResetUser2)
|
||||||
#define RESET_USER_TEXT_2_Y (RESET_USER_TEXT_1_Y + CHAR_HEIGHT)
|
#define RESET_USER_TEXT_2_Y (RESET_USER_TEXT_1_Y + charHeight)
|
||||||
#define RESET_USER_TEXT_3_X centerStr_P(StrResetUser3)
|
#define RESET_USER_TEXT_3_X centerStr_P(StrResetUser3)
|
||||||
#define RESET_USER_TEXT_3_Y (RESET_USER_TEXT_2_Y + CHAR_HEIGHT)
|
#define RESET_USER_TEXT_3_Y (RESET_USER_TEXT_2_Y + charHeight)
|
||||||
#define RESET_USER_SURE_Q_X centerStr_P(StrAreYouSureQ)
|
#define RESET_USER_SURE_Q_X centerStr_P(StrAreYouSureQ)
|
||||||
#define RESET_USER_SURE_Q_Y 32
|
#define RESET_USER_SURE_Q_Y 32
|
||||||
#define RESET_USER_BTN_YES_X centerStr_P(StrBtnResetYes)
|
#define RESET_USER_BTN_YES_X centerStr_P(StrBtnResetYes)
|
||||||
#define RESET_USER_BTN_YES_Y 48
|
#define RESET_USER_BTN_YES_Y 48
|
||||||
#define RESET_USER_BTN_NO_X centerStr_P(StrBtnResetYes)
|
#define RESET_USER_BTN_NO_X centerStr_P(StrBtnResetYes)
|
||||||
#define RESET_USER_BTN_NO_Y (RESET_USER_BTN_YES_Y + CHAR_HEIGHT)
|
#define RESET_USER_BTN_NO_Y (RESET_USER_BTN_YES_Y + charHeight)
|
||||||
|
|
||||||
#define RESET_USER_CONFIRMED_1_X centerStr2_P(StrUser)
|
#define RESET_USER_CONFIRMED_1_X centerStr2_P(StrUser)
|
||||||
#define RESET_USER_CONFIRMED_1_Y 7
|
#define RESET_USER_CONFIRMED_1_Y 7
|
||||||
#define RESET_USER_CONFIRMED_2_X centerStr2_P(StrEEPROM)
|
#define RESET_USER_CONFIRMED_2_X centerStr2_P(StrEEPROM)
|
||||||
#define RESET_USER_CONFIRMED_2_Y (RESET_USER_CONFIRMED_1_Y + (CHAR_HEIGHT * 2) + 2)
|
#define RESET_USER_CONFIRMED_2_Y (RESET_USER_CONFIRMED_1_Y + char2Height + 2)
|
||||||
#define RESET_USER_CONFIRMED_3_X centerStr2_P(StrReset)
|
#define RESET_USER_CONFIRMED_3_X centerStr2_P(StrReset)
|
||||||
#define RESET_USER_CONFIRMED_3_Y (RESET_USER_CONFIRMED_2_Y + (CHAR_HEIGHT * 2) + 2)
|
#define RESET_USER_CONFIRMED_3_Y (RESET_USER_CONFIRMED_2_Y + char2Height + 2)
|
||||||
|
|
||||||
#define RESET_USER_WRITING_X centerStr2_P(StrWriting)
|
#define RESET_USER_WRITING_X centerStr2_P(StrWriting)
|
||||||
#define RESET_USER_WRITING_Y ((HEIGHT / 2) - (CHAR_HEIGHT - 1))
|
#define RESET_USER_WRITING_Y ((HEIGHT / 2) - (char2Height / 2 - 1))
|
||||||
|
|
||||||
// EEPROM addresses
|
// EEPROM addresses
|
||||||
#define EEPROM_START (0x0000)
|
constexpr unsigned int EEPROMstart = 0x0000;
|
||||||
#define EEPROM_SIZE (1024)
|
constexpr unsigned int EEPROMsize = 1024;
|
||||||
#define EEPROM_END (EEPROM_START + EEPROM_SIZE - 1)
|
constexpr unsigned int EEPROMend = EEPROMstart + EEPROMsize - 1;
|
||||||
|
|
||||||
// Calculation of the number of frames to wait before button auto-repeat starts
|
// Calculation of the number of frames to wait before button auto-repeat starts
|
||||||
#define DELAY_FRAMES (REPEAT_DELAY / (1000 / FRAME_RATE))
|
constexpr unsigned int delayFrames = repeatDelay / (1000 / frameRate);
|
||||||
|
|
||||||
// The Arduino "magic" has trouble creating prototypes for functions called
|
// The Arduino "magic" has trouble creating prototypes for functions called
|
||||||
// by pointers, so they're declared here manually
|
// by pointers, so they're declared here manually
|
||||||
|
|
@ -298,27 +294,39 @@ void screenSaveName(), screenSaveID(), screenResetSys(), screenResetUser();
|
||||||
|
|
||||||
Arduboy2 arduboy;
|
Arduboy2 arduboy;
|
||||||
|
|
||||||
|
constexpr uint8_t charSpacing = arduboy.getCharacterSpacing(1);
|
||||||
|
constexpr uint8_t char2Spacing = arduboy.getCharacterSpacing(2);
|
||||||
|
constexpr uint8_t charWidth = arduboy.getCharacterWidth(1) + charSpacing;
|
||||||
|
constexpr uint8_t char2Width = arduboy.getCharacterWidth(2) + char2Spacing;
|
||||||
|
constexpr uint8_t charHeight = arduboy.getCharacterHeight(1) +
|
||||||
|
arduboy.getLineSpacing(1);
|
||||||
|
constexpr uint8_t char2Height = arduboy.getCharacterHeight(2) +
|
||||||
|
arduboy.getLineSpacing(2);
|
||||||
|
|
||||||
|
// The number of pixels for a small space between groups
|
||||||
|
constexpr uint8_t smallSpace = 4;
|
||||||
|
|
||||||
char unitName[ARDUBOY_UNIT_NAME_BUFFER_SIZE];
|
char unitName[ARDUBOY_UNIT_NAME_BUFFER_SIZE];
|
||||||
byte nameIndex;
|
uint8_t nameIndex;
|
||||||
|
|
||||||
uint16_t unitID;
|
uint16_t unitID;
|
||||||
byte idIndex;
|
uint8_t idIndex;
|
||||||
|
|
||||||
boolean showLogoFlag;
|
bool showLogoFlag;
|
||||||
boolean showLEDsFlag;
|
bool showLEDsFlag;
|
||||||
boolean showNameFlag;
|
bool showNameFlag;
|
||||||
|
|
||||||
// Selected flag
|
// Selected flag
|
||||||
enum SelectedFlag : byte {
|
enum class SelectedFlag : uint8_t {
|
||||||
selFlagLogo,
|
selFlagLogo,
|
||||||
selFlagLEDs,
|
selFlagLEDs,
|
||||||
selFlagName
|
selFlagName
|
||||||
};
|
};
|
||||||
|
|
||||||
byte currentFlag;
|
SelectedFlag currentFlag;
|
||||||
|
|
||||||
// Assign numbers for each state/screen
|
// Assign numbers for each state/screen
|
||||||
enum State : byte {
|
enum class State : uint8_t {
|
||||||
sMain,
|
sMain,
|
||||||
sName,
|
sName,
|
||||||
sID,
|
sID,
|
||||||
|
|
@ -331,10 +339,10 @@ enum State : byte {
|
||||||
sMAX = sResetUser
|
sMAX = sResetUser
|
||||||
};
|
};
|
||||||
|
|
||||||
byte currentState;
|
State currentState;
|
||||||
|
|
||||||
// Function pointer array for button handling
|
// Function pointer array for button handling
|
||||||
void (*stateFunc[sMAX + 1])() = {
|
void (*stateFunc[static_cast<uint8_t>(State::sMAX) + 1])() = {
|
||||||
stateMain,
|
stateMain,
|
||||||
stateName,
|
stateName,
|
||||||
stateID,
|
stateID,
|
||||||
|
|
@ -347,7 +355,7 @@ void (*stateFunc[sMAX + 1])() = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function pointer array for screen drawing
|
// Function pointer array for screen drawing
|
||||||
void (*screenFunc[sMAX + 1])() = {
|
void (*screenFunc[static_cast<uint8_t>(State::sMAX) + 1])() = {
|
||||||
screenMain,
|
screenMain,
|
||||||
screenName,
|
screenName,
|
||||||
screenID,
|
screenID,
|
||||||
|
|
@ -360,14 +368,14 @@ void (*screenFunc[sMAX + 1])() = {
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int delayCount = 0;
|
unsigned int delayCount = 0;
|
||||||
boolean repeating = false;
|
bool repeating = false;
|
||||||
|
|
||||||
|
|
||||||
// ============================= SETUP ===================================
|
// ============================= SETUP ===================================
|
||||||
void setup() {
|
void setup() {
|
||||||
arduboy.begin();
|
arduboy.begin();
|
||||||
arduboy.setFrameRate(FRAME_RATE);
|
arduboy.setFrameRate(frameRate);
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
|
||||||
|
|
@ -380,7 +388,7 @@ void loop() {
|
||||||
|
|
||||||
arduboy.pollButtons();
|
arduboy.pollButtons();
|
||||||
|
|
||||||
(*stateFunc[currentState])();
|
(*stateFunc[static_cast<uint8_t>(currentState)])();
|
||||||
|
|
||||||
if ((delayCount != 0) && (--delayCount == 0)) {
|
if ((delayCount != 0) && (--delayCount == 0)) {
|
||||||
repeating = true;
|
repeating = true;
|
||||||
|
|
@ -393,7 +401,7 @@ void loop() {
|
||||||
|
|
||||||
// Set to the given state and display the screen for that state
|
// Set to the given state and display the screen for that state
|
||||||
// Can be called with the current state to update the current screen
|
// Can be called with the current state to update the current screen
|
||||||
void setState(byte newState) {
|
void setState(State newState) {
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
stopButtonRepeat();
|
stopButtonRepeat();
|
||||||
drawScreen();
|
drawScreen();
|
||||||
|
|
@ -402,16 +410,16 @@ void setState(byte newState) {
|
||||||
// STATE: Main selection screen
|
// STATE: Main selection screen
|
||||||
void stateMain() {
|
void stateMain() {
|
||||||
if (arduboy.justPressed(UP_BUTTON)) {
|
if (arduboy.justPressed(UP_BUTTON)) {
|
||||||
setState(sName);
|
setState(State::sName);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(DOWN_BUTTON)) {
|
else if (arduboy.justPressed(DOWN_BUTTON)) {
|
||||||
setState(sID);
|
setState(State::sID);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(LEFT_BUTTON)) {
|
else if (arduboy.justPressed(LEFT_BUTTON)) {
|
||||||
setState(sFlags);
|
setState(State::sFlags);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(RIGHT_BUTTON)) {
|
else if (arduboy.justPressed(RIGHT_BUTTON)) {
|
||||||
setState(sReset);
|
setState(State::sReset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,10 +446,10 @@ void stateName() {
|
||||||
nameCursorLeft();
|
nameCursorLeft();
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(A_BUTTON)) {
|
else if (arduboy.justPressed(A_BUTTON)) {
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(B_BUTTON)) {
|
else if (arduboy.justPressed(B_BUTTON)) {
|
||||||
setState(sSaveName);
|
setState(State::sSaveName);
|
||||||
}
|
}
|
||||||
else if (repeating) {
|
else if (repeating) {
|
||||||
stopButtonRepeat();
|
stopButtonRepeat();
|
||||||
|
|
@ -459,12 +467,12 @@ void stateID() {
|
||||||
startButtonDelay();
|
startButtonDelay();
|
||||||
}
|
}
|
||||||
else if (repeating && arduboy.pressed(UP_BUTTON)) {
|
else if (repeating && arduboy.pressed(UP_BUTTON)) {
|
||||||
if (arduboy.everyXFrames(ID_REPEAT_FRAMES)) {
|
if (arduboy.everyXFrames(idRepeatFrames)) {
|
||||||
idDigitInc();
|
idDigitInc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (repeating && arduboy.pressed(DOWN_BUTTON)) {
|
else if (repeating && arduboy.pressed(DOWN_BUTTON)) {
|
||||||
if (arduboy.everyXFrames(ID_REPEAT_FRAMES)) {
|
if (arduboy.everyXFrames(idRepeatFrames)) {
|
||||||
idDigitDec();
|
idDigitDec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -475,10 +483,10 @@ void stateID() {
|
||||||
idCursorLeft();
|
idCursorLeft();
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(A_BUTTON)) {
|
else if (arduboy.justPressed(A_BUTTON)) {
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(B_BUTTON)) {
|
else if (arduboy.justPressed(B_BUTTON)) {
|
||||||
setState(sSaveID);
|
setState(State::sSaveID);
|
||||||
}
|
}
|
||||||
else if (repeating) {
|
else if (repeating) {
|
||||||
stopButtonRepeat();
|
stopButtonRepeat();
|
||||||
|
|
@ -496,8 +504,8 @@ void stateFlags() {
|
||||||
else {
|
else {
|
||||||
displayNoLogo();
|
displayNoLogo();
|
||||||
}
|
}
|
||||||
currentFlag = selFlagLogo;
|
currentFlag = SelectedFlag::selFlagLogo;
|
||||||
setState(sFlags);
|
setState(State::sFlags);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(UP_BUTTON)) {
|
else if (arduboy.justPressed(UP_BUTTON)) {
|
||||||
flagsCursorUp();
|
flagsCursorUp();
|
||||||
|
|
@ -510,24 +518,24 @@ void stateFlags() {
|
||||||
flagToggle();
|
flagToggle();
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(A_BUTTON)) {
|
else if (arduboy.justPressed(A_BUTTON)) {
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(B_BUTTON)) {
|
else if (arduboy.justPressed(B_BUTTON)) {
|
||||||
saveFlags();
|
saveFlags();
|
||||||
setState(sFlags);
|
setState(State::sFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATE: Reset EEPROM areas
|
// STATE: Reset EEPROM areas
|
||||||
void stateReset() {
|
void stateReset() {
|
||||||
if (arduboy.justPressed(UP_BUTTON)) {
|
if (arduboy.justPressed(UP_BUTTON)) {
|
||||||
setState(sResetSys);
|
setState(State::sResetSys);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(DOWN_BUTTON)) {
|
else if (arduboy.justPressed(DOWN_BUTTON)) {
|
||||||
setState(sResetUser);
|
setState(State::sResetUser);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(A_BUTTON)) {
|
else if (arduboy.justPressed(A_BUTTON)) {
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -535,10 +543,10 @@ void stateReset() {
|
||||||
void stateSaveName() {
|
void stateSaveName() {
|
||||||
if (arduboy.justPressed(A_BUTTON)) {
|
if (arduboy.justPressed(A_BUTTON)) {
|
||||||
arduboy.writeUnitName(unitName);
|
arduboy.writeUnitName(unitName);
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(B_BUTTON)) {
|
else if (arduboy.justPressed(B_BUTTON)) {
|
||||||
setState(sName);
|
setState(State::sName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -546,10 +554,10 @@ void stateSaveName() {
|
||||||
void stateSaveID() {
|
void stateSaveID() {
|
||||||
if (arduboy.justPressed(A_BUTTON)) {
|
if (arduboy.justPressed(A_BUTTON)) {
|
||||||
arduboy.writeUnitID(unitID);
|
arduboy.writeUnitID(unitID);
|
||||||
setState(sMain);
|
setState(State::sMain);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(B_BUTTON)) {
|
else if (arduboy.justPressed(B_BUTTON)) {
|
||||||
setState(sID);
|
setState(State::sID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -557,13 +565,13 @@ void stateSaveID() {
|
||||||
void stateResetSys() {
|
void stateResetSys() {
|
||||||
if (arduboy.justPressed(B_BUTTON) && arduboy.pressed(A_BUTTON)) {
|
if (arduboy.justPressed(B_BUTTON) && arduboy.pressed(A_BUTTON)) {
|
||||||
resetSysEEPROM();
|
resetSysEEPROM();
|
||||||
setState(sReset);
|
setState(State::sReset);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(UP_BUTTON) ||
|
else if (arduboy.justPressed(UP_BUTTON) ||
|
||||||
arduboy.justPressed(DOWN_BUTTON) ||
|
arduboy.justPressed(DOWN_BUTTON) ||
|
||||||
arduboy.justPressed(RIGHT_BUTTON) ||
|
arduboy.justPressed(RIGHT_BUTTON) ||
|
||||||
arduboy.justPressed(LEFT_BUTTON)) {
|
arduboy.justPressed(LEFT_BUTTON)) {
|
||||||
setState(sReset);
|
setState(State::sReset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -571,13 +579,13 @@ void stateResetSys() {
|
||||||
void stateResetUser() {
|
void stateResetUser() {
|
||||||
if (arduboy.justPressed(B_BUTTON) && arduboy.pressed(A_BUTTON)) {
|
if (arduboy.justPressed(B_BUTTON) && arduboy.pressed(A_BUTTON)) {
|
||||||
resetUserEEPROM();
|
resetUserEEPROM();
|
||||||
setState(sReset);
|
setState(State::sReset);
|
||||||
}
|
}
|
||||||
else if (arduboy.justPressed(UP_BUTTON) ||
|
else if (arduboy.justPressed(UP_BUTTON) ||
|
||||||
arduboy.justPressed(DOWN_BUTTON) ||
|
arduboy.justPressed(DOWN_BUTTON) ||
|
||||||
arduboy.justPressed(RIGHT_BUTTON) ||
|
arduboy.justPressed(RIGHT_BUTTON) ||
|
||||||
arduboy.justPressed(LEFT_BUTTON)) {
|
arduboy.justPressed(LEFT_BUTTON)) {
|
||||||
setState(sReset);
|
setState(State::sReset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -586,7 +594,7 @@ void stateResetUser() {
|
||||||
// Display the screen for the current state
|
// Display the screen for the current state
|
||||||
void drawScreen() {
|
void drawScreen() {
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
(*screenFunc[currentState])();
|
(*screenFunc[static_cast<uint8_t>(currentState)])();
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -594,7 +602,7 @@ void drawScreen() {
|
||||||
void screenMain() {
|
void screenMain() {
|
||||||
readEEPROM();
|
readEEPROM();
|
||||||
nameIndex = idIndex = 0;
|
nameIndex = idIndex = 0;
|
||||||
currentFlag = selFlagLogo;
|
currentFlag = SelectedFlag::selFlagLogo;
|
||||||
|
|
||||||
printStr_P(MENU_BTN_CHANGE_NAME_X, MENU_BTN_CHANGE_NAME_Y, StrBtnChangeName);
|
printStr_P(MENU_BTN_CHANGE_NAME_X, MENU_BTN_CHANGE_NAME_Y, StrBtnChangeName);
|
||||||
printName(MENU_NAME_X, MENU_NAME_Y);
|
printName(MENU_NAME_X, MENU_NAME_Y);
|
||||||
|
|
@ -667,7 +675,7 @@ void screenSaveID() {
|
||||||
printIDLarge(ID_SAVE_X, ID_SAVE_Y);
|
printIDLarge(ID_SAVE_X, ID_SAVE_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DISPLAY: Propmt to reset the system EEPROM area
|
// DISPLAY: Prompt to reset the system EEPROM area
|
||||||
void screenResetSys() {
|
void screenResetSys() {
|
||||||
printStr_P(RESET_SYS_TEXT_1_X, RESET_SYS_TEXT_1_Y, StrResetSys1);
|
printStr_P(RESET_SYS_TEXT_1_X, RESET_SYS_TEXT_1_Y, StrResetSys1);
|
||||||
printStr_P(RESET_SYS_TEXT_2_X, RESET_SYS_TEXT_2_Y, StrResetSys2);
|
printStr_P(RESET_SYS_TEXT_2_X, RESET_SYS_TEXT_2_Y, StrResetSys2);
|
||||||
|
|
@ -677,7 +685,7 @@ void screenResetSys() {
|
||||||
printStr_P(RESET_SYS_BTN_NO_X, RESET_SYS_BTN_NO_Y, StrBtnResetNo);
|
printStr_P(RESET_SYS_BTN_NO_X, RESET_SYS_BTN_NO_Y, StrBtnResetNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DISPLAY: Propmt to reset the user EEPROM area
|
// DISPLAY: Prompt to reset the user EEPROM area
|
||||||
void screenResetUser() {
|
void screenResetUser() {
|
||||||
printStr_P(RESET_USER_TEXT_1_X, RESET_USER_TEXT_1_Y, StrResetUser1);
|
printStr_P(RESET_USER_TEXT_1_X, RESET_USER_TEXT_1_Y, StrResetUser1);
|
||||||
printStr_P(RESET_USER_TEXT_2_X, RESET_USER_TEXT_2_Y, StrResetUser2);
|
printStr_P(RESET_USER_TEXT_2_X, RESET_USER_TEXT_2_Y, StrResetUser2);
|
||||||
|
|
@ -708,7 +716,7 @@ void saveFlags() {
|
||||||
|
|
||||||
// Reset the system EEPROM area and display the confirmation message
|
// Reset the system EEPROM area and display the confirmation message
|
||||||
void resetSysEEPROM() {
|
void resetSysEEPROM() {
|
||||||
for (unsigned int i = EEPROM_START; i < EEPROM_STORAGE_SPACE_START; i++) {
|
for (unsigned int i = EEPROMstart; i < EEPROM_STORAGE_SPACE_START; i++) {
|
||||||
EEPROM.update(i, 0xFF);
|
EEPROM.update(i, 0xFF);
|
||||||
}
|
}
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
|
|
@ -726,7 +734,7 @@ void resetUserEEPROM() {
|
||||||
printStr_P(RESET_USER_WRITING_X, RESET_USER_WRITING_Y, StrWriting);
|
printStr_P(RESET_USER_WRITING_X, RESET_USER_WRITING_Y, StrWriting);
|
||||||
arduboy.setTextSize(1);
|
arduboy.setTextSize(1);
|
||||||
arduboy.display(CLEAR_BUFFER);
|
arduboy.display(CLEAR_BUFFER);
|
||||||
for (unsigned int i = EEPROM_STORAGE_SPACE_START; i <= EEPROM_END; i++) {
|
for (unsigned int i = EEPROM_STORAGE_SPACE_START; i <= EEPROMend; i++) {
|
||||||
EEPROM.update(i, 0xFF);
|
EEPROM.update(i, 0xFF);
|
||||||
}
|
}
|
||||||
printStrLargeRev_P(RESET_USER_CONFIRMED_1_X, RESET_USER_CONFIRMED_1_Y, StrUser);
|
printStrLargeRev_P(RESET_USER_CONFIRMED_1_X, RESET_USER_CONFIRMED_1_Y, StrUser);
|
||||||
|
|
@ -745,7 +753,7 @@ void printNameScreenCommon() {
|
||||||
printNameDecimal(NAME_DECIMAL_X, NAME_DECIMAL_Y);
|
printNameDecimal(NAME_DECIMAL_X, NAME_DECIMAL_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the name entry screen common information
|
// Print the ID entry screen common information
|
||||||
void printIDScreenCommon() {
|
void printIDScreenCommon() {
|
||||||
printStr_P(ID_TITLE_X, ID_TITLE_Y, StrID);
|
printStr_P(ID_TITLE_X, ID_TITLE_Y, StrID);
|
||||||
printIDDecimalBytes(ID_2_DECIMAL_X, ID_2_DECIMAL_Y);
|
printIDDecimalBytes(ID_2_DECIMAL_X, ID_2_DECIMAL_Y);
|
||||||
|
|
@ -755,41 +763,45 @@ void printIDScreenCommon() {
|
||||||
|
|
||||||
// Print the name screen cursors
|
// Print the name screen cursors
|
||||||
void printNameCursors() {
|
void printNameCursors() {
|
||||||
arduboy.fillRect(NAME_LARGE_X + (nameIndex * CHAR_WIDTH * 2),
|
arduboy.fillRect(NAME_LARGE_X + (nameIndex * char2Width),
|
||||||
NAME_LARGE_Y + (CHAR_HEIGHT * 2) + 2,
|
NAME_LARGE_Y + char2Height + 2,
|
||||||
(CHAR_WIDTH * 2) - 2, 2);
|
char2Width - char2Spacing, 2);
|
||||||
|
|
||||||
arduboy.drawFastHLine(NAME_HEX_X +
|
arduboy.drawFastHLine(NAME_HEX_X +
|
||||||
(nameIndex * (CHAR_WIDTH * 3 + SMALL_SPACE)),
|
(nameIndex * (charWidth * 3 + smallSpace)),
|
||||||
NAME_HEX_Y + CHAR_HEIGHT + 1, CHAR_WIDTH * 3 - 1);
|
NAME_HEX_Y + charHeight + 1,
|
||||||
|
charWidth * 3 - charSpacing);
|
||||||
|
|
||||||
arduboy.drawFastHLine(NAME_DECIMAL_X +
|
arduboy.drawFastHLine(NAME_DECIMAL_X +
|
||||||
(nameIndex * (CHAR_WIDTH * 3 + SMALL_SPACE)),
|
(nameIndex * (charWidth * 3 + smallSpace)),
|
||||||
NAME_DECIMAL_Y + CHAR_HEIGHT + 1, CHAR_WIDTH * 3 - 1);
|
NAME_DECIMAL_Y + charHeight + 1,
|
||||||
|
charWidth * 3 - charSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the ID screen cursors
|
// Print the ID screen cursors
|
||||||
void printIDCursors() {
|
void printIDCursors() {
|
||||||
arduboy.fillRect(ID_LARGE_X + ((idIndex + 1) * (CHAR_WIDTH * 2)),
|
arduboy.fillRect(ID_LARGE_X + ((idIndex + 1) * char2Width),
|
||||||
ID_LARGE_Y + (CHAR_HEIGHT * 2),
|
ID_LARGE_Y + char2Height,
|
||||||
(CHAR_WIDTH * 2) - 2, 2);
|
char2Width - char2Spacing, 2);
|
||||||
|
|
||||||
arduboy.drawFastHLine(ID_2_DECIMAL_X +
|
arduboy.drawFastHLine(ID_2_DECIMAL_X +
|
||||||
((idIndex / 2) * (CHAR_WIDTH * 3 + SMALL_SPACE)),
|
((idIndex / 2) * (charWidth * 3 + smallSpace)),
|
||||||
ID_2_DECIMAL_Y + CHAR_HEIGHT + 1, CHAR_WIDTH * 3 - 1);
|
ID_2_DECIMAL_Y + charHeight + 1,
|
||||||
|
charWidth * 3 - charSpacing);
|
||||||
|
|
||||||
arduboy.drawFastHLine(ID_DECIMAL_X, ID_DECIMAL_Y + CHAR_HEIGHT + 1,
|
arduboy.drawFastHLine(ID_DECIMAL_X, ID_DECIMAL_Y + charHeight + 1,
|
||||||
CHAR_WIDTH * 5 - 1);
|
charWidth * 5 - 1);
|
||||||
|
|
||||||
arduboy.drawFastHLine((ID_BINARY_X + CHAR_WIDTH + SMALL_SPACE) +
|
arduboy.drawFastHLine((ID_BINARY_X + charWidth + smallSpace) +
|
||||||
(idIndex * (CHAR_WIDTH * 4 + SMALL_SPACE)),
|
(idIndex * (charWidth * 4 + smallSpace)),
|
||||||
ID_BINARY_Y + CHAR_HEIGHT + 1, CHAR_WIDTH * 4 - 1);
|
ID_BINARY_Y + charHeight + 1,
|
||||||
|
charWidth * 4 - charSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the values and cursor for the flags
|
// Print the values and cursor for the flags
|
||||||
void printFlagSettings() {
|
void printFlagSettings() {
|
||||||
int cursorY;
|
int cursorY;
|
||||||
byte cursorLen = strlen_P(StrYes) * CHAR_WIDTH - 1 ;
|
uint8_t cursorLen = strlen_P(StrYes) * charWidth - charSpacing;
|
||||||
|
|
||||||
if (showLogoFlag) {
|
if (showLogoFlag) {
|
||||||
printStr_P(FLAGS_SET_X, FLAGS_LOGO_Y, StrYes);
|
printStr_P(FLAGS_SET_X, FLAGS_LOGO_Y, StrYes);
|
||||||
|
|
@ -813,22 +825,22 @@ void printFlagSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (currentFlag) {
|
switch (currentFlag) {
|
||||||
case selFlagLEDs:
|
case SelectedFlag::selFlagLEDs:
|
||||||
cursorY = FLAGS_LEDS_Y;
|
cursorY = FLAGS_LEDS_Y;
|
||||||
if (!showLEDsFlag) {
|
if (!showLEDsFlag) {
|
||||||
cursorLen = strlen_P(StrNo) * CHAR_WIDTH - 1;
|
cursorLen = strlen_P(StrNo) * charWidth - charSpacing;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case selFlagName:
|
case SelectedFlag::selFlagName:
|
||||||
cursorY = FLAGS_NAME_Y;
|
cursorY = FLAGS_NAME_Y;
|
||||||
if (!showNameFlag) {
|
if (!showNameFlag) {
|
||||||
cursorLen = strlen_P(StrNo) * CHAR_WIDTH - 1;
|
cursorLen = strlen_P(StrNo) * charWidth - charSpacing;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: // selFlagLogo
|
default: // selFlagLogo
|
||||||
cursorY = FLAGS_LOGO_Y;
|
cursorY = FLAGS_LOGO_Y;
|
||||||
if (!showLogoFlag) {
|
if (!showLogoFlag) {
|
||||||
cursorLen = strlen_P(StrNo) * CHAR_WIDTH - 1;
|
cursorLen = strlen_P(StrNo) * charWidth - charSpacing;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -836,7 +848,7 @@ void printFlagSettings() {
|
||||||
arduboy.setCursor(FLAGS_CURSOR_X, cursorY);
|
arduboy.setCursor(FLAGS_CURSOR_X, cursorY);
|
||||||
arduboy.print('\x10');
|
arduboy.print('\x10');
|
||||||
|
|
||||||
arduboy.drawFastHLine(FLAGS_SET_X, cursorY + CHAR_HEIGHT, cursorLen);
|
arduboy.drawFastHLine(FLAGS_SET_X, cursorY + charHeight, cursorLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the unit name in normal size including an extent underline
|
// Print the unit name in normal size including an extent underline
|
||||||
|
|
@ -844,9 +856,9 @@ void printFlagSettings() {
|
||||||
void printName(int x, int y) {
|
void printName(int x, int y) {
|
||||||
printStr(x, y, unitName);
|
printStr(x, y, unitName);
|
||||||
|
|
||||||
y += (CHAR_HEIGHT + 1);
|
y += (charHeight + 1);
|
||||||
for (byte i = 0; i < ARDUBOY_UNIT_NAME_LEN; i++, x += CHAR_WIDTH) {
|
for (uint8_t i = 0; i < ARDUBOY_UNIT_NAME_LEN; i++, x += charWidth) {
|
||||||
arduboy.drawFastHLine(x, y, CHAR_WIDTH - 1);
|
arduboy.drawFastHLine(x, y, charWidth - charSpacing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -864,8 +876,8 @@ void printNameUnderline(int x, int y) {
|
||||||
|
|
||||||
if (unitName[0] != 0) {
|
if (unitName[0] != 0) {
|
||||||
x -= 1;
|
x -= 1;
|
||||||
y += ((CHAR_HEIGHT * 2) + 6);
|
y += (char2Height + 6);
|
||||||
lWidth = (strlen(unitName) * (CHAR_WIDTH * 2));
|
lWidth = (strlen(unitName) * char2Width);
|
||||||
arduboy.drawPixel(x, y);
|
arduboy.drawPixel(x, y);
|
||||||
arduboy.drawPixel(x + lWidth - 1, y);
|
arduboy.drawPixel(x + lWidth - 1, y);
|
||||||
arduboy.drawFastHLine(x, y + 1, lWidth);
|
arduboy.drawFastHLine(x, y + 1, lWidth);
|
||||||
|
|
@ -874,17 +886,17 @@ void printNameUnderline(int x, int y) {
|
||||||
|
|
||||||
// Print the unit name in hex at the given location
|
// Print the unit name in hex at the given location
|
||||||
void printNameHex(int x, int y) {
|
void printNameHex(int x, int y) {
|
||||||
for (byte i = 0; i < ARDUBOY_UNIT_NAME_LEN; i++) {
|
for (uint8_t i = 0; i < ARDUBOY_UNIT_NAME_LEN; i++) {
|
||||||
printHex8(x, y, unitName[i]);
|
printHex8(x, y, unitName[i]);
|
||||||
x += CHAR_WIDTH * 3 + SMALL_SPACE;
|
x += charWidth * 3 + smallSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the unit name in decimal at the given location
|
// Print the unit name in decimal at the given location
|
||||||
void printNameDecimal(int x, int y) {
|
void printNameDecimal(int x, int y) {
|
||||||
for (byte i = 0; i < ARDUBOY_UNIT_NAME_LEN; i++) {
|
for (uint8_t i = 0; i < ARDUBOY_UNIT_NAME_LEN; i++) {
|
||||||
printDecimal8(x, y, unitName[i]);
|
printDecimal8(x, y, unitName[i]);
|
||||||
x += CHAR_WIDTH * 3 + SMALL_SPACE;
|
x += charWidth * 3 + smallSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -903,7 +915,7 @@ void printIDHex(int x, int y) {
|
||||||
// Print the unit ID as 2 decimal bytes at the given location
|
// Print the unit ID as 2 decimal bytes at the given location
|
||||||
void printIDDecimalBytes(int x, int y) {
|
void printIDDecimalBytes(int x, int y) {
|
||||||
printDecimal8(x, y, unitID >> 8);
|
printDecimal8(x, y, unitID >> 8);
|
||||||
printDecimal8(x + CHAR_WIDTH * 3 + SMALL_SPACE, y, unitID & 0x00FF);
|
printDecimal8(x + charWidth * 3 + smallSpace, y, unitID & 0x00FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the unit ID in decimal at the given location
|
// Print the unit ID in decimal at the given location
|
||||||
|
|
@ -916,17 +928,17 @@ void printIDDecimal(int x, int y) {
|
||||||
void printIDBinary(int x, int y) {
|
void printIDBinary(int x, int y) {
|
||||||
arduboy.setCursor(x, y);
|
arduboy.setCursor(x, y);
|
||||||
arduboy.print('b');
|
arduboy.print('b');
|
||||||
x += CHAR_WIDTH + SMALL_SPACE;
|
x += charWidth + smallSpace;
|
||||||
for (char i = 3 * 4; i >= 0; i -= 4) {
|
for (char i = 3 * 4; i >= 0; i -= 4) {
|
||||||
printBinaryNybble(x, y, (byte)(unitID >> i));
|
printBinaryNybble(x, y, static_cast<uint8_t>(unitID >> i));
|
||||||
x += CHAR_WIDTH * 4 + SMALL_SPACE;
|
x += charWidth * 4 + smallSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the save prompt in reverse at the given location
|
// Print the save prompt in reverse at the given location
|
||||||
void printSavePrompt(int x, int y) {
|
void printSavePrompt(int x, int y) {
|
||||||
arduboy.fillRect(x - 2, y - 2,
|
arduboy.fillRect(x - 2, y - 2,
|
||||||
strlen_P(StrSaveQ) * CHAR_WIDTH + 3, CHAR_HEIGHT + 3);
|
strlen_P(StrSaveQ) * charWidth + 3, charHeight + 3);
|
||||||
arduboy.setTextColor(BLACK);
|
arduboy.setTextColor(BLACK);
|
||||||
arduboy.setTextBackground(WHITE);
|
arduboy.setTextBackground(WHITE);
|
||||||
printStr_P(x, y, StrSaveQ);
|
printStr_P(x, y, StrSaveQ);
|
||||||
|
|
@ -947,18 +959,18 @@ void printStr_P(int x, int y, const char* str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print an 8 bit number in decimal, right justified with leading spaces
|
// Print an 8 bit number in decimal, right justified with leading spaces
|
||||||
void printDecimal8(int x, int y, byte val) {
|
void printDecimal8(int x, int y, uint8_t val) {
|
||||||
printDecimalHelper(x, y, 2, 100, val);
|
printDecimalHelper(x, y, 2, 100, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a 16 bit number in decimal, right justified with leading spaces
|
// Print a 16 bit number in decimal, right justified with leading spaces
|
||||||
void printDecimal16(int x, int y, unsigned int val) {
|
void printDecimal16(int x, int y, uint16_t val) {
|
||||||
printDecimalHelper(x, y, 4, 10000, val);
|
printDecimalHelper(x, y, 4, 10000, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a right justified decimal number, given width-1 and (width-1)^10
|
// Print a right justified decimal number, given width-1 and (width-1)^10
|
||||||
void printDecimalHelper(int x, int y, byte width, unsigned int pwr10,
|
void printDecimalHelper(int x, int y, uint8_t width, uint16_t pwr10,
|
||||||
unsigned int val) {
|
uint16_t val) {
|
||||||
arduboy.setCursor(x, y);
|
arduboy.setCursor(x, y);
|
||||||
while (width > 0) {
|
while (width > 0) {
|
||||||
if (val >= pwr10) {
|
if (val >= pwr10) {
|
||||||
|
|
@ -972,7 +984,7 @@ void printDecimalHelper(int x, int y, byte width, unsigned int pwr10,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print an 8 bit hex number with leading x and zeros
|
// Print an 8 bit hex number with leading x and zeros
|
||||||
void printHex8(int x, int y, byte val) {
|
void printHex8(int x, int y, uint8_t val) {
|
||||||
arduboy.setCursor(x, y);
|
arduboy.setCursor(x, y);
|
||||||
arduboy.print('x');
|
arduboy.print('x');
|
||||||
if (val < 16) {
|
if (val < 16) {
|
||||||
|
|
@ -982,7 +994,7 @@ void printHex8(int x, int y, byte val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a 16 bit hex number with leading x and zeros
|
// Print a 16 bit hex number with leading x and zeros
|
||||||
void printHex16(int x, int y, unsigned int val) {
|
void printHex16(int x, int y, uint16_t val) {
|
||||||
arduboy.setCursor(x, y);
|
arduboy.setCursor(x, y);
|
||||||
arduboy.print('x');
|
arduboy.print('x');
|
||||||
for (char i = 3 * 4; i >= 0; i -= 4) {
|
for (char i = 3 * 4; i >= 0; i -= 4) {
|
||||||
|
|
@ -991,7 +1003,7 @@ void printHex16(int x, int y, unsigned int val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print a nybble in binary from the lowest 4 bits of the provided byte
|
// Print a nybble in binary from the lowest 4 bits of the provided byte
|
||||||
void printBinaryNybble(int x, int y, byte val) {
|
void printBinaryNybble(int x, int y, uint8_t val) {
|
||||||
arduboy.setCursor(x, y);
|
arduboy.setCursor(x, y);
|
||||||
|
|
||||||
for (char i = 3; i >= 0; i--) {
|
for (char i = 3; i >= 0; i--) {
|
||||||
|
|
@ -1002,7 +1014,7 @@ void printBinaryNybble(int x, int y, byte val) {
|
||||||
// Print a constant string in large size and reversed
|
// Print a constant string in large size and reversed
|
||||||
void printStrLargeRev_P(int x, int y, const char* string) {
|
void printStrLargeRev_P(int x, int y, const char* string) {
|
||||||
arduboy.fillRect(x - 4, y - 4,
|
arduboy.fillRect(x - 4, y - 4,
|
||||||
strlen_P(string) * CHAR_WIDTH * 2 + 6, CHAR_HEIGHT * 2 + 6);
|
strlen_P(string) * char2Width + 6, char2Height + 6);
|
||||||
arduboy.setTextColor(BLACK);
|
arduboy.setTextColor(BLACK);
|
||||||
arduboy.setTextBackground(WHITE);
|
arduboy.setTextBackground(WHITE);
|
||||||
arduboy.setTextSize(2);
|
arduboy.setTextSize(2);
|
||||||
|
|
@ -1037,8 +1049,8 @@ void nameCharDec() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the given character is not allowed
|
// Return true if the given character is not allowed
|
||||||
boolean invalidChar(char c) {
|
bool invalidChar(char c) {
|
||||||
return (c == '\n') || (c == '\r') || ((byte)c == 0xFF);
|
return (c == '\n') || (c == '\r') || (static_cast<uint8_t>(c) == 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the name cursor right
|
// Move the name cursor right
|
||||||
|
|
@ -1100,14 +1112,14 @@ void idCursorLeft() {
|
||||||
// Move the Flags cursor down
|
// Move the Flags cursor down
|
||||||
void flagsCursorDown() {
|
void flagsCursorDown() {
|
||||||
switch (currentFlag) {
|
switch (currentFlag) {
|
||||||
case selFlagLogo:
|
case SelectedFlag::selFlagLogo:
|
||||||
currentFlag = selFlagLEDs;
|
currentFlag = SelectedFlag::selFlagLEDs;
|
||||||
break;
|
break;
|
||||||
case selFlagLEDs:
|
case SelectedFlag::selFlagLEDs:
|
||||||
currentFlag = selFlagName;
|
currentFlag = SelectedFlag::selFlagName;
|
||||||
break;
|
break;
|
||||||
case selFlagName:
|
case SelectedFlag::selFlagName:
|
||||||
currentFlag = selFlagLogo;
|
currentFlag = SelectedFlag::selFlagLogo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
drawScreen();
|
drawScreen();
|
||||||
|
|
@ -1116,14 +1128,14 @@ void flagsCursorDown() {
|
||||||
// Move the Flags cursor up
|
// Move the Flags cursor up
|
||||||
void flagsCursorUp() {
|
void flagsCursorUp() {
|
||||||
switch (currentFlag) {
|
switch (currentFlag) {
|
||||||
case selFlagName:
|
case SelectedFlag::selFlagName:
|
||||||
currentFlag = selFlagLEDs;
|
currentFlag = SelectedFlag::selFlagLEDs;
|
||||||
break;
|
break;
|
||||||
case selFlagLEDs:
|
case SelectedFlag::selFlagLEDs:
|
||||||
currentFlag = selFlagLogo;
|
currentFlag = SelectedFlag::selFlagLogo;
|
||||||
break;
|
break;
|
||||||
case selFlagLogo:
|
case SelectedFlag::selFlagLogo:
|
||||||
currentFlag = selFlagName;
|
currentFlag = SelectedFlag::selFlagName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
drawScreen();
|
drawScreen();
|
||||||
|
|
@ -1132,13 +1144,13 @@ void flagsCursorUp() {
|
||||||
// Toggle the currently selected flag
|
// Toggle the currently selected flag
|
||||||
void flagToggle() {
|
void flagToggle() {
|
||||||
switch (currentFlag) {
|
switch (currentFlag) {
|
||||||
case selFlagLogo:
|
case SelectedFlag::selFlagLogo:
|
||||||
showLogoFlag = !showLogoFlag;
|
showLogoFlag = !showLogoFlag;
|
||||||
break;
|
break;
|
||||||
case selFlagLEDs:
|
case SelectedFlag::selFlagLEDs:
|
||||||
showLEDsFlag = !showLEDsFlag;
|
showLEDsFlag = !showLEDsFlag;
|
||||||
break;
|
break;
|
||||||
case selFlagName:
|
case SelectedFlag::selFlagName:
|
||||||
showNameFlag = !showNameFlag;
|
showNameFlag = !showNameFlag;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1147,7 +1159,7 @@ void flagToggle() {
|
||||||
|
|
||||||
// Start the button auto-repeat delay
|
// Start the button auto-repeat delay
|
||||||
void startButtonDelay() {
|
void startButtonDelay() {
|
||||||
delayCount = DELAY_FRAMES;
|
delayCount = delayFrames;
|
||||||
repeating = false;
|
repeating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1159,22 +1171,22 @@ void stopButtonRepeat() {
|
||||||
|
|
||||||
// Calculate the X coordinate to center a string of the given length
|
// Calculate the X coordinate to center a string of the given length
|
||||||
int centerStrLen(unsigned int len) {
|
int centerStrLen(unsigned int len) {
|
||||||
return (WIDTH / 2) - (len * CHAR_WIDTH / 2);
|
return (WIDTH / 2) - (len * charWidth / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the X coordinate to center a string located in program memory
|
// Calculate the X coordinate to center a string located in program memory
|
||||||
int centerStr_P(const char* str) {
|
int centerStr_P(const char* str) {
|
||||||
return (WIDTH / 2) - (strlen_P(str) * CHAR_WIDTH / 2);
|
return (WIDTH / 2) - (strlen_P(str) * charWidth / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the X coordinate to center a size 2 string located in
|
// Calculate the X coordinate to center a size 2 string located in
|
||||||
// program memory
|
// program memory
|
||||||
int centerStr2_P(const char* str) {
|
int centerStr2_P(const char* str) {
|
||||||
return (WIDTH / 2) - (strlen_P(str) * CHAR_WIDTH);
|
return (WIDTH / 2) - (strlen_P(str) * char2Width / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the X coordinate to right justify a string in program memory
|
// Calculate the X coordinate to right justify a string in program memory
|
||||||
int rightStr_P(const char* str) {
|
int rightStr_P(const char* str) {
|
||||||
return WIDTH - (strlen_P(str) * CHAR_WIDTH) + 1;
|
return WIDTH - (strlen_P(str) * charWidth) + charSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
DOXYFILE_ENCODING = UTF-8
|
DOXYFILE_ENCODING = UTF-8
|
||||||
PROJECT_NAME = "Arduboy2 Library"
|
PROJECT_NAME = "Arduboy2 Library"
|
||||||
PROJECT_NUMBER = 5.3.0
|
PROJECT_NUMBER = 6.0.0
|
||||||
PROJECT_BRIEF =
|
PROJECT_BRIEF =
|
||||||
PROJECT_LOGO =
|
PROJECT_LOGO =
|
||||||
OUTPUT_DIRECTORY = doxygen
|
OUTPUT_DIRECTORY = doxygen
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 238 B |
Binary file not shown.
|
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 343 B |
|
|
@ -77,10 +77,13 @@ given and a non-zero exit code will be returned.
|
||||||
|
|
||||||
## Input file decoding
|
## Input file decoding
|
||||||
|
|
||||||
The input file should be a PNG file containing the image to be converted. The
|
The input file should be a PNG file containing the image to be converted.
|
||||||
image will be translated to a raw array of 32 bit RGBA (Red, Green, Blue, Alpha)
|
The height of the image must be a multiple of 8 pixels (8, 16, 24, 32, ...).
|
||||||
pixels internally before being processed to output. Ideally, pixels that are to
|
The width can be any size.
|
||||||
be drawn (represented as a 1 in the image output) should be fully white.
|
|
||||||
|
The image will be translated to a raw array of 32 bit RGBA (Red, Green, Blue,
|
||||||
|
Alpha) pixels internally before being processed to output. Ideally, pixels that
|
||||||
|
are to be drawn (represented as a 1 in the image output) should be fully white.
|
||||||
Non-drawn (0) pixels should be fully black. Pixels intended to be masked out of
|
Non-drawn (0) pixels should be fully black. Pixels intended to be masked out of
|
||||||
the image (represented as a 0 in both the image and mask output), should be
|
the image (represented as a 0 in both the image and mask output), should be
|
||||||
fully transparent and their color doesn't matter.
|
fully transparent and their color doesn't matter.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ https://www.lexaloffle.com/bbs/?uid=1
|
||||||
https://twitter.com/lexaloffle
|
https://twitter.com/lexaloffle
|
||||||
Contributed to Team A.R.G.
|
Contributed to Team A.R.G.
|
||||||
|
|
||||||
Modifications by Scott Allen - July 2016
|
Modifications by Scott Allen - July 2020, September 2020
|
||||||
|
|
||||||
To the extent possible under law, the author(s) have dedicated all copyright
|
To the extent possible under law, the author(s) have dedicated all copyright
|
||||||
and related and neighboring rights to this software to the public domain
|
and related and neighboring rights to this software to the public domain
|
||||||
|
|
@ -332,12 +332,18 @@ int main(int argc, char **argv)
|
||||||
exit(result);
|
exit(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (h % 8 != 0) {
|
||||||
|
printf("error 120: file %s: image height must be a multiple of 8 but is %u\n", argv[1], h);
|
||||||
|
free(bmp);
|
||||||
|
exit(120);
|
||||||
|
}
|
||||||
|
|
||||||
// generate sprite and mask
|
// generate sprite and mask
|
||||||
|
|
||||||
rawlen = w * (h+7) / 8;
|
rawlen = w * (h+7) / 8;
|
||||||
|
|
||||||
bmp0 = malloc(rawlen); memset(bmp0, 0, rawlen);
|
bmp0 = (unsigned char *)malloc(rawlen); memset(bmp0, 0, rawlen);
|
||||||
bmp1 = malloc(rawlen); memset(bmp1, 0, rawlen);
|
bmp1 = (unsigned char *)malloc(rawlen); memset(bmp1, 0, rawlen);
|
||||||
|
|
||||||
printf("// %s width: %u height: %u\n", argv[1], w, h);
|
printf("// %s width: %u height: %u\n", argv[1], w, h);
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 199 B |
|
|
@ -6,7 +6,7 @@ Documentation for files contained in this repository that aren't self explanator
|
||||||
|
|
||||||
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).
|
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.
|
The value of *version* must be set to the latest stable tagged release. This should be changed and committed just before tagging the new release.
|
||||||
|
|
||||||
See the [Arduino IDE 1.5: Library specification](https://arduino.github.io/arduino-cli/library-specification/) for details.
|
See the [Arduino IDE 1.5: Library specification](https://arduino.github.io/arduino-cli/library-specification/) for details.
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ See the [Arduino IDE 1.5: Library specification](https://arduino.github.io/ardui
|
||||||
|
|
||||||
This JSON file is a manifest used by the [PlatformIO IDE](https://platformio.org/) to make this library available in its [Library Manager](https://docs.platformio.org/en/latest/librarymanager/index.html).
|
This JSON file is a manifest used by the [PlatformIO IDE](https://platformio.org/) to make this library available in its [Library Manager](https://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.
|
The value of *version* must be set to the latest stable tagged release. This should be changed and committed just before tagging the new release.
|
||||||
|
|
||||||
See the [PlatformIO library.json](https://docs.platformio.org/en/latest/librarymanager/config.html) documentation for details.
|
See the [PlatformIO library.json](https://docs.platformio.org/en/latest/librarymanager/config.html) documentation for details.
|
||||||
|
|
||||||
|
|
|
||||||
22
keywords.txt
22
keywords.txt
|
|
@ -26,6 +26,7 @@ blank KEYWORD2
|
||||||
boot KEYWORD2
|
boot KEYWORD2
|
||||||
bootLogo KEYWORD2
|
bootLogo KEYWORD2
|
||||||
bootLogoCompressed KEYWORD2
|
bootLogoCompressed KEYWORD2
|
||||||
|
bootLogoExtra KEYWORD2
|
||||||
bootLogoShell KEYWORD2
|
bootLogoShell KEYWORD2
|
||||||
bootLogoSpritesBOverwrite KEYWORD2
|
bootLogoSpritesBOverwrite KEYWORD2
|
||||||
bootLogoSpritesBSelfMasked KEYWORD2
|
bootLogoSpritesBSelfMasked KEYWORD2
|
||||||
|
|
@ -67,11 +68,16 @@ flipHorizontal KEYWORD2
|
||||||
freeRGBled KEYWORD2
|
freeRGBled KEYWORD2
|
||||||
generateRandomSeed KEYWORD2
|
generateRandomSeed KEYWORD2
|
||||||
getBuffer KEYWORD2
|
getBuffer KEYWORD2
|
||||||
|
getCharacterHeight KEYWORD2
|
||||||
|
getCharacterSpacing KEYWORD2
|
||||||
|
getCharacterWidth KEYWORD2
|
||||||
getCursorX KEYWORD2
|
getCursorX KEYWORD2
|
||||||
getCursorY KEYWORD2
|
getCursorY KEYWORD2
|
||||||
|
getLineSpacing KEYWORD2
|
||||||
getPixel KEYWORD2
|
getPixel KEYWORD2
|
||||||
getTextBackground KEYWORD2
|
getTextBackground KEYWORD2
|
||||||
getTextColor KEYWORD2
|
getTextColor KEYWORD2
|
||||||
|
getTextRawMode KEYWORD2
|
||||||
getTextSize KEYWORD2
|
getTextSize KEYWORD2
|
||||||
getTextWrap KEYWORD2
|
getTextWrap KEYWORD2
|
||||||
height KEYWORD2
|
height KEYWORD2
|
||||||
|
|
@ -104,6 +110,7 @@ setFrameRate KEYWORD2
|
||||||
setRGBled KEYWORD2
|
setRGBled KEYWORD2
|
||||||
setTextBackground KEYWORD2
|
setTextBackground KEYWORD2
|
||||||
setTextColor KEYWORD2
|
setTextColor KEYWORD2
|
||||||
|
setTextRawMode KEYWORD2
|
||||||
setTextSize KEYWORD2
|
setTextSize KEYWORD2
|
||||||
setTextWrap KEYWORD2
|
setTextWrap KEYWORD2
|
||||||
SPItransfer KEYWORD2
|
SPItransfer KEYWORD2
|
||||||
|
|
@ -131,6 +138,21 @@ drawOverwrite KEYWORD2
|
||||||
drawPlusMask KEYWORD2
|
drawPlusMask KEYWORD2
|
||||||
drawSelfMasked KEYWORD2
|
drawSelfMasked KEYWORD2
|
||||||
|
|
||||||
|
##### Public variables #####
|
||||||
|
|
||||||
|
audio KEYWORD2
|
||||||
|
arduboy_logo KEYWORD2
|
||||||
|
arduboy_logo_compressed KEYWORD2
|
||||||
|
arduboy_logo_sprite KEYWORD2
|
||||||
|
currentButtonState KEYWORD2
|
||||||
|
font5x7 KEYWORD2
|
||||||
|
frameCount KEYWORD2
|
||||||
|
previousButtonState KEYWORD2
|
||||||
|
sBuffer KEYWORD2
|
||||||
|
|
||||||
|
# Arduboy2Beep classes
|
||||||
|
duration KEYWORD2
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Constants (LITERAL1)
|
# Constants (LITERAL1)
|
||||||
#######################################
|
#######################################
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/MLXXXp/Arduboy2.git"
|
"url": "https://github.com/MLXXXp/Arduboy2.git"
|
||||||
},
|
},
|
||||||
"version": "5.3.0",
|
"version": "6.0.0",
|
||||||
"export":
|
"export":
|
||||||
{
|
{
|
||||||
"exclude": "extras"
|
"exclude": "extras"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name=Arduboy2
|
name=Arduboy2
|
||||||
version=5.3.0
|
version=6.0.0
|
||||||
author=Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen, Ross O. Shoger
|
author=Chris J. Martinez, Kevin Bates, Josh Goebel, Scott Allen, Ross O. Shoger
|
||||||
maintainer=Scott Allen <saydisp-git@yahoo.ca>
|
maintainer=Scott Allen <saydisp-git@yahoo.ca>
|
||||||
sentence=An alternative library for use with the Arduboy game system.
|
sentence=An alternative library for use with the Arduboy game system.
|
||||||
|
|
|
||||||
301
src/Arduboy2.cpp
301
src/Arduboy2.cpp
|
|
@ -12,20 +12,40 @@
|
||||||
|
|
||||||
uint8_t Arduboy2Base::sBuffer[];
|
uint8_t Arduboy2Base::sBuffer[];
|
||||||
|
|
||||||
Arduboy2Base::Arduboy2Base()
|
uint16_t Arduboy2Base::frameCount = 0;
|
||||||
{
|
|
||||||
currentButtonState = 0;
|
uint8_t Arduboy2Base::currentButtonState = 0;
|
||||||
previousButtonState = 0;
|
uint8_t Arduboy2Base::previousButtonState = 0;
|
||||||
// frame management
|
|
||||||
setFrameDuration(16);
|
uint8_t Arduboy2Base::eachFrameMillis = 16;
|
||||||
frameCount = 0;
|
uint8_t Arduboy2Base::thisFrameStart;
|
||||||
justRendered = false;
|
uint8_t Arduboy2Base::lastFrameDurationMs;
|
||||||
}
|
bool Arduboy2Base::justRendered = false;
|
||||||
|
|
||||||
// functions called here should be public so users can create their
|
// functions called here should be public so users can create their
|
||||||
// own init functions if they need different behavior than `begin`
|
// own init functions if they need different behavior than `begin`
|
||||||
// provides by default
|
// provides by default.
|
||||||
|
//
|
||||||
|
// This code and it's documentation should be kept in sync with
|
||||||
|
// Aruduboy2::begin()
|
||||||
void Arduboy2Base::begin()
|
void Arduboy2Base::begin()
|
||||||
|
{
|
||||||
|
beginDoFirst();
|
||||||
|
|
||||||
|
bootLogo();
|
||||||
|
// alternative logo functions. Work the same as bootLogo() but may reduce
|
||||||
|
// memory size if the sketch uses the same bitmap drawing function or
|
||||||
|
// `Sprites`/`SpritesB` class
|
||||||
|
// bootLogoCompressed();
|
||||||
|
// bootLogoSpritesSelfMasked();
|
||||||
|
// bootLogoSpritesOverwrite();
|
||||||
|
// bootLogoSpritesBSelfMasked();
|
||||||
|
// bootLogoSpritesBOverwrite();
|
||||||
|
|
||||||
|
waitNoButtons(); // wait for all buttons to be released
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2Base::beginDoFirst()
|
||||||
{
|
{
|
||||||
boot(); // raw hardware
|
boot(); // raw hardware
|
||||||
|
|
||||||
|
|
@ -37,17 +57,6 @@ void Arduboy2Base::begin()
|
||||||
systemButtons();
|
systemButtons();
|
||||||
|
|
||||||
audio.begin();
|
audio.begin();
|
||||||
|
|
||||||
bootLogo();
|
|
||||||
// alternative logo functions. Work the same as bootLogo() but may reduce
|
|
||||||
// memory size if the sketch uses the same bitmap drawing function
|
|
||||||
// bootLogoCompressed();
|
|
||||||
// bootLogoSpritesSelfMasked();
|
|
||||||
// bootLogoSpritesOverwrite();
|
|
||||||
// bootLogoSpritesBSelfMasked();
|
|
||||||
// bootLogoSpritesBOverwrite();
|
|
||||||
|
|
||||||
waitNoButtons(); // wait for all buttons to be released
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2Base::flashlight()
|
void Arduboy2Base::flashlight()
|
||||||
|
|
@ -159,12 +168,12 @@ void Arduboy2Base::drawLogoSpritesBOverwrite(int16_t y)
|
||||||
|
|
||||||
// bootLogoText() should be kept in sync with bootLogoShell()
|
// bootLogoText() should be kept in sync with bootLogoShell()
|
||||||
// if changes are made to one, equivalent changes should be made to the other
|
// if changes are made to one, equivalent changes should be made to the other
|
||||||
void Arduboy2Base::bootLogoShell(void (*drawLogo)(int16_t))
|
bool Arduboy2Base::bootLogoShell(void (&drawLogo)(int16_t))
|
||||||
{
|
{
|
||||||
bool showLEDs = readShowBootLogoLEDsFlag();
|
bool showLEDs = readShowBootLogoLEDsFlag();
|
||||||
|
|
||||||
if (!readShowBootLogoFlag()) {
|
if (!readShowBootLogoFlag()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showLEDs) {
|
if (showLEDs) {
|
||||||
|
|
@ -174,7 +183,7 @@ void Arduboy2Base::bootLogoShell(void (*drawLogo)(int16_t))
|
||||||
for (int16_t y = -15; y <= 24; y++) {
|
for (int16_t y = -15; y <= 24; y++) {
|
||||||
if (pressed(RIGHT_BUTTON)) {
|
if (pressed(RIGHT_BUTTON)) {
|
||||||
digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF); // all LEDs off
|
digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF); // all LEDs off
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showLEDs && y == 4) {
|
if (showLEDs && y == 4) {
|
||||||
|
|
@ -197,14 +206,12 @@ void Arduboy2Base::bootLogoShell(void (*drawLogo)(int16_t))
|
||||||
delayShort(400);
|
delayShort(400);
|
||||||
digitalWriteRGB(BLUE_LED, RGB_OFF);
|
digitalWriteRGB(BLUE_LED, RGB_OFF);
|
||||||
|
|
||||||
bootLogoExtra();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Virtual function overridden by derived class
|
|
||||||
void Arduboy2Base::bootLogoExtra() { }
|
|
||||||
|
|
||||||
// wait for all buttons to be released
|
// wait for all buttons to be released
|
||||||
void Arduboy2Base::waitNoButtons() {
|
void Arduboy2Base::waitNoButtons()
|
||||||
|
{
|
||||||
do {
|
do {
|
||||||
delayShort(50); // simple button debounce
|
delayShort(50); // simple button debounce
|
||||||
} while (buttonsState());
|
} while (buttonsState());
|
||||||
|
|
@ -287,12 +294,10 @@ void Arduboy2Base::clear()
|
||||||
|
|
||||||
void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
|
void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
|
||||||
{
|
{
|
||||||
#ifdef PIXEL_SAFE_MODE
|
|
||||||
if (x < 0 || x > (WIDTH-1) || y < 0 || y > (HEIGHT-1))
|
if (x < 0 || x > (WIDTH-1) || y < 0 || y > (HEIGHT-1))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t row_offset;
|
uint16_t row_offset;
|
||||||
uint8_t bit;
|
uint8_t bit;
|
||||||
|
|
@ -331,12 +336,10 @@ void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
|
||||||
// For reference, this is the C++ equivalent
|
// For reference, this is the C++ equivalent
|
||||||
void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
|
void Arduboy2Base::drawPixel(int16_t x, int16_t y, uint8_t color)
|
||||||
{
|
{
|
||||||
#ifdef PIXEL_SAFE_MODE
|
|
||||||
if (x < 0 || x > (WIDTH-1) || y < 0 || y > (HEIGHT-1))
|
if (x < 0 || x > (WIDTH-1) || y < 0 || y > (HEIGHT-1))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t row_offset;
|
uint16_t row_offset;
|
||||||
uint8_t bit;
|
uint8_t bit;
|
||||||
|
|
@ -578,10 +581,10 @@ void Arduboy2Base::drawFastHLine
|
||||||
w = xEnd - x;
|
w = xEnd - x;
|
||||||
|
|
||||||
// buffer pointer plus row offset + x offset
|
// buffer pointer plus row offset + x offset
|
||||||
register uint8_t *pBuf = sBuffer + ((y / 8) * WIDTH) + x;
|
uint8_t *pBuf = sBuffer + ((y / 8) * WIDTH) + x;
|
||||||
|
|
||||||
// pixel mask
|
// pixel mask
|
||||||
register uint8_t mask = 1 << (y & 7);
|
uint8_t mask = 1 << (y & 7);
|
||||||
|
|
||||||
switch (color)
|
switch (color)
|
||||||
{
|
{
|
||||||
|
|
@ -620,7 +623,7 @@ void Arduboy2Base::fillScreen(uint8_t color)
|
||||||
// {
|
// {
|
||||||
// color = 0xFF; // all pixels on
|
// color = 0xFF; // all pixels on
|
||||||
// }
|
// }
|
||||||
// for (int16_t i = 0; i < WIDTH * HEIGTH / 8; i++)
|
// for (int16_t i = 0; i < WIDTH * HEIGHT / 8; i++)
|
||||||
// {
|
// {
|
||||||
// sBuffer[i] = color;
|
// sBuffer[i] = color;
|
||||||
// }
|
// }
|
||||||
|
|
@ -860,17 +863,18 @@ void Arduboy2Base::drawSlowXYBitmap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper for drawCompressed()
|
// Helper for drawCompressed()
|
||||||
struct Arduboy2Base::BitStreamReader
|
class Arduboy2Base::BitStreamReader
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
const uint8_t *source;
|
const uint8_t *source;
|
||||||
uint16_t sourceIndex;
|
uint16_t sourceIndex;
|
||||||
uint8_t bitBuffer;
|
uint8_t bitBuffer;
|
||||||
uint8_t byteBuffer;
|
uint8_t byteBuffer;
|
||||||
|
|
||||||
BitStreamReader(const uint8_t *source)
|
public:
|
||||||
: source(source), sourceIndex(), bitBuffer(), byteBuffer()
|
BitStreamReader(const uint8_t *bitmap)
|
||||||
|
: source(bitmap), sourceIndex(), bitBuffer(), byteBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -879,17 +883,17 @@ struct Arduboy2Base::BitStreamReader
|
||||||
uint16_t result = 0;
|
uint16_t result = 0;
|
||||||
for (uint16_t i = 0; i < bitCount; i++)
|
for (uint16_t i = 0; i < bitCount; i++)
|
||||||
{
|
{
|
||||||
if (this->bitBuffer == 0)
|
if (bitBuffer == 0)
|
||||||
{
|
{
|
||||||
this->bitBuffer = 0x1;
|
bitBuffer = 0x1;
|
||||||
this->byteBuffer = pgm_read_byte(&this->source[this->sourceIndex]);
|
byteBuffer = pgm_read_byte(&source[sourceIndex]);
|
||||||
++this->sourceIndex;
|
++sourceIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this->byteBuffer & this->bitBuffer) != 0)
|
if ((byteBuffer & bitBuffer) != 0)
|
||||||
result |= (1 << i);
|
result |= (1 << i);
|
||||||
|
|
||||||
this->bitBuffer <<= 1;
|
bitBuffer <<= 1;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -898,7 +902,7 @@ struct Arduboy2Base::BitStreamReader
|
||||||
void Arduboy2Base::drawCompressed(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t color)
|
void Arduboy2Base::drawCompressed(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t color)
|
||||||
{
|
{
|
||||||
// set up decompress state
|
// set up decompress state
|
||||||
BitStreamReader cs = BitStreamReader(bitmap);
|
BitStreamReader cs(bitmap);
|
||||||
|
|
||||||
// read header
|
// read header
|
||||||
int width = (int)cs.readBits(8) + 1;
|
int width = (int)cs.readBits(8) + 1;
|
||||||
|
|
@ -1149,14 +1153,83 @@ void Arduboy2Base::swapInt16(int16_t& a, int16_t& b)
|
||||||
//========== class Arduboy2 ==========
|
//========== class Arduboy2 ==========
|
||||||
//====================================
|
//====================================
|
||||||
|
|
||||||
Arduboy2::Arduboy2()
|
int16_t Arduboy2::cursor_x = 0;
|
||||||
|
int16_t Arduboy2::cursor_y = 0;
|
||||||
|
uint8_t Arduboy2::textColor = WHITE;
|
||||||
|
uint8_t Arduboy2::textBackground = BLACK;
|
||||||
|
uint8_t Arduboy2::textSize = 1;
|
||||||
|
bool Arduboy2::textWrap = false;
|
||||||
|
bool Arduboy2::textRaw = false;
|
||||||
|
|
||||||
|
// functions called here should be public so users can create their
|
||||||
|
// own init functions if they need different behavior than `begin`
|
||||||
|
// provides by default.
|
||||||
|
//
|
||||||
|
// This code and it's documentation should be kept in sync with
|
||||||
|
// Aruduboy2Base::begin()
|
||||||
|
void Arduboy2::begin()
|
||||||
{
|
{
|
||||||
cursor_x = 0;
|
beginDoFirst();
|
||||||
cursor_y = 0;
|
|
||||||
textColor = 1;
|
bootLogo();
|
||||||
textBackground = 0;
|
// alternative logo functions. Work the same as bootLogo() but may reduce
|
||||||
textSize = 1;
|
// memory size if the sketch uses the same bitmap drawing function or
|
||||||
textWrap = 0;
|
// `Sprites`/`SpritesB` class
|
||||||
|
// bootLogoCompressed();
|
||||||
|
// bootLogoSpritesSelfMasked();
|
||||||
|
// bootLogoSpritesOverwrite();
|
||||||
|
// bootLogoSpritesBSelfMasked();
|
||||||
|
// bootLogoSpritesBOverwrite();
|
||||||
|
|
||||||
|
waitNoButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2::bootLogo()
|
||||||
|
{
|
||||||
|
if (bootLogoShell(drawLogoBitmap))
|
||||||
|
{
|
||||||
|
bootLogoExtra();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2::bootLogoCompressed()
|
||||||
|
{
|
||||||
|
if (bootLogoShell(drawLogoCompressed))
|
||||||
|
{
|
||||||
|
bootLogoExtra();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2::bootLogoSpritesSelfMasked()
|
||||||
|
{
|
||||||
|
if (bootLogoShell(drawLogoSpritesSelfMasked))
|
||||||
|
{
|
||||||
|
bootLogoExtra();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2::bootLogoSpritesOverwrite()
|
||||||
|
{
|
||||||
|
if (bootLogoShell(drawLogoSpritesOverwrite))
|
||||||
|
{
|
||||||
|
bootLogoExtra();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2::bootLogoSpritesBSelfMasked()
|
||||||
|
{
|
||||||
|
if (bootLogoShell(drawLogoSpritesBSelfMasked))
|
||||||
|
{
|
||||||
|
bootLogoExtra();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Arduboy2::bootLogoSpritesBOverwrite()
|
||||||
|
{
|
||||||
|
if (bootLogoShell(drawLogoSpritesBOverwrite))
|
||||||
|
{
|
||||||
|
bootLogoExtra();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bootLogoText() should be kept in sync with bootLogoShell()
|
// bootLogoText() should be kept in sync with bootLogoShell()
|
||||||
|
|
@ -1173,7 +1246,7 @@ void Arduboy2::bootLogoText()
|
||||||
digitalWriteRGB(RED_LED, RGB_ON);
|
digitalWriteRGB(RED_LED, RGB_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int16_t y = -16; y <= 24; y++) {
|
for (int16_t y = -15; y <= 24; y++) {
|
||||||
if (pressed(RIGHT_BUTTON)) {
|
if (pressed(RIGHT_BUTTON)) {
|
||||||
digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF); // all LEDs off
|
digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_OFF); // all LEDs off
|
||||||
return;
|
return;
|
||||||
|
|
@ -1237,64 +1310,106 @@ void Arduboy2::bootLogoExtra()
|
||||||
|
|
||||||
size_t Arduboy2::write(uint8_t c)
|
size_t Arduboy2::write(uint8_t c)
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
if ((c == '\r') && !textRaw)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((c == '\n') && !textRaw) ||
|
||||||
|
(textWrap && (cursor_x > (WIDTH - (characterWidth * textSize)))))
|
||||||
{
|
{
|
||||||
cursor_y += textSize * 8;
|
|
||||||
cursor_x = 0;
|
cursor_x = 0;
|
||||||
|
cursor_y += fullCharacterHeight * textSize;
|
||||||
}
|
}
|
||||||
else if (c == '\r')
|
|
||||||
{
|
if ((c != '\n') || textRaw)
|
||||||
// skip em
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
drawChar(cursor_x, cursor_y, c, textColor, textBackground, textSize);
|
drawChar(cursor_x, cursor_y, c, textColor, textBackground, textSize);
|
||||||
cursor_x += textSize * 6;
|
cursor_x += fullCharacterWidth * textSize;
|
||||||
if (textWrap && (cursor_x > (WIDTH - textSize * 6)))
|
|
||||||
{
|
|
||||||
// calling ourselves recursively for 'newline' is
|
|
||||||
// 12 bytes smaller than doing the same math here
|
|
||||||
write('\n');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arduboy2::drawChar
|
void Arduboy2::drawChar
|
||||||
(int16_t x, int16_t y, unsigned char c, uint8_t color, uint8_t bg, uint8_t size)
|
(int16_t x, int16_t y, uint8_t c, uint8_t color, uint8_t bg, uint8_t size)
|
||||||
{
|
{
|
||||||
uint8_t line;
|
// It is assumed that rendering characters fully off screen will be rare,
|
||||||
bool draw_background = bg != color;
|
// so let drawPixel() handle off screen checks, to reduce code size at the
|
||||||
const uint8_t* bitmap = font5x7 + c * 5;
|
// expense of slower off screen character handling.
|
||||||
|
#if 0
|
||||||
if ((x >= WIDTH) || // Clip right
|
if ((x >= WIDTH) || // Clip right
|
||||||
(y >= HEIGHT) || // Clip bottom
|
(y >= HEIGHT) || // Clip bottom
|
||||||
((x + 5 * size - 1) < 0) || // Clip left
|
((x + characterWidth * size - 1) < 0) || // Clip left
|
||||||
((y + 8 * size - 1) < 0) // Clip top
|
((y + characterHeight * size - 1) < 0) // Clip top
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++ )
|
bool drawBackground = bg != color;
|
||||||
|
const uint8_t* bitmap =
|
||||||
|
&font5x7[c * characterWidth * ((characterHeight + 8 - 1) / 8)];
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < fullCharacterWidth; i++)
|
||||||
{
|
{
|
||||||
line = pgm_read_byte(bitmap++);
|
uint8_t column;
|
||||||
if (i == 5) {
|
|
||||||
line = 0x0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint8_t j = 0; j < 8; j++)
|
if (characterHeight <= 8)
|
||||||
{
|
{
|
||||||
uint8_t draw_color = (line & 0x1) ? color : bg;
|
column = (i < characterWidth) ? pgm_read_byte(bitmap++) : 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (draw_color || draw_background) {
|
// draw the character by columns. Top to bottom, left to right
|
||||||
for (uint8_t a = 0; a < size; a++ ) {
|
// including character spacing on the right
|
||||||
for (uint8_t b = 0; b < size; b++ ) {
|
for (uint8_t j = 0; j < characterHeight; j++)
|
||||||
drawPixel(x + (i * size) + a, y + (j * size) + b, draw_color);
|
{
|
||||||
|
if (characterHeight > 8)
|
||||||
|
{
|
||||||
|
// at this point variable "column" will be 0, either from initialization
|
||||||
|
// or by having eight 0 bits shifted in by the >>= operation below
|
||||||
|
if ((j % 8 == 0) && (i < characterWidth))
|
||||||
|
{
|
||||||
|
column = pgm_read_byte(bitmap++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pixelIsSet should be a bool but at the time of writing,
|
||||||
|
// the GCC AVR compiler generates less code if it's a uint8_t
|
||||||
|
uint8_t pixelIsSet = column & 0x01;
|
||||||
|
|
||||||
|
if (pixelIsSet || drawBackground)
|
||||||
|
{
|
||||||
|
for (uint8_t a = 0; a < size; a++)
|
||||||
|
{
|
||||||
|
for (uint8_t b = 0; b < size; b++)
|
||||||
|
{
|
||||||
|
drawPixel(x + (i * size) + a, y + (j * size) + b,
|
||||||
|
pixelIsSet ? color : bg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
column >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw the inter-line spacing pixels for this column if required
|
||||||
|
if (drawBackground)
|
||||||
|
{
|
||||||
|
for (uint8_t j = characterHeight; j < fullCharacterHeight; j++)
|
||||||
|
{
|
||||||
|
for (uint8_t a = 0; a < size; a++)
|
||||||
|
{
|
||||||
|
for (uint8_t b = 0; b < size; b++)
|
||||||
|
{
|
||||||
|
drawPixel(x + (i * size) + a, y + (j * size) + b, bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line >>= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1366,6 +1481,16 @@ bool Arduboy2::getTextWrap()
|
||||||
return textWrap;
|
return textWrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Arduboy2::setTextRawMode(bool raw)
|
||||||
|
{
|
||||||
|
textRaw = raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Arduboy2::getTextRawMode()
|
||||||
|
{
|
||||||
|
return textRaw;
|
||||||
|
}
|
||||||
|
|
||||||
void Arduboy2::clear()
|
void Arduboy2::clear()
|
||||||
{
|
{
|
||||||
Arduboy2Base::clear();
|
Arduboy2Base::clear();
|
||||||
|
|
|
||||||
2799
src/Arduboy2.h
2799
src/Arduboy2.h
File diff suppressed because it is too large
Load Diff
|
|
@ -80,10 +80,7 @@ class Arduboy2Audio
|
||||||
*
|
*
|
||||||
* \details
|
* \details
|
||||||
* The speaker is initialized based on the current mute setting saved in
|
* The speaker is initialized based on the current mute setting saved in
|
||||||
* system EEPROM. This function is called by `Arduboy2Base::begin()` so it
|
* system EEPROM.
|
||||||
* isn't normally required to call it within a sketch. However, if
|
|
||||||
* `Arduboy2Core::boot()` is used instead of `Arduboy2Base::begin()` and the
|
|
||||||
* sketch includes sound, then this function should be called after `boot()`.
|
|
||||||
*/
|
*/
|
||||||
static void begin();
|
static void begin();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
* for. For example, with a rate of 60 frames per second a duration of 30
|
* for. For example, with a rate of 60 frames per second a duration of 30
|
||||||
* would be used to play a tone for half a second.
|
* would be used to play a tone for half a second.
|
||||||
*
|
*
|
||||||
* The variable named `#duration` is the counter that times the duration of a
|
* The variable named #duration is the counter that times the duration of a
|
||||||
* tone. A sketch can determine if a tone is currently playing by testing if
|
* tone. A sketch can determine if a tone is currently playing by testing if
|
||||||
* the `#duration` variable is non-zero (assuming it's a timed tone, not a
|
* the #duration variable is non-zero (assuming it's a timed tone, not a
|
||||||
* continuous tone).
|
* continuous tone).
|
||||||
*
|
*
|
||||||
* To keep the code small and efficient, the frequency of a tone is specified
|
* To keep the code small and efficient, the frequency of a tone is specified
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@
|
||||||
//========== class Arduboy2Core ==========
|
//========== class Arduboy2Core ==========
|
||||||
//========================================
|
//========================================
|
||||||
|
|
||||||
Arduboy2Core::Arduboy2Core() { }
|
|
||||||
|
|
||||||
// Commands sent to the OLED display to initialize it
|
// Commands sent to the OLED display to initialize it
|
||||||
const PROGMEM uint8_t Arduboy2Core::lcdBootProgram[] = {
|
const PROGMEM uint8_t Arduboy2Core::lcdBootProgram[] = {
|
||||||
// boot defaults are commented out but left here in case they
|
// boot defaults are commented out but left here in case they
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,6 @@ class Arduboy2Core : public Arduboy2NoUSB
|
||||||
friend class Arduboy2Ex;
|
friend class Arduboy2Ex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Arduboy2Core();
|
|
||||||
|
|
||||||
/** \brief
|
/** \brief
|
||||||
* Idle the CPU to save power.
|
* Idle the CPU to save power.
|
||||||
|
|
@ -573,7 +572,7 @@ class Arduboy2Core : public Arduboy2NoUSB
|
||||||
* Invert the entire display or set it back to normal.
|
* Invert the entire display or set it back to normal.
|
||||||
*
|
*
|
||||||
* \param inverse `true` will invert the display. `false` will set the
|
* \param inverse `true` will invert the display. `false` will set the
|
||||||
* display to no-inverted.
|
* display to non-inverted.
|
||||||
*
|
*
|
||||||
* \details
|
* \details
|
||||||
* Calling this function with a value of `true` will set the display to
|
* Calling this function with a value of `true` will set the display to
|
||||||
|
|
@ -797,14 +796,21 @@ class Arduboy2Core : public Arduboy2NoUSB
|
||||||
* \details
|
* \details
|
||||||
* This function initializes the display, buttons, etc.
|
* This function initializes the display, buttons, etc.
|
||||||
*
|
*
|
||||||
* This function is called by begin() so isn't normally called within a
|
* This function is called by `begin()` so isn't normally called within a
|
||||||
* sketch. However, in order to free up some code space, by eliminating
|
* sketch. However, in order to free up some code space, by eliminating
|
||||||
* some of the start up features, it can be called in place of begin().
|
* some of the start up features, it can be called in place of begin().
|
||||||
* The functions that begin() would call after boot() can then be called
|
* The functions that `begin()` would call after `boot()` can then be
|
||||||
* to add back in some of the start up features, if desired.
|
* called to add back in some of the start up features as space permits.
|
||||||
* See the README file or documentation on the main page for more details.
|
|
||||||
*
|
*
|
||||||
* \see Arduboy2Base::begin()
|
* See the README file or main page, in section
|
||||||
|
* _Substitute or remove boot up features_, for more details.
|
||||||
|
*
|
||||||
|
* \warning
|
||||||
|
* If this function is used, it is recommended that at least `flashlight()`
|
||||||
|
* or `safeMode()` be called after it to provide a means to upload a new
|
||||||
|
* sketch if the bootloader "magic number" problem is encountered.
|
||||||
|
*
|
||||||
|
* \see Arduboy2::begin() Arduboy2Base::flashlight() safeMode()
|
||||||
*/
|
*/
|
||||||
static void boot();
|
static void boot();
|
||||||
|
|
||||||
|
|
@ -818,8 +824,8 @@ class Arduboy2Core : public Arduboy2NoUSB
|
||||||
* sketch, for sketches that interfere with the bootloader "magic number".
|
* sketch, for sketches that interfere with the bootloader "magic number".
|
||||||
* The problem occurs with certain sketches that use large amounts of RAM.
|
* The problem occurs with certain sketches that use large amounts of RAM.
|
||||||
*
|
*
|
||||||
* This function should be called after `boot()` in sketches that
|
* This function should be called after `boot()` in sketches that don't
|
||||||
* potentially could cause the problem.
|
* call `flashlight()`.
|
||||||
*
|
*
|
||||||
* It is intended to replace the `flashlight()` function when more
|
* It is intended to replace the `flashlight()` function when more
|
||||||
* program space is required. If possible, it is more desirable to use
|
* program space is required. If possible, it is more desirable to use
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
// arduboy_logo.png
|
// arduboy_logo.png
|
||||||
// drawBitmap() format
|
// drawBitmap() format
|
||||||
// 88x16
|
// 88x16 px (176 bytes)
|
||||||
const PROGMEM uint8_t Arduboy2Base::arduboy_logo[] = {
|
const PROGMEM uint8_t Arduboy2Base::arduboy_logo[] = {
|
||||||
0xF0, 0xF8, 0x9C, 0x8E, 0x87, 0x83, 0x87, 0x8E, 0x9C, 0xF8,
|
0xF0, 0xF8, 0x9C, 0x8E, 0x87, 0x83, 0x87, 0x8E, 0x9C, 0xF8,
|
||||||
0xF0, 0x00, 0x00, 0xFE, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03,
|
0xF0, 0x00, 0x00, 0xFE, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||||
|
|
@ -33,7 +33,7 @@ const PROGMEM uint8_t Arduboy2Base::arduboy_logo[] = {
|
||||||
|
|
||||||
// arduboy_logo.png
|
// arduboy_logo.png
|
||||||
// drawCompressed() format
|
// drawCompressed() format
|
||||||
// 88x16
|
// 88x16 px (151 bytes)
|
||||||
const PROGMEM uint8_t Arduboy2Base::arduboy_logo_compressed[] = {
|
const PROGMEM uint8_t Arduboy2Base::arduboy_logo_compressed[] = {
|
||||||
0x57, 0x0F, 0x9C, 0x53, 0x72, 0x75, 0x29, 0xE5, 0x9C, 0x92,
|
0x57, 0x0F, 0x9C, 0x53, 0x72, 0x75, 0x29, 0xE5, 0x9C, 0x92,
|
||||||
0xCE, 0x95, 0x52, 0xAD, 0x4E, 0x49, 0xE7, 0x08, 0x09, 0xED,
|
0xCE, 0x95, 0x52, 0xAD, 0x4E, 0x49, 0xE7, 0x08, 0x09, 0xED,
|
||||||
|
|
@ -55,7 +55,7 @@ const PROGMEM uint8_t Arduboy2Base::arduboy_logo_compressed[] = {
|
||||||
|
|
||||||
// arduboy_logo.png
|
// arduboy_logo.png
|
||||||
// Sprites::drawSelfMasked() format
|
// Sprites::drawSelfMasked() format
|
||||||
// 88x16
|
// 88x16 px (178 bytes)
|
||||||
const PROGMEM uint8_t Arduboy2Base::arduboy_logo_sprite[] = {
|
const PROGMEM uint8_t Arduboy2Base::arduboy_logo_sprite[] = {
|
||||||
88, 16,
|
88, 16,
|
||||||
0xF0, 0xF8, 0x9C, 0x8E, 0x87, 0x83, 0x87, 0x8E, 0x9C, 0xF8,
|
0xF0, 0xF8, 0x9C, 0x8E, 0x87, 0x83, 0x87, 0x8E, 0x9C, 0xF8,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue