marcmerlin / FastLED_NeoMatrix

Adafruit GFX compatible library for NeoPixel based Matrices using FastLED library
GNU General Public License v3.0
193 stars 50 forks source link

MatrixGFXdemo custom size matrix #8

Closed dallen98 closed 3 years ago

dallen98 commented 3 years ago

Thank you for opening an issue on an Adafruit Arduino library repository. To improve the speed of resolution please review the following guidelines and common troubleshooting steps below before creating the issue:

If you're sure this issue is a defect in the code and checked the steps above please fill in the following fields to provide enough troubleshooting information. You may delete the guideline and text above to just leave the following details:

dallen98 commented 3 years ago

in the above example I wish to use 60w x 34h .H image and when I view it on my ws2812b 60w x 34h matrix the code seems to shrink it down to 32x32, where in the code can I either disable or define my 60x34 without it getting shrunk below is how my matrix is set up thanks

define mw 60

define mh 34

define NUMMATRIX (mw*mh)

CRGB leds[NUMMATRIX]; // Define matrix width and height. FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds, mw, mh, NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG);

marcmerlin commented 3 years ago

I'm sorry, your description is way too vague for me to know what your issue is. mw and mh are defined correctly, so that part should work.

You probably want to go through this guide: https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library It doesn't use my library, but explains how neomatrix works, and also the adafruit neopixel library is less capable, you can probably try that first if you need a step by step which you can likely apply to my lib as they are compatible in how they work. If you end up using the adafruit lib first, once that works, you can switch back to FastLED which is better in hardware support and faster with the options it offers.

dallen98 commented 3 years ago

Yes sorry I badly worded the above, what I want is simply a scrolling text and a static bitmap which is 60px wide x 34px wide, to this end my loop looks like this.. void loop() { display_scrollText(); //display_panOrBounceBitmap(32); display_panOrBounceBitmap(); } so I,m trying to edit the below to display my "bitmap32" (which is 60wx32h) statically not bouncing around, any help much appreciated.

`void display_panOrBounceBitmap (uint8_t bitmapSize) { // keep integer math, deal with values 16 times too big // start by showing upper left of big bitmap or centering if the display is big int16_t xf = max(0, (mw-bitmapSize)/2) << 4; int16_t yf = max(0, (mh-bitmapSize)/2) << 4; // scroll speed in 1/16th int16_t xfc = 6; int16_t yfc = 3; // scroll down and right by moving upper left corner off screen // more up and left (which means negative numbers) int16_t xfdir = -1; int16_t yfdir = -1;

for (uint16_t i=1; i<200; i++) {
bool updDir = false;

// Get actual x/y by dividing by 16.
int16_t x = xf >> 4;
int16_t y = yf >> 4;

matrix->clear();
// bounce 8x8 tri color smiley face around the screen
if (bitmapSize == 8) fixdrawRGBBitmap(x, y, RGB_bmp[10], 8, 8);
// pan 24x24 pixmap
if (bitmapSize == 24) matrix->drawRGBBitmap(x, y, (const uint16_t *) bitmap24, bitmapSize, bitmapSize);

ifdef BM32

if (bitmapSize == 32) matrix->drawRGBBitmap(x, y, (const uint16_t *) bitmap32, bitmapSize, bitmapSize);

endif

matrix->show();

// Only pan if the display size is smaller than the pixmap
// but not if the difference is too small or it'll look bad.
if (bitmapSize-mw>2) {
    xf += xfc*xfdir;
    if (xf >= 0)                      { xfdir = -1; updDir = true ; };
    // we don't go negative past right corner, go back positive
    if (xf <= ((mw-bitmapSize) << 4)) { xfdir = 1;  updDir = true ; };
}
if (bitmapSize-mh>2) {
    yf += yfc*yfdir;
    // we shouldn't display past left corner, reverse direction.
    if (yf >= 0)                      { yfdir = -1; updDir = true ; };
    if (yf <= ((mh-bitmapSize) << 4)) { yfdir = 1;  updDir = true ; };
}
// only bounce a pixmap if it's smaller than the display size
if (mw>bitmapSize) {
    xf += xfc*xfdir;
    // Deal with bouncing off the 'walls'
    if (xf >= (mw-bitmapSize) << 4) { xfdir = -1; updDir = true ; };
    if (xf <= 0)           { xfdir =  1; updDir = true ; };
}
if (mh>bitmapSize) {
    yf += yfc*yfdir;
    if (yf >= (mh-bitmapSize) << 4) { yfdir = -1; updDir = true ; };
    if (yf <= 0)           { yfdir =  1; updDir = true ; };
}

if (updDir) {
    // Add -1, 0 or 1 but bind result to 1 to 1.
    // Let's take 3 is a minimum speed, otherwise it's too slow.
    xfc = constrain(xfc + random(-1, 2), 3, 16);
    yfc = constrain(xfc + random(-1, 2), 3, 16);
}
delay(10);
}

}`

marcmerlin commented 3 years ago

Ok, this does not seem like a problem with my library but you need help with your custom code (if I misunderstood, sorry). the first line you sent in your report, does say "Do not use GitHub issues for troubleshooting projects and issues. "

Long story short, I gets hundreds of emails per day, I really don't have time to help people with custom code, or I wouldn't get any of my own work done, sorry about that.