Commit Graph

179 Commits

Author SHA1 Message Date
Scott Allen 674ac8a774 Don't disable timer 0 for Arduboy core 2018-03-22 08:11:24 -04:00
Scott Allen 9a13011474 Use display() in begin() instead of blank()
This saves some code since display() is used multiple times but
blank() normally isn't.
2018-03-22 08:11:24 -04:00
Scott Allen a43e745250 Add system EEPROM flag to disable the boot logo
Flag SYS_FLAG_SHOW_LOGO added to EEPROM_SYS_FLAGS. The boot logo
functions check the flag and bypass the logo sequence if the flag
isn't set.

Added functions writeShowBootLogoFlag() and readShowBootLogoFlag()
for writing and reading the SYS_FLAG_SHOW_LOGO flag.

Renamed example sketch SetNameAndID to SetSystemEEPROM and added
the ability to set the SYS_FLAG_SHOW_LOGO flag, plus menus to reset
the system and user EEPROM areas.
2018-03-22 08:11:24 -04:00
Delio Brignoli da2c7e3d35 Add SpritesB class as alternative to Sprites
The SpritesB class has functions identical to those in Sprites.
When used in place of Sprites it will usually reduce code size (at the
expense of slower execution speed). Code size reduction is accomplished
by factoring all draw modes into the same loop.

Modifications made to the Sprites class to create this class made by
@dxxb (Delio Brignoli).

Creation of the SpritesB class and documentation by
@MLXXXp (Scott Allen).

Also, bootLogoSpritesBSelfMasked() and bootLogoSpritesBOverwrite()
alternative boot logo functions added by @MLXXXp.
2018-03-22 08:11:24 -04:00
Scott Allen d76eb15c51 Explicitly specify the type in doxygen code blocks
Just to be safe.
2018-03-11 05:40:44 -04:00
Scott Allen c00fee0a78 Add the ability to eliminate the USB stack code
Macro ARDUBOY_NO_USB will provide a substitute main() which will cause
the compiler to leave out the USB code. The macro also adds a check
for the DOWN button being pressed and, if so, will call the new
exitToBootloader() function.

New function exitToBootloader() will invoke the bootloader in command
mode, similar to pressing reset.
2018-03-11 05:40:44 -04:00
Scott Allen fb77929126 Refactor setRGBled() and add freeRGBled()
- setRGBled() has been rewritten to directly control the hardware
  instead of using the Arduino analogWrite() function.

- Added a two parameter version of setRGBled() that sets the brightness
  of one LED without affecting the others.

- Added function freeRGBled() for freeing the PWM control of the LEDs
  so they can be used digitally.

- Added example sketch RGBled.
2018-03-11 05:40:44 -04:00
Scott Allen eb041d24f8 Add function to wait for all buttons released
New function waitNoButtons() replaces the code at the end of begin()
that waits for all buttons to be released. This is to make it easier
to add back this functionality when using boot() in place of begin().
2018-03-11 05:40:44 -04:00
Scott Allen 53ea8188d5 Add Beep classes for playing simple tones
Also added a BeepDemo example sketch and modified the ArduBreakout
example sketch to use the BeepPin1 class instead of Arduino tone().
2018-03-11 05:40:44 -04:00
Scott Allen 460e768ea9 Refactor nextFrame() and add setFrameDuration()
nextFrame() changes were in colaboration with @MrBlinky

