Skip to content

Instantly share code, notes, and snippets.

@TheNotary
Last active August 29, 2015 14:20
Show Gist options
  • Save TheNotary/972aec44d5c2a02e56a3 to your computer and use it in GitHub Desktop.
Save TheNotary/972aec44d5c2a02e56a3 to your computer and use it in GitHub Desktop.
(Map.h)
#ifndef HEADER_MAP
#define HEADER_MAP
class Map {
public:
Map(uint8_t walls_bmp[8]);
uint8_t walls[8];
void draw(Adafruit_BicolorMatrix matrix);
};
#endif
(Map.cpp)
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "Map.h"
#include "Arduino.h"
Map::Map(uint8_t walls_bmp[8]) {
for (uint8_t i = 0; i < 8; i++) {
walls[i] = walls_bmp[i];
}
}
void Map::draw(Adafruit_BicolorMatrix matrix){
matrix.clear();
matrix.drawBitmap(0, 0, walls, 8, 8, LED_YELLOW);
matrix.writeDisplay();
}
(Main.ino)
// For organizing maps
#include <Map.h>
static const uint8_t PROGMEM
walls1_bmp[] =
{ B10100000,
B10110000,
B10010000,
B11011100,
B01000100,
B01110100,
B00010100,
B00011100 };
setup() {
// untested example
Map map = new Map(walls1_bmp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment