EmbDev.net

Forum: µC & Digital Electronics RGB Matrix Library


Author: Fabian Müller (Guest)
Posted on:

Rate this post
-2 useful
not useful
Hi all

I wanted to create a word clock with a RGB LED Matrix. I bought the 
32x32 LED RGB Matrix off Adafruit (Product ID: 1484) and it looks 
awesome.
I 3D printed a front plate with the letters cut out.
my next idea was to combine it with a DCF77 module. but that wasnt 
reliable enough to use in the final version.
So i settled for a RTC. (Chip DS3231) which communicates with Arduino 
over I2C.
It doesnt seem to be working. I assume that the two librarys dont work 
together because they define a same thing in 2 different ways.
This is the whole code (im very sorry, some words are in swiss german, 
those are only variables to describe the time tho and could be chosen 
freely):
//-------Librarys Realtime Clock---------
//#include <Wire.h>
//#include "DS3231.h"

//-------Librarys LED Matrix-------------
#include <gamma.h>
#include <RGBmatrixPanel.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>


//------Defines for LED Matrix----------
#define CLK  8
#define OE   9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3

//--------Colour Variables-------------
int red, green, blue;

//--------All Pins for LED Matrix------
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

//---------Realtime Clock--------------
RTClib RTC;

void setup()
{
  matrix.begin();
  Wire.begin();
 
  red = 0;
  green = 7;
  blue = 0;
}

void loop()
{
  delay(100);

  DateTime now = RTC.now();
  
  //clear Matrix
  matrix.fillScreen(0);
  
  //write the time to the Matrix
  es();
  isch();

  switch(int stund = now.hour())
  {
    case 1:
    {
      eis();
      break;
    }
    case 2:
    {
      zwei();
      break;
    }
    case 3:
    {
      drue();
      break;
    }
    case 4:
    {
      vieri();
      break;
    }
    case 5:
    {
      fuefi();
      break;
    }
    case 6:
    {
      saechsi();
      break;
    }
    case 7:
    {
      sibni();
      break;
    }
    case 8:
    {
      achti();
      break;
    }
    case 9:
    {
      nueni();
      break;
    }
    case 10:
    {
      zaeni();
      break;
    }
    case 11:
    {
      elfi();
      break;
    }
    case 12:
    {
      zwoelfi();
      break;
    }
  }
  
  switch(int minuute = now.minute())
  {
    case 1:
    {
      //progressBalk
      break;
    }
    case 2:
    {
      //progressBalk
      break;
    }
    case 3:
    {
      //progressBalk
      break;
    }
    case 4:
    {
      //progressBalk
      break;
    }
    case 5:
    {
      fuef();
      ab();
      //progressBalk
      break;
    }
    case 6:
    {
      fuef();
      ab();
      //progressBalk
      break;
    }
    case 7:
    {
      fuef();
      ab();
      //progressBalk
      break;
    }
    
//i think you get the point here... ;)
    
    case 55:
    {
      fuef();
      vor();
      //progressBalk
      break;
    }
    case 56:
    {
      fuef();
      vor();
      //progressBalk
      break;
    }
    case 57:
    {
      fuef();
      vor();
      //progressBalk
      break;
    }
    case 58:
    {
      fuef();
      vor();
      //progressBalk
      break;
    }
    case 59:
    {
      fuef();
      vor();
      //progressBalk
      break;
    }
    case 0:
    {
      //progressBalk
      break;
    }
  }
}

void es(void)
{
  matrix.fillRect(5, 1, 4, 3, matrix.Color333(red, green, blue));
}

void isch(void)
{
  matrix.fillRect(11, 1, 8, 3, matrix.Color333(red, green, blue));
}

void fuef(void)
{
  matrix.fillRect(21, 1, 6, 3, matrix.Color333(red, green, blue));
}

void viertl(void)
{
  matrix.fillRect(5, 4, 12, 3, matrix.Color333(red, green, blue));
}

void zaeae(void)
{
  matrix.fillRect(21, 4, 6, 3, matrix.Color333(red, green, blue));
}

void zwaenzg(void)
{
  matrix.fillRect(5, 7, 12, 3, matrix.Color333(red, green, blue));
}

void vor(void)
{
  matrix.fillRect(21, 7, 6, 3, matrix.Color333(red, green, blue));
}

void ab(void)
{
  matrix.fillRect(5, 10, 4, 3, matrix.Color333(red, green, blue));
}

void halbi(void)
{
  matrix.fillRect(11, 10, 10, 3, matrix.Color333(red, green, blue));
}

void eis(void)
{
  matrix.fillRect(5, 13, 6, 3, matrix.Color333(red, green, blue));
}

void zwei(void)
{
  matrix.fillRect(11, 13, 8, 3, matrix.Color333(red, green, blue));
}

void drue(void)
{
  matrix.fillRect(21, 13, 6, 3, matrix.Color333(red, green, blue));
}

void vieri(void)
{
  matrix.fillRect(5, 16, 10, 3, matrix.Color333(red, green, blue));
}

void fuefi(void)
{
  matrix.fillRect(15, 16, 8, 3, matrix.Color333(red, green, blue));
}

void saechsi(void)
{
  matrix.fillRect(5, 19, 12, 3, matrix.Color333(red, green, blue));
}

void sibni(void)
{
  matrix.fillRect(18, 19, 10, 3, matrix.Color333(red, green, blue));
}

void achti(void)
{
  matrix.fillRect(5, 22, 10, 3, matrix.Color333(red, green, blue));
}

void nueni(void)
{
  matrix.fillRect(15, 22, 8, 3, matrix.Color333(red, green, blue));
}

void zaeni(void)
{
  matrix.fillRect(5, 25, 8, 3, matrix.Color333(red, green, blue));
}

void elfi(void)
{
  matrix.fillRect(18, 25, 8, 3, matrix.Color333(red, green, blue));
}

void zwoelfi(void)
{
  matrix.fillRect(5, 28, 12, 3, matrix.Color333(red, green, blue));
}


It would be awesome if i could get a tipp about whats the problem.
Im quite stuck at the moment.

Every help is deeply apprechiated!
Greetings from switzerland and thanks in advance!

Cheers Fabian :):)

Here is the discussion on the Arduino Forum.
https://forum.arduino.cc/index.php?topic=604825.msg4105484#msg4105484

: Moved by Moderator
Author: Fabian Müller (Guest)
Posted on:

Rate this post
0 useful
not useful
Sorry ich habe gerade gemerkt dass ich den Code als Datei angehängt 
haben sollte.
Tut mir leid, kann ich dies noch anpassen?

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig