INFO: Dieses Forum nutzt Cookies...
Cookies sind für den Betrieb des Forums unverzichtbar. Mit der Nutzung des Forums erklärst Du dich damit einverstanden, dass wir Cookies verwenden.

Es wird in jedem Fall ein Cookie gesetzt um diesen Hinweis nicht mehr zu erhalten. Desweiteren setzen wir Google Adsense und Google Analytics ein.

Antwort schreiben 
 
Themabewertung:
  • 0 Bewertungen - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
3 Stück LED 8x8 Matrix via Array ansteuern
08.10.2017, 18:35
Beitrag #1
3 Stück LED 8x8 Matrix via Array ansteuern
Hallo,

hab ein kleines Verständnisproblem.

Ich habe einen Arduino UNO R3 und an diesem sind 3 (BiColor) 8x8 LED Matrix-Panele angesteckt.
Jedes Panel hat seine eigene Adresse (0x70,0x71,0x72).
Das ansteuern klappt, kann auf allen etwas darstellen.
Bin diesem Tutorial gefolgt:
https://learn.adafruit.com/animating-mul...s/software

Jetzt blick ich aber am Schluss nicht wie die eine Bitmap (mouthImg[][24] =) auf drei Panele bekommen haben.
Mein Sketch sieht so weit so aus:
Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

Adafruit_BicolorMatrix matrix[4] = Adafruit_BicolorMatrix();

void setup() {
  Serial.begin(9600);
  Serial.println("8x8 LED Matrix Test");

   for(uint8_t i=0; i<3; i++) {
   matrix[i].begin(0x70 + i);
  }
}

static const uint8_t PROGMEM
  test[][24] = {                
  { B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B01111111, B11111111, B11111110,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000 },
  };

void loop() {
for(uint8_t i=0;i<3;i++){
  matrix[i+1].clear();
  matrix[i+1].drawBitmap(i * -8, 0, test, 24, 8, LED_GREEN);
  matrix[i+1].writeDisplay();
  delay(500);

  }
}

Als Fehlermeldung kommt folgendes:
Code:
Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Benno\Desktop\Neuer Ordner (2)\_1\_1.ino: In function 'void loop()':

_1:31: error: no matching function for call to 'Adafruit_BicolorMatrix::drawBitmap(int, int, const uint8_t [1][24], int, int, int)'

   matrix[i+1].drawBitmap(i * -8, 0, test, 24, 8, LED_GREEN);

                                                           ^

C:\Users\Benno\Desktop\Neuer Ordner (2)\_1\_1.ino:31:59: note: candidates are:

In file included from C:\Users\Benno\Desktop\Neuer Ordner (2)\_1\_1.ino:2:0:

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:67:5: note: void Adafruit_GFX::drawBitmap(int16_t, int16_t, const uint8_t*, int16_t, int16_t, uint16_t)

     drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],

     ^

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:67:5: note:   no known conversion for argument 3 from 'const uint8_t [1][24] {aka const unsigned char [1][24]}' to 'const uint8_t* {aka const unsigned char*}'

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:69:5: note: void Adafruit_GFX::drawBitmap(int16_t, int16_t, const uint8_t*, int16_t, int16_t, uint16_t, uint16_t)

     drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],

     ^

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:69:5: note:   candidate expects 7 arguments, 6 provided

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:71:5: note: void Adafruit_GFX::drawBitmap(int16_t, int16_t, uint8_t*, int16_t, int16_t, uint16_t)

     drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,

     ^

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:71:5: note:   no known conversion for argument 3 from 'const uint8_t [1][24] {aka const unsigned char [1][24]}' to 'uint8_t* {aka unsigned char*}'

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:73:5: note: void Adafruit_GFX::drawBitmap(int16_t, int16_t, uint8_t*, int16_t, int16_t, uint16_t, uint16_t)

     drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,

     ^

C:\Users\Benno\Documents\Arduino\libraries\Adafruit-GFX-Library-master/Adafruit_GFX.h:73:5: note:   candidate expects 7 arguments, 6 provided

exit status 1
no matching function for call to 'Adafruit_BicolorMatrix::drawBitmap(int, int, const uint8_t [1][24], int, int, int)'

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.

Was genau läuft falsch und wie kann ich die LED Panele mit einem Bitmap zum laufen bringen anstatt drei?

Schon mal Danke
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
08.10.2017, 18:47
Beitrag #2
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
Vergleiche mal Deinen Aufruf von drawBitmap im Sletch mit der Headerdatei Adafruit_LEDBackpack.h oder Adafruit_GFX.h

Gruß Tommy

"Wer den schnellen Erfolg sucht, sollte nicht programmieren, sondern Holz hacken." (Quelle unbekannt)
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
08.10.2017, 19:31
Beitrag #3
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
(08.10.2017 18:47)Tommy56 schrieb:  Vergleiche mal Deinen Aufruf von drawBitmap im Sletch mit der Headerdatei Adafruit_LEDBackpack.h oder Adafruit_GFX.h

Gruß Tommy

Ehrlich gesagt sehen meine ungeschulten Augen keine Unstimmigkeiten.
Ich wüsste nciht was ich anders machen müsste.
Hier mal die Adafruit_GFX.h:
Code:
#ifndef _ADAFRUIT_GFX_H
#define _ADAFRUIT_GFX_H

#if ARDUINO >= 100
#include "Arduino.h"
#include "Print.h"
#else
#include "WProgram.h"
#endif
#include "gfxfont.h"

class Adafruit_GFX : public Print {

public:

  Adafruit_GFX(int16_t w, int16_t h); // Constructor

  // This MUST be defined by the subclass:
  virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;

  // TRANSACTION API / CORE DRAW API
  // These MAY be overridden by the subclass to provide device-specific
  // optimized code.  Otherwise 'generic' versions are used.
  virtual void startWrite(void);
  virtual void writePixel(int16_t x, int16_t y, uint16_t color);
  virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
  virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
  virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
  virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
  virtual void endWrite(void);

  // CONTROL API
  // These MAY be overridden by the subclass to provide device-specific
  // optimized code.  Otherwise 'generic' versions are used.
  virtual void setRotation(uint8_t r);
  virtual void invertDisplay(boolean i);

  // BASIC DRAW API
  // These MAY be overridden by the subclass to provide device-specific
  // optimized code.  Otherwise 'generic' versions are used.
  virtual void
    // It's good to implement those, even if using transaction API
    drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
    drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
    fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
    fillScreen(uint16_t color),
    // Optional and probably not necessary to change
    drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
    drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);

  // These exist only with Adafruit_GFX (no subclass overrides)
  void
    drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
    drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
      uint16_t color),
    fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
    fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
      int16_t delta, uint16_t color),
    drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
      int16_t x2, int16_t y2, uint16_t color),
    fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
      int16_t x2, int16_t y2, uint16_t color),
    drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
      int16_t radius, uint16_t color),
    fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
      int16_t radius, uint16_t color),
    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h),
    drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h),
    drawGrayscaleBitmap(int16_t x, int16_t y,
      const uint8_t bitmap[], const uint8_t mask[],
      int16_t w, int16_t h),
    drawGrayscaleBitmap(int16_t x, int16_t y,
      uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
      int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,
      int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y,
      const uint16_t bitmap[], const uint8_t mask[],
      int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y,
      uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
    drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
      uint16_t bg, uint8_t size),
    setCursor(int16_t x, int16_t y),
    setTextColor(uint16_t c),
    setTextColor(uint16_t c, uint16_t bg),
    setTextSize(uint8_t s),
    setTextWrap(boolean w),
    cp437(boolean x=true),
    setFont(const GFXfont *f = NULL),
    getTextBounds(char *string, int16_t x, int16_t y,
      int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
    getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
      int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);

#if ARDUINO >= 100
  virtual size_t write(uint8_t);
#else
  virtual void   write(uint8_t);
#endif

  int16_t height(void) const;
  int16_t width(void) const;

  uint8_t getRotation(void) const;

  // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y)
  int16_t getCursorX(void) const;
  int16_t getCursorY(void) const;

protected:
  void
    charBounds(char c, int16_t *x, int16_t *y,
      int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy);
  const int16_t
    WIDTH, HEIGHT;   // This is the 'raw' display w/h - never changes
  int16_t
    _width, _height, // Display w/h as modified by current rotation
    cursor_x, cursor_y;
  uint16_t
    textcolor, textbgcolor;
  uint8_t
    textsize,
    rotation;
  boolean
    wrap,   // If set, 'wrap' text at right edge of display
    _cp437; // If set, use correct CP437 charset (default is off)
  GFXfont
    *gfxFont;
};

class Adafruit_GFX_Button {

public:
  Adafruit_GFX_Button(void);
  // "Classic" initButton() uses center & size
  void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
   uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
   uint16_t textcolor, char *label, uint8_t textsize);
  // New/alt initButton() uses upper-left corner & size
  void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1,
   uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
   uint16_t textcolor, char *label, uint8_t textsize);
  void drawButton(boolean inverted = false);
  boolean contains(int16_t x, int16_t y);

  void press(boolean p);
  boolean isPressed();
  boolean justPressed();
  boolean justReleased();

private:
  Adafruit_GFX *_gfx;
  int16_t       _x1, _y1; // Coordinates of top-left corner
  uint16_t      _w, _h;
  uint8_t       _textsize;
  uint16_t      _outlinecolor, _fillcolor, _textcolor;
  char          _label[10];

  boolean currstate, laststate;
};

class GFXcanvas1 : public Adafruit_GFX {
public:
  GFXcanvas1(uint16_t w, uint16_t h);
  ~GFXcanvas1(void);
  void     drawPixel(int16_t x, int16_t y, uint16_t color),
           fillScreen(uint16_t color);
  uint8_t *getBuffer(void);
private:
  uint8_t *buffer;
};

class GFXcanvas8 : public Adafruit_GFX {
public:
  GFXcanvas8(uint16_t w, uint16_t h);
  ~GFXcanvas8(void);
  void     drawPixel(int16_t x, int16_t y, uint16_t color),
           fillScreen(uint16_t color),
           writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);

  uint8_t *getBuffer(void);
private:
  uint8_t *buffer;
};

class GFXcanvas16 : public Adafruit_GFX {
public:
  GFXcanvas16(uint16_t w, uint16_t h);
  ~GFXcanvas16(void);
  void      drawPixel(int16_t x, int16_t y, uint16_t color),
            fillScreen(uint16_t color);
  uint16_t *getBuffer(void);
private:
  uint16_t *buffer;
};

#endif // _ADAFRUIT_GFX_H

Ich hab den Teil der den Fehler liefert aus einem anderen Sketch übernommen und für meine Zwecke abgeleitet.
Das andere Sketch hat die gleichen Komponenten und bewirkt das gleiche, bitmap auf 3 LED Matrixe.
Hier mal der Sketch:
Code:
// 'wavface' example sketch for Adafruit I2C 8x8 LED backpacks
// and Wave Shield:
//
//  www.adafruit.com/products/870   www.adafruit.com/products/1049
//  www.adafruit.com/products/871   www.adafruit.com/products/1050
//  www.adafruit.com/products/872   www.adafruit.com/products/1051
//  www.adafruit.com/products/959   www.adafruit.com/products/1052
//                  www.adafruit.com/products/94
//
// Requires Adafruit_LEDBackpack, Adafruit_GFX libraries and WaveHC
// libraries.
//
// This sketch shows animation roughly synchronized to prerecorded
// speech.  It's fairly complex and may be overwhelming to novice
// programmers, who may want to start with the 'matrix8x8' example
// and then 'roboface' before working through this code.  Also, much
// of the comments relating to the face animation have been stripped
// here for brevity...refer to the 'roboface' sketch if you have any
// questions how that part works.
//
// Additional hardware required: sounds are triggered using three
// normally-open momentary buttons connected to Digital pins 6, 7, 8
// and GND. (e.g. www.adafruit.com/products/1009 )
//
// Adafruit invests time and resources providing this open source code,
// please support Adafruit and open-source hardware by purchasing
// products from Adafruit!
//
// Written by P. Burgess for Adafruit Industries, parts adapted from
// 'PiSpeakHC' sketch included with WaveHC library.
// BSD license, all text above must be included in any redistribution.

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <WaveHC.h>
#include <WaveUtil.h>
#include "Adafruit_LEDBackpack.h"

// These WAV files should be in the root level of the SD card:
static const char PROGMEM
  wav0[] = "beware_i.wav",
  wav1[] = "ihunger.wav",
  wav2[] = "run_cowd.wav";
static const char * const wavname[] PROGMEM = { wav0, wav1, wav2 };
// PROGMEM makes frequent appearances throughout this code, reason being that
// the SD card library requires gobs of precious RAM (leaving very little to
// our own sketch).  PROGMEM lets us put fixed data into program flash memory,
// which is considerably more spacious.  String tables are paritcularly nasty.
// See www.arduino.cc/en/Reference/PROGMEM for more info.

SdReader  card; // This object holds the information for the card
FatVolume vol;  // This holds the information for the partition on the card
FatReader root; // This holds the information for the volumes root directory
FatReader file; // This object represent the WAV file for a phrase
WaveHC    wave; // A single wave object -- only one sound is played at a time

// Because the two eye matrices share the same address, only four
// matrix objects are needed for the five displays:
#define MATRIX_EYES         0
#define MATRIX_MOUTH_LEFT   1
#define MATRIX_MOUTH_MIDDLE 2
#define MATRIX_MOUTH_RIGHT  3
Adafruit_8x8matrix matrix[4] = { // Array of Adafruit_8x8matrix objects
  Adafruit_8x8matrix(), Adafruit_8x8matrix(),
  Adafruit_8x8matrix(), Adafruit_8x8matrix() };

// Rather than assigning matrix addresses sequentially in a loop, each
// has a spot in this array.  This makes it easier if you inadvertently
// install one or more matrices in the wrong physical position --
// re-order the addresses in this table and you can still refer to
// matrices by index above, no other code or wiring needs to change.
static const uint8_t PROGMEM matrixAddr[] = { 0x70, 0x71, 0x72, 0x73 };

static const uint8_t PROGMEM // Bitmaps are stored in program memory
  blinkImg[][8] = {    // Eye animation frames
  { B00111100,         // Fully open eye
    B01111110,
    B11111111,
    B11111111,
    B11111111,
    B11111111,
    B01111110,
    B00111100 },
  { B00000000,
    B01111110,
    B11111111,
    B11111111,
    B11111111,
    B11111111,
    B01111110,
    B00111100 },
  { B00000000,
    B00000000,
    B00111100,
    B11111111,
    B11111111,
    B11111111,
    B00111100,
    B00000000 },
  { B00000000,
    B00000000,
    B00000000,
    B00111100,
    B11111111,
    B01111110,
    B00011000,
    B00000000 },
  { B00000000,         // Fully closed eye
    B00000000,
    B00000000,
    B00000000,
    B10000001,
    B01111110,
    B00000000,
    B00000000 } },
  mouthImg[][24] = {                 // Mouth animation frames
  { B00000000, B00000000, B00000000, // Mouth position A
    B00000000, B00000000, B00000000,
    B01111111, B11111111, B11111110,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000 },
  { B00000000, B00000000, B00000000, // Mouth position B
    B00000000, B00000000, B00000000,
    B00111111, B11111111, B11111100,
    B00000111, B00000000, B11100000,
    B00000000, B11111111, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000 },
  { B00000000, B00000000, B00000000, // Mouth position C
    B00000000, B00000000, B00000000,
    B00111111, B11111111, B11111100,
    B00001000, B00000000, B00010000,
    B00000110, B00000000, B01100000,
    B00000001, B11000011, B10000000,
    B00000000, B00111100, B00000000,
    B00000000, B00000000, B00000000 },
  { B00000000, B00000000, B00000000, // Mouth position D
    B00000000, B00000000, B00000000,
    B00111111, B11111111, B11111100,
    B00100000, B00000000, B00000100,
    B00010000, B00000000, B00001000,
    B00001100, B00000000, B00110000,
    B00000011, B10000001, B11000000,
    B00000000, B01111110, B00000000 },
  { B00000000, B00000000, B00000000, // Mouth position E
    B00000000, B00111100, B00000000,
    B00011111, B11000011, B11111000,
    B00000011, B10000001, B11000000,
    B00000000, B01111110, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000 },
  { B00000000, B00111100, B00000000, // Mouth position F
    B00000000, B11000011, B00000000,
    B00001111, B00000000, B11110000,
    B00000001, B00000000, B10000000,
    B00000000, B11000011, B00000000,
    B00000000, B00111100, B00000000,
    B00000000, B00000000, B00000000,
    B00000000, B00000000, B00000000 } };

