Fixed co-ordinate check bug in updateMatrixDMABuffer

Thanks to @FrenchLab47 for finding this one.

Co-Authored-By: Patrick BESSE <pbe33@free.fr>
This commit is contained in:
mrfaptastic 2018-10-29 22:48:57 +00:00
parent 528c8ed561
commit 7f9fd475ac
3 changed files with 22 additions and 12 deletions

View file

@ -175,8 +175,8 @@ void RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(int16_t x_coord, int16_t
if ( !dma_configuration_success)
assert("DMA configuration in begin() not performed or completed successfully.");
// Need to check that the co-ordinate is within range, or it'll break everything big time.
if ( x_coord < 0 || y_coord < 0 || x_coord > MATRIX_WIDTH || y_coord > MATRIX_HEIGHT)
// Need to check that the co-ordinates are within range, or it'll break everything big time.
if ( x_coord < 0 || y_coord < 0 || x_coord >= MATRIX_WIDTH || y_coord >= MATRIX_HEIGHT)
{
return;
}
@ -220,13 +220,13 @@ void RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(int16_t x_coord, int16_t
// turn off OE after brightness value is reached when displaying MSBs
// MSBs always output normal brightness
// LSB (!color_depth_idx) outputs normal brightness as MSB from previous row is being displayed
//if((color_depth_idx > lsbMsbTransitionBit || !color_depth_idx) && ((x_coord) >= brightness)) v|=BIT_OE;
//if((color_depth_idx > lsbMsbTransitionBit || !color_depth_idx) && ((x_coord) >= brightness)) v|=BIT_OE; // ???
// special case for the bits *after* LSB through (lsbMsbTransitionBit) - OE is output after data is shifted, so need to set OE to fractional brightness
if(color_depth_idx && color_depth_idx <= lsbMsbTransitionBit) {
// divide brightness in half for each bit below lsbMsbTransitionBit
int lsbBrightness = brightness >> (lsbMsbTransitionBit - color_depth_idx + 1);
// if((x_coord) >= lsbBrightness) v|=BIT_OE;
// if((x_coord) >= lsbBrightness) v|=BIT_OE; // ???
}
// need to turn off OE one clock before latch, otherwise can get ghosting
@ -315,7 +315,8 @@ void RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(int16_t x_coord, int16_t
} // updateDMABuffer
/*
// WORK IN PROGRESS
void RGB64x32MatrixPanel_I2S_DMA::writeRGB24Frame2DMABuffer(rgb_24 *framedata, int16_t frame_width = MATRIX_WIDTH, int16_t frame_height = MATRIX_HEIGHT)
{
if ( !dma_configuration_success)
@ -436,7 +437,7 @@ void RGB64x32MatrixPanel_I2S_DMA::writeRGB24Frame2DMABuffer(rgb_24 *framedata, i
} // updateDMABuffer
*/

View file

@ -171,7 +171,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
allocateDMAbuffers();
backbuf_id = 0;
brightness = 16;
brightness = 32;
}
@ -193,7 +193,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
inline void drawPixelRGB24(int16_t x, int16_t y, rgb_24 color);
// TODO: Draw a frame! Oooh.
void writeRGB24Frame2DMABuffer(rgb_24 *framedata, int16_t frame_width, int16_t frame_height);
//void writeRGB24Frame2DMABuffer(rgb_24 *framedata, int16_t frame_width, int16_t frame_height);
@ -209,6 +209,8 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
void setBrightness(int _brightness)
{
// Change to set the brightness of the display, range of 1 to matrixWidth (i.e. 1 - 64)
// Warning: When set to 64, make sure to wear sunglasses when looking directly at panel :-)
brightness = _brightness;
}

View file

@ -32,11 +32,18 @@ RGB64x32MatrixPanel_I2S_DMA matrix;
#include "GifDecoder.h"
#include "FilenameFunctions.h"
/* GIF files for this particular example need to be put into the 'data' directoy of the
* sketch and saved to the ESP32 using the "ESP32 Sketch Data Upload" tool in Arduino.
*
* URL: https://github.com/me-no-dev/arduino-esp32fs-plugin
*
*/
#define GIF_DIRECTORY "/"
#define DISPLAY_TIME_SECONDS 5
const uint8_t kMatrixWidth = 64; // known working: 32, 64, 96, 128
const uint8_t kMatrixHeight = 32; // known working: 16, 32, 48, 64
// Gif sizes should match exactly that of the RGB Matrix display.
const uint8_t GIFWidth = 64;
const uint8_t GIFHeight = 32;
/* template parameters are maxGifWidth, maxGifHeight, lzwMaxBits
*
@ -44,7 +51,7 @@ const uint8_t kMatrixHeight = 32; // known working: 16, 32, 48, 64
* lzwMaxBits can be set to 10 or 11 for small displays, 12 for large displays
* All 32x32-pixel GIFs tested work with 11, most work with 10
*/
GifDecoder<kMatrixWidth, kMatrixHeight, 12> decoder;
GifDecoder<GIFWidth, GIFHeight, 12> decoder;
int num_files;
@ -57,7 +64,7 @@ void updateScreenCallback(void) {
}
void drawPixelCallback(int16_t x, int16_t y, uint8_t red, uint8_t green, uint8_t blue) {
matrix.drawPixel(x, y, matrix.color565(red, green, blue));
matrix.drawPixelRGB888(x, y, red, green, blue);
}
// Setup method runs once, when the sketch starts