Data Polarity

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Data Polarity

Post by dinhhuynhky » Sun May 05, 2019 3:34 am

First, thanks so much about DMD Lib, It's nice.
I've a problem with Data polarity: Positive; and Data polarity: Native;
How DMD Lib can set this properties ?
I only need my P10 turn on led on my data.
Thanks so much !
Video: https://youtu.be/QcyHCUmK0OE

Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Mon May 06, 2019 12:07 am

Difficult to give an accurate answer without knowing more about your sketch.
I will assume you are using the DMD library as you mention 'DMD Lib' and not DMD2.
If that is the case, have a look at the format of drawMarquee():

Code: Select all

drawMarquee(const char *bChars, byte length, int left, int top, byte fgcolour, byte bgcolour)
fgcolour is the foreground colour (colour of your text)
bgcolour is the background colour
You want yours to look something like this:

Code: Select all

dmd.drawMarquee("Your scrolling text", length, left, top, TRUE, FALSE);
Have a look at the examples supplied with the library.

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Mon May 06, 2019 3:35 am

Im following this video: https://www.youtube.com/watch?v=cpOpOGVOY5s
In this video just only data led on ( like X, O character )
In my video, my data led off ( "PlanB Studio" message ) : https://www.youtube.com/watch?v=QcyHCUm ... e=youtu.be

sorry for my Language

Thanks !

Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Mon May 06, 2019 5:27 am

Once again, if you do not post your sketch, I can only guess at what you are doing.
From the download via the link you provided, it appears to be the DMD library.
In that download there are several examples which will help you understand how these DMDs work. Try 'dmd_demo' and see how that goes. If that works correctly then you know your setup is correct.
The scroll operation uses drawMarquee() so this is where you need to start looking.
I'm not sure about the code available via the link you provided as I did not check to see if it was the same as the master copy which is available here. It might be worthwhile downloading a new copy just to be sure.

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Mon May 06, 2019 7:45 am

Here is my sketch:
Connection:
Image
Code:

Code: Select all

#include "SPI.h"
#include "DMD.h"
#include "TimerOne.h"  
#include "Arial_black_16.h"
 
/*-----------------------------------------------------------------------
 Only 7 of the 16 pins on the DMD are actually used:
 GND - Hopefully obvious
 nOE - Enable / Disable ALL the LEDs on the DMD
 A - A&B pins select which 1/4 of the DMD is selected
 B - A&B pins select which 1/4 of the DMD is selected
 CLK - Used to clock each pixel into the DMD shift registers
 SCLK - Latches the current content of the DMD shift registers
 R - The raw pixel data stream (NB: The 'R' stands for RED. You might notice an unused 'G' pin which is for Green on a HUB12 connector)
 --------
 nOE(D9) |1     2| A(D6)
 Gnd     |3     4| B(D7)
 Gnd     |5     6| C
 Gnd     |6     8| CLK(D13)
 Gnd     |7    10| SCLK(D8)
 Gnd     |11   12| R(D11)
 Gnd     |13   14| G
 Gnd     |15   16| D
 ---------
 -----------------------------------------------------------------------*/
//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
 
/*-----------------------------------------------------------------------
 Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
 called at the period set in Timer1.initialize();
 -----------------------------------------------------------------------*/
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}
 String readString;
const byte PanelWidth = 32;
const byte MaxStringLength = 5;
char CharBuf[MaxStringLength + 1];
 
void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
  //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 5000 );          //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );  //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
  dmd.selectFont(Arial_Black_16);
  dmd.clearScreen(true);
}
  String myString;
void loop() {
 //dmd.setBrightness(10);
 
  
  
  if (Serial.available())  {
    while(Serial.available()) {
      myString = Serial.readString();// read the incoming data as string
      Serial.println(readString);
      dmd.clearScreen(true);
    }
  }
  center_theDisplay("OK"); 
  delay(5000);
}
void center_theDisplay(String input_Str) {
  byte charCount, total_charWidth, x_position;
  input_Str.toCharArray(CharBuf, MaxStringLength + 1); //string to char array
 
  charCount=  input_Str.length();
  if (charCount==0) exit;
 
  total_charWidth= 0;
  for (byte thisChar = 0; thisChar <charCount; thisChar++) {
    total_charWidth= total_charWidth + dmd.charWidth(CharBuf[thisChar]) +1; //add 1 pixel for space
  }  
 
  total_charWidth= total_charWidth -1; //no space for last letter
  x_position= (PanelWidth - total_charWidth) /2; //position(x) of first letter
  dmd.clearScreen(true);
 
  for (byte thisChar = 0; thisChar <charCount; thisChar++) {
    //dmd.drawChar(x, y,‘@', GRAPHICS_NORMAL)
    dmd.drawChar( x_position,  1, CharBuf[thisChar], GRAPHICS_NORMAL );
    x_position= x_position + dmd.charWidth(CharBuf[thisChar]) + 1; //position for next letter
  }  
}
Here is result:
Image

But i want this:
Image

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Mon May 06, 2019 8:48 am

Image
THIS OPTION OF TVLEDSHOW 2015 working great !

Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Mon May 06, 2019 10:30 am

Did you try the dmd_demo? Did that work correctly for you?
For some reason your setup does not appear to be working as expected. There are 2 options for the graphics mode: GRAPHICS_INVERSE and GRAPHICS_NORMAL - have you tried GRAPHICS_INVERSE?

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Mon May 06, 2019 2:39 pm

I had tried GRAPHICS_INVERSE? It work with that code but not perfect. It wont work with drawChar and drawString

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Mon May 06, 2019 2:44 pm

2nd picture that I used GRAPHICS_INVERSE?. Character display not coẻctly. Let look top line and bottom line.

Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Tue May 07, 2019 7:51 am

Did you try the example dmd_demo? Did that work correctly for you?

Post Reply