[Conseil] Arduino + 5 x AS1107 + 5 x matrice 8x8

Bonjour,
Tout nouveau sur le forum, j’essaie de faire un petit projet avec mon fils de 10 ans.
Pour le moment j’ai reussi le basique de l’arduino,allumer une led. On a reussi a faire un chenillard, bref que des choses hyper simples.

J’ai un arduino mega 2560 et je me sers de l’application arduino pour saisir les codes.

donc pour en arriver a ma demande de conseil, j’ai trouvé sur un wiki des informations concernant le multiplexage pour piloter des matrices de leds. Au debut je voulais utilisé un MAX7221, mais j’ai trouvé le AS1107 qui à les mêmes fonctions et est moins chers.
Je ne vous cacherais pas non plus que je ne connais pas grand chose au C, je connais les bases rudimentaires. mais la j’ai un problème que je ne sais pas résoudre.
voici mon code et la librairie que j’utilise :

La librairie
AS1107.h

/*
   AS1107.h - Library for interfacing the AS1107 LED Driver Chip
   Created by Stephan Elsner 2011
   version 0.82

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef AS1107_h
#define AS1107_h

#include "WProgram.h"
#include <avr/pgmspace.h>

#define ON 1
#define OFF 0


// --------------------------------------------------------------------------------------------------------------------------
 class AS1107
{
   public:
     AS1107(byte cspin, byte clkpin, byte datapin);
     void WriteRegister2(byte chip, byte reg, byte data);
     void WriteRegister(byte chip, byte reg, byte data);
     void WriteColumn( byte column, byte data);
     void Init(byte *buffer);
     void SetBuffer(byte *buffer);
     void SetLed(int x, int y, byte value);
     void Clear();
     void Update();
     void ShiftLeft();
     void ShiftRight();
     void ShiftUp();
     void ShiftDown();
     void ShiftUp(byte from, byte to);
     void ShiftDown(byte from, byte to);
     void DrawLine(int x0, int y0, int x1, int y1);
     void DrawBox(int x0, int y0, int x1, int y1);
     void DrawEllipse(int xm, int ym, int a, int b);
     void SetScrollText(char *string, int charspacing);
     void DrawText (int x, int y, char *str);
     byte DrawChar (int x, int y, char thechar);

     boolean TextScroll();

     // ***************************************
     // Set your module configuration here
     // ***************************************
     static const byte Maxx=39;      // maximum x - Pixels of the Module
     static const byte Maxy=7;         // maximum y - Pixels of the Module
     static const byte HighestCtrlNum=4; // Number of Matrix modules -1 (0 = single module)

   private:
     byte _cspin;
     byte _clkpin;
     byte _datapin;
     byte *_buffer;                    // pointer to current screen buffer

     static const byte _repcharoff;    // Offset of the replacement for unknown characers
     int  _charoffset[82];             // Start position in Array
     char *_outputstring;              // pointer to start of output string
     char *_curchr;                    // pointer to current char of output String
     int _fontidx;                     // current byte in font to display
     int _colct;                       // to count the columns of character to display
     byte _charspacing;                // the coulumns of space between characters
     boolean _hastext;

     void SetLedInternal(byte x, byte y, byte value);
     boolean NextCharacter();
     void CalculateCharOffsets();
     byte GetInternalCharCode(byte thechar);
};

// --------------------------------------------------------------------------------------------------------------------------
// AS1107-Register
 class Registers
{
   public:
     static const byte NoOp   = 0x00;
     static const byte Digit0 = 0x01;
     static const byte Digit1 = 0x02;
     static const byte Digit2 = 0x03;
     static const byte Digit3 = 0x04;
     static const byte Digit4 = 0x05;
     static const byte Digit5 = 0x06;
     static const byte Digit6 = 0x07;
     static const byte Digit7 = 0x08;
     static const byte DecodeMode = 0x09;
     static const byte IntensityControl = 0x0A;
     static const byte ScanLimit = 0x0B;
     static const byte Shutdown = 0x0C;
     static const byte Feature = 0x0E;
     static const byte DisplayTest = 0x0F;
};

// --------------------------------------------------------------------------------------------------------------------------
// Values to write to the Shutdown Register
 class ShutdownModes
{
   public:
     static const byte ShutdownResetFeature = 0x00;  // Shutdown Mode, Reset Feature Register to Default Settings
     static const byte Shutdown             = 0x80;  // Shutdown Mode, leaving Feature Register unchanged
     static const byte NormalResetFeature   = 0x01;  // Normal Mode, Reset Feature
     static const byte Normal               = 0x81;  // Normal Mode, Feature unchanged
};

// Bits in the feature-Register, desired Settings must be OR'ed together
 class Features
{
   public:
     static const byte ExternalClock        = 0x01;  // ExternalClock active
     static const byte ResetRegisters       = 0x02;  // Resets all control registers except the Feature Register.
     static const byte HexDecoding          = 0x04;  // 1 = Enable HEX decoding, 0 = Enable Code-B decoding
     static const byte SPIEnable            = 0x08;  // Enables the SPI-compatible interface.(AS1106 only).
     static const byte BlinkEnable          = 0x10;  // Enables blinking.
     static const byte BlinkSlow            = 0x20;  // Sets blink with low frequency
                                                     // (with the internal oscillator enabled)

     static const byte BlinkSync            = 0x40;  // Synchronizes blinking on the rising edge of pin LOAD/CSN.
                                                     // The multiplex and blink timing counter is cleared on the
                                                     // rising edge of pin LOAD/CSN. By setting this bit in
                                                     // multiple AS1106/AS1107 devices, the blink timing can
                                                     // be synchronized across all the devices.

     static const byte BlinkStartWithOn     = 0x80;  // Start Blinking with display enabled phase.
                                                     // When bit D4 (blink_en) is set, bit D7
                                                     // determines how blinking starts.
                                                     // 0 = Blinking starts with the display turned off.
                                                     // 1 = Blinking starts with the display turned on.
};

#endif

la suite au message suivant :wink:

la suite.
AS1107.cpp (attention elle est coupée en 2 +de 9500 caractères)

/*
   AS1107.cpp - Library for interfacing the AS1107 LED Driver Chip
   Created by Stephan Elsner, March 29, 2011

   Scrolltext uses a proportional character font
   Tested with Arduino Duemilenove
   version 0.82

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version. 

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
#include <avr/pgmspace.h>
#include "WProgram.h"
#include "AS1107.h"

const byte AS1107::_repcharoff  = 27;

// Font Data
 PROGMEM prog_uchar _font[] = {
     // -------- Space
     0b00000000,
     0b00000000,
     0b00000000,
     0b00000000,
     // -------- A
     0b01111110,
     0b10010000,
     0b10010000,
     0b01111110,
     // -------- B
     0b01101100,
     0b10010010,
     0b10010010,
     0b11111110,
     // -------- C
     0b10000010,
     0b10000010,
     0b01111100,
     // -------- D
     0b00111000,
     0b01000100,
     0b10000010,
     0b11111110,    
     // -------- E
     0b10000010,    
     0b10010010,    
     0b11111110,
     // -------- F
     0b10000000,        
     0b10010000,        
     0b11111110,
     // -------- G
     0b01011100,      
     0b10010010,
     0b10000010,
     0b01111100,
     // -------- H
     0b11111110,
     0b00010000,
     0b00010000,
     0b11111110,     
     // -------- I
     0b10000010,    
     0b11111110,    
     0b10000010,    
     // -------- J
     0b11111100,     
     0b00000010,
     0b00001100,
     // -------- K
     0b10000110,     
     0b01001000,     
     0b00110000,
     0b11111110,
     // -------- L
     0b00000010,      
     0b00000010,      
     0b11111110,
     // -------- M
     0b11111110,
     0b01100000,
     0b00111100,      
     0b01100000,      
     0b11111110, 
     // -------- N
     0b11111110,
     0b00011000,
     0b01100000,      
     0b11111110,     
     // -------- O
     0b01111100,
     0b10000010,
     0b10000010,
     0b01111100,      
     // -------- P
     0b01100000,    
     0b10010000,
     0b10010000,
     0b11111110,
     // -------- Q
     0b01111010,
     0b10000100,
     0b10001010,
     0b01111100,     
     // -------- R
     0b01100110,      
     0b10011000,
     0b10010000,
     0b11111110,
     // -------- S
     0b10001100,
     0b10010010,
     0b01100010,    
     // -------- T
     0b10000000,      
     0b11111110,
     0b10000000,      
     // -------- U
     0b11111100,
     0b00000010,
     0b00000010,
     0b11111100,       
     // -------- V
     0b11000000,
     0b00111000,
     0b00000110,
     0b00111000,
     0b11000000,       
     // -------- W
     0b11111110,
     0b00001100,
     0b00111000,      
     0b00001100,      
     0b11111110,     
     // -------- X
     0b11000110,
     0b00111000,
     0b00111000,     
     0b11000110,
     // -------- Y
     0b11100000,
     0b00011110,
     0b11100000,    
     // -------- Z
     0b11000010,
     0b10110010,
     0b10001110,      
     // -------- Unknown character
     0b00111000,      
     0b00111000,
     0b00111000,
     // -------- 0
     0b01111100,
     0b10100010,
     0b10010010,
     0b01111100,      
     // -------- 1
     0b11111110,
     0b01000000,
     // -------- 2
     0b01100010,
     0b10010010,
     0b10001110,      
     // -------- 3
     0b01101100,
     0b10010010,
     0b10000010,      
     // -------- 4
     0b11111110,
     0b00010000,
     0b11110000,      
     // -------- 5
     0b10001100,
     0b10010010,
     0b11110010,      
     // -------- 6
     0b01001100,
     0b10010010,
     0b10010010,
     0b01111100,      
     // -------- 7
     0b11100000,
     0b10011110,
     0b10000000,      
     // -------- 8
     0b01101100,
     0b10010010,
     0b10010010,
     0b01101100,      
     // -------- 9
     0b01111100,
     0b10010010,
     0b10010010,
     0b01100100,      
     // -------- :
     0b00100100,
     // -------- ;
     0b00100110,
     0b00000001,
     // -------- !
     0b01100000,
     0b11111010,
     0b01100000,
     // -------- Heart
     0b01111000,
     0b11111100,
     0b11111110,
     0b01111111,
     0b11111110,
     0b11111100,
     0b01111000,
     // -------- <
     0b01000100,
     0b00101000,
     0b00010000,
     // -------- =
     0b00101000,
     0b00101000,
     0b00101000,
     0b00101000,
     // -------- >
     0b00010000,
     0b00101000,
     0b01000100,
     // -------- ?
     0b01100000,
     0b10011010,
     0b10000000,
     // -------- @
     0b01111100,
     0b10000010,
     0b10111010,
     0b10100010,
     0b01011100,
     // -------- (
     0b10000010,
     0b01111100,
     // -------- )
     0b01111100,
     0b10000010,
     // -------- *
     0b00101000,
     0b00010000,
     0b00101000,
     // -------- +
     0b00010000,
     0b00010000,
     0b01111100,
     0b00010000,
     0b00010000,
     // -------- ,
     0b00000110,
     0b00000001,   
     // -------- -
     0b00010000,
     0b00010000,
     0b00010000,
     0b00010000,
     // -------- .
     0b00000010,
     // -------- /
     0b11000000,
     0b00111000,
     0b00000110,
     // -------- a
     0b00111110,
     0b00100010,
     0b00100010,
     0b00011100,
     // -------- b
     0b00011100,
     0b00100010,
     0b00100010,
     0b11111110,
     // -------- c
     0b00100010,
     0b00100010,
     0b00011100,
     // -------- d
     0b11111110,
     0b00100010,
     0b00100010,
     0b00011100,
     // -------- e
     0b00011000,
     0b00101010,
     0b00101010,
     0b00011100,
     // -------- f
     0b10010000,
     0b01111110,
     0b00010000,
     // -------- g
     0b00111110,
     0b00100101,
     0b00100101,
     0b00011000,
     // -------- h
     0b00011110,
     0b00100000,
     0b00100000,
     0b11111110,
     // -------- i
     0b00000010,
     0b01011110,
     0b00010010,
     // -------- j
     0b01011110,
     0b00000001,
     0b00000001,
     // -------- k
     0b00100010,
     0b00010100,
     0b00001000,
     0b11111110,
     // -------- l
     0b00000010,
     0b11111100,
     // -------- m
     0b00011110,
     0b00100000,
     0b00111110,
     0b00100000,
     0b00111110,
     // -------- n
     0b00011110,
     0b00100000,
     0b00100000,
     0b00111110,
     // -------- o
     0b00011100,
     0b00100010,
     0b00100010,
     0b00011100,
     // -------- p
     0b00011100,
     0b00100010,
     0b00100010,
     0b00111111,
     // -------- q
     0b00111111,
     0b00100010,
     0b00100010,
     0b00011100,
     // -------- r
     0b00010000,
     0b00100000,
     0b00111110,
     // -------- s
     0b00100100,
     0b00101010,
     0b00101010,
     0b00010010,
     // -------- t
     0b00100010,
     0b11111100,
     0b00100000,
     // -------- u
     0b00111110,
     0b00000010,
     0b00000010,
     0b00111100,
     // -------- v
     0b00111000,
     0b00000110,
     0b00111000,
     // -------- w
     0b00111110,
     0b00000010,
     0b00011110,
     0b00000010,
     0b00111100,
     // -------- x
     0b00110110,
     0b00001000,
     0b00110110,
     // -------- y
     0b00111110,
     0b00000101,
     0b00000101,
     0b00111001,
     // -------- z
     0b00110010,
     0b00101010,
     0b00100110,
     0b00100010, 
     0b11000001
};

// Char width table
 PROGMEM prog_uchar _charwidth[] = {4,4,4,3,4,3,3,4,4,3,3,4,3,5,4,4,4,4,4,3,3,4,5,5,4,3,3,
                                    3,4,2,3,3,3,3,4,3,4,4,1,2,3,7,3,4,3,3,5,2,2,3,5,2,4,1,3,
                                    4,4,3,4,4,3,4,4,3,3,4,2,5,4,4,4,4,3,4,3,4,3,5,3,4,4,0 };

// ASCII Codes of the implemented characters                                    
 PROGMEM prog_uchar _charcodes[] = {32,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
                            81,82,83,84,85,86,87,88,89,90,255,48,49,50,51,52,53,
                            54,55,56,57,58,59,33,3,60,61,62,63,64,40,41,42,43,44,
                                                    45,46,47,97,98,99,100,101,102,103,104,105,106,107,108,
                                                    109,110,111,112,113,114,115,116,117,118,119,120,121,
                                                    122,0};

La suite du cpp.

// ------------------------------------------------------------------------------------
// Constructor, initialize arduino
AS1107::AS1107(byte cspin, byte clkpin, byte datapin)
{
   _cspin = cspin;
   _clkpin = clkpin;
   _datapin = datapin;
   pinMode(cspin, OUTPUT); 
   pinMode(clkpin, OUTPUT); 
   pinMode(datapin, OUTPUT); 
   digitalWrite(cspin,HIGH);
   digitalWrite(clkpin,LOW);
   digitalWrite(datapin,LOW);
}

// ------------------------------------------------------------------------------------
// Initializes Arduino and AS1107
// buffer is the initial screen buffer
void AS1107::Init(byte * buffer)
{
   _buffer = buffer;
   CalculateCharOffsets();
   // Clear Screen buffer
   Clear();
   for (int i=0; i<=HighestCtrlNum; i++) {
     WriteRegister(i, Registers::Shutdown, ShutdownModes::Normal);
     WriteRegister(i, Registers::DecodeMode, 0x00);
     WriteRegister(i, Registers::IntensityControl, 0x00);
     WriteRegister(i, Registers::ScanLimit, 0x07);
   }
}

// ------------------------------------------------------------------------------------
// Set the Screen buffer
void AS1107::SetBuffer(byte * buffer)
{
   _buffer = buffer;
}

// ------------------------------------------------------------------------------------
// Writes Data to a Register of the AS1106/AS1107
// chip: Number of the controller chip (starting at 0 for the left)
// reg:  Register of the controller
// data: Data to be written
void AS1107::WriteRegister( byte chip, byte reg,  byte data)
{
   if (chip>=0 && chip <= HighestCtrlNum) {
     chip = HighestCtrlNum -chip;
     digitalWrite(_cspin,LOW);
     for (int i=0; i<=HighestCtrlNum; i++) {
     if (i == chip) {
       shiftOut(_datapin, _clkpin, MSBFIRST, reg);
       shiftOut(_datapin, _clkpin, MSBFIRST, data);
     }
     else {
       shiftOut(_datapin, _clkpin, MSBFIRST, Registers::NoOp);
       shiftOut(_datapin, _clkpin, MSBFIRST, 0);
     }
   }
     digitalWrite(_cspin,HIGH);
   }
}

// ------------------------------------------------------------------------------------
// Writes a column of data to the LED-Matrix
// column: column number, starting at 0
// data  : screen data to be written
void AS1107::WriteColumn( byte column,  byte data)
{
   // if you use unusual matrix row wiring, you can manipulate data here
   byte chip = (column) >>3;
   byte reg = (column % 8) +1;
   WriteRegister(chip, reg, data);
}

// ------------------------------------------------------------------------------------
// Sets the status of a LED in the screen buffer
void AS1107::SetLed(int x, int y, byte value)
{
   if (x<=Maxx && y<=Maxy && x>=0 && y>=0) {
     if (value>0) value = 1;
     SetLedInternal(x, y, value);
   }
}

// ------------------------------------------------------------------------------------
// Writes Buffer to Screen
// needs to be called after a graphics operation to see anything
void AS1107::Update()
{
   for (byte i=0; i<=Maxx; i++) {
     WriteColumn(i, _buffer[i]);
   }
}
// ------------------------------------------------------------------------------------
// Clear the Screen Buffer
void AS1107::Clear()
{
   for (byte i=0; i<=Maxx; _buffer[i++]=0); 
}

// ------------------------------------------------------------------------------------
// Shift the content of the Screen buffer to the left
void AS1107::ShiftLeft()
{
   for (byte i=1; i<=Maxx; i++) {
     _buffer[i-1] = _buffer[i];
   }
   _buffer[Maxx] = 0;
}
// ------------------------------------------------------------------------------------
// Shift the content of the Screen buffer to the right
void AS1107::ShiftRight()
{
   for (byte i=Maxx; i>=1; i--) {
     _buffer[i] = _buffer[i-1];
   }
   _buffer[0] = 0;
}
// ------------------------------------------------------------------------------------
// Shift the content of the Screen buffer up
void AS1107::ShiftUp()
{
   for (byte i=0; i<=Maxx; i++) {
     _buffer[i] = _buffer[i]<<1 & 0xFE;
   }
}
// ------------------------------------------------------------------------------------
// Shift the content of the Screen buffer up
void AS1107::ShiftUp(byte from, byte to)
{
   for (byte i=from; i<=to; i++) {
     _buffer[i] = _buffer[i]<<1 & 0xFE;
   }
}
// ------------------------------------------------------------------------------------
// Shift the content of the Screen buffer down
void AS1107::ShiftDown()
{
   for (byte i=0; i<=Maxx; i++) {
     _buffer[i] = _buffer[i]>>1 & 0x7F;
   }
}
// ------------------------------------------------------------------------------------
// Shift the content of the Screen buffer down
void AS1107::ShiftDown(byte from, byte to)
{
   for (byte i=from; i<=to; i++) {
     _buffer[i] = _buffer[i]>>1 & 0x7F;
   }
}
// ------------------------------------------------------------------------------------
// draws a line from x0 ,y0 to x1,y1
void AS1107::DrawLine(int x0, int y0, int x1, int y1)
{

   int dx =  abs(x1-x0), sx = x0<x1 ? 1 : -1;
   int dy = -abs(y1-y0), sy = y0<y1 ? 1 : -1; 
   int err = dx+dy, e2; /* error value e_xy */

   for(;;){  /* loop */
     SetLed(x0,y0,ON);
     if (x0==x1 && y0==y1) break;
     e2 = 2*err;
     if (e2 >= dy) { err += dy; x0 += sx; } /* e_xy+e_x > 0 */
     if (e2 <= dx) { err += dx; y0 += sy; } /* e_xy+e_y < 0 */
   }
}
// ------------------------------------------------------------------------------------
// draws a box from x0,x0 to x1,y1
void AS1107::DrawBox(int x0, int y0, int x1, int y1)
{
   DrawLine(x0,y0,x1,y0);
   DrawLine(x1,y0,x1,y1);
   DrawLine(x1,y1,x0,y1);
   DrawLine(x0,y1,x0,y0);
}
// ------------------------------------------------------------------------------------
// draws an ellipse
// center xm, ym   - radius a,b
void AS1107::DrawEllipse(int xm, int ym, int a, int b)
{
    if (a ==0 && b== 0) {
   SetLed(xm,ym,ON);
   return;
    }

    int dx = 0, dy = b; /* first quadrant from top left to bottom right */
    int a2 = a*a, b2 = b*b;
    int err = b2-(2*b-1)*a2, e2; /* error value in the first step */

    do {
      SetLed(xm+dx, ym+dy, ON); /* I. Quadrant */
      SetLed(xm-dx, ym+dy, ON); /* II. Quadrant */
      SetLed(xm-dx, ym-dy, ON); /* III. Quadrant */
      SetLed(xm+dx, ym-dy, ON); /* IV. Quadrant */

      e2 = 2*err;
      if (e2 <  (2*dx+1)*b2) { dx++; err += (2*dx+1)*b2; }
      if (e2 > -(2*dy-1)*a2) { dy--; err -= (2*dy-1)*a2; }
    } while (dy >= 0);

    while (dx++ < a) { /* correction for flat ellipses (b=1) */
      SetLed(xm+dx, ym, ON); 
      SetLed(xm-dx, ym, ON); 
    }
}