// Animation sequences corresponding to each WAV.  First number in
// each pair is a mouth bitmap index.  Second number is the hold
// time (in frames).  255 marks end of list.
// There is no 'magic' here, the software is NOT deriving mouth
// position from the sound...the tables were determined by hand,
// just as animators do it.  Further explanation here:
// http://www.idleworm.com/how/anm/03t/talk1.shtml

static const uint8_t PROGMEM
  seq1[] = { 0, 2,   2, 5,   5, 3,   3, 7, // "Beware, I live!"
             4, 5,   3, 4,   2, 5,   4, 3,
             3, 4,   1, 5,   3, 5,    255 },
  seq2[] = { 0, 1,   3, 5,   1, 5,   4, 2, // "I hunger!"
             3, 2,   1, 2,   4, 4,   1, 3,
             4, 2,   255 },
  seq3[] = { 0, 1,   1, 2,   3, 6,   2, 5, // "Run, coward!"
             0, 1,   4, 4,   5, 2,   1, 5,
             3, 6,   1, 4,    255 };
static const uint8_t * const anim[] = { seq1, seq2, seq3 };

const uint8_t
  blinkIndex[] PROGMEM = { 1, 2, 3, 4, 3, 2, 1 }; // Blink bitmap sequence
uint8_t
  blinkCountdown = 100, // Countdown to next blink (in frames)
  gazeCountdown  =  75, // Countdown to next eye movement
  gazeFrames     =  50, // Duration of eye movement (smaller = faster)
  mouthPos       =   0, // Current image number for mouth
  mouthCountdown =  10, // Countdown to next mouth change
  newPos         = 255, // New mouth position for current frame
  *seq,                 // Animation sequence currently being played back
  idx,                  // Current array index within animation sequence
  prevBtn        = 99,  // Button # pressed on last loop() iteration
  btnCount       = 0;   // Number of iterations same button has been held
int8_t
  eyeX = 3, eyeY = 3,   // Current eye position
  newX = 3, newY = 3,   // Next eye position
  dX   = 0, dY   = 0;   // Distance from prior to new position

void setup() {

  Serial.begin(9600);          
  
  Serial.println(F("WAV face"));
  
  if(!card.init())        Serial.println(F("Card init. failed!"));
  if(!vol.init(card))     Serial.println(F("No partition!"));
  if(!root.openRoot(vol)) Serial.println(F("Couldn't open dir"));
  Serial.println(F("Files found:"));
  root.ls();

  // Seed random number generator from an unused analog input:
  randomSeed(analogRead(A0));

  // Initialize each matrix object:
  for(uint8_t i=0; i<4; i++) {
    matrix[i].begin(pgm_read_byte(&matrixAddr[i]));
    // If using 'small' (1.2") displays vs. 'mini' (0.8"), enable this:
    // matrix[i].setRotation(3);
  }

  // Enable pull-up resistors on three button inputs.
  // Other end of each button then connects to GND.
  for(uint8_t i=6; i<=8; i++) {
    pinMode(i, INPUT);
    digitalWrite(i, HIGH); // Enable pullup
  }
}

