Arduboy lib for NRF and mbed

Dependencies:   Adafruit_GFX

Committer:
lmayencou
Date:
Tue Dec 27 11:27:14 2016 +0000
Revision:
0:2b6d7af79c9c
first publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lmayencou 0:2b6d7af79c9c 1 #ifndef FABOY_BLE_H
lmayencou 0:2b6d7af79c9c 2 #define FABOY_BLE_H
lmayencou 0:2b6d7af79c9c 3
lmayencou 0:2b6d7af79c9c 4 #include "Adafruit_SSD1306.h"
lmayencou 0:2b6d7af79c9c 5 #include <stdint.h>
lmayencou 0:2b6d7af79c9c 6
lmayencou 0:2b6d7af79c9c 7 // main hardware compile flags
lmayencou 0:2b6d7af79c9c 8
lmayencou 0:2b6d7af79c9c 9 #if !defined(FABOY_BLE)
lmayencou 0:2b6d7af79c9c 10 #define FABOY_BLE //< compile for the ble board
lmayencou 0:2b6d7af79c9c 11 #endif
lmayencou 0:2b6d7af79c9c 12
lmayencou 0:2b6d7af79c9c 13 // EEPROM settings
lmayencou 0:2b6d7af79c9c 14 #define EEPROM_VERSION 0
lmayencou 0:2b6d7af79c9c 15 #define EEPROM_BRIGHTNESS 1
lmayencou 0:2b6d7af79c9c 16 #define EEPROM_AUDIO_ON_OFF 2
lmayencou 0:2b6d7af79c9c 17 // we reserve the first 16 byte of EEPROM for system use
lmayencou 0:2b6d7af79c9c 18 #define EEPROM_STORAGE_SPACE_START 16 // and onward
lmayencou 0:2b6d7af79c9c 19
lmayencou 0:2b6d7af79c9c 20 // eeprom settings above are needed for audio
lmayencou 0:2b6d7af79c9c 21
lmayencou 0:2b6d7af79c9c 22 #define PIXEL_SAFE_MODE
lmayencou 0:2b6d7af79c9c 23 #define SAFE_MODE
lmayencou 0:2b6d7af79c9c 24
lmayencou 0:2b6d7af79c9c 25 #ifdef FABOY_BLE
lmayencou 0:2b6d7af79c9c 26 #define SCL p12
lmayencou 0:2b6d7af79c9c 27 #define SDA p11
lmayencou 0:2b6d7af79c9c 28 #elif defined(FABOY_DEV)
lmayencou 0:2b6d7af79c9c 29 #define CS 19
lmayencou 0:2b6d7af79c9c 30 #define DC 8
lmayencou 0:2b6d7af79c9c 31 #define RST 18
lmayencou 0:2b6d7af79c9c 32 #else
lmayencou 0:2b6d7af79c9c 33 #define CS 12
lmayencou 0:2b6d7af79c9c 34 #define DC 4
lmayencou 0:2b6d7af79c9c 35 #define RST 6
lmayencou 0:2b6d7af79c9c 36 #endif
lmayencou 0:2b6d7af79c9c 37
lmayencou 0:2b6d7af79c9c 38 #ifdef FABOY_BLE
lmayencou 0:2b6d7af79c9c 39 #define RED_LED p17
lmayencou 0:2b6d7af79c9c 40 #define GREEN_LED p18
lmayencou 0:2b6d7af79c9c 41 #define BLUE_LED p19
lmayencou 0:2b6d7af79c9c 42 //#define TX_LED p20
lmayencou 0:2b6d7af79c9c 43 //#define RX_LED p20
lmayencou 0:2b6d7af79c9c 44
lmayencou 0:2b6d7af79c9c 45 #define PIN_LEFT_BUTTON p13
lmayencou 0:2b6d7af79c9c 46 #define PIN_RIGHT_BUTTON p14
lmayencou 0:2b6d7af79c9c 47 #define PIN_UP_BUTTON p15
lmayencou 0:2b6d7af79c9c 48 #define PIN_DOWN_BUTTON p16
lmayencou 0:2b6d7af79c9c 49 #define PIN_A_BUTTON p16
lmayencou 0:2b6d7af79c9c 50 #define PIN_B_BUTTON p16
lmayencou 0:2b6d7af79c9c 51
lmayencou 0:2b6d7af79c9c 52 #define LEFT_BUTTON _BV(0)
lmayencou 0:2b6d7af79c9c 53 #define RIGHT_BUTTON _BV(1)
lmayencou 0:2b6d7af79c9c 54 #define UP_BUTTON _BV(2)
lmayencou 0:2b6d7af79c9c 55 #define DOWN_BUTTON _BV(3)
lmayencou 0:2b6d7af79c9c 56 #define A_BUTTON _BV(4)
lmayencou 0:2b6d7af79c9c 57 #define B_BUTTON _BV(5)
lmayencou 0:2b6d7af79c9c 58
lmayencou 0:2b6d7af79c9c 59 #define PIN_SPEAKER_1 p20
lmayencou 0:2b6d7af79c9c 60
lmayencou 0:2b6d7af79c9c 61 #elif defined(FABOY_DEV)
lmayencou 0:2b6d7af79c9c 62 #define LEFT_BUTTON _BV(5)
lmayencou 0:2b6d7af79c9c 63 #define RIGHT_BUTTON _BV(0)
lmayencou 0:2b6d7af79c9c 64 #define UP_BUTTON _BV(4)
lmayencou 0:2b6d7af79c9c 65 #define DOWN_BUTTON _BV(1)
lmayencou 0:2b6d7af79c9c 66 #define A_BUTTON _BV(3)
lmayencou 0:2b6d7af79c9c 67 #define B_BUTTON _BV(2)
lmayencou 0:2b6d7af79c9c 68
lmayencou 0:2b6d7af79c9c 69 #define PIN_LEFT_BUTTON A2
lmayencou 0:2b6d7af79c9c 70 #define PIN_RIGHT_BUTTON A5
lmayencou 0:2b6d7af79c9c 71 #define PIN_UP_BUTTON A3
lmayencou 0:2b6d7af79c9c 72 #define PIN_DOWN_BUTTON A4
lmayencou 0:2b6d7af79c9c 73 #define PIN_A_BUTTON 0
lmayencou 0:2b6d7af79c9c 74 #define PIN_B_BUTTON 1
lmayencou 0:2b6d7af79c9c 75
lmayencou 0:2b6d7af79c9c 76 #define RED_LED 10
lmayencou 0:2b6d7af79c9c 77 #define GREEN_LED 11
lmayencou 0:2b6d7af79c9c 78 #define BLUE_LED 9
lmayencou 0:2b6d7af79c9c 79 #define TX_LED 7
lmayencou 0:2b6d7af79c9c 80 #define RX_LED 7
lmayencou 0:2b6d7af79c9c 81
lmayencou 0:2b6d7af79c9c 82 #define PIN_SPEAKER_1 5
lmayencou 0:2b6d7af79c9c 83 #define PIN_SPEAKER_2 13
lmayencou 0:2b6d7af79c9c 84
lmayencou 0:2b6d7af79c9c 85 #else
lmayencou 0:2b6d7af79c9c 86 #error no platform defined !
lmayencou 0:2b6d7af79c9c 87 #endif
lmayencou 0:2b6d7af79c9c 88
lmayencou 0:2b6d7af79c9c 89 #define WIDTH 128
lmayencou 0:2b6d7af79c9c 90 #define HEIGHT 64
lmayencou 0:2b6d7af79c9c 91
lmayencou 0:2b6d7af79c9c 92 #define WHITE 1
lmayencou 0:2b6d7af79c9c 93 #define BLACK 0
lmayencou 0:2b6d7af79c9c 94
lmayencou 0:2b6d7af79c9c 95 #define COLUMN_ADDRESS_END (WIDTH - 1) & 0x7F
lmayencou 0:2b6d7af79c9c 96 #define PAGE_ADDRESS_END ((HEIGHT/8)-1) & 0x07
lmayencou 0:2b6d7af79c9c 97
lmayencou 0:2b6d7af79c9c 98 #define SPRITE_MASKED 1
lmayencou 0:2b6d7af79c9c 99 #define SPRITE_UNMASKED 2
lmayencou 0:2b6d7af79c9c 100 #define SPRITE_OVERWRITE 2
lmayencou 0:2b6d7af79c9c 101 #define SPRITE_PLUS_MASK 3
lmayencou 0:2b6d7af79c9c 102 #define SPRITE_IS_MASK 250
lmayencou 0:2b6d7af79c9c 103 #define SPRITE_IS_MASK_ERASE 251
lmayencou 0:2b6d7af79c9c 104 #define SPRITE_AUTO_MODE 255
lmayencou 0:2b6d7af79c9c 105
lmayencou 0:2b6d7af79c9c 106 class ArduboyAudio
lmayencou 0:2b6d7af79c9c 107 {
lmayencou 0:2b6d7af79c9c 108 public:
lmayencou 0:2b6d7af79c9c 109 void setup();
lmayencou 0:2b6d7af79c9c 110 void on();
lmayencou 0:2b6d7af79c9c 111 void off();
lmayencou 0:2b6d7af79c9c 112 void saveOnOff();
lmayencou 0:2b6d7af79c9c 113 bool enabled();
lmayencou 0:2b6d7af79c9c 114 void tone(unsigned int frequency, unsigned long duration);
lmayencou 0:2b6d7af79c9c 115
lmayencou 0:2b6d7af79c9c 116 protected:
lmayencou 0:2b6d7af79c9c 117 bool audio_enabled;
lmayencou 0:2b6d7af79c9c 118 };
lmayencou 0:2b6d7af79c9c 119
lmayencou 0:2b6d7af79c9c 120 struct Rect
lmayencou 0:2b6d7af79c9c 121 {
lmayencou 0:2b6d7af79c9c 122 public:
lmayencou 0:2b6d7af79c9c 123 int x;
lmayencou 0:2b6d7af79c9c 124 int y;
lmayencou 0:2b6d7af79c9c 125 uint8_t width;
lmayencou 0:2b6d7af79c9c 126 int height;
lmayencou 0:2b6d7af79c9c 127 };
lmayencou 0:2b6d7af79c9c 128
lmayencou 0:2b6d7af79c9c 129 struct Point
lmayencou 0:2b6d7af79c9c 130 {
lmayencou 0:2b6d7af79c9c 131 public:
lmayencou 0:2b6d7af79c9c 132 int x;
lmayencou 0:2b6d7af79c9c 133 int y;
lmayencou 0:2b6d7af79c9c 134 };
lmayencou 0:2b6d7af79c9c 135
lmayencou 0:2b6d7af79c9c 136 class Arduboy : public Adafruit_SSD1306_I2c
lmayencou 0:2b6d7af79c9c 137 {
lmayencou 0:2b6d7af79c9c 138 public:
lmayencou 0:2b6d7af79c9c 139 Arduboy();
lmayencou 0:2b6d7af79c9c 140 // void LCDDataMode();
lmayencou 0:2b6d7af79c9c 141 // void LCDCommandMode();
lmayencou 0:2b6d7af79c9c 142
lmayencou 0:2b6d7af79c9c 143 I2C i2c;
lmayencou 0:2b6d7af79c9c 144
lmayencou 0:2b6d7af79c9c 145 uint8_t getInput();
lmayencou 0:2b6d7af79c9c 146 void poll();
lmayencou 0:2b6d7af79c9c 147 bool pressed(uint8_t buttons);
lmayencou 0:2b6d7af79c9c 148 bool notPressed(uint8_t buttons);
lmayencou 0:2b6d7af79c9c 149 bool justPressed(uint8_t buttons);
lmayencou 0:2b6d7af79c9c 150 void start();
lmayencou 0:2b6d7af79c9c 151 void saveMuchPower();
lmayencou 0:2b6d7af79c9c 152 void idle();
lmayencou 0:2b6d7af79c9c 153 void blank();
lmayencou 0:2b6d7af79c9c 154 void clearDisplay();
lmayencou 0:2b6d7af79c9c 155 void display();
lmayencou 0:2b6d7af79c9c 156 // void drawScreen(const unsigned char *image);
lmayencou 0:2b6d7af79c9c 157 // void drawScreen(unsigned char image[]);
lmayencou 0:2b6d7af79c9c 158 // void drawPixel(int x, int y, uint8_t color);
lmayencou 0:2b6d7af79c9c 159 // uint8_t getPixel(uint8_t x, uint8_t y);
lmayencou 0:2b6d7af79c9c 160 // void drawCircle(int16_t x0, int16_t y0, int16_t r, uint8_t color);
lmayencou 0:2b6d7af79c9c 161 // void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint8_t color);
lmayencou 0:2b6d7af79c9c 162 // void fillCircle(int16_t x0, int16_t y0, int16_t r, uint8_t color);
lmayencou 0:2b6d7af79c9c 163 // void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint8_t color);
lmayencou 0:2b6d7af79c9c 164 // void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint8_t color);
lmayencou 0:2b6d7af79c9c 165 // void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t color);
lmayencou 0:2b6d7af79c9c 166 // void drawFastVLine(int16_t x, int16_t y, int16_t h, uint8_t color);
lmayencou 0:2b6d7af79c9c 167 // void drawFastHLine(int16_t x, int16_t y, int16_t w, uint8_t color);
lmayencou 0:2b6d7af79c9c 168 // void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t color);
lmayencou 0:2b6d7af79c9c 169 // void fillScreen(uint8_t color);
lmayencou 0:2b6d7af79c9c 170 // void drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint8_t color);
lmayencou 0:2b6d7af79c9c 171 // void fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint8_t color);
lmayencou 0:2b6d7af79c9c 172 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint8_t color);
lmayencou 0:2b6d7af79c9c 173 void drawCompressed(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t color);
lmayencou 0:2b6d7af79c9c 174 unsigned char* getBuffer();
lmayencou 0:2b6d7af79c9c 175 uint8_t width();
lmayencou 0:2b6d7af79c9c 176 uint8_t height();
lmayencou 0:2b6d7af79c9c 177 virtual size_t write(uint8_t);
lmayencou 0:2b6d7af79c9c 178 void initRandomSeed();
lmayencou 0:2b6d7af79c9c 179 void swap(int16_t& a, int16_t& b);
lmayencou 0:2b6d7af79c9c 180
lmayencou 0:2b6d7af79c9c 181 //ArduboyTunes tunes;
lmayencou 0:2b6d7af79c9c 182 ArduboyAudio audio;
lmayencou 0:2b6d7af79c9c 183
lmayencou 0:2b6d7af79c9c 184 void setFrameRate(uint8_t rate);
lmayencou 0:2b6d7af79c9c 185 bool nextFrame();
lmayencou 0:2b6d7af79c9c 186 bool everyXFrames(uint8_t frames);
lmayencou 0:2b6d7af79c9c 187 int cpuLoad();
lmayencou 0:2b6d7af79c9c 188 uint8_t frameRate ;
lmayencou 0:2b6d7af79c9c 189 uint16_t frameCount ;
lmayencou 0:2b6d7af79c9c 190 uint8_t eachFrameMillis ;
lmayencou 0:2b6d7af79c9c 191 long lastFrameStart;
lmayencou 0:2b6d7af79c9c 192 long nextFrameStart ;
lmayencou 0:2b6d7af79c9c 193 bool post_render;
lmayencou 0:2b6d7af79c9c 194 uint8_t lastFrameDurationMs;
lmayencou 0:2b6d7af79c9c 195
lmayencou 0:2b6d7af79c9c 196 bool static collide(Point point, Rect rect);
lmayencou 0:2b6d7af79c9c 197 bool static collide(Rect rect, Rect rect2);
lmayencou 0:2b6d7af79c9c 198
lmayencou 0:2b6d7af79c9c 199 private:
lmayencou 0:2b6d7af79c9c 200 static unsigned char sBuffer[(HEIGHT * WIDTH) / 8];
lmayencou 0:2b6d7af79c9c 201
lmayencou 0:2b6d7af79c9c 202 void bootLCD() __attribute__((always_inline));
lmayencou 0:2b6d7af79c9c 203 void safeMode() __attribute__((always_inline));
lmayencou 0:2b6d7af79c9c 204 void slowCPU() __attribute__((always_inline));
lmayencou 0:2b6d7af79c9c 205 uint8_t readCapacitivePin(int pinToMeasure);
lmayencou 0:2b6d7af79c9c 206 uint8_t readCapXtal(int pinToMeasure);
lmayencou 0:2b6d7af79c9c 207 uint16_t rawADC(char adc_bits);
lmayencou 0:2b6d7af79c9c 208 volatile uint8_t *mosiport, *clkport, *csport, *dcport;
lmayencou 0:2b6d7af79c9c 209 uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
lmayencou 0:2b6d7af79c9c 210 uint8_t currentButtonState ;
lmayencou 0:2b6d7af79c9c 211 uint8_t previousButtonState ;
lmayencou 0:2b6d7af79c9c 212 };
lmayencou 0:2b6d7af79c9c 213
lmayencou 0:2b6d7af79c9c 214
lmayencou 0:2b6d7af79c9c 215 /////////////////////////////////
lmayencou 0:2b6d7af79c9c 216 // sprites by Dreamer3 //
lmayencou 0:2b6d7af79c9c 217 /////////////////////////////////
lmayencou 0:2b6d7af79c9c 218 class Sprites
lmayencou 0:2b6d7af79c9c 219 {
lmayencou 0:2b6d7af79c9c 220 public:
lmayencou 0:2b6d7af79c9c 221 Sprites(Arduboy &arduboy);
lmayencou 0:2b6d7af79c9c 222
lmayencou 0:2b6d7af79c9c 223 // drawExternalMask() uses a separate mask to mask image (MASKED)
lmayencou 0:2b6d7af79c9c 224 //
lmayencou 0:2b6d7af79c9c 225 // image mask before after
lmayencou 0:2b6d7af79c9c 226 //
lmayencou 0:2b6d7af79c9c 227 // ..... .OOO. ..... .....
lmayencou 0:2b6d7af79c9c 228 // ..O.. OOOOO ..... ..O..
lmayencou 0:2b6d7af79c9c 229 // OO.OO OO.OO ..... OO.OO
lmayencou 0:2b6d7af79c9c 230 // ..O.. OOOOO ..... ..O..
lmayencou 0:2b6d7af79c9c 231 // ..... .OOO. ..... .....
lmayencou 0:2b6d7af79c9c 232 //
lmayencou 0:2b6d7af79c9c 233 // image mask before after
lmayencou 0:2b6d7af79c9c 234 //
lmayencou 0:2b6d7af79c9c 235 // ..... .OOO. OOOOO O...O
lmayencou 0:2b6d7af79c9c 236 // ..O.. OOOOO OOOOO ..O..
lmayencou 0:2b6d7af79c9c 237 // OO.OO OOOOO OOOOO OO.OO
lmayencou 0:2b6d7af79c9c 238 // ..O.. OOOOO OOOOO ..O..
lmayencou 0:2b6d7af79c9c 239 // ..... .OOO. OOOOO O...O
lmayencou 0:2b6d7af79c9c 240 //
lmayencou 0:2b6d7af79c9c 241 void drawExternalMask(int16_t x, int16_t y, const uint8_t *bitmap, const uint8_t *mask, uint8_t frame, uint8_t mask_frame);
lmayencou 0:2b6d7af79c9c 242
lmayencou 0:2b6d7af79c9c 243 // drawPlusMask has the same behavior as drawExternalMask except the
lmayencou 0:2b6d7af79c9c 244 // data is arranged in byte tuples interposing the mask right along
lmayencou 0:2b6d7af79c9c 245 // with the image data (SPRITE_PLUS_MASK)
lmayencou 0:2b6d7af79c9c 246 //
lmayencou 0:2b6d7af79c9c 247 // typical image data (8 bytes):
lmayencou 0:2b6d7af79c9c 248 // [I][I][I][I][I][I][I][I]
lmayencou 0:2b6d7af79c9c 249 //
lmayencou 0:2b6d7af79c9c 250 // interposed image/mask data (8 byes):
lmayencou 0:2b6d7af79c9c 251 // [I][M][I][M][I][M][I][M]
lmayencou 0:2b6d7af79c9c 252 //
lmayencou 0:2b6d7af79c9c 253 // The byte order does not change, just for every image byte you mix
lmayencou 0:2b6d7af79c9c 254 // in it's matching mask byte. Softare tools make easy work of this.
lmayencou 0:2b6d7af79c9c 255 //
lmayencou 0:2b6d7af79c9c 256 // See: https://github.com/yyyc514/img2ard
lmayencou 0:2b6d7af79c9c 257 void drawPlusMask(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame);
lmayencou 0:2b6d7af79c9c 258
lmayencou 0:2b6d7af79c9c 259 // drawOverwrite() replaces the existing content completely (UNMASKED)
lmayencou 0:2b6d7af79c9c 260 //
lmayencou 0:2b6d7af79c9c 261 // image before after
lmayencou 0:2b6d7af79c9c 262 //
lmayencou 0:2b6d7af79c9c 263 // ..... ..... .....
lmayencou 0:2b6d7af79c9c 264 // ..O.. ..... ..O..
lmayencou 0:2b6d7af79c9c 265 // OO.OO ..... OO.OO
lmayencou 0:2b6d7af79c9c 266 // ..O.. ..... ..O..
lmayencou 0:2b6d7af79c9c 267 // ..... ..... .....
lmayencou 0:2b6d7af79c9c 268 //
lmayencou 0:2b6d7af79c9c 269 // image before after
lmayencou 0:2b6d7af79c9c 270 //
lmayencou 0:2b6d7af79c9c 271 // ..... OOOOO .....
lmayencou 0:2b6d7af79c9c 272 // ..O.. OOOOO ..O..
lmayencou 0:2b6d7af79c9c 273 // OO.OO OOOOO OO.OO
lmayencou 0:2b6d7af79c9c 274 // ..O.. OOOOO ..O..
lmayencou 0:2b6d7af79c9c 275 // ..... OOOOO .....
lmayencou 0:2b6d7af79c9c 276 //
lmayencou 0:2b6d7af79c9c 277 void drawOverwrite(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame);
lmayencou 0:2b6d7af79c9c 278
lmayencou 0:2b6d7af79c9c 279 // drawErase() removes the lit pixels in the image from the display
lmayencou 0:2b6d7af79c9c 280 // (SPRITE_IS_MASK_ERASE)
lmayencou 0:2b6d7af79c9c 281 //
lmayencou 0:2b6d7af79c9c 282 // image before after
lmayencou 0:2b6d7af79c9c 283 //
lmayencou 0:2b6d7af79c9c 284 // ..... ..... .....
lmayencou 0:2b6d7af79c9c 285 // ..O.. ..... .....
lmayencou 0:2b6d7af79c9c 286 // OO.OO ..... .....
lmayencou 0:2b6d7af79c9c 287 // ..O.. ..... .....
lmayencou 0:2b6d7af79c9c 288 // ..... ..... .....
lmayencou 0:2b6d7af79c9c 289 //
lmayencou 0:2b6d7af79c9c 290 // image before after
lmayencou 0:2b6d7af79c9c 291 //
lmayencou 0:2b6d7af79c9c 292 // ..... OOOOO OOOOO
lmayencou 0:2b6d7af79c9c 293 // ..O.. OOOOO OO.OO
lmayencou 0:2b6d7af79c9c 294 // OO.OO OOOOO ..O..
lmayencou 0:2b6d7af79c9c 295 // ..O.. OOOOO OO.OO
lmayencou 0:2b6d7af79c9c 296 // ..... OOOOO OOOOO
lmayencou 0:2b6d7af79c9c 297 //
lmayencou 0:2b6d7af79c9c 298
lmayencou 0:2b6d7af79c9c 299 void drawErase(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame);
lmayencou 0:2b6d7af79c9c 300
lmayencou 0:2b6d7af79c9c 301 // drawSelfMasked() only draws lit pixels, black pixels in
lmayencou 0:2b6d7af79c9c 302 // your image are treated as "transparent" (SPRITE_IS_MASK)
lmayencou 0:2b6d7af79c9c 303 //
lmayencou 0:2b6d7af79c9c 304 // image before after
lmayencou 0:2b6d7af79c9c 305 //
lmayencou 0:2b6d7af79c9c 306 // ..... ..... .....
lmayencou 0:2b6d7af79c9c 307 // ..O.. ..... ..O..
lmayencou 0:2b6d7af79c9c 308 // OO.OO ..... OO.OO
lmayencou 0:2b6d7af79c9c 309 // ..O.. ..... ..O..
lmayencou 0:2b6d7af79c9c 310 // ..... ..... .....
lmayencou 0:2b6d7af79c9c 311 //
lmayencou 0:2b6d7af79c9c 312 // image before after
lmayencou 0:2b6d7af79c9c 313 //
lmayencou 0:2b6d7af79c9c 314 // ..... OOOOO OOOOO (no change because all pixels were
lmayencou 0:2b6d7af79c9c 315 // ..O.. OOOOO OOOOO already white)
lmayencou 0:2b6d7af79c9c 316 // OO.OO OOOOO OOOOO
lmayencou 0:2b6d7af79c9c 317 // ..O.. OOOOO OOOOO
lmayencou 0:2b6d7af79c9c 318 // ..... OOOOO OOOOO
lmayencou 0:2b6d7af79c9c 319 //
lmayencou 0:2b6d7af79c9c 320 void drawSelfMasked(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame);
lmayencou 0:2b6d7af79c9c 321 // master function, needs to be abstracted into sep function for
lmayencou 0:2b6d7af79c9c 322 // every render type
lmayencou 0:2b6d7af79c9c 323 void draw(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t frame, const uint8_t *mask, uint8_t sprite_frame, uint8_t drawMode);
lmayencou 0:2b6d7af79c9c 324 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, const uint8_t *mask, int8_t w, int8_t h, uint8_t draw_mode);
lmayencou 0:2b6d7af79c9c 325
lmayencou 0:2b6d7af79c9c 326 private:
lmayencou 0:2b6d7af79c9c 327
lmayencou 0:2b6d7af79c9c 328 Arduboy *arduboy;
lmayencou 0:2b6d7af79c9c 329 unsigned char *sBuffer;
lmayencou 0:2b6d7af79c9c 330 };
lmayencou 0:2b6d7af79c9c 331
lmayencou 0:2b6d7af79c9c 332 #endif