setFrameDuration() can be used as an alternative to setFrameRate()
2018-03-11 05:40:44 -04:00
Mr.Blinky 4788b1ab01 Refactor buttonsState()
By @MrBlinky
With some source code formatting and cleanup by @MLXXXp (Scott Allen).
2018-03-11 05:39:57 -04:00
Scott Allen d356be4e13 Refactor and speed up bootLogo functions 2018-03-04 13:51:37 -05:00
Scott Allen 6e1c47cbe0 Refactor idle() to reduce code size 2018-03-04 13:42:17 -05:00
Mr.Blinky bd726fc112 Refactor and optimise paintScreen() in assembler
By @MrBlinky with contributions from @veritazz (Michael Gollnick) and
@MLXXXp (Scott Allen).
2018-03-04 13:31:43 -05:00
Scott Allen d44b89e01f Minor source format changes for drawCompressed()
No code changes from previous commit.
2018-01-17 13:56:25 -05:00
Pharap 6f6849a5bb Reduce drawCompressed progmem usage (#19)
Reduce drawCompressed() progmem usage
2018-01-17 13:51:34 -05:00
Erwin Ried d6336803a2 Small typo on the code example 2017-12-19 15:33:01 +01:00
Scott Allen 93c33f6ad6 Change characters used for Sprites examples 2017-12-10 09:13:11 -05:00
Scott Allen 5e58d9b6a8 Fix minor grammar error in Sprites documentation 2017-12-09 22:48:59 -05:00
Scott Allen 383bdfc144 fix and clarify Sprite assembly comments 2017-08-28 21:31:10 -04:00
Scott Allen 420b958208 Merge branch 'master' of https://github.com/MLXXXp/Arduboy2 2017-08-28 21:13:10 -04:00
Scott Allen 5370409875 fix documentation comments for initRandomSeed() 2017-08-28 21:09:13 -04:00
Josh Goebel 4478b1fe0a fix random display glitches with sprite rendering
Sometimes the compiler would assign r28/29 to one of our input
variables despite our needing to use that register ourselves. This
fix attempts to prevent that from happening and also cleans up a
few other small details.

- remove unnecessary y_count (-1 register)
- set buffer_ofs_2 inside assembly (-1 register)
- require inputs/outputs to use lower or simple upper registers
2017-08-26 14:55:02 -04:00
Scott Allen 1bb4726ed0 Change version to 4.1.0 2017-07-31 17:10:21 -04:00
Scott Allen fe30863dbe Add complimentary "get" for text "set" functions
Added functions getTextColor(), getTextBackground(),
getTextSize() and getTextWrap() to the Arduboy2 class
2017-07-31 16:57:28 -04:00
Scott Allen 6ab6b83e2c Fix some small errors in documentation comments 2017-07-31 11:56:10 -04:00
Scott Allen fd614ab586 Change version to 4.0.2 2017-07-07 11:38:02 -04:00
Scott Allen e6e82bf336 Fix initialisation of Right button for DevKit 2017-07-07 11:30:48 -04:00
Scott Allen 46ecb2dd78 Change version to 4.0.1 2017-06-16 18:44:44 -04:00
Scott Allen b121d19b77 Refactor fillScreen() 2017-06-16 18:37:19 -04:00
Scott Allen bd5b470294 Change drawPixel() to avoid Z reg corruption
Also use _BV() to specify bit masks in the bitshift_left array,
and other minor formatting changes
2017-06-16 18:05:19 -04:00
Pharap 427c1d53f2 Fix bug in drawPixel asm 2017-06-14 19:31:54 +01:00
Scott Allen 342186281a Change version to 4.0.0 2017-04-26 10:14:51 -04:00
Scott Allen 3c4915b0d5 Add commented out logo alternatives to begin() 2017-04-26 10:08:07 -04:00
Scott Allen a01ceffb20 Fix improper masking in Sprites drawPlusMask()
As per Josh Goebel @yyyc514
2017-04-25 15:36:42 -04:00
Scott Allen babf6893c8 Eliminate "may be uninitialized" variable warning
Code in Sprites.cpp refactored to eliminate
"warning: 'mask_ofs' may be used uninitialized in this function"
2017-04-25 15:36:42 -04:00
Josh Goebel b4d8fd8d6f fix register pressure
- declare a high register clobber

This seems to have the side effect of freeing up a high register and
preventing the error:

"can't find a register in class 'LD_REGS' while reloading 'asm'""
2017-04-25 15:36:42 -04:00
Josh Goebel 606c80268b tmp variables can be flagged as output only
- this saves a few bytes
2017-04-25 15:36:42 -04:00
Josh Goebel 5d428a3a33 Fix buffer underflow in drawPlusMask
When sRow == -1 drawPlusMask can cause buffer underflow if it's
interrupted by an interrupt that changes memory that it's in the middle
of writing.  Of course it shouldn't be writing to this memory at all.

This fixes the issue.
2017-04-25 15:36:42 -04:00
Josh Goebel 520be03d59 any upper register is fine 2017-04-25 15:36:42 -04:00
Josh Goebel 3aa015b997 minor code fixes for sprites
- saves several bytes for sketches using drawPlusMask()
2017-04-25 15:36:42 -04:00
Scott Allen dac16d5e36 Remove inadvertently added space character 2017-04-25 15:36:42 -04:00
Josh Goebel e235f26def remove unnecessary carry 2017-04-25 15:36:42 -04:00
Josh Goebel 50df1a221b make sure row_offset and y do not overlap 2017-04-25 15:36:42 -04:00
Josh Goebel 6f9056f99c add back original C implimentation 2017-04-25 15:36:42 -04:00
Josh Goebel 554c21f759 make sure we use upper registers 2017-04-25 15:36:42 -04:00
Josh Goebel e1cce03580 Optimize drawPixel for speed (-20 bytes)
- Inlined     : 332 -> 358 ops/ms
- Non-inlined : 222 -> 303 ops/ms

Moves most of the pixel offset calculation math into assembly.
Also uses a shift lookup table vs calculting bit shifts on the
CPU (which is slow)
2017-04-25 15:36:42 -04:00
Scott Allen ab1a7b3bdd Add delayShort() function
Same as Arduino delay() except takes a 16 bit value.
Mainly added to save some code in the library but can be used by
sketches for the same purpose.

Also changed a delay in bootLogoText() to match a previous change in
bootLogo()
2017-04-25 15:36:42 -04:00
Scott Allen fc61d180d9 Add displayOff() and displayOn() functions
displayOff() puts the display in low power mode.
displayOn() re-initializes the display after displayOff() is used.

The SPI initialization code was separated from the display
initialization code to facilitate the new functions.
2017-04-25 15:36:42 -04:00
Scott Allen 9bfb499169 Remove "inline" keywords and attributes
Optimization done by the compiler makes these unnecessary.
2017-04-25 15:36:42 -04:00
Scott Allen 96b53875b5 Eliminate mismatched type warning in drawChar()
Also changed a loop index from int8_t to uint8_t to match other loops.
2017-04-25 15:36:42 -04:00
Josh Goebel ae8e284d41 optimize drawChar (-126 bytes) 2017-04-25 15:36:42 -04:00
Scott Allen 6e13fc019f Remove extra 50ms delay added by de1725
by Josh Goebel.
Merge conflict resolved.
2017-04-25 15:36:42 -04:00
Josh Goebel 1280160f89 optimize readUnitName (-6 bytes) 2017-04-25 15:36:42 -04:00
Josh Goebel 5877208a57 optimize writeUnitName (-130 bytes) 2017-04-25 15:36:42 -04:00
Josh Goebel 6050dda391 clean up frame management code (-6 bytes)
- saves 6 bytes compiling Mystic Balloon on Arduino 1.8.1
2017-04-25 15:36:42 -04:00
Scott Allen 449532f1e9 Add alternative boot logo functions
New functions bootLogoCompressed(), bootLogoSpritesSelfMasked() and
bootLogoSpritesOverwrite() can be used in place of bootLogo() to
reduce code size in cases where their drawing functions are shared
with the same functions used by the sketch.

New function bootLogoShell() added to provide common code for the
above functions.

Also, the Sprites class functions, and functions used for drawing the
logos, were made static.
2017-04-25 15:36:42 -04:00
Scott Allen 79f24c47cc Adjust location of some braces for consistency
This is just a source formatting change.
2017-04-25 15:36:42 -04:00
Scott Allen cfb5e89d5c Simplify initRandomSeed() to reduce code size
Use only an ADC reading from an unconnected pin shifted left 16 bits
then added to micros().
2017-04-25 15:36:42 -04:00
Scott Allen 3572a013e1 Make showing the unit name with the logo optional
- Added a flag in system EEPROM to indicate if the unit name
  should be displayed at the end of the boot logo sequence.
  Function bootLogoExtra() displays the unit name only if the
  flag is set.

- Added functions writeShowUnitNameFlag() and readShowUnitNameFlag()
  to write and read the "Show Unit Name" flag in EEPROM.

- Enhanced the SetNameAndID example sketch to allow setting the
  "Show Unit Name" flag in EEPROM.
2017-04-25 15:36:42 -04:00
Scott Allen 14d5877dae Add bootLogoText() function
Displays the boot logo using text instead of a bitmap,
as an option to reduce code size.
2017-04-25 15:36:42 -04:00
Scott Allen f294a045e0 Fix flashlight() and safeMode() for boot problem
- Timer 0 is disabled in flashlight() and safeMode() in case its
  variables overlap the bootloader "magic key" location.
- Flashlight mode never exits if invoked.
- Made safeMode() public for use as a smaller code size alternative
  to flashlight().
2017-04-25 15:36:42 -04:00
Scott Allen 1e7f251ce0 Direct control of ports and pins
This eliminates calls to pinMode(), digitalWrite(), functions to
initialize hardware, etc.

New 2 parameter version of digitalWriteRGB() added, which sets an
individual RGB LED on or off digitally.

New function SPItransfer() added to replace Arduino SPI.transfer().
2017-04-25 15:36:42 -04:00
Scott Allen 4ff6973a4b Change version to 3.1.1 2017-03-22 18:16:10 -04:00
Scott Allen cf648850c4 Merge branch 'master' of https://github.com/MLXXXp/Arduboy2 2017-03-22 18:04:31 -04:00
Josh Goebel b560ff9f60 fix internal drawBitmap call to use correct types 2017-03-22 17:43:56 -04:00
Scott Allen 2851dcf4cc Fix Sprites class data array documentation
A separate mask array does not include width and height values at
the beginning.
2017-03-13 18:00:40 -04:00
Scott Allen 2760d87194 Change version to 3.1.0 2017-02-07 10:03:48 -05:00
Scott Allen 6c297fab1e Add nextFrameDEV() function for checking CPU load 2017-02-06 18:09:50 -05:00
Scott Allen de17257029 Add boot logo bypass feature
Pressing the RIGHT button while the boot logo is scrolling down will
abort the sequence, to start running the actual sketch faster.
2017-02-06 18:09:50 -05:00
Scott Allen 2fede9cb86 Add read/write EEPROM unit name and ID functions
Also:
- Changes to show the unit name on the boot logo screen
- Added new example sketch SetNameAndID to allow setting the name and ID
- Updated the LICENSE.txt file and made changes to include it in the
  Doxygen generated documentation
2017-02-06 18:09:50 -05:00
Scott Allen 8125862bfe Make frameCount public and document it 2017-02-06 18:09:50 -05:00
Scott Allen 3e82f484a2 Add missing "details" keyword to Doxygen comments
Also add missing angle brackets around email address in library.properties
2017-02-06 18:09:50 -05:00
Scott Allen 4607f087a2 Make display buffer array public 2017-02-06 18:09:13 -05:00
Scott Allen 7dfb4f14f7 Add sound on/off toggle function 2016-12-13 11:49:29 -05:00
Scott Allen e5a7dc5982 Declare friend class Arduboy2Ex
A friend class named Arduboy2Ex is declared by the Arduboy2 classes.
The intention is to allow a sketch to create an Arduboy2Ex class which would
have access to the private and protected members of the Arduboy2 classes.
It is hoped that this may eliminate the need to create an entire local copy
of the library, in order to extend the functionality, in most circumstances.
2016-11-24 14:51:45 -05:00
Scott Allen 0b0c111757 Add clear option to display() and paintScreen()
Also remove some trailing whitespace
2016-11-24 14:51:45 -05:00
Scott Allen d89a2bd590 Improve embedded Doxygen documentation 2016-11-24 14:51:22 -05:00
Scott Allen 867f2d000c Rename Arduboy... classes to Arduboy2...
Change ArduboyCore to Arduboy2Core and ArduboyAudio to Arduboy2Audio
Rename files accordingly
Change version to 3.0.0
2016-11-21 16:29:46 -05:00
Scott Allen 40a028e5a1 Remove Sprites class constructor parameter
The Sprites class has been given direct access to the screen buffer so it
doesn't need a pointer to been given to it.

Also updated README.md and keywords.txt, and made minor indent changes in
the .h files.
2016-10-20 13:28:29 -04:00
Scott Allen f763263d2b Add Team A.R.G. Arglib functionality
- Version changed to 2.1.0
- Added sprite, button and collision functions from ArduboyExtra
- Added drawCompressed() function from Arglib
- Updated LICENSE.txt
- Removed CONTRIBUTORS.md (now covered by LICENSE.txt)
2016-10-19 20:23:34 -04:00
Scott Allen f9dc4cb0e5 Fixes and cleanups of ArduBreakout example sketch
- Changed banner name from ARAKNOID to BREAKOUT.
- Set frame rate appropriately for the corrected nextFrame() function.
- Removed dead and non-functioning code.
- Cleaned up save, load and display of high scores.
- Made pausing the game work.
- Display the achieved score on the "game over" screen.

Also: Minor refactor of function nextFrame()
2016-09-17 18:54:55 -04:00
Scott Allen 72ae94aca1 Update version numbers to 2.0.4 2016-09-15 19:05:51 -04:00
Scott Allen 15d1b0dab4 Revert nextFrame() back to the original version
A change made to nextFrame(), from the Arduboy library, caused it to not work
correctly. The original version works as designed.

Also:
- Changed longs to unsigned longs for better type matching.
- Removed the frameRate variable. It was being set but never used.
- Added a missing return value to the write() function.
- Changed a int8_t to uint8_t in function lcdCommandMode() to address a
  compiler warning.
- Rearranged the specification of the font[] array to address a compiler
  warning.
2016-09-15 18:12:27 -04:00
Scott Allen fd4cef7025 Fix unsigned/signed compare bug in drawFastHLine
Also change int arguments to int16_t in drawPixel for consistency
2016-09-14 17:50:05 -04:00
Scott Allen 9f9691d546 Update version to 2.0.1 2016-08-03 20:55:45 -04:00
Scott Allen ecedeac7af Fix paintScreen() for IDE 1.6.10
paintScreen() used instruction padding for a delay to allow a byte to be sent
to the display using SPI. This delay became to short with the new gcc version
in Arduino IDE 1.6.10

The function has been changed to test for the serial transfer to complete
before sending the next byte.
2016-08-03 20:49:16 -04:00
Scott Allen d0c0a940f2 No need for size of sBuffer[] array in definition
The number of elements in the sBuffer[] array is already specified
in the declaration.
2016-08-03 20:16:54 -04:00
Scott Allen d17075f7be Make screen buffer static & frame vars protected 2016-06-30 19:59:56 -04:00
Scott Allen 5285c9d2af Move core and audio files to the src directory
To allow ArduboyCore and ArduboyAudio to be used as public base classes.
Changed the file names to match the names of the classes they contain.
2016-06-27 18:52:10 -04:00
Scott Allen ad5da39fdc Make color parameter in draw functions optional
Color defaults to WHITE.

Also:
- Document frame functions and getPixel().
- Change screen buffer from unsigned char to uint8_t
2016-06-27 17:04:01 -04:00
Scott Allen 44b6a6df98 Remove unnecessary includes 2016-06-27 15:42:02 -04:00
Scott Allen 2c023b30ef Change indenting and rearrange audio.cpp
Only cosmetic changes. No functional changes.
2016-06-26 17:37:58 -04:00
Scott Allen 1f641b1e67 Remove #define DEVKIT
DEVKIT was an alias of AB_DEVKIT.
2016-06-15 15:16:31 -04:00
Scott Allen 53fd241064 Remove start(), clearDisplay(), getInput()
These functions were previously deprecated and renamed to
begin(), clear(), buttonsState()
2016-06-15 14:59:31 -04:00
Scott Allen 0e89bcdf2e Change boolean to bool, byte to uint8_t 2016-06-15 14:15:47 -04:00
Scott Allen f7915cd0a9 Turn on all display pixels in "flashlight" mode
Mainly to give an indication that the device is in "flashlight" mode
for units that have the RGB LED installed reversed.

Also, the test for the UP button is moved to within flashlight() itself.
2016-06-15 13:25:57 -04:00
Scott Allen 3c4ebf59c2 Set RGB LED digitally for boot logo & flashlight
Instead of PWM, basic digital output is used to control the RGB LED in the
bootLogo() and flashlight() functions. This reduces code size for sketches
which don't use the setRGBled() function. In bootLogo(), instead of dimming
the red LED, the red then green then blue LEDs are lit in sequence at full
brightness.

digitalWriteRGB() was added as a public function and is also used for the
changes above.
2016-06-14 16:27:21 -04:00
Scott Allen e2458e6645 Add boot up system control
Checks if the "B" button is being held down when begin() is called.
If so, waits for other buttons to be pressed to control system functions.
Functions implemented:
 "UP" button: Set "sound enabled" in EEPROM.
 "DOWN" button: Set "sound disabled" (mute) in EEPROM.
2016-06-13 14:21:45 -04:00
Scott Allen 54c1fb79ba Changes to create Arduboy2 library from Arduboy
Based on Arduboy library V1.2 development as of April 2, 2016

- Class Arduboy2 replaces class Arduboy.
- Removed files ab_printer.h and ab_printer.cpp. Integrated their
  functionality into class Arduboy2 (as with Arduboy V1.1).
- Added new text functions:
  - getCursorX(), getCursorY() to get the current cursor position.
  - setTextColor(), setTextBackground() to allow inverted text
    (black on white).
  - clear() is overridden to set the cursor to 0, 0 in addition to clearing
    the screen buffer.
- New Class: Arduboy2Base which contains most of the Arduboy functions and
  is inherited by Arduboy2. It doesn't inherit Print, and doesn't include
  text display and cursor control functions. Using it instead of Arduboy2,
  in sketches that don't use text functions, frees up some code space.
- Function drawChar() is in Arduboy2 instead of Arduboy2Base.
- Made setRGBled() static. Not making it static was an oversight.

("Tunes" functions are still moved to the separate ArduboyPlaytune library,
as they were in Arduboy V1.2)
2016-06-10 20:00:39 -04:00