LED Cube Sketch and atTiny84.

Hi all, I am playing with a LED cube sketch I found in the Net. It works fine if I run it from the Arduino. But I cant get it to load on an atTiny84.

Here is the sketch

/*
    ledcube.pde - Example sketch for controlling an LED cube.
    Created by Gamaiel Zavala (gzip), 2009-2012
    MIT License. See accompanying LICENSE file for terms.
*/

#include <LedCube.h>

#define SIZE 3
#define COLS (SIZE*SIZE)

byte levelPins[SIZE] = {2,3,4};
byte colPins[COLS] = {0,1,5,6,7,8,9,10};

LedCube cube(SIZE, levelPins, colPins);

void setup ()
{
}

void loop ()
{
    delay(10);
    
    // light each light one at a time
    for(byte level=0; level<cube.getLevels(); level++)
    {
        for(byte col=0; col<cube.getCols(); col++)
        {
            cube.lightPulse(level, col, 100);
        }
    }
    
    // light one level at a time, increasing speed each time
    for(byte d=25; d>2; d-=2)
    {
        for(byte l=1; l <= cube.getLevels(); l++)
        {
            cube.lightLevel(l, d);
        }
    }
    
    // light each row on each level
    for(byte level=1; level<=cube.getLevels(); level++)
    {
        for(byte row=1; row<=cube.getLevels()*2; row++)
        {
            cube.lightRow(row, level);
        }
    }
    
    // light each plane
    for(byte i=3; i; i--)
    {
        for(byte row=1; row<=cube.getLevels()*2; row++)
        {
            cube.lightPlane(row, 10*i);
        }
    }
    
    // single random light at a time
    cube.randomLight(random(25,100),100);
    
    // random column drop
    for(byte x=0; x<=15; x++)
    {
        cube.lightDrop(random(0,cube.getCols()), random(50,150));
    }
    
    // circle around cube at a random level
    for(byte x=0; x<=5; x++)
    {
        cube.lightPerimeter(random(0,cube.getLevels()), random(1,5), random(25,100));
    }
    
    // light each face
    byte planes[] = {cube.getLevels()+1,cube.getLevels(),cube.getLevels()*2,1};
    for(byte i=5; i; i--)
    {
        for(byte p=0; p<sizeof(planes); p++)
        {
            cube.lightPlane(planes[p], 5*i);
        }
    }
    
    // random columns
    cube.randomColumn(25);
    
    // turn off a single column randomly
    cube.enableBuffer();
    for(byte c=0; c<30; c++)
    {
        cube.fillBuffer();
        cube.invertBuffer();
        cube.randomColumn();
        cube.drawBuffer(7);
    }
    cube.enableBuffer(false);
    
    // cols in and out
    for(byte c=1, d=0; c<=10; c++)
    {
        if(c%2 == 0)
        {
            for(d=0; d<20; d++)
            {
                cube.lightColumn(2,1);
                cube.lightColumn(4,1);
                cube.lightColumn(6,1);
                cube.lightColumn(8,1);
            }
        }
        else if(c%4 == 1)
        {
            for(d=0; d<30; d++)
            {
                cube.lightColumn(1,1);
                cube.lightColumn(3,1);
                cube.lightColumn(7,1);
                cube.lightColumn(9,1);
            }
        }
        else
        {
            for(d=0; d<70; d++)
            {
                cube.lightColumn(5,1);
            }
        }
    }
    
    // diamond and box
    byte diamond[] = {0,4,  1,1, 1,3, 1,4, 1,5, 1,7,   2,4};
    byte box[] = {
        2,0, 2,1, 2,2, 2,3, 2,5, 2,6, 2,7, 2,8,
        1,0, 1,2, 1,6, 1,8,
        0,0, 0,1, 0,2, 0,3, 0,5, 0,6, 0,7, 0,8
    };
    cube.lightSequence(box, sizeof(box), 200);
    cube.lightSequence(diamond, sizeof(diamond), 400);
    
    // helicopter effect
    byte topSeq[8] = {0,3,6,7,8,5,2,1};
    byte botSeq[8] = {8,5,2,1,0,3,6,7};
    for(byte loops = 0, delay = 50; loops<=8; loops++)
    {
        for(byte s=0; s<8; s++)
        {
            byte seq[] = {2,topSeq[s], 1,4, 0,botSeq[s]};
            cube.lightSequence(seq, sizeof(seq), delay);
        } 
        if(loops < 5) delay-=10;  else delay += 10;
    }
    
    // turn off one light at a time
    cube.enableBuffer();
    cube.fillBuffer();
    cube.drawBuffer(25);
    for(byte w=0, l, c, max = cube.getNumLights(); w<max; )
    {
        // lower bound is inclusive, upper is exclusive
        l = random(0, cube.getLevels());
        c = random(0, cube.getCols());
        
        if(cube.getBufferAt(l,c) == HIGH)
        {
            cube.lightOff(l,c);
            cube.drawBuffer(5);
            w++;
        }
    }
    cube.enableBuffer(false);
}

And Here is the Error I get when I try to load it on the 84

c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o: In function `__vector_default':
(.vectors+0x16): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_11' defined in .text.__vector_11 section in core.a(wiring.c.o)
c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.main section in core.a(main.cpp.o)
c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
core.a(WMath.cpp.o): In function `randomSeed(unsigned int)':
C:\Users\techsupport\Documents\Arduino\hardware\tiny\cores\tiny/WMath.cpp:33: relocation truncated to fit: R_AVR_13_PCREL against symbol `srandom' defined in .text section in c:/arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25\libc.a(random.o)

Thanks

truncated to fit

Well, now, there's a clue.

Hi

What is the sketchsize.

If it is more than 4k you will have to use this fix:

Erni: Hi

What is the sketchsize.

If it is more than 4k you will have to use this fix:

https://github.com/TCWORLD/ATTinyCore

I apologizes in advanced for this question. But how do I tell the size of the sketch. Is it the file size it self.

Hi,

Look in the black window in the button of Arduino IDE. I just tried to verify your schetch, and got this

Binary sketch size: 7.280 bytes (of a 8.192 byte maximum)

Erni: Binary sketch size: 7.280 bytes (of a 8.192 byte maximum)

So am I correct in saying its not a size issue?

So am I correct in saying its not a size issue?

If, in your universe, 7280 is less than 4000, yes.

So am I correct in saying its not a size issue?

Ehhm 7.280 bytes is more than 4.000 bytes, so you have to use the fix I shoved you.

It is quit easy, just a single file to replace

PaulS:

So am I correct in saying its not a size issue?

If, in your universe, 7280 is less than 4000, yes.

My bad I was looking Binary sketch size: 7.280 bytes (of a [u]8.192 byte maximum[/u]).

I was wondering why this universe seamed so empty.

Erni:

So am I correct in saying its not a size issue?

Ehhm 7.280 bytes is more than 4.000 bytes, so you have to use the fix I shoved you.

It is quit easy, just a single file to replace

I will give it a shot when I get back to my house this afternoon. Not to be a pain, but as I am very new to all this, What file would I replace?. Sorry.

It is a file called ld.exe , it is all explained in the link

https://github.com/TCWORLD/ATTinyCore

Thanks.

Ill let you know how it goes.

kculm:

PaulS:

So am I correct in saying its not a size issue?

If, in your universe, 7280 is less than 4000, yes.

My bad I was looking Binary sketch size: 7.280 bytes (of a [u]8.192 byte maximum[/u]).

I was wondering why this universe seamed so empty.

Where are you getting the 4K limit for the atTiny84. That datasheet on https://www.sparkfun.com/products/11232? site where I purchased them lists them as having 8k. am I missing something?

I am assuming that's it is why it stats 8.192 maximum.

Will someone correct me if I am wrong.

Thanks

It is not a hardware limitation.

Take a look at this:

http://arduino.cc/forum/index.php/topic,116674.0.html