void loop() {

  uint8_t i;

  // Draw eyeball in current state of blinkyness (no pupil).
  matrix[MATRIX_EYES].clear();
  matrix[MATRIX_EYES].drawBitmap(0, 0,
    blinkImg[
      (blinkCountdown < sizeof(blinkIndex)) ?      // Currently blinking?
      pgm_read_byte(&blinkIndex[blinkCountdown]) : // Yes, look up bitmap #
      0                                            // No, show bitmap 0
    ], 8, 8, LED_ON);
  // Decrement blink counter.  At end, set random time for next blink.
  if(--blinkCountdown == 0) blinkCountdown = random(5, 180);

  if(--gazeCountdown <= gazeFrames) {
    // Eyes are in motion - draw pupil at interim position
    matrix[MATRIX_EYES].fillRect(
      newX - (dX * gazeCountdown / gazeFrames),
      newY - (dY * gazeCountdown / gazeFrames),
      2, 2, LED_OFF);
    if(gazeCountdown == 0) {    // Last frame?
      eyeX = newX; eyeY = newY; // Yes.  What's new is old, then...
      do { // Pick random positions until one is within the eye circle
        newX = random(7); newY = random(7);
        dX   = newX - 3;  dY   = newY - 3;
      } while((dX * dX + dY * dY) >= 10);      // Thank you Pythagoras
      dX            = newX - eyeX;             // Horizontal distance to move
      dY            = newY - eyeY;             // Vertical distance to move
      gazeFrames    = random(3, 15);           // Duration of eye movement
      gazeCountdown = random(gazeFrames, 120); // Count to end of next movement
    }
  } else {
    // Not in motion yet -- draw pupil at current static position
    matrix[MATRIX_EYES].fillRect(eyeX, eyeY, 2, 2, LED_OFF);
  }

  // Scan buttons 6, 7, 8 looking for first button pressed...
  for(i=0; (i<3) && (digitalRead(i+6) == HIGH); i++);

  if(i < 3) {               // Anything pressed?  Yes!
    if(i == prevBtn) {      // Same as last time we checked?  Good!
      if(++btnCount == 3) { // 3 passes to 'debounce' button input
        playfile((char *)pgm_read_word(&wavname[i])); // Start WAV
        // Look up animation sequence # corresponding to this WAV...
        seq            = (uint8_t *)pgm_read_word(&anim[i]);
        idx            = 0; // Begin at first byte of data
        newPos         = pgm_read_byte(&seq[idx++]); // Initial mouth pos
        mouthCountdown = pgm_read_byte(&seq[idx++]); // Hold time for pos
      }
    } else btnCount = 0; // Different button than before - start count over
    prevBtn = i;
  } else prevBtn = 99;   // No buttons pressed

  if(newPos != 255) { // Is the mouth in motion?
    if(--mouthCountdown == 0) { // Count down frames to next position
      newPos = pgm_read_byte(&seq[idx++]); // New mouth position
      if(newPos == 255) { // End of list?
        mouthPos = 0;     // Yes, set mouth to neutral position
      } else {
        mouthPos       = newPos; // Set mouth to new position
        mouthCountdown = pgm_read_byte(&seq[idx++]); // Read hold time
      }
    }
  } else mouthPos = 0; // Mouth not in motion -- set to neutral position

  drawMouth(mouthImg[mouthPos]);

  // Refresh all matrices in one quick pass
  for(uint8_t i=0; i<4; i++) matrix[i].writeDisplay();

  delay(20);
}

// Draw mouth image across three adjacent displays
void drawMouth(const uint8_t *img) {
  for(uint8_t i=0; i<3; i++) {
    matrix[MATRIX_MOUTH_LEFT + i].clear();
    matrix[MATRIX_MOUTH_LEFT + i].drawBitmap(i * -8, 0, img, 24, 8, LED_ON);
  }
}

