DMD Brightness control

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
User avatar
stryker
Posts: 267
Joined: Sat Jan 14, 2012 2:44 pm

Re: DMD Brightness control

Post by stryker » Wed Apr 23, 2014 1:53 pm

For the sake of completeness, here's that brightness control sketch using the DMD2 beta library

Code: Select all

#include <SPI.h>                                           // for DMD display
#include <DMD2.h>                                           // also, for DMD display
#include "SystemFont5x7.h"                                 // font used for brightness setting confirmation

// DMD2 brightness tester.  Cycles through values to show effect of dimming.
 
SoftDMD dmd(1,1);  // DMD controls the entire display

// cycle through these values
const int dimmerValues[12] = {
  0, 10, 16, 25, 40, 64, 100, 160, 250, 400, 640, 1024};
unsigned long brightnessUpdateTime;
int dimmerIdx;
int incrementer = 1;

// the setup routine runs once when you press reset:
void setup() {
  dmd.setBrightness(255);
  dmd.selectFont(SystemFont5x7);
  dmd.begin();
}

// ---------------------------------------------------------------------------------
//
void loop() {
  if(millis() > brightnessUpdateTime) {
    int Brightness = dimmerValues[dimmerIdx];
    dimmerIdx += incrementer;
    if(dimmerIdx < 0) { 
      dimmerIdx = 1; 
      incrementer = 1;
    }
    if(dimmerIdx > 11) {
      dimmerIdx = 10; 
      incrementer = -1;
    }
    dmd.setBrightness(Brightness);
    dmd.drawFilledBox(0,0,31,15, false); // Passing false here clears the box
    String power = String(Brightness);
    dmd.drawString(0,0,"PWM:");
    dmd.drawString(0,8,String(Brightness));
    brightnessUpdateTime = millis() + 500;
  }
}
Looks promising so far...
Geoff

Loki
Posts: 18
Joined: Mon Jul 06, 2015 7:12 pm

Re: DMD Brightness control

Post by Loki » Thu Aug 18, 2016 5:54 pm

Hi into original DMD Library this is easiest way to do it:

DMD.h: (just add lines)

Code: Select all

inline void setBrightness(byte level) { this->brightness = level; };
uint8_t brightness;

DMD.cpp: added lines toscanDisplaySPI:

Code: Select all

/*--------------------------------------------------------------------------------------
 Scan the dot matrix LED panel display, from the RAM mirror out to the display hardware.
 Call 4 times to scan the whole display which is made up of 4 interleaved rows within the 16 total rows.
 Insert the calls to this function into the main loop for the highest call rate, or from a timer interrupt
--------------------------------------------------------------------------------------*/
void DMD::scanDisplayBySPI()
{
    //if PIN_OTHER_SPI_nCS is in use during a DMD scan request then scanDisplayBySPI() will exit without conflict! (and skip that scan)
    if( digitalRead( PIN_OTHER_SPI_nCS ) == HIGH )
    {
        //SPI transfer pixels to the display hardware shift registers
        int rowsize=DisplaysTotal<<2;
        int offset=rowsize * bDMDByte;
        for (int i=0;i<rowsize;i++) {
            SPI.transfer(bDMDScreenRAM[offset+i+row3]);
            SPI.transfer(bDMDScreenRAM[offset+i+row2]);
            SPI.transfer(bDMDScreenRAM[offset+i+row1]);
            SPI.transfer(bDMDScreenRAM[offset+i]);
        }

        OE_DMD_ROWS_OFF();
        LATCH_DMD_SHIFT_REG_TO_OUTPUT();
        switch (bDMDByte) {
        case 0:			// row 1, 5, 9, 13 were clocked out
            LIGHT_DMD_ROW_01_05_09_13();
            bDMDByte=1;
            break;
        case 1:			// row 2, 6, 10, 14 were clocked out
            LIGHT_DMD_ROW_02_06_10_14();
            bDMDByte=2;
            break;
        case 2:			// row 3, 7, 11, 15 were clocked out
            LIGHT_DMD_ROW_03_07_11_15();
            bDMDByte=3;
            break;
        case 3:			// row 4, 8, 12, 16 were clocked out
            LIGHT_DMD_ROW_04_08_12_16();
            bDMDByte=0;
            break;
        }
        OE_DMD_ROWS_ON();
    }
    
                              
	if(brightness == 255)
		digitalWrite(PIN_DMD_nOE, HIGH);
  	else
    	analogWrite(PIN_DMD_nOE, brightness);
}

video:https://youtu.be/Dntkgb75-9w

it works without visible flickering when Timer1.initialize( 5100 ) is about 5.1ms but you must try it

this code is reworked a little from DMD2 Beta
Last edited by Loki on Tue Feb 21, 2017 9:21 pm, edited 1 time in total.

Ho!mer
Posts: 2
Joined: Wed Jan 18, 2017 2:08 pm

Re: DMD Brightness control

Post by Ho!mer » Sat Jan 21, 2017 10:10 am

In DMD.h found this:

Code: Select all

#define DMD_BITSPERPIXEL           1      //1 bit per pixel, use more bits to allow for pwm screen brightness control
Can you tell in simple language, how to use it?

Papbo
Posts: 12
Joined: Sun Feb 19, 2017 10:59 am

Re: DMD Brightness control

Post by Papbo » Sun Feb 19, 2017 11:57 am

Hello, I am a new user of the DMD display. I have a project with 2 DMD's using the DMD2.lib and an Arduino méga with the DMDCON. The DMD's will be attached together back to back.
Each display will receive the same data and could be addressed in a daisy chain method.
I would like to have the possibility to change the brightness of each display separately.
If I am using the "dmd.setBrightness(xxx)" command , both dmd brightness is affected on the same value.
Is possible to change the brightness separately?
Regards
Papbo

User avatar
stryker
Posts: 267
Joined: Sat Jan 14, 2012 2:44 pm

Re: DMD Brightness control

Post by stryker » Sun Feb 19, 2017 12:51 pm

No it is not. With a single Arduino controlling them both, each DMD will receive the same PWM signal that controls the brightness.

Papbo
Posts: 12
Joined: Sun Feb 19, 2017 10:59 am

Re: DMD Brightness control

Post by Papbo » Sun Feb 19, 2017 2:58 pm

Hi stryker,
Thanks a lot for the answer, I will use an arduino méga for the main program and one nano to the second display.
By the way is there a new DMD2.lib or an enhancement of the scrolling text. With the DMD2.lib, scrolling is not very nice compare to the DMD.lib features.
Regards
Papbo

Loki
Posts: 18
Joined: Mon Jul 06, 2015 7:12 pm

Re: DMD Brightness control

Post by Loki » Sun Feb 19, 2017 9:51 pm

Papbo wrote:Hi stryker,
Thanks a lot for the answer, I will use an arduino méga for the main program and one nano to the second display.
By the way is there a new DMD2.lib or an enhancement of the scrolling text. With the DMD2.lib, scrolling is not very nice compare to the DMD.lib features.
Regards
Papbo
you can edit and use original DMD lib to have brightness control and nice scrolling

Papbo
Posts: 12
Joined: Sun Feb 19, 2017 10:59 am

Re: DMD Brightness control

Post by Papbo » Tue Feb 21, 2017 11:59 am

Hi Loki,
Could you tell me how to do that...
thanks in advance
Papbo

User avatar
stryker
Posts: 267
Joined: Sat Jan 14, 2012 2:44 pm

Re: DMD Brightness control

Post by stryker » Tue Feb 21, 2017 12:20 pm

Papbo wrote:Hi Loki,
Could you tell me how to do that...
Read from teh start of this thread. It's what it's all about. Note if you have a recently purchased DMD you will have the revised DMDCON board with the additional resistor in place.

Papbo
Posts: 12
Joined: Sun Feb 19, 2017 10:59 am

Re: DMD Brightness control

Post by Papbo » Tue Feb 21, 2017 4:54 pm

Hi Stryker,
Ok, I have seen the post at the start of this thread.
I have purchased my DMD 2 weeks ago, but there are no resistor on the DMDCON.
On Freetronic site, there are no Resistor on the DMDCON connector drawing pdf.
Is it possible to update the drawing.
Regards
Papbo

Post Reply