This commit is contained in:
@@ -2,15 +2,14 @@
|
||||
http://tomeko.net/online_tools/file_to_hex.php?lang=en
|
||||
|
||||
If needed, first resize and crop to an appropriate width and height
|
||||
to suit your display with an image editting program such as IrfanView.
|
||||
to suit your display with an image editing program such as IrfanView.
|
||||
|
||||
You can also change the image "guality" to reduce the file size.
|
||||
You can also change the image "quality" to reduce the file size.
|
||||
|
||||
Paste the array into a new tabe, top and tail the array from the
|
||||
Paste the array into a new tab, top and tail the array from the
|
||||
tool to look like the one below with:
|
||||
|
||||
#include <pgmspace.h>
|
||||
const uint8_t name[] PROGMEM = {
|
||||
const uint8_t name[] PROGMEM = {
|
||||
|
||||
to start and and end with:
|
||||
|
||||
@@ -22,7 +21,6 @@
|
||||
|
||||
*/
|
||||
|
||||
#include <pgmspace.h>
|
||||
const uint8_t panda[] PROGMEM = {
|
||||
0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0xB4,
|
||||
0x00, 0xB4, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06, 0x05, 0x08,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// https://en.wikipedia.org/wiki/Direct_memory_access
|
||||
|
||||
// Tested with ESP32, Nucleo 64 STM32F446RE and Nucleo 144 STM32F767ZI
|
||||
// TFT's with SPI can use DMA, the sketch also works with 8 bit
|
||||
// TFT's with SPI can use DMA, the sketch also works with 8-bit
|
||||
// parallel TFT's (tested with ILI9341 and ILI9481)
|
||||
|
||||
// The sketch will run on processors without DMA and also parallel
|
||||
@@ -36,7 +36,7 @@
|
||||
// Color depth has to be 16 bits if DMA is used to render image
|
||||
#define COLOR_DEPTH 16
|
||||
|
||||
// 128x128 for a 16 bit colour Sprite (32Kbytes RAM)
|
||||
// 128x128 for a 16-bit colour Sprite (32Kbytes RAM)
|
||||
// Maximum is 181x181 (64Kbytes) for DMA - restricted by processor design
|
||||
#define IWIDTH 128
|
||||
#define IHEIGHT 128
|
||||
@@ -56,7 +56,7 @@ TFT_eSprite spr[2] = {TFT_eSprite(&tft), TFT_eSprite(&tft) };
|
||||
// Toggle buffer selection
|
||||
bool sprSel = 0;
|
||||
|
||||
// Pointers to start of Sprties in RAM
|
||||
// Pointers to start of Sprites in RAM
|
||||
uint16_t* sprPtr[2];
|
||||
|
||||
// Define the cube face colors
|
||||
@@ -305,7 +305,7 @@ void drawCube()
|
||||
p2y[i] = IHEIGHT / 2 + ay[i] * CUBE_SIZE / az[i];
|
||||
}
|
||||
|
||||
// Fill the buffer with color 0 (Black)
|
||||
// Fill the buffer with colour 0 (Black)
|
||||
spr[sprSel].fillSprite(TFT_BLACK);
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
@@ -353,7 +353,7 @@ void drawCube()
|
||||
uint32_t computePrimeNumbers(int32_t n) {
|
||||
if (n<2) return 1;
|
||||
|
||||
int32_t i, fact, j, p;
|
||||
int32_t i, fact, j, p = 0;
|
||||
|
||||
//Serial.print("\nPrime Numbers are: \n");
|
||||
for (i = 1; i <= n; i++)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
// Blue Pill overclocked to 128MHz *no* DMA - 32MHz SPI 64 fps
|
||||
// Blue Pill overclocked to 128MHz with DMA - 32MHz SPI 116 fps
|
||||
|
||||
// ESP32 - 8 bit parallel 110 fps (no DMA)
|
||||
// ESP32 - 8-bit parallel 110 fps (no DMA)
|
||||
// ESP32 - 40MHz SPI *no* DMA 93 fps
|
||||
// ESP32 - 40MHz SPI with DMA 112 fps
|
||||
|
||||
@@ -39,7 +39,7 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
|
||||
#define RED 0xF800
|
||||
#define WHITE 0xFFFF
|
||||
|
||||
#define YBOTTOM 123 // Ball Y coord at bottom
|
||||
#define YBOTTOM 123 // Ball Y coordinate at bottom
|
||||
#define YBOUNCE -3.5 // Upward velocity on ball bounce
|
||||
|
||||
// Ball coordinates are stored floating-point because screen refresh
|
||||
@@ -49,7 +49,7 @@ float ballx = 20.0, bally = YBOTTOM, // Current ball position
|
||||
ballframe = 3; // Ball animation frame #
|
||||
int balloldx = ballx, balloldy = bally; // Prior ball position
|
||||
|
||||
// Working buffer for ball rendering...2 scanlines that alternate,
|
||||
// Working buffer for ball rendering...2 scan lines that alternate,
|
||||
// one is rendered while the other is transferred via DMA.
|
||||
uint16_t renderbuf[2][SCREENWIDTH];
|
||||
|
||||
@@ -64,7 +64,7 @@ void setup() {
|
||||
tft.begin();
|
||||
tft.setRotation(3); // Landscape orientation, USB at bottom right
|
||||
tft.setSwapBytes(false);
|
||||
// Draw initial framebuffer contents:
|
||||
// Draw initial frame buffer contents:
|
||||
//tft.setBitmapColor(GRIDCOLOR, BGCOLOR);
|
||||
tft.fillScreen(BGCOLOR);
|
||||
|
||||
@@ -144,7 +144,7 @@ void loop() {
|
||||
(by >= 0) && (by < BALLHEIGHT)) { // inside the ball bitmap area?
|
||||
// Yes, do ball compositing math...
|
||||
p = ball[by][bx1 / 2]; // Get packed value (2 pixels)
|
||||
c = (bx1 & 1) ? (p & 0xF) : (p >> 4); // Unpack high or low nybble
|
||||
c = (bx1 & 1) ? (p & 0xF) : (p >> 4); // Unpack high or low nibble
|
||||
if(c == 0) { // Outside ball - just draw grid
|
||||
c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDCOLOR : BGCOLOR;
|
||||
} else if(c > 1) { // In ball area...
|
||||
@@ -155,7 +155,7 @@ void loop() {
|
||||
} else { // Outside ball bitmap, just draw background bitmap...
|
||||
c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDCOLOR : BGCOLOR;
|
||||
}
|
||||
*destPtr++ = c<<8 | c>>8; // Store pixel color
|
||||
*destPtr++ = c<<8 | c>>8; // Store pixel colour
|
||||
bx1++; // Increment bitmap position counters (X axis)
|
||||
bgx1++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user