update ArduboyFX library
Added more example sketches to library. + minor changes
This commit is contained in:
parent
c933c2b804
commit
d2f8227b1a
|
@ -1,2 +1,2 @@
|
|||
# ArduboyFX
|
||||
Arduboy library for accessing external flash memory
|
||||
Library for accessing the external flash memory of the Arduboy FX and home made Arduboys with a flash chip.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 613 B |
|
@ -0,0 +1,52 @@
|
|||
/* *****************************************************************************
|
||||
* FX basic example v1.0 by Mr.Blinky May 2021 licenced under CC0
|
||||
* *****************************************************************************
|
||||
*
|
||||
* This is a basic example that shows how you can draw a image from FX external
|
||||
* flash memory. It will draw the Arduboy FX logo and move it around the screen.
|
||||
*
|
||||
* This test depend on the file fxdata.bin being uploaded to the external FX flash
|
||||
* chip using the uploader-gui.py or flash-writer.py Python script in the
|
||||
* development area. When using the flash writer script. Use the following command:
|
||||
*
|
||||
* python flash-writer.py -d fxdata.bin
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <Arduboy2.h> // required to build for Arduboy
|
||||
#include <ArduboyFX.h> // required to access the FX external flash
|
||||
#include "fxdata.h" // this file contains all references to FX data
|
||||
|
||||
//constant values
|
||||
constexpr uint8_t FXlogoWidth = 115;
|
||||
constexpr uint8_t FXlogoHeight = 16;
|
||||
|
||||
Arduboy2 arduboy;
|
||||
|
||||
//assign values;
|
||||
int16_t x = (WIDTH - FXlogoWidth) / 2;
|
||||
int16_t y = 25;
|
||||
int8_t xDir = 1;
|
||||
int8_t yDir = 1;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin(); // normal initialisation with Arduboy startup logo
|
||||
//arduboy.setFrameRate(60); // Only needed when frameRate != 60
|
||||
FX::disableOLED(); // OLED must be disabled before external flash is accessed. OLED display should only be enabled prior updating the display.
|
||||
FX::begin(FX_DATA_PAGE); // external flash chip may be in power down mode so wake it up (Cathy bootloader puts chip into powerdown mode)
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!arduboy.nextFrame()) return; // Do nothing until it's time for the next frame
|
||||
|
||||
//program code
|
||||
FX::drawBitmap(x, y, FXlogo, 0, dbmNormal);
|
||||
x += xDir;
|
||||
y += yDir;
|
||||
if (x == 0 || x == WIDTH - FXlogoWidth) xDir = -xDir;
|
||||
if (y == 0 || y == HEIGHT - FXlogoHeight) yDir = -yDir;
|
||||
|
||||
FX::enableOLED(); // only enable OLED for updating the display
|
||||
arduboy.display(CLEAR_BUFFER); // Using CLEAR_BUFFER will clear the display buffer after it is displayed
|
||||
FX::disableOLED(); // disable display again so external flash can be accessed at any time
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
/**** FX data header generated by fx-data.py tool version 1.00 ****/
|
||||
|
||||
using uint24_t = __uint24;
|
||||
|
||||
// Initialize FX hardware using FX::begin(FX_DATA_PAGE); in the setup() function.
|
||||
|
||||
constexpr uint16_t FX_DATA_PAGE = 0xffff;
|
||||
constexpr uint24_t FX_DATA_BYTES = 234;
|
||||
|
||||
constexpr uint24_t FXlogo = 0x000000;
|
|
@ -0,0 +1,65 @@
|
|||
/*******************************************************************************
|
||||
FX Data resource file.
|
||||
********************************************************************************
|
||||
|
||||
Run this file through the fx-data.py Python script (drag and drop) to create
|
||||
a c-style header file that can be included with your project.
|
||||
|
||||
a .bin file will also be created containing the actual resource data. This .bin
|
||||
file can be uploaded to the FX flash chip using the uploader-gui.py Python
|
||||
script (Use Upload Development data button).
|
||||
|
||||
The .bin file can also be uploaded to FX flash chip using the flash-writer.py
|
||||
Python command line script using the -d switch.
|
||||
|
||||
Data types:
|
||||
|
||||
int8_t, uint8_t values will be stored as 8-bit bytes (unsigned char)
|
||||
|
||||
int16_t, uint16_t values will be stored as 16-bit (half)words (int)
|
||||
|
||||
int24_t,uint24_t values will be stored as 24-bit address that points to
|
||||
a FX data resource
|
||||
|
||||
int32_t,uint32_t values will be stored as 32-bit long words
|
||||
|
||||
image_t a filename with a relative path to a .bmp or .png image file
|
||||
raw_t a filename with a relative path to a raw file
|
||||
|
||||
to create a constant to point to a FX resource, a similar format as in C(++):
|
||||
is used.
|
||||
|
||||
image_t FXlogo = "FX-logo.png";
|
||||
image_t FxSprite = "FXSprite.png";
|
||||
|
||||
when data of the same format is used the data type may be ommited. The semicolon
|
||||
may also be ommited in all cases.
|
||||
|
||||
image_t FXlogo = "FX-logo.png"
|
||||
FxSprite = "FXSprite.png"
|
||||
|
||||
or even:
|
||||
|
||||
image_t FXlogo = "FX-logo.png", FxSprite = "FXSprite.png"
|
||||
|
||||
When specifying multiple data make sure they are seperated by at least a space
|
||||
(comma is optional). A data array can be simplified. For examle:
|
||||
|
||||
uint8_t tilemap[] = {
|
||||
0, 1, 2, 3, 4, 5, 6
|
||||
};
|
||||
|
||||
can also be written simply as:
|
||||
|
||||
uint8_t tilemap = 0 1 2 3 4 5 6
|
||||
|
||||
data can be commented out using // for a single line or
|
||||
using /* */ for a block comment
|
||||
|
||||
********************************************************************************
|
||||
basic example :
|
||||
*******************************************************************************/
|
||||
|
||||
// Arduboy FX logo image:
|
||||
|
||||
image_t FXlogo = "assets/FXlogo.png"
|
|
@ -0,0 +1,2 @@
|
|||
The map and whale images were made by Arduboy community member and twitter user
|
||||
2bitCrook and are shared under a CC-BY-NC-SA licence.
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
After Width: | Height: | Size: 920 B |
|
@ -0,0 +1,85 @@
|
|||
/* *****************************************************************************
|
||||
* FX drawBitmap test v1.3 by Mr.Blinky Apr 2019-May 2021 licenced under CC0
|
||||
* *****************************************************************************
|
||||
*
|
||||
* The map and whale images used in this example were made by 2bitcrook and are
|
||||
* licenced under CC-BY-NC-SA licence.
|
||||
|
||||
* This test depend on the file fxdata.bin being uploaded to the external FX flash
|
||||
* chip using the uploader-gui.py or flash-writer.py Python script in the
|
||||
* development area. When using the flash writer script. Use the following command:
|
||||
*
|
||||
* python flash-writer.py -d fxdata.bin
|
||||
*
|
||||
* This example uses a 816 by 368 pixel image as background and a
|
||||
* 107 x 69 image for masked sprite. Both can be moved around using the button combos
|
||||
* below. This example also shows how you can make use of the different draw modes.
|
||||
*
|
||||
*
|
||||
* A Invert the while sprite from black to white and vice versa
|
||||
* B Show or hide the coordinates in the top left corner
|
||||
* D-PAD move around the whale sprite
|
||||
* D-PAD + A move around the whale sprite in single pixel steps
|
||||
* D-PAD + B move around the background image
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <Arduboy2.h> // required to build for Arduboy
|
||||
#include <ArduboyFX.h> // required to access the FX external flash
|
||||
#include "fxdata.h" // this file contains all references to FX data
|
||||
|
||||
#define FRAME_RATE 120
|
||||
|
||||
Arduboy2 arduboy;
|
||||
bool showposition = true;
|
||||
uint8_t select,color;
|
||||
int x [2];
|
||||
int y [2];
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
arduboy.setFrameRate(FRAME_RATE);
|
||||
FX::disableOLED(); // OLED must be disabled before external flash is accessed. OLED display should only be enabled prior updating the display.
|
||||
FX::begin(FX_DATA_PAGE); //external flash chip may be in power down mode so wake it up (Cathy bootloader puts chip into powerdown mode)
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!arduboy.nextFrame()) return;
|
||||
|
||||
arduboy.pollButtons();
|
||||
if (arduboy.justPressed(B_BUTTON)) showposition = !showposition;
|
||||
if (arduboy.pressed(B_BUTTON)) select = 0;
|
||||
else select = 1;
|
||||
if (arduboy.justPressed(A_BUTTON)) color ^= dbmReverse;
|
||||
if (arduboy.pressed(A_BUTTON))
|
||||
{
|
||||
if (arduboy.justPressed(UP_BUTTON)) y[select]--;
|
||||
if (arduboy.justPressed(DOWN_BUTTON)) y[select]++;
|
||||
if (arduboy.justPressed(LEFT_BUTTON)) x[select]--;
|
||||
if (arduboy.justPressed(RIGHT_BUTTON)) x[select]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arduboy.pressed(UP_BUTTON)) y[select]--;
|
||||
if (arduboy.pressed(DOWN_BUTTON)) y[select]++;
|
||||
if (arduboy.pressed(LEFT_BUTTON)) x[select]--;
|
||||
if (arduboy.pressed(RIGHT_BUTTON)) x[select]++;
|
||||
}
|
||||
|
||||
FX::drawBitmap(x[0],y[0],mapGfx,0,dbmNormal);
|
||||
FX::drawBitmap(x[1],y[1],whaleGfx,0,dbmMasked | color); // comment this line and uncomment one below to test the drawing modes
|
||||
//FX::drawBitmap(x[1],y[1],whaleGfx,0,dbmMasked | dbmBlack); // black pixels as drawn solid. White pixels are transparent. Mask is ignored.
|
||||
//FX::drawBitmap(x[1],y[1],whaleGfx,0,dbmMasked | dbmWhite); // white pixels are drawn solid. Black pixels are transparent. Mask is ignored.
|
||||
//FX::drawBitmap(x[1],y[1],whaleGfx,0,dbmMasked | dbmInvert); // white pixels are xored together with background pixels. Mask is ignored.
|
||||
//FX::drawBitmap(x[1],y[1],whaleGfx,0,dbmMasked | dbmReverse); // Inverts the image: white pixels are drawn as black, black pixels are drawn as white pixels. Mask is applied.
|
||||
if (showposition)
|
||||
{
|
||||
arduboy.setCursor(0,0);
|
||||
arduboy.print(x[select]);
|
||||
arduboy.setCursor(0,8);
|
||||
arduboy.print(y[select]);
|
||||
}
|
||||
FX::enableOLED(); // only enable OLED for updating the display
|
||||
arduboy.display(CLEAR_BUFFER); // Using CLEAR_BUFFER will clear the display buffer after it is displayed
|
||||
FX::disableOLED(); // disable display again so external flash can be accessed at any time
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
/**** FX data header generated by fx-data.py tool version 1.00 ****/
|
||||
|
||||
using uint24_t = __uint24;
|
||||
|
||||
// Initialize FX hardware using FX::begin(FX_DATA_PAGE); in the setup() function.
|
||||
|
||||
constexpr uint16_t FX_DATA_PAGE = 0xff65;
|
||||
constexpr uint24_t FX_DATA_BYTES = 39470;
|
||||
|
||||
constexpr uint24_t mapGfx = 0x000000;
|
||||
constexpr uint24_t whaleGfx = 0x0092A4;
|
|
@ -0,0 +1,69 @@
|
|||
/*******************************************************************************
|
||||
FX Data resource file.
|
||||
********************************************************************************
|
||||
|
||||
Run this file through the fx-data.py Python script (drag and drop) to create
|
||||
a c-style header file that can be included with your project.
|
||||
|
||||
a .bin file will also be created containing the actual resource data. This .bin
|
||||
file can be uploaded to the FX flash chip using the uploader-gui.py Python
|
||||
script (Use Upload Development data button).
|
||||
|
||||
The .bin file can also be uploaded to FX flash chip using the flash-writer.py
|
||||
Python command line script using the -d switch.
|
||||
|
||||
Data types:
|
||||
|
||||
int8_t, uint8_t values will be stored as 8-bit bytes (unsigned char)
|
||||
|
||||
int16_t, uint16_t values will be stored as 16-bit (half)words (int)
|
||||
|
||||
int24_t,uint24_t values will be stored as 24-bit address that points to
|
||||
a FX data resource
|
||||
|
||||
int32_t,uint32_t values will be stored as 32-bit long words
|
||||
|
||||
image_t a filename with a relative path to a .bmp or .png image file
|
||||
raw_t a filename with a relative path to a raw file
|
||||
|
||||
to create a constant to point to a FX resource, a similar format as in C(++):
|
||||
is used.
|
||||
|
||||
image_t FXlogo = "FX-logo.png";
|
||||
image_t FxSprite = "FXSprite.png";
|
||||
|
||||
when data of the same format is used the data type may be ommited. The semicolon
|
||||
may also be ommited in all cases.
|
||||
|
||||
image_t FXlogo = "FX-logo.png"
|
||||
FxSprite = "FXSprite.png"
|
||||
|
||||
or even:
|
||||
|
||||
image_t FXlogo = "FX-logo.png", FxSprite = "FXSprite.png"
|
||||
|
||||
When specifying multiple data make sure they are seperated by at least a space
|
||||
(comma is optional). A data array can be simplified. For examle:
|
||||
|
||||
uint8_t tilemap[] = {
|
||||
0, 1, 2, 3, 4, 5, 6
|
||||
};
|
||||
|
||||
can also be written simply as:
|
||||
|
||||
uint8_t tilemap = 0 1 2 3 4 5 6
|
||||
|
||||
data can be commented out using // for a single line or
|
||||
using /* */ for a block comment
|
||||
|
||||
********************************************************************************
|
||||
Chompies draw bitmap example :
|
||||
*******************************************************************************/
|
||||
|
||||
// A large map background image:
|
||||
|
||||
image_t map = "assets/map.png"
|
||||
|
||||
// chompies masked sprite image:
|
||||
|
||||
image_t whale = "assets/whale.png"
|
|
@ -1,5 +1,5 @@
|
|||
/* *****************************************************************************
|
||||
* FX draw balls test v1.15 by Mr.Blinky May 2019 May2021 licenced under MIT
|
||||
* FX draw balls test v1.15 by Mr.Blinky May 2019 May2021 licenced under CC0
|
||||
* *****************************************************************************
|
||||
*
|
||||
* This test depend on the file fxdata.bin being uploaded to the external FX flash
|
||||
|
|
|
@ -3,7 +3,7 @@ version=1.0.0
|
|||
author=Mr.Blinky
|
||||
maintainer=mstr.blinky@gmail.com
|
||||
sentence=The Arduboy FX library.
|
||||
paragraph=This library is for accessing the external flash memory used by Arduboy FX and home made Arduboys with flash chip.
|
||||
paragraph=This library is for accessing the external flash memory of the Arduboy FX and home made Arduboys with a flash chip.
|
||||
category=Communication
|
||||
url=https://github.com/mrblinky/ArduboyFX
|
||||
architectures=avr
|
||||
|
|
Loading…
Reference in New Issue