Go Down

Topic: direct wire 8x8 led matrix compile error (Read 903 times) previous topic - next topic

beer lover

I am trying to get the playground direct wire led matrix working and I keep getting compile errors
this is the code i am using


Code: [Select]
/*
* Show messages on an 8x8 led matrix,
* scrolling from right to left.
*
* Uses FrequencyTimer2 library to
* constantly run an interrupt routine
* at a specified frequency. This
* refreshes the display without the
* main loop having to do anything.
*
*/

#include <FrequencyTimer2.h>

#define SPACE { \
    {0, 0, 0, 0, 0, 0, 0, 0},  \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0} \
}

#define H { \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}  \
}

#define E  { \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}

#define L { \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}

#define O { \
    {0, 0, 0, 1, 1, 0, 0, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 0, 0, 1, 1, 0, 0, 0}  \
}

byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};

const int numPatterns = 6;
byte patterns[numPatterns][8][8] = {
  H,E,L,L,O,SPACE
};

int pattern = 0;

void setup() {
  // sets the pins as output
  for (int i = 1; i <= 16; i++) {
    pinMode(pins[i], OUTPUT);
  }

  // set up cols and rows
  for (int i = 1; i <= 8; i++) {
    digitalWrite(cols[i - 1], LOW);
  }

  for (int i = 1; i <= 8; i++) {
    digitalWrite(rows[i - 1], LOW);
  }

  clearLeds();

  // Turn off toggling of pin 11
  FrequencyTimer2::disable();
  // Set refresh rate (interrupt timeout period)
  FrequencyTimer2::setPeriod(2000);
  // Set interrupt routine to be called
  FrequencyTimer2::setOnOverflow(display);

  setPattern(pattern);
}

void loop() {
    pattern = ++pattern % numPatterns;
    slidePattern(pattern, 60);
}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = 0;
    }
  }
}

void setPattern(int pattern) {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = patterns[pattern][i][j];
    }
  }
}

void slidePattern(int pattern, int del) {
  for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + l];
    }
    delay(del);
  }
}

// Interrupt routine
void display() {
  digitalWrite(cols[col], LOW);  // Turn whole previous column off
  col++;
  if (col == 8) {
    col = 0;
  }
  for (int row = 0; row < 8; row++) {
    if (leds[col][7 - row] == 1) {
      digitalWrite(rows[row], LOW);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], HIGH); // Turn off this led
    }
  }
  digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}



here is the error I am getting in arduino 22
I have tried arduino 1.0 as well no dice
yes my frequencytimer2 is installed in libraries for both arduino 22 and 1.0


In file included from C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino-0022\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:6,
                 from sketch_jun18a.cpp:70:
c:/documents and settings/administrator/my documents/dropbox/arduino-0022/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected unqualified-id before 'double'
c:/documents and settings/administrator/my documents/dropbox/arduino-0022/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected `)' before 'double'
c:/documents and settings/administrator/my documents/dropbox/arduino-0022/arduino-0022/hardware/tools/avr/lib/gcc/../../avr/include/math.h:439: error: expected `)' before 'double'

any suggestions
thanks
bryan

Riva

Hi beer lover,

I just downloaded the FrequenceyTimer2 library from http://www.pjrc.com/teensy/td_libs_FrequencyTimer2.html and copied and pasted your code into arduino 1.01 and it compiled no bother.
Code: [Select]
Binary sketch size: 2,872 bytes (of a 32,256 byte maximum)
http://forum.arduino.cc/index.php?action=unread;boards=5,67,10,11,66,12,15,17,21,22,23,24,25,29;ALL

Nick Gammon

It compiled for me OK under version 0022, but that line reminds me of a problem with round.

In Arduino.h, line 68, there is this line:

Code: [Select]
#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

In math.h, line 439 (your problem line) there is ths line:

Code: [Select]
double round (double __x) __ATTR_CONST__;

These are not compatible. Comment one of them out, and see what happens (maybe the one in Arduino.h).
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

beer lover

downloaded arduino 1.01 and this is my new error


In file included from sketch_jun19a.cpp:13:
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2/FrequencyTimer2.h:30: error: 'uint8_t' does not name a type

beer lover

when using the test example for frequencytimer2 in arduino 1.01 I get this error

In file included from Test.cpp:4:
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2/FrequencyTimer2.h:30: error: 'uint8_t' does not name a type
Test.cpp: In function 'void setup()':
Test.pde:-1: error: 'FREQUENCYTIMER2_PIN' was not declared in this scope

beer lover

commented the math.h one using arduino 22
this is my error
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::setOnOverflow(void (*)())':
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:51: error: 'TIMSK' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:51: error: 'OCIE2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:52: error: 'TIMSK' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:52: error: 'OCIE2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::setPeriod(long unsigned int)':
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:99: error: 'TCCR2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:102: error: 'OCR2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:103: error: 'COM20' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp: In static member function 'static long unsigned int FrequencyTimer2::getPeriod()':
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:113: error: 'TCCR2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:114: error: 'OCR2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::enable()':
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:150: error: 'TCCR2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:150: error: 'COM20' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp: In static member function 'static void FrequencyTimer2::disable()':
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:160: error: 'TCCR2' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Dropbox\arduino backups\libraries\FrequencyTimer2\FrequencyTimer2.cpp:160: error: 'COM20' was not declared in this scope

Go Up