// Open and start playing a WAV file
void playfile(const char *name) {
  char filename[13]; // 8.3+NUL

  if(wave.isplaying) wave.stop(); // Stop any currently-playing WAV

  strcpy_P(filename, name); // Copy name out of PROGMEM into RAM

  if(!file.open(root, filename)) {
    Serial.print(F("Couldn't open file "));
    Serial.println(filename);
    return;
  }
  if(!wave.create(file)) {
    Serial.println(F("Not a valid WAV"));
    return;
  }
  wave.play();
}

Bin grad echt am Verzweifeln weil das nach meiner Terminierung heute schon hätte klappen sollen Sad
Will ja auch nur verstehen wie ich die Funktion mit Arrays anwenden kann damit ein Bitmap auf drei LED Matrixe angezeigt wird.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
08.10.2017, 19:43
Beitrag #4
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
Wie sieht den diue drawBitmap-Funktion/Methode in der Lib aus und wie rufst Du sie auf?

Lib:
Code:
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
Dein Aufruf:
Code:
matrix[i+1].drawBitmap(i * -8, 0, test, 24, 8, LED_GREEN);
Wo ist LED_GREEN definiert?
test liegt im PROGMEM. Das kann die Lib nicht.

Gruß Tommy

"Wer den schnellen Erfolg sucht, sollte nicht programmieren, sondern Holz hacken." (Quelle unbekannt)
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
08.10.2017, 20:07
Beitrag #5
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
(08.10.2017 19:43)Tommy56 schrieb:  Wie sieht den diue drawBitmap-Funktion/Methode in der Lib aus und wie rufst Du sie auf?

Lib:
Code:
drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
Dein Aufruf:
Code:
matrix[i+1].drawBitmap(i * -8, 0, test, 24, 8, LED_GREEN);
Wo ist LED_GREEN definiert?
test liegt im PROGMEM. Das kann die Lib nicht.

Gruß Tommy

LED_GREEN wird in der Adafruit_LEDBackpack.h definiert.

Code:
/***************************************************
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED Matrix backpacks
  ----> http://www.adafruit.com/products/
  ----> http://www.adafruit.com/products/

  These displays use I2C to communicate, 2 pins are required to
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  MIT license, all text above must be included in any redistribution
****************************************************/
#ifndef Adafruit_LEDBackpack_h
#define Adafruit_LEDBackpack_h

#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif


#include <Wire.h>

#include "Adafruit_GFX.h"

#define LED_ON 1
#define LED_OFF 0

#define LED_RED 1
#define LED_YELLOW 2
#define LED_GREEN 3



#define HT16K33_BLINK_CMD 0x80
#define HT16K33_BLINK_DISPLAYON 0x01
#define HT16K33_BLINK_OFF 0
#define HT16K33_BLINK_2HZ  1
#define HT16K33_BLINK_1HZ  2
#define HT16K33_BLINK_HALFHZ  3

#define HT16K33_CMD_BRIGHTNESS 0xE0

#define SEVENSEG_DIGITS 5


// this is the raw HT16K33 controller
class Adafruit_LEDBackpack {
public:
  Adafruit_LEDBackpack(void);
  void begin(uint8_t _addr);
  void setBrightness(uint8_t b);
  void blinkRate(uint8_t b);
  void writeDisplay(void);
  void clear(void);

  uint16_t displaybuffer[8];

  void init(uint8_t a);
protected:
  uint8_t i2c_addr;
};

class Adafruit_AlphaNum4 : public Adafruit_LEDBackpack {
public:
  Adafruit_AlphaNum4(void);

  void writeDigitRaw(uint8_t n, uint16_t bitmask);
  void writeDigitAscii(uint8_t n, uint8_t ascii, boolean dot = false);

private:


};

class Adafruit_24bargraph : public Adafruit_LEDBackpack {
public:
  Adafruit_24bargraph(void);

  void setBar(uint8_t bar, uint8_t color);

private:
};


class Adafruit_8x16matrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
  Adafruit_8x16matrix(void);

  void drawPixel(int16_t x, int16_t y, uint16_t color);

private:
};

class Adafruit_8x16minimatrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
  Adafruit_8x16minimatrix(void);

  void drawPixel(int16_t x, int16_t y, uint16_t color);

