Commit Graph

241 Commits

Author SHA1 Message Date
Andrew Dent ccedf84434 Clarify Contribution style requirements
Add examples to give clear guidance (and a reminder),
of commit message style requirements.
2021-06-26 00:18:59 +01:00
Scott Allen 36cbdc734c Fix typo in fillScreen() C++ equivalent code 2021-06-05 07:37:01 -04:00
Scott Allen ab4df7c77a Remove register keywords 2021-04-16 08:47:32 -04:00
Scott Allen 7dc88bed30 Change version to 6.0.0
The major version number has been incremented only because there's a
chance that a sketch that sets text wrap on will behave differently,
due to the changes in the way wrapping is now handled.
2020-09-29 09:44:41 -04:00
Scott Allen 191e9a2e45 Document bitmap image height requirements
Added the requirement that bitmap heights must be a multiple of
8 pixels in the documentation for drawBitmap() and drawCompressed().
2020-09-29 09:44:41 -04:00
Scott Allen 014e6e0a8b Add FontDemo example sketch
Shows the entire font and demonstrates the wrap and raw mode handling.
2020-09-29 09:44:40 -04:00
Scott Allen 500d81abb7 Add image height check to cabi.c
An image converted using the cabi utility must have a height that is
a multiple of 8 pixels. An error is now reported if not.

Also, the README.md file for cabi was updated with this requirement.
2020-09-29 09:44:40 -04:00
Scott Allen 2baca75689 Fix colors in logo PNG files
Files arduboy_logo.png and arduboy_screen.png had some pixels that
were a dark gray color instead of fully black. The images now contain
only fully black and fully white pixels.
2020-09-29 09:44:40 -04:00
Scott Allen 2f1c515672 Add public variables to keywords.txt 2020-09-29 09:44:40 -04:00
Scott Allen 98f03773b2 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.
2020-09-29 09:44:40 -04:00
Scott Allen 4698dd276e Make all possible functions and variables static
This is mainly to reduce code size.

The write() function in class Arduboy2 has to remain virtual,
so functions that result in it eventually being called could
not be made static.

The members of the Point and Rect structures could not be made static
due to their intended use as having multiple instances.

Also to reduce code size, bootLogoExtra() was made non-virtual.
This meant that the begin() and bootLogo...() functions in the
Arduboy2Base class had to have duplicate or equivalent functions
added to the Arduboy2 class.

Related documentation was updated and some minor changes were made to
non-related documentation.
2020-09-29 09:44:40 -04:00
Scott Allen e78e7c9d55 Add more Doxygen cross-referencing
Also:
- Rearrange the order of some member function declarations.
- Minor documentation changes.
2020-09-29 09:44:40 -04:00
Scott Allen 1264edc748 Refactor function BitStreamReader()
Changed from struct to class.

Removed explicit use of the "this" pointer for consistency with
the rest of the library.
2020-09-29 09:44:40 -04:00
Scott Allen aaf4159274 Remove PIXEL_SAFE_MODE define
The ability to compile drawPixel() to not check for
drawing pixels off screen has been removed.
2020-09-29 09:44:20 -04:00
Scott Allen 86169a0027 Modify SetSystemEEPROM to use char size functions
The library functions to get the dimensions of text characters replace
values hard coded in the sketch.

Also changed some #define constants to constexpr variables.

The actual operation of the sketch is unchanged.
2020-09-28 21:12:31 -04:00
Scott Allen 58a35e2ad9 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.
  When set, the write() function will render the value \n (0x0a) as
  an "inverse white circle" instead of handling it as a newline and
  render value \r (0x0d) as a "musical eighth note" instead of
  ignoring it.

- Spacing added at the end of each character is no longer factored in
  when determining if a character will fit on screen at the end of
  a line.

- Checking if line wrap is neccessary is done before drawing a
  character, instead of doing it after drawing to prepare for the
  next character. This fixed a problem with requested line feeds
  interacting with wrapping, resulting in unexpected blank lines.

- Fixed a bug that caused the drawing of characters with a transparent
  background to not work properly. (This is selected by setting the
  background color to be the same as the text color.)

- Added new functions getCharacterWidth() getCharacterHeight()
  getCharacterSpacing() getLineSpacing() to programmatically get
  the dimensions of a character, given the desired text size.

- Functions write() and drawChar() are now able to render a font of
  any character size, and with any character and line spacing, by
  setting variables characterWidth characterHeight characterSpacing
  and lineSpacing, and providing a matching font array. This doesn't
  affect their use with this library but has been done for the sake
  of code portability.
2020-09-28 21:11:13 -04:00
Andrew Dent bbebec346d Add array lengths to comments for boot logos 2020-08-23 15:23:01 -04:00
Scott Allen 350a6ee629 Fix a cursor position bug in BeepDemo example 2020-08-23 15:23:00 -04:00
Scott Allen 7fcbd35266 Fix minor documentation issues 2020-08-23 15:21:28 -04:00
Scott Allen 5d154f817a Make SetSystemEEPROM more C++ correct
(Compiled output is identical to previous)

- Made enumerations scoped
- Changed all type byte to uint8_t
- Changed all type boolean to bool
- Changed some type unsigned int to uint16_t
- Changed C-style casts to static_cast
2020-07-27 09:37:55 -04:00
Scott Allen f1009abd7b Change version to 5.3.0 2020-07-25 18:38:05 -04:00
Scott Allen 8fc6eee194 Add file extras/docs/VERSIONING.txt
Lists the files containing the library version number that must be
updated for a new release.
2020-07-25 18:38:05 -04:00
Scott Allen f0be8ad3b4 Update Doxyfile for Doxygen version 1.8.18
Also made a few settings changes
2020-07-25 18:38:05 -04:00
Scott Allen ecb74632ba Remove emphasis in headers in README.md
Recent releases of Doxygen have problems with using markdown within
markdown headers. Headers in README.md containing emphasis were
changed to only plain text.
2020-07-25 18:38:05 -04:00
Scott Allen 13130f368a Move generateRandomSeed() to Arduboy2Core
Suggested by @yyyc514 (Josh Goebel)
The generateRandomSeed() function was moved from the Arduboy2Base class
to the Arduboy2Core class, since it deals directly with hardware.
It was also made static.

Some related documentation was changed.
2020-07-25 18:38:05 -04:00
Scott Allen 2491e639aa Fix a minor visual glitch in ArduBreakout
Submitted by @uXeBoy (Dan O'Shea).
The game screen was displayed very briefly after entering a high score,
before the title screen is displayed.
2020-07-25 18:38:05 -04:00
Scott Allen 32d23b7984 Refactor ArduBreakout sound and constants
- Use precomputed constant values directly usable by the Beep class
  for tone generation arguments.
  This reduces program size significantly.

- Use the constexpr specifier for all constants.
2020-07-25 18:38:05 -04:00
Scott Allen e0ade6ca99 Clean up ArduBreakout a bit
No actual code changes.

- Changed colors hardcoded as 0 and 1 to BLACK and WHITE.
- Added a comment describing EEPROM space used.
- Made placement of braces and else statements consistent.
- Added spaces between some function call arguments.
- Fixed some spelling mistakes in comments.
- Removed commented out diagnostic code.
- Updated "modifications" comment.
2020-07-25 18:38:05 -04:00
Scott Allen 4530325412 Fix portability issues in the Sprites classes
Issues discovered and fixes developed by @Pharap

The Sprites classes relied on the behavior of 16 bit integer arithmetic
for operations that cause an overflow; specifically (ofs + WIDTH)
calculations for an index into the screen buffer. This would cause
problems if the code was ported to an environment in which the basic
integer type (i.e. "int") is larger than 16 bits.

Also, there was code that assumed little endianness for a technique
used to retrieve the high byte a 16 bit value. This would cause
problems if the code was ported to a big endian architecture.

The changes made are strictly for the sake of improved portability and
better programming practices. They don’t affect code compiled for the
Arduboy in any way.
2020-07-25 18:38:05 -04:00
Scott Allen d7758249fa Add function SPItransferAndRead()
Suggested by @MrBlinky
Same as SPItransfer() but also returns the byte received.
Provided for use with homemade or expanded units that have had
additional peripherals added to the SPI bus that are capable of
sending data.
2020-07-25 18:38:05 -04:00
Pharap 5563599c6d Make writeUnitName() const-correct
Changed the writeUnitName() parameter from
"char* name" to "const char* name".
This will prevent warnings or errors when a string literal or
an array of type "const char" is passed to it.
2020-07-25 18:38:05 -04:00
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