Commit Graph

210 Commits

Author SHA1 Message Date
Scott Allen 30fb448db5 Make lcdBootProgram[] a member of Arduboy2Core
The lcdBootProgram[] array, containing the commands to initialize
the OLED display, isn't considered to be part of the API.
To enforce this, and to avoid the possibility of conflicts from
other code using the same name, it has been changed from being a
global variable to a protected member of the Arduboy2Core class.
2020-07-25 18:38:04 -04:00
Scott Allen a04edf24c1 Move mainNoUSB() to its own class
Suggested and developed by @Pharap

The mainNoUSB() function was never intended to be used directly in
sketches. To help prevent this, it has been made a private member of
a new class, Arduboy2NoUSB, which declares main() as a friend.

The ARDUBOY_NO_USB macro has been modified appropriately.

The Arduboy2Core class now inherits Arduboy2NoUSB, for sketches that
improperly have their own main() which calls the old version of
mainNoUSB() instead of using the ARDUBOY_NO_USB macro.
2020-07-25 18:38:04 -04:00
Scott Allen b668114475 Add Cabi and LodePNG to LICENSE.txt
Also applied the CC0 public domain dedication to the
BeepDemo and RGBled example sketches
2020-07-25 18:38:04 -04:00
Scott Allen c74438e377 Rewrite Cabi README.md with more details
Also added file sample.png in the cabi directory, which is used
for the example sketch in the Cabi README.md file

Also added a note referring to Cabi in the documentation for
drawCompressed()
2020-07-25 18:37:44 -04:00
Scott Allen 566557eab3 Delete trailing whitespace in cabi.c 2020-07-24 17:15:37 -04:00
Scott Allen 3345198d3d Eliminate compile warnings and minor mods for cabi
Compiler warnings generated by cabi.c were mostly due to
signed/unsigned mismatches and unused variables. Unused variables
were removed and most type int variables were changed to unsigned,
since there is no signed math or negative numbers required.

More detailed error messages are reported by using the LodePNG
capability to provide text descriptions for its error codes.

The default output array name prefix was changed
from "out" to "compressed_image".

Changed the on/off opaque/transparent thresholds from 128 to 127,
the half way point, because it makes more sense.

Added a program description to the usage output given when no
arguments are provided.

Other unused code was removed and some code was refactored.
2020-07-24 17:15:37 -04:00
Scott Allen 1bcf707616 Add LodePNG files used by cabi to read PNG files
Added lodepng.c (renamed from lodepng.cpp), lodepng.h and LICENSE from
the LodePNG project by Lode Vandevenne.
https://github.com/lvandeve/lodepng
Since this code is licensed separately from the cabi code, it has been
placed in its own subdirectory named lodepng.

cabi.c and README.md have been modified for the LodePNG file location.
2020-07-24 17:15:37 -04:00
Scott Allen 568a15ff87 Elaborate on description and CC0 waiver in cabi.c
Also renamed file LICENSE to COPYING as recommended for CC0
2020-07-24 17:15:37 -04:00
Scott Allen 966c2125f1 Add the Team A.R.G. cabi program to extras
cabi is a command line program written in C. Its purpose is to read
a PNG file containing a bitmap image and convert it to C/C++ code
suitable for use with the drawCompressed() function.

cabi was published by the Team A.R.G. organization. This organization
has been dissolved and its presence on the internet has been removed,
thus public access to cabi from them is no longer available.

A copy of the relevant cabi files has been added under the extras
directory to maintain a method of creating drawCompressed() compatible
bitmaps.
2020-07-24 17:15:37 -04:00
Scott Allen 355e2d2081 Update or remove outdated URLs 2020-07-24 17:15:37 -04:00
Scott Allen 2d04cf60e1 Change non-API EEPROM defines to constexpr
Macro defines for system EEPROM access that were not intended to be
part of the API have been made into protected constexpr variables of
the Arduboy2Base class.
2020-07-24 17:15:37 -04:00
Scott Allen 6a8041f2fa Start boot logo with a row visible on screen
The first time the boot logo was displayed, for scrolling it down,
it was entirely off screen. It now starts with the lowest row of pixels
visible.
2020-07-24 17:15:37 -04:00
Scott Allen 205e84eae6 Fix off screen tests for bitmap functions
Issue reported by @MrBlinky
For drawBitmap(), drawSlowXYBitmap() and drawCompressed() the initial
check for the bitmap being entirely off screen would sometimes consider
a bitmap to be partially on screen when it is only one pixel above or
to the left of the screen. This would result in unnecessarily doing the
work to draw the bitmap when none of it would be visible.
2020-07-24 17:15:37 -04:00
Scott Allen 0adb83693a Add functions anyPressed() setCursorX() setCursorY()
Suggested by @Pharap
2020-07-24 17:15:37 -04:00
Scott Allen 53096d87bf Refactor API code. Clarify and enhance user docs.
Includes some suggestions and guidance by @Pharap

API:
- Rename non-API function swap() to swapInt16()
- Make swapInt16(), drawCircleHelper(), fillCircleHelper() and
  struct BitStreamReader protected members of Arduboy2Base
- Add #define ARDUBOY_UNIT_NAME_BUFFER_SIZE for the size of a buffer
  to hold a Unit Name
- Move the position of the PROGMEM keyword for lcdBootProgram[]
  for consistency

Documentation:
- Remove absolute values referring to a Unit Name
- More details relating to the use of the Unit Name
- More details relating to the font and text functions
- Other minor documentation changes and spelling corrections
2020-07-24 17:15:13 -04:00
Scott Allen b854e2295f Make "static" the first keyword, for consistency
Suggested by @Pharap
2020-07-20 19:19:50 -04:00
Scott Allen 4f884f4ed2 Make font and logo data arrays class members
To address a compiler warning for the font array and improve the API.
With help and guidance from @Pharap
2020-07-20 19:12:45 -04:00
Scott Allen 3f9e86ab99
Merge pull request #46 from Pharap/constexpr-point-and-rect
Make Rect and Point's constructors constexpr
2020-02-21 13:33:04 -05:00
Pharap 4e513a15d0
Make Rect and Point's constructors constexpr 2020-02-21 18:18:15 +00:00
Scott Allen bc4e0ed0b5
Merge pull request #45 from Pharap/add-drawexternalmask-comment
Add additional information to drawExternalMask
2019-07-14 11:46:00 -04:00
Pharap 891f68a0be
Add additional information to drawExternalMask
This information is already contained in the main details block,
but providing it here as well should make it more obvious.
2019-07-13 10:33:29 +01:00
Scott Allen 2fbde21e66
Merge pull request #44 from Pharap/make-width-and-height-constexpr
Make width and height constexpr
2019-05-31 12:22:56 -04:00
Pharap a31e5091d6
Make width and height constexpr
This allows these functions to be used as constant expressions.
2019-05-31 06:38:43 +01:00
Scott Allen 096aaac8dd Change version to 5.2.1 2019-02-27 17:33:10 -05:00
Scott Allen 903cfd9414 Add CONTRIBUTING.md file 2019-02-27 17:24:48 -05:00
Pharap b40e3b9c57 Fix missing Print::write overloads
Problem:
The overloading of `Print::write` was previously causing the other
overloads of `write` to be hidden.
For more information on this behaviour, see the following
StackOverflow question:
https://stackoverflow.com/questions/1628768

Solution:
The solution uses a `using`-declaration to bring the `Print::write`
overloads into `Arduboy2`'s scope.
For more information on this usage of a `using`-declaration, see the
following cppreference page:
https://en.cppreference.com/w/cpp/language/using_declaration#In_class_definition
2019-02-27 15:38:57 -05:00
Blake W. Ford 6ded14fb0e Use local label for loop in fillScreen() assembly
To fix error: symbol loopto is already defined with -O3 optimization.
2019-02-27 14:48:29 -05:00
Scott Allen 974f5298ee Change version to 5.2.0 2018-11-15 19:27:26 -05:00
Scott Allen c87f512b53 Document Rect and Point constructor parameters 2018-11-15 19:27:26 -05:00
Scott Allen 195d3e5cde Add C++ equivalent code for drawPixel() 2018-11-15 19:27:26 -05:00
Mr.Blinky 2941ed100f Fix a compiler issue and optimize drawPixel()
The new compiler in Arduino IDE 1.8.6/1.8.7 has an optimization glitch
where it fails to see the difference between a data structure in RAM
and in PROGMEM when the data is the same and optimizes one out.

drawPixel() is unable to fetch the correct pixel mask from the
bitshift_left array in PROGMEM causing junk to be drawn.

The bitshift_left[] array has now been optimised out and drawPixel()
will function properly. The optimization uses the same number of cycles
and saves 6 bytes.

drawPixel() has also been made static so the Arduboy object pointer is
no longer needlesly passed on to drawPixel() saving more bytes.
2018-11-15 19:26:58 -05:00
Pharap 1d49ce5df8 Move avr/wdt.h include to cpp file 2018-11-13 12:20:14 -05:00
Pharap d5b4a45706 Make both collide functions static 2018-11-13 12:20:14 -05:00
Pharap 1f86208163 Add constructors to Point 2018-11-13 12:19:35 -05:00
Pharap bc63e39931 Add constructors to Rect 2018-11-13 12:15:55 -05:00
Pharap 54d47ec04e
Remove unncessary limits.h includes 2018-09-03 07:37:16 +01:00
Scott Allen 0eae58c760 Fix initRandomSeed(). Minor code and doc changes
The call to generateRandomSeed() in initRandomSeed() was missing
parentheses.

Added keyword for generateRandomSeed.

Minor code changes, and documentation changes and additions.
2018-04-23 15:44:15 -04:00
Pharap 4c2e412985
Introduce generateRandomSeed function 2018-04-18 01:33:30 +01:00
Scott Allen 58ae256412 Change version to 5.1.0 2018-04-07 07:33:28 -04:00
Scott Allen 928c40813d Make sure TX and RX LEDs are off in mainNoUSB() 2018-04-07 07:28:15 -04:00
Scott Allen b8c1cb742a Add EEPROM flag to disable RGB LED with boot logo
Flag SYS_FLAG_SHOW_LOGO_LEDS added to EEPROM_SYS_FLAGS.
The boot logo functions check the flag and leave the RGB LED off if
the flag isn't set.

Added functions writeShowBootLogoLEDsFlag() and
readShowBootLogoLEDsFlag() for writing and reading the
SYS_FLAG_SHOW_LOGO_LEDS flag.

Example sketch SetSystemEEPROM modified to allow setting the
SYS_FLAG_SHOW_LOGO_LEDS flag.
2018-04-07 07:09:49 -04:00
Scott Allen 15db34cab2 Change version to 5.0.0 2018-03-22 08:11:24 -04:00
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 53b50a9766 Add some previously missed keywords 2018-03-22 08:11:07 -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