private:
};

class Adafruit_8x8matrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
  Adafruit_8x8matrix(void);

  void drawPixel(int16_t x, int16_t y, uint16_t color);

private:
};

class Adafruit_BicolorMatrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
public:
  Adafruit_BicolorMatrix(void);

  void drawPixel(int16_t x, int16_t y, uint16_t color);

private:
};


#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0

class Adafruit_7segment : public Adafruit_LEDBackpack {
public:
  Adafruit_7segment(void);
  size_t write(uint8_t c);

  void print(char, int = BYTE);
  void print(unsigned char, int = BYTE);
  void print(int, int = DEC);
  void print(unsigned int, int = DEC);
  void print(long, int = DEC);
  void print(unsigned long, int = DEC);
  void print(double, int = 2);
  void println(char, int = BYTE);
  void println(unsigned char, int = BYTE);
  void println(int, int = DEC);
  void println(unsigned int, int = DEC);
  void println(long, int = DEC);
  void println(unsigned long, int = DEC);
  void println(double, int = 2);
  void println(void);
  
  void writeDigitRaw(uint8_t x, uint8_t bitmask);
  void writeDigitNum(uint8_t x, uint8_t num, boolean dot = false);
  void drawColon(boolean state);
  void printNumber(long, uint8_t = 2);
  void printFloat(double, uint8_t = 2, uint8_t = DEC);
  void printError(void);

  void writeColon(void);
    
private:
  uint8_t position;
};
#endif // Adafruit_LEDBackpack_h
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
08.10.2017, 20:37
Beitrag #6
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
Was ist mit PROGMEM?

Gruß Tommy

"Wer den schnellen Erfolg sucht, sollte nicht programmieren, sondern Holz hacken." (Quelle unbekannt)
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
09.10.2017, 06:32
Beitrag #7
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
(08.10.2017 20:37)Tommy56 schrieb:  Was ist mit PROGMEM?

Gruß Tommy

Ich wüsste nicht warum PROGMEM das nicht können sollte, immerhin wird das bitmap im beispiel sketch (siehe oben) auch im Flashspeicher abgelegt. Huh
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
09.10.2017, 11:12
Beitrag #8
RE: 3 Stück LED 8x8 Matrix via Array ansteuern
Probier mal test[0] anstelle von test.

Gruß Tommy

"Wer den schnellen Erfolg sucht, sollte nicht programmieren, sondern Holz hacken." (Quelle unbekannt)
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
Antwort schreiben 


Möglicherweise verwandte Themen...
Thema: Verfasser Antworten: Ansichten: Letzter Beitrag
Sad Arduino Matrix Led Laufschrift fehlkauf_1234 4 321 26.10.2018 17:13
Letzter Beitrag: Chopp
  array aus Methode/Funktion sepp01 3 230 14.10.2018 19:16
Letzter Beitrag: Tommy56
  [gelöst]String, char .... ich begreife es einfach nicht - char Array <> mit SDexist christian@schiltkamp.info 10 934 31.08.2018 23:05
Letzter Beitrag: Tommy56
  900 WS2812 ansteuern b_mertke 6 622 31.08.2018 12:45
Letzter Beitrag: Hilgi
  Array mit 433MHz-Modul versenden Matthias_Arduino 14 922 22.08.2018 15:20
Letzter Beitrag: hotsystems
  Menu mit char*Array TKRoth 7 809 01.05.2018 21:02
Letzter Beitrag: MicroBahner
  Led Matrix dani1994 3 587 03.03.2018 12:44
Letzter Beitrag: hotsystems
  SSR (Solid State Relais) mit PID-Regler ansteuern pernschi 10 1.668 05.01.2018 15:13
Letzter Beitrag: hotsystems
Question Relais in Reihenfolge ansteuern. Jonas Lindenblatt 32 3.484 27.12.2017 12:40
Letzter Beitrag: MiReu
  String nach Byte Array in ASCII-Codierung nexus1212 7 1.567 05.11.2017 14:36
Letzter Beitrag: Tommy56

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste