byte variable type

We have a project using an OLED display and would like to display a bitmap picture using a two dimensional array.

Usually we put the bitmap in an include file since it can be quite large as shown below.

const byte arduino1[57][60] = { //

For some strange reason, this causes a compile error, but if the array is in the main file everything is fine. Logged this as an issue (697) but it was marked Invalid which seems strange since this problem is very annoying and limiting. We are using Arduino 1.0 RC2.

We also had another issue that we cannot include a file called Arduino.h. This causes the compiler massive issues.

What board are you using?

The const keyword can be misleading. You're using 3420 bytes of RAM just for that array.

For some strange reason, this causes a compile error

And that error is?

Something to do with duplicate symbols?

[Asutralia?]

Shields_Arduino:
We also had another issue that we cannot include a file called Arduino.h. This causes the compiler massive issues.

Oh? What issues?

runaway_pancake:
Asutralia?

lol.

const byte arduino1[57][60] = { // 
};

void loop () {}
void setup () {}

No problems here.

Asutralia

An island off the west coast of Nwe Zaelnad

Shields_Arduino:
Usually we put the bitmap in an include file since it can be quite large as shown below.
...

Put it in a separate .cpp file. Putting it in a .h file, and then including it multiple times, will mean you get multiple copies and thus a linker error.

To use it, look up the "extern" keyword.

Thanks for the replies. OK, here is the error message for

const byte arduinox[115][128] = { //

In file included from Test.cpp:9:
arduinoa.h:2: error: 'byte' does not name a type
Test.cpp: In function 'void loop()':
Test:63: error: 'arduinox' was not declared in this scope

If the byte is changed to unsigned char, everything compiles fine.

If a file called arduino.h is in the same directory as the sketch, these errors happen:

Test.cpp: In function 'void setup()':
Test:33: error: 'OUTPUT' was not declared in this scope
Test:33: error: 'pinMode' was not declared in this scope
Test:40: error: 'HIGH' was not declared in this scope
Test:40: error: 'digitalWrite' was not declared in this scope
Test.cpp: In function 'void loop()':
Test:57: error: 'delay' was not declared in this scope
Test.cpp: In function 'void test_screen1()':
Test:79: error: 'delay' was not declared in this scope
Test.cpp: In function 'void command(int)':
Test:97: error: 'LOW' was not declared in this scope
Test:97: error: 'digitalWrite' was not declared in this scope
Test:100: error: 'DDRD' was not declared in this scope
Test:101: error: 'PORTD' was not declared in this scope
Test:103: error: 'HIGH' was not declared in this scope
Test.cpp: In function 'void data(int)':
Test:116: error: 'HIGH' was not declared in this scope
Test:116: error: 'digitalWrite' was not declared in this scope
Test:117: error: 'LOW' was not declared in this scope
Test:119: error: 'DDRD' was not declared in this scope
Test:120: error: 'PORTD' was not declared in this scope
Test.cpp: In function 'void init_colorlcd(int)':
Test:137: error: 'delay' was not declared in this scope
Test.cpp: At global scope:
Test:259: error: 'byte' does not name a type
Test.cpp: In function 'void xyputs(unsigned char, unsigned char, int, int, char*)':
Test:263: error: 'byte' was not declared in this scope
Test:263: error: expected `;' before 'd'
Test:280: error: 'strlen' was not declared in this scope
Test:295: error: 'd' was not declared in this scope
Test:297: error: 'mask' was not declared in this scope
Test.cpp: In function 'void draw_line(unsigned char, unsigned char, unsigned char, unsigned char, int)':
Test:339: error: 'delay' was not declared in this scope
Test.cpp: In function 'void draw_rectangle(unsigned char, unsigned char, unsigned char, unsigned char, int, int)':
Test:358: error: 'delay' was not declared in this scope
Test.cpp: In function 'void draw_circle(unsigned char, unsigned char, unsigned char, int, int)':
Test:374: error: 'delay' was not declared in this scope

Shields_Arduino:
Thanks for the replies. OK, here is the error message for

const byte arduinox[115][128] = { //

In file included from Test.cpp:9:
arduinoa.h:2: error: 'byte' does not name a type

The type "byte" is declared in Arduino.h (or WProgram.h). If you can't include Arduino.h, that explains that problem. Are you even attempting to include Arduino.h? There is usually an error message if avr-g++ cannot find it in its search path. It may be helpful to post more of your code.

115 * 128 = 14,720 bytes. No Arduino has that much SRAM. You might as well stop now.

With the Arduino.h problem, yes we did rename the file to fix this problem. The only reason we called it arduino.h was that we were trying to do a arduino logo on a screen.

With the byte problem, please refer to the attached zip file.

With the RAM issue, I thought that const meant the array is compiled into flash and not RAM. Thanks.

Test.zip (14 KB)

No, const just means you cannot programmatically change it.