// ------------------------------------------------------------------------------------
// Writes Text at a screen position
void AS1107::DrawText (int x, int y, char *str)
{
   byte count;
   char thechar;
   while (*str != '\0') {
     Serial.println(*str,DEC);
     x+=DrawChar(x, y, *str);
     str++;
   }
}

// ------------------------------------------------------------------------------------
// Draws a single character at a screen position
// returns the x-position for the next character
 byte AS1107::DrawChar (int x, int y, char thechar)
{
   y+=7;
   byte charnum, colct, count=0, colbits;
   int fontidx;
   charnum = GetInternalCharCode(thechar);

   // get the location of the first column of the font
   fontidx = _charoffset[charnum]-1;

   // get the width of the font
   colct = pgm_read_byte_near(_charwidth + charnum);
   for (byte i=colct; i>0; i--) {
     colbits = pgm_read_byte_near(_font + fontidx + i);
     for (byte j=0; j<=7; j++) {
       if ((colbits >>j) & 1) {
         SetLed(x, y-j, 1);
       }
     }
     x++;
   }
   return colct+1;
}
// ------------------------------------------------------------------------------------
// Sets the Text for Scrolline
void AS1107::SetScrollText(char *string, int charspacing)
{
   _charspacing = charspacing;
   _outputstring = string;
   _curchr = string;
   _hastext = true;
   _colct =-1;
}

// ------------------------------------------------------------------------------------
// Scrolls the text one pixel to the left
// returns true if last character has been displayed
 boolean AS1107::TextScroll()
{
   boolean lastchar = false;
   byte colbits = 0;
   if (_colct == (0-_charspacing-1)) {
     lastchar = NextCharacter();
   }
   if (_colct>=0) {
     colbits = pgm_read_byte_near(_font + _fontidx + _colct);
   }
   ShiftLeft();
   _buffer[Maxx] = colbits;
   Update();
   _colct--;
   return lastchar;
}

// ------------------------------------------------------------------------------------
// PRIVATE (Internal) functions
// ------------------------------------------------------------------------------------
// Set LED without Parameter check
void AS1107::SetLedInternal(byte x, byte y, byte value)
{
   _buffer[x] |= value << (Maxy-y);
}

la suite et fin du cpp.

// ------------------------------------------------------------------------------------
// fetches the next character of the Scrollline
// returns true if string is at the end
 boolean AS1107::NextCharacter()
{
   boolean lastchar = false;
   if (_hastext) {
     char thechar = *_curchr;
     boolean found = false;
     byte charnum = 0;
     byte i;
     // if the string ends, start from the beginning
     if (thechar == 0) {
       lastchar = true;
       _curchr = _outputstring;
       thechar = *_curchr;
     }

     charnum = GetInternalCharCode(thechar);

     // get the offset of the first column of the character
     _fontidx = _charoffset[charnum];

     // get the width of the font
     _colct = pgm_read_byte_near(_charwidth + charnum) -1;
   }
   else {
     _fontidx= _charoffset[_repcharoff];
     _colct = pgm_read_byte_near(_charwidth + _repcharoff);
   }
   *_curchr++;
   return lastchar;
}
// ------------------------------------------------------------------------------------
// calculates Character offsets from font width table in EEPROM
void AS1107::CalculateCharOffsets()
{
   int off =0;
   int idx=0;
   int w=0;
   int i=0;

   do {
     _charoffset[i]=off;
     w = pgm_read_byte_near(_charwidth+i);
     off += w;
     i++;
   } while (w != 0);
}

// ------------------------------------------------------------------------------------
// gets the character number of the built-in-font from the ASCII table
// returns number of the replacement character for unknown characters
 byte AS1107::GetInternalCharCode(byte thechar)
{
     int i=0;
     int charnum;
     do {
       charnum = pgm_read_byte_near(_charcodes + i);
       if (charnum == thechar) break;
       i++;
     } while (charnum != 0 );
     if (charnum == 0) i = _repcharoff;
     return i;
}

et enfin le programme pour l’arduino

// test program for five cascaded AS1107
// if you got a different configuration you need to 
// modify the library itself.

#include <AS1107.h>

// Arduino pins 
const byte CsnPin = 2;    // Chip select (Low active)
const byte ClkPin = 3;    // Serial Clock
const byte DataPin = 4;   // Serial Data

 byte buffer[40];          // Screen buffer (No. of modules * 8)
 AS1107 matrix(CsnPin, ClkPin, DataPin);

const byte d = 0;
int count=1;
void setup()
{
   matrix.Init(buffer);
   matrix.SetScrollText(" Five 8x8 LED dot matrix modules driven by three AS1107 LED controllers using just four I/O pins of the Arduino for serial data. That is surprisingly fast, look:", 1); 
}

void loop()
{
   if (matrix.TextScroll()) {
     delay(2000);
     for (int i=0; i<=7; i++) {
       matrix.ShiftUp();
       delay(50);
       matrix.Update();
     }
     for (int i=0; i<=10; i++) {
       CirclePulsate();
     }
     StarsDown();
     for (int i=0; i<=5; i++) {
       Rotator1();
     }
     EyeBlink();
     StarsRight();
     for (int i=0; i<=AS1107::Maxx; i++) {
       matrix.ShiftRight();
       delay(5);
       matrix.Update();
     }
     for (int i=1; i<=3; i++)
     {
       bounce();
     }
   }
   delay(10);
}

void EyeBlink()
{
 for (int i=0; i<=5; i++)
 {
   matrix.Clear();
   //Y|00000000|00111111|11112222|22222233|33333333|
   //Y|01234567|89012345|67890123|45678901|23456789|
   //0|
   //1|          ¤¤¤¤¤¤            ¤¤¤¤¤¤ 
   //2|          ¤¤¤¤¤¤            ¤¤¤¤¤¤
   //3|          ¤¤  ¤¤            ¤¤  ¤¤
   //4|          ¤¤  ¤¤            ¤¤  ¤¤
   //5|          ¤¤¤¤¤¤            ¤¤¤¤¤¤
   //6|          ¤¤¤¤¤¤            ¤¤¤¤¤¤
   //7|
   //
   // first eye
   matrix.DrawBox(9,1,14,6);
   matrix.DrawBox(10,2,13,5);
   // second eye
   matrix.DrawBox(25,1,30,6);
   matrix.DrawBox(26,2,29,5);
   matrix.Update();
   delay(1000);
   matrix.Clear();
   matrix.DrawBox(9,3,13,4);
   matrix.DrawBox(25,3,30,4);
   matrix.Update();
   delay(500);
 }
}
  
void CirclePulsate()
{
   for( int i=0; i<=15; i++) {
     matrix.Clear();
     matrix.DrawEllipse(AS1107::Maxx/2,4,i,i);
     matrix.Update();
     delay(d);
   }
}
void StarsDown()
{
     for( int i=0; i<=200; i++) {
       matrix.ShiftDown();
       matrix.SetLed((byte) random(0,AS1107::Maxx+1),0,1);
       matrix.Update();
       delay(d);
     }
}
void StarsRight()
{
     for( int i=0; i<=200; i++) {
       matrix.ShiftRight();
       matrix.SetLed(0,(byte) random(0,AS1107::Maxy+1),1);
       matrix.Update();
       delay(d);
     }
}
void Rotator1()
{
   for( int i=0; i<=AS1107::Maxx-1; i++) {
     matrix.Clear();
     matrix.DrawLine(i,0,AS1107::Maxx-i,AS1107::Maxy);
     matrix.Update();
     delay(d);
   }
   for( int i=0; i<=6; i++) {
     matrix.Clear();
     matrix.DrawLine(AS1107::Maxx,i,0,7-i);
     matrix.Update();
     delay(d);
   }
}

void bounce()
{
   int rad=0;
   float y=random(0,AS1107::Maxy+1);
   float x=random(0,AS1107::Maxx+1);
   float xacc=random(0,5)-2;
   float yacc=random(0,5)-2;
   float yg=0.08;
   if (xacc == 0) xacc == 1;
   if (yacc == 0) yacc == -1;
   for (int i=1; i<=300; i++)
   {
     x+=xacc;
     y+=yacc;
     yacc += yg;
     if (x >= (AS1107::Maxx-rad)) {
       xacc = -xacc*0.9;
       x= AS1107::Maxx -rad;
     }
     else if (x <= rad) {
       xacc = -xacc*0.8;
       x= rad;
     }
     if (y >= (AS1107::Maxy-rad)) {
       yacc = -(yacc*0.80);
       y= AS1107::Maxy -rad;
     }
     else if (y <= rad) {
       yacc = -yacc*0.8;
       y= rad;
     }
     matrix.Clear();
     matrix.SetLed(x,y,1);
     matrix.Update();
   }
}

lors de la compilation c'est la ligne 5 qui est surlignée : AS1107 matrix(CsnPin, ClkPin, DataPin); et les messages d'erreurs :

In file included from LEDMatrix.ino:5:
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:35: error: expected `)' before 'cspin'
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:36: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:36: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:36: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:37: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:37: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:37: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:38: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:38: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:39: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:40: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:41: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:48: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:48: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:49: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:49: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:55: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:57: error: 'boolean' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:62: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:63: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:64: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:67: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:68: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:69: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:70: error: ISO C++ forbids declaration of 'byte' with no type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:70: error: expected ';' before '*' token
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:72: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:78: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:79: error: 'boolean' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:81: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:81: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:81: error: 'byte' has not been declared
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:82: error: 'boolean' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:84: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:92: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:93: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:94: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:95: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:96: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:97: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:98: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:99: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:100: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:101: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:102: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:103: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:104: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:105: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:106: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:114: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:115: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:116: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:117: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:124: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:125: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:126: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:127: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:128: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:129: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:132: error: 'byte' does not name a type
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:138: error: 'byte' does not name a type
LEDMatrix:13: error: no matching function for call to 'AS1107::AS1107(const byte&, const byte&, const byte&)'
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:33: note: candidates are: AS1107::AS1107()
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:33: note:                 AS1107::AS1107(const AS1107&)
LEDMatrix.ino: In function 'void setup()':
LEDMatrix:19: error: no matching function for call to 'AS1107::Init(byte [40])'
C:\Program Files (x86)\Arduino\libraries\AS1107/AS1107.h:39: note: candidates are: void AS1107::Init(int*)
LEDMatrix.ino: In function 'void loop()':
LEDMatrix:25: error: 'class AS1107' has no member named 'TextScroll'
LEDMatrix:41: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix.ino: In function 'void CirclePulsate()':
LEDMatrix:90: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix.ino: In function 'void StarsDown()':
LEDMatrix:99: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix.ino: In function 'void StarsRight()':
LEDMatrix:108: error: 'Maxy' is not a member of 'AS1107'
LEDMatrix.ino: In function 'void Rotator1()':
LEDMatrix:115: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix:117: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix:117: error: 'Maxy' is not a member of 'AS1107'
LEDMatrix:123: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix.ino: In function 'void bounce()':
LEDMatrix:132: error: 'Maxy' is not a member of 'AS1107'
LEDMatrix:133: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix:144: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix:146: error: 'Maxx' is not a member of 'AS1107'
LEDMatrix:152: error: 'Maxy' is not a member of 'AS1107'
LEDMatrix:154: error: 'Maxy' is not a member of 'AS1107'

Il y a beaucoup d'erreur, mais je vais me concentrer surtout sur la première erreur qui me ressort une erreur sur la déclaration dans le prototype alors qu'il s'agit d'une librairie publique.

Si quelqu'un a une explication ou la gentillesse de me dire ou le noob que je suis a 'merdouiller' ca serait super sympa. Car je trouve le potentiel de ce µcontrolleur génial pour continuer la formation robotique de mon fils. car l’étape suivante sera de de commander les NXT via l'arduino lui permettant d'avoir plus d'E/S pour ses projets. Mais pour ça il faut que moi aussi je puisse comprendre mes erreurs pour lui expliquer.

Merci beaucoup pour votre aide.

Bonjour, Ta library AS1107 est installé où dans le répertoire de l'IDE Arduino ou dans le répertoire programme ? @+ P.S.: Pour éviter tout ces topics qui se suivent pour le code, tu devrais mettre le lien de téléchargent pour AS1107.h et cpp et ne mettre que ton programme => tout tient dans un seule message

Bonjour, Pour que ta compilation se fasse, il faut que tu remplaces dans AS1107.h et AS1107.cpp la ligne suivante : #include "WProgram.h" par #include "Arduino.h" et ça passe. Reste plus qu'à faire les tests de ton programme @+ P.S. : tu peux également regarder ce projet : http://www.elsniwiki.de/index.php/Main/ArduinoLedMatrix

Merci beaucoup ICARE pour ton aide et tes conseils concernant le message original. Je ne suis pas trop familier avec les forums. J'espère que tu excuseras ma maladresse.

En voyant Wprogram.h, j'ai testé le même programme avec Wiring, mais j'ai eu plus de mal avec ce programme. J'essaie ce soir en rentrant à la maison. Grace à toi, j'ai appris que WProgram.h, c'est pour Wiring et pour Arduino c'est Arduino.h

Le wiki que tu me met en PS c'est de celui ci que j'ai attraper la librairie AS1107. Merci. Je ferais un retour ce soir après mes tests. :)

tilowil:
Merci beaucoup ICARE pour ton aide et tes conseils concernant le message original. Je ne suis pas trop familier avec les forums. J’espère que tu excuseras ma maladresse.

Ce n’est rien, on est tous sur le forum pour apprendre.
Si tu souhaites que ta bibliothèque soit plus général, il faudrait remplacer <WProgram.h> par (pour être compatible avec plusieurs environnements) :

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

@+

Merci beaucoup pour ce nouveau conseil. Je n'ai pas pu attendre ce soir, j'ai installé Arduino sur mon poste de travail pour faire mes tests et ça marche du tonnerre. Plus une seule erreur de compilation. Merci. Maintenant vivement ce soir que je reste ça en vrai. :) Quel est la différence entre ces 2 fichiers WProgram.h et Arduino.h ? Hormis que un semble spécifique Arduino et l'autre plus générique. Pourquoi dans ton test de tu as un Arduino>=100 ? Ce 100 correspond il a un numéro de version ? Encore merci pour ton aide et excuses ma curiosité .

Re,

Quel est la différence entre ces 2 fichiers WProgram.h et Arduino.h ?

Va voir ici : http://www.pobot.org/Changements-avec-Arduino-1.html C'était normal que cela compile, j'avais fait l'essaye avant. @+

Merci beaucoup Icare pour ton aide. Tout fonctionne et j'ai pu encore ajouter des effet pour que mon fils s'ammuse avec son Arduino. Merci.