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

RGB 32x16 led matrix using stm32f103 controller matrix have A, B, C others pins like D AND E is ground. #68

Closed nawab-sw closed 8 months ago

nawab-sw commented 8 months ago

https://github.com/board707/DMD_STM32/assets/49905624/58cbc53c-bfcc-43f0-88a5-36cc7c2b67e5

I am working on RGB 32x16 led matrix using stm32f103 controller all the connection same as in library. given but still not get the result, matrix is not faulty i have checked it with esp8266 working but don't know what is issues with stm32f103, please help me like wring connection pins between controller and 32x16 matrix, and i want to inform you matric have A,B, C others pins like D AND E is ground. I want to print "WELCOME" on this matrix. code is below:

/*-------------------------------------------------------------------------------------- Demo for RGB panels

DMD_STM32a example code for STM32F103xxx board ------------------------------------------------------------------------------------- */

include "DMD_RGB.h"

// Fonts includes

include "st_fonts/UkrRusArial14.h"

include "st_fonts/SystemFont5x7.h"

pragma GCC diagnostic ignored "-Wnarrowing"

pragma GCC diagnostic ignored "-Woverflow"

include "gfx_fonts/GlametrixLight12pt7b.h"

include "gfx_fonts/GlametrixBold12pt7b.h"

pragma GCC diagnostic warning "-Wnarrowing"

pragma GCC diagnostic warning "-Woverflow"

//Number of panels in x and y axis

define DISPLAYS_ACROSS 1

define DISPLAYS_DOWN 1

// Enable of output buffering // if true, changes only outputs to matrix after // swapBuffers(true) command // If dual buffer not enabled, all output draw at matrix directly // and swapBuffers(true) cimmand do nothing

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

define DMD_PIN_D PB3

define DMD_PIN_E PB8

// put all mux pins at list uint8_t mux_list[] = { DMD_PIN_A , DMD_PIN_B , DMD_PIN_C , DMD_PIN_D , DMD_PIN_E };

// pin OE must be one of PB0 PB1 PA6 PA7

define DMD_PIN_nOE PB0

define DMD_PIN_SCLK PB7

// Pins for R0, G0, B0, R1, G1, B1 channels and for clock. // By default the library uses RGB color order. // If you need to change this - reorder the R0, G0, B0, R1, G1, B1 pins. // All this pins also must be selected from same port! uint8_t custom_rgbpins[] = { PA6, PA0,PA1,PA2,PA3,PA4,PA5 }; // CLK, R0, G0, B0, R1, G1, B1

// Fire up the DMD object as dmd<MATRIX_TYPE, COLOR_DEPTH> // We use 64x32 matrix with 16 scans and 4bit color: DMD_RGB <RGB32x16plainS8, COLOR_4BITS> dmd(mux_list, DMD_PIN_nOE, DMD_PIN_SCLK, custom_rgbpins, DISPLAYS_ACROSS, DISPLAYS_DOWN, ENABLE_DUAL_BUFFER); // other options are: // - 32x16 matrix with 8scans // - 80x40 matrix with 20scans // - 64x64 matrix with 32scans // Color depth - , or

// --- Define fonts ---- // DMD.h old style font DMD_Standard_Font UkrRusArial_F(UkrRusArial_14); // GFX font with sepatate parts for Latin and Cyrillic chars DMD_GFX_Font GlametrixL((uint8_t)&GlametrixLight12pt7b, (uint8_t)&GlametrixLight12pt8b_rus, 0x80, 13);

/*-------------------------------------------------------------------------------------- UTF8 char recoding

--------------------------------------------------------------------------------------/ int utf8_rus(char dest, const unsigned char* src) {

uint16_t i, j;
for (i = 0, j = 0; src[i]; i++) {
    if ((src[i] == 0xD0) && src[i + 1]) { dest[j++] = src[++i] - 0x10; }
    else if ((src[i] == 0xD1) && src[i + 1]) { dest[j++] = src[++i] + 0x30; }
    else dest[j++] = src[i];
}
dest[j] = '\0';
return j;

}

/-------------------------------------------------------------------------------------- setup Called by the Arduino architecture before the main loop begins --------------------------------------------------------------------------------------/

void setup(void) {

// initialize DMD objects
dmd.init(); 

}

/-------------------------------------------------------------------------------------- loop Arduino architecture main loop --------------------------------------------------------------------------------------/

void loop(void) {

// create foreground colors
uint16_t col[] = {
    dmd.Color888(255,0, 0), // red
    dmd.Color888(0, 255, 0), // green
    dmd.Color888(0, 0, 255)  // blue

};
uint16_t bg = 0;  // background - black
int col_cnt = 3;   // color count

// text
char s[] = "WELCOME!";
// transcode message to UTF for use with GFX fonts
char k[30];

utf8_rus(k, (const unsigned char*)s);
char* m = s;
// select standard font
dmd.selectFont(&UkrRusArial_F);

// set text foreground and background colors
dmd.setTextColor(col[0], bg);

// shift steps in pixels for running text (positive - shift right, negative - left)
int8_t step[] = { 1,-1,-2,2 };
// running text shift interval
uint16_t interval = 30;

long prev_step = millis();
uint8_t col_ptr = 0;
uint8_t i = 0, b = 0;
uint8_t test = 255;
uint8_t test_cnt = 4;
dmd.setBrightness(200);

// Cycle for tests:
// -- running texts moving at x and y axis with single and double speed
// -- vertical scrolling message
while (1) {
    if ((millis() - prev_step) > interval) {
        if (test >= test_cnt) {
            test = 0;
            // draw message
            dmd.drawMarqueeX(m, -1 * (dmd.stringWidth(m)), 0);

            dmd.swapBuffers(true);

        }
        switch (test) {
            // moving text at x axis
        case 0:
            if (dmd.stepMarquee(step[i], 0) & 1) { // if text is reached screen bounds

                dmd.clearScreen(true);
                // set next text color
                col_ptr++;
                if (col_ptr >= col_cnt) col_ptr = 0;
                dmd.setTextColor(col[col_ptr], bg);
                // set new text speed
                i++;
                // if all moving finished
                if (i > 3) {
                    // go to next stage
                    i = 0;
                    test++;
                    dmd.drawMarqueeX(m, 0, (dmd.height() > 16)? 8 : 0);
                }
                else {
                    if (step[i] < 0) dmd.drawMarqueeX(m, dmd.width() - 1, 0);
                    else dmd.drawMarqueeX(m, -1 * dmd.stringWidth(m), 0);
                }
            }
            else {

                if (step[i] != 1) dmd.drawFilledBox(0, 0, 5, dmd.height() - 1, GRAPHICS_INVERSE);
            }
            // output mem buffer to matrix
            dmd.swapBuffers(true);
            break;
        case 1:
            b++;
            dmd.setBrightness(b);
            if (b > 250) {
                test++;
                b = 80;
                i = 0;
                dmd.setBrightness(b);
                dmd.drawMarqueeX(m, 0, 0);
            }
            dmd.swapBuffers(true);
            break;
            // moving text at y axis
        case 2:
            if (dmd.stepMarquee(0, step[i]) & 1) {  // if text is reached screen bounds

                // clear the screen
                dmd.clearScreen(true);
                // select new moving speed
                i++;
                // if all moving finished
                if (i > 3) {
                    // go to next stage
                    test++;
                    // select GFX font for vertical scroll
                    dmd.selectFont(&GlametrixL);
                    dmd.drawMarquee(k, strlen(k), dmd.width() - 1,
                       (dmd.height() > 16)? 8 : 0, 1);

                }
                else {
                    if (step[i] < 0) dmd.drawMarqueeX(m, 0, dmd.height());
                    else dmd.drawMarqueeX(m, 0, 0);
                }
            }
            // output mem buffer to matrix
            dmd.swapBuffers(true);
            break;

            // vertical scrolling    
        case 3:

            dmd.stepMarquee(-1, 0, 1);
            dmd.swapBuffers(true);
            break;

        }

        prev_step = millis();

    }
}

}

board707 commented 8 months ago

Hi Please show a clear photo of the panels's rear side. What are the markings on the chips on the back of the matrix? There should be at least three different types of the chips.

nawab-sw commented 8 months ago

IMG_20240116_140938 IMG_20240116_141002 IMG_20240116_141036 IMG_20240116_141105 IMG_20240116_141203

board707 commented 8 months ago

I don't see a chip's ID on your photos.

However, it appears to be a standard panel. Try changing the A B C pins and start again

#define DMD_PIN_A PB6
#define DMD_PIN_B PB5
#define DMD_PIN_C PB8

You don't need D and E

nawab-sw commented 8 months ago

Thank you very much. all done by this #define DMD_PIN_C PB8 //PB4 (replace PB4 by PB8).

nawab-sw commented 8 months ago

can we operate rgb matrix and monochrome matrix at the same time by stm32f103 controller. its means both matrix init and display the text on both type of matrix. actuly i want to display text on both matrix rgb and monochrome by write the single code

board707 commented 8 months ago

Sorry, the current library doesn't supports this