Tomáš
Tomáš

Reputation: 2108

Store array of arrays in array

It is possible store bitmap in array in Wiring programing language (Arduino)?

boolean triangleMap[DISPLAY_HEIGHT][DISPLAY_WIDTH] = {
{0,0,0,1,1,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},
{1,1,1,1,1,1,1,1}
};

boolean squareMap[DISPLAY_HEIGHT][DISPLAY_WIDTH] = {
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1}
};

boolean symbols[] = {triangleMap, squareMap};

??? symbols[] = {triangleMap, squareMap};

error: invalid conversion from ‘boolean ()[8] {aka unsigned char ()[8]}’ to ‘boolean {aka unsigned char}’ [-fpermissive]

I do not know whether it is possible to store triangleMap and squareMap bitmap in symbols array?

Thanks a lot.

Upvotes: 0

Views: 190

Answers (2)

Tomáš
Tomáš

Reputation: 2108

Sorry, this does not work:

byte symbols[][DISPLAY_HEIGHT][DISPLAY_WIDTH] = {triangleMap, squareMap};

But, this work:

byte symbols[][DISPLAY_HEIGHT][DISPLAY_WIDTH] ={  
        { //triangle
          {0,0,0,1,1,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},
          {1,1,1,1,1,1,1,1}
        },
        {//square
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1},
          {1,1,1,1,1,1,1,1}
      },
      {//cycle
          {0,0,0,0,0,0,0,0},
          {0,0,0,0,0,0,0,0},
          {0,0,0,0,1,0,0,0},
          {0,0,0,1,1,1,0,0},
          {0,0,0,0,1,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}
      }    
  };

Thanks a lot.

Upvotes: 0

frarugi87
frarugi87

Reputation: 2880

You are not using the correct type.

boolean symbols[] means "I want an array of booleans", while what you want is "an array of booleans MATRICES. So this

boolean symbols[][DISPLAY_HEIGHT][DISPLAY_WIDTH] = {triangleMap, squareMap};

should work

Upvotes: 1

Related Questions