board707 / DMD_STM32

STM32Duino library for RGB, Monochrome and Two-color led matrix panels
GNU General Public License v3.0
64 stars 21 forks source link

issues with P8 40x20 1/5 scan panel #90

Closed saka2080 closed 6 months ago

saka2080 commented 6 months ago

Hi, I am using P8 40x20 1/5 scan panel, it shows as video below when using

DMD_RGB <RGB40x20_S5_LNikon, COLOR_4BITS_Packed> dmd(mux_list, DMD_PIN_nOE, DMD_PIN_SCLK, custom_rgbpins, DISPLAYS_ACROSS, DISPLAYS_DOWN, ENABLE_DUAL_BUFFER);

https://github.com/board707/DMD_STM32/assets/160825352/32671cac-e72d-4e85-b0e4-378cb192c61b

Please suggest what should I do now.

board707 commented 6 months ago

Please add the line to the start of the code

#define RGB40x20_S5_saka2080        3,40,20,5,2

and show the video using this pattern

DMD_RGB <RGB40x20_S5_saka2080, COLOR_4BITS_Packed> dmd(mux_list, DMD_PIN_nOE, DMD_PIN_SCLK, custom_rgbpins, DISPLAYS_ACROSS, DISPLAYS_DOWN, ENABLE_DUAL_BUFFER);
saka2080 commented 6 months ago

Sure. The full code and video are as following.

#include "DMD_RGB.h"
#define RGB40x20_S5_saka2080    3,40,20,5,2

//Number of panels in x and y axis
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1

#define ENABLE_DUAL_BUFFER false
// ==== DMD_RGB pins ====
// mux pins - A, B, C... all mux pins must be selected from same port!
#define DMD_PIN_A PB6
#define DMD_PIN_B PB5
#define DMD_PIN_C PB4

uint8_t mux_list[] = { DMD_PIN_A , DMD_PIN_B , DMD_PIN_C };

// pin OE must be one of PB0 PB1 PA6 PA7
#define DMD_PIN_nOE PB0
#define DMD_PIN_SCLK PB7

uint8_t custom_rgbpins[] = { PA15, PA0,PA1,PA2,PA3,PA4,PA5 }; // CLK, R0, G0, B0, R1, G1, B1
DMD_RGB <RGB40x20_S5_saka2080, COLOR_4BITS_Packed> dmd(mux_list, DMD_PIN_nOE, DMD_PIN_SCLK, custom_rgbpins, DISPLAYS_ACROSS, DISPLAYS_DOWN, ENABLE_DUAL_BUFFER);

uint16_t bg = 0;  // background - black
uint16_t fg = 0;  // foreground

void setup(void)
{
  enableDebugPorts();
    dmd.init();
    fg = dmd.Color888(0, 0, 255);
    dmd.setBrightness(50);

    dmd.drawPixel(0,0, dmd.Color888(255, 0, 255));
    delay(2000);
}

void loop(void) {
    // fill the matrix with points row by row
    for (int i = 0; i < dmd.height(); i++) {
        for (int j = 0; j < dmd.width(); j++) {
            dmd.drawPixel(j,i, fg);
            delay(30);
        }
    }
    // clear the screen
    dmd.fillScreen(bg);
}

https://github.com/board707/DMD_STM32/assets/160825352/3f7c3c7e-8afd-4cfc-be00-cd6bad549c36

board707 commented 6 months ago

Thank you. It is a bit irregular... A good news - the panel works correct, and can be setup for the library.

I'll need some time to figure out how to work with this panel.

board707 commented 6 months ago

Could you add this code after #include "DMD_RGB.h" line

#define RGB40x20_S5_saka2080_2      3,40,20,5,12
template <int MUX_CNT, int P_Width, int P_Height, int SCAN, int COL_DEPTH>
class DMD_RGB<MUX_CNT, P_Width, P_Height, SCAN, 12, COL_DEPTH> : public DMD_RGB_BASE2<COL_DEPTH>
{
public:
    DMD_RGB(uint8_t* mux_list, byte _pin_nOE, byte _pin_SCLK, uint8_t* pinlist,
        byte panelsWide, byte panelsHigh, bool d_buf = false) :
        DMD_RGB_BASE2<COL_DEPTH>(MUX_CNT, mux_list, _pin_nOE, _pin_SCLK, pinlist,
            panelsWide, panelsHigh, d_buf, COL_DEPTH, SCAN, P_Width, P_Height)
    {}

protected:
    uint16_t get_base_addr(int16_t& x, int16_t& y) override {
        this->transform_XY(x, y);
        uint8_t pol_y = y % this->pol_displ;
                static const uint8_t pix_base = 8;
        x += (y / this->DMD_PIXELS_DOWN) * this->WIDTH;
        uint16_t base_addr = (pol_y % this->nRows) * this->x_len +
            (x / pix_base) * this->multiplex * pix_base +
            (pol_y / this->nRows) * pix_base + x % pix_base;
        return base_addr;
    }
};

and show the video for this pattern RGB40x20_S5_saka2080_2 ?

It is not a solution, but just an additional test. Thank you

saka2080 commented 6 months ago

https://github.com/board707/DMD_STM32/assets/160825352/c79a54a7-7765-4bc1-9cc7-c8d5326a5722

board707 commented 6 months ago

Thanks! Great!! it's much easier... try this:

#define RGB40x20_S5_saka2080_2      3,40,20,5,12
template <int MUX_CNT, int P_Width, int P_Height, int SCAN, int COL_DEPTH>
class DMD_RGB<MUX_CNT, P_Width, P_Height, SCAN, 12, COL_DEPTH> : public DMD_RGB_BASE2<COL_DEPTH>
{
public:
    DMD_RGB(uint8_t* mux_list, byte _pin_nOE, byte _pin_SCLK, uint8_t* pinlist,
        byte panelsWide, byte panelsHigh, bool d_buf = false) :
        DMD_RGB_BASE2<COL_DEPTH>(MUX_CNT, mux_list, _pin_nOE, _pin_SCLK, pinlist,
            panelsWide, panelsHigh, d_buf, COL_DEPTH, SCAN, P_Width, P_Height)
    {}

protected:
    uint16_t get_base_addr(int16_t& x, int16_t& y) override {
        this->transform_XY(x, y);
        uint8_t pol_y = y % this->pol_displ;
                static const uint8_t pix_base = 8;
        x += (y / this->DMD_PIXELS_DOWN) * this->WIDTH;
        uint16_t base_addr = (pol_y % this->nRows) * this->x_len +
            (x / pix_base) * this->multiplex * pix_base +
            (pol_y / this->nRows) * pix_base;
        if (pol_y < this->nRows)  base_addr += pix_base -  x % pix_base - 1;
                else base_addr +=x % pix_base ;
               return base_addr;
    }
};
saka2080 commented 6 months ago

Thanks. Great. It worked with the pixel. The problem is now with scrolling text. the example code for scrolling when run,it shows as in video:

https://github.com/board707/DMD_STM32/assets/160825352/c87282fe-fb8f-41e8-a0d1-a8bd9bd87bc8

board707 commented 6 months ago

Ooo I forget to disable fast text scroll. This should resolve the problem:

#define RGB40x20_S5_saka2080_2      3,40,20,5,12
template <int MUX_CNT, int P_Width, int P_Height, int SCAN, int COL_DEPTH>
class DMD_RGB<MUX_CNT, P_Width, P_Height, SCAN, 12, COL_DEPTH> : public DMD_RGB_BASE2<COL_DEPTH>
{
public:
    DMD_RGB(uint8_t* mux_list, byte _pin_nOE, byte _pin_SCLK, uint8_t* pinlist,
        byte panelsWide, byte panelsHigh, bool d_buf = false) :
        DMD_RGB_BASE2<COL_DEPTH>(MUX_CNT, mux_list, _pin_nOE, _pin_SCLK, pinlist,
            panelsWide, panelsHigh, d_buf, COL_DEPTH, SCAN, P_Width, P_Height)
     {
      this->fast_Hbyte = false;
      this->use_shift = false;
      }
    // Fast text shift is disabled for complex patterns, so we don't need the method
    void disableFastTextShift(bool shift) override {}

protected:
    uint16_t get_base_addr(int16_t& x, int16_t& y) override {
        this->transform_XY(x, y);
        uint8_t pol_y = y % this->pol_displ;
                static const uint8_t pix_base = 8;
        x += (y / this->DMD_PIXELS_DOWN) * this->WIDTH;
        uint16_t base_addr = (pol_y % this->nRows) * this->x_len +
            (x / pix_base) * this->multiplex * pix_base +
            (pol_y / this->nRows) * pix_base;
        if (pol_y < this->nRows)  base_addr += pix_base -  x % pix_base - 1;
                else base_addr +=x % pix_base ;
               return base_addr;
    }
};
saka2080 commented 6 months ago

Thank you so much. It works like charm. Great.

board707 commented 6 months ago

Thank you. Star the library if you satisfied it.

board707 commented 5 months ago

Pattern RGB40x20_S5_saka2080 added to the library v1.1.3. Now you can use it directly in the DMD class init