Hier ist das Testprogramm dazu. Ich habe einfach nur ein paar Parameter am Programm geändert um nur diese zwei Funktionen aus dem Programm zu aktivieren. Ganz unten im Programm befindet sich der Loop, indem die Funktionen aufgerufen werden. Dort habe ich einige deaktiviert. Ich muss erst mal die Möglichkeiten der Lib. ausloten, dann mache ich mal bischen eigene Funktionen. Aber da muss ich mich jetzt erst mal damit bischen einarbeiten.
Code: Alles auswählen
/*
* SPI Schnittstelle Mega
* MOSI(Data) - pin 51
* MISO - pin 50
* CLK - pin 52
* CS - pin 53 (for MKRZero SD: SDCARD_SS_PIN)
*/
#include <MD_MAX72xx.h >
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTD(x) Serial.println(x, DEC)
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTD(x)
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN 52 // or SCK
#define DATA_PIN 51 // or MOSI
#define CS_PIN 53 // or SS
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
#define DELAYTIME 100 // in milliseconds
//###################################################################
void scrollText(char *p) { //----------Text scrollen-----------------
uint8_t charWidth;
uint8_t cBuf[8]; // Dies sollte für alle integrierten Schriftarten in Ordnung sein
PRINTS("\nScrolling text");
mx.clear();
while (*p != '\0') {
charWidth = mx.getChar(*p++, sizeof(cBuf) / sizeof(cBuf[0]), cBuf);
// Platz zwischen den Zeichen zulassen
for (uint8_t i=0; i<=charWidth; i++) {
mx.transform(MD_MAX72XX::TSL);
if (i < charWidth) {
mx.setColumn(0, cBuf[i]);
}
delay(DELAYTIME);
}
}
}
void rows() { //-----------------Reihen-------------------------------
mx.clear();
for (uint8_t row=0; row<ROW_SIZE; row++) {
mx.setRow(row, 0xff); delay(2*DELAYTIME);
mx.setRow(row, 0x00);
}
}
void columns() { //---------------Säulen------------------------------
mx.clear();
for (uint8_t col=0; col<mx.getColumnCount(); col++) {
mx.setColumn(col, 0xff); delay(DELAYTIME/MAX_DEVICES);
mx.setColumn(col, 0x00);
}
}
void stripe() {//------------------Streifen---------------------------
const uint16_t maxCol = MAX_DEVICES*ROW_SIZE;
const uint8_t stripeWidth = 10;
mx.clear();
for (uint16_t col=0; col<maxCol + ROW_SIZE + stripeWidth; col++) {
for(uint8_t row=0; row < ROW_SIZE; row++) {
mx.setPoint(row, col-row, true);
mx.setPoint(row, col-row - stripeWidth, false);
}
delay(DELAYTIME);
}
}
void spiral() {//-------------Spirale----------------------------
int rmin = 0, rmax = ROW_SIZE-1;
int cmin = 0, cmax = (COL_SIZE*MAX_DEVICES)-1;
mx.clear();
while ((rmax > rmin) && (cmax > cmin)) {
for (int i=cmin; i<=cmax; i++) { // do row
mx.setPoint(rmin, i, true); delay(DELAYTIME/MAX_DEVICES);
}
rmin++;
for (uint8_t i=rmin; i<=rmax; i++) { // do column
mx.setPoint(i, cmax, true); delay(DELAYTIME/MAX_DEVICES);
}
cmax--;
for (int i=cmax; i>=cmin; i--) { // do row
mx.setPoint(rmax, i, true); delay(DELAYTIME/MAX_DEVICES);
}
rmax--;
for (uint8_t i=rmax; i>=rmin; i--) { // do column
mx.setPoint(i, cmin, true); delay(DELAYTIME/MAX_DEVICES);
}
cmin++;
}
}
void bounce() {//-------------------Ball_Springt-----------------
const int minC = 0;
const int maxC = mx.getColumnCount()-1;
const int minR = 0;
const int maxR = ROW_SIZE-1;
int nCounter = 0;
int r = 0, c = 2;
int8_t dR = 1, dC = 1; // delta row and column
mx.clear();
while (nCounter++ < 60) { // Das war 200
mx.setPoint(r, c, false);
r += dR; c += dC;
mx.setPoint(r, c, true);
delay(DELAYTIME/2);
if ((r == minR) || (r == maxR)) {
dR = -dR;
}
if ((c == minC) || (c == maxC)) {
dC = -dC;
}
}
}
void intensity() { //-------------Intensität Steuern-------------
uint8_t row;
mx.clear();
for (int8_t i=0; i<=MAX_INTENSITY; i++) {
mx.control(MD_MAX72XX::INTENSITY, i);
mx.setRow(0, 0xff); delay(DELAYTIME*10);
}
mx.control(MD_MAX72XX::INTENSITY, 8);
}
void transformation() { //----------Pfeile scrollen---------------
uint8_t arrow[COL_SIZE] = {
0b00001000,
0b00011100,
0b00111110,
0b01111111,
0b00011100,
0b00011100,
0b00111110,
0b00000000 };
MD_MAX72XX::transformType_t t[] = {
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL, MD_MAX72XX::TSL,
MD_MAX72XX::TFLR,
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR, MD_MAX72XX::TSR,
MD_MAX72XX::TRC,
MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD,
MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD, MD_MAX72XX::TSD,
MD_MAX72XX::TFUD,
MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU,
MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU, MD_MAX72XX::TSU,
MD_MAX72XX::TINV,
MD_MAX72XX::TRC, MD_MAX72XX::TRC, MD_MAX72XX::TRC, MD_MAX72XX::TRC,
MD_MAX72XX::TINV };
mx.clear();
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
for (uint8_t j=0; j<mx.getDeviceCount(); j++) {
mx.setBuffer(((j+1)*COL_SIZE)-1, COL_SIZE, arrow);
}
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
delay(DELAYTIME);
mx.control(MD_MAX72XX::WRAPAROUND, MD_MAX72XX::ON);
// one tab
for (uint8_t i=0; i<(sizeof(t)/sizeof(t[0])); i++) {
mx.transform(t[i]); delay(DELAYTIME*4);
}
mx.control(MD_MAX72XX::WRAPAROUND, MD_MAX72XX::OFF);
}
void showCharset() { //-------------Zeichensatz anzeigen--------------
mx.clear();
mx.update(MD_MAX72XX::OFF);
for (uint16_t i=0; i<256; i++) {
mx.clear(0);
mx.setChar(COL_SIZE-1, i);
if (MAX_DEVICES >= 3) {
char hex[3]; //-------------------------????????????------------------
sprintf(hex, "%02X", i);
mx.clear(1); mx.setChar((2*COL_SIZE)-1, hex[1]);
mx.clear(2); mx.setChar((3*COL_SIZE)-1, hex[0]);
}
mx.update();
delay(DELAYTIME*6);//--------------War Mal 2 !!!!!!!!!!!!!!!!!!!!!!!!!
}
mx.update(MD_MAX72XX::ON);
}
//######################################################################
void setup() { mx.begin(); }
//######################################################################
void loop() {
scrollText("> Das ist ein Graphics scroll Test !! < ");
//rows();
//columns();
//stripe();
bounce(); // Ball springt durchs Display
//spiral(); // Spirale
//intensity();
//transformation();
//showCharset();
delay(30);
}
//--------------------------------LOOP ENDE-----------------------------
//######################################################################