Skip to content

Instantly share code, notes, and snippets.

@polygondoor
Created December 17, 2015 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polygondoor/ada118a557953751636a to your computer and use it in GitHub Desktop.
Save polygondoor/ada118a557953751636a to your computer and use it in GitHub Desktop.
animation Play 2
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
// tell the little OLED screen that we are 128 x 32 pixels
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // dont worry about this line, it looks complex
// set text size and other things
display.setTextSize(1);
display.setTextColor(WHITE);
display.setTextWrap(1);
// Tell the Arduino that pin 3 is an input pin.
pinMode(3, INPUT);
}
void loop() {
display.clearDisplay();
drawBitMap(60,0);
// send info to display
display.display();
}
static const unsigned char PROGMEM icon_bmp_1[] =
{ B00000000, B00000000, // 0
B00000000, B00000000, // 1
B00000000, B01100000, // 2
B00000000, B01110000, // 3
B00000000, B11110000, // 4
B00000001, B11110000, // 5
B00001111, B11100000, // 6
B00011111, B11110000, // 7
B00011111, B10111000, // 8
B00011111, B00111000, // 9
B00001100, B00011000, // 10
B00000000, B00111000, // 11
B00000001, B11110000, // 12
B00000000, B00000000, // 13
B00000000, B00000000, // 14
B00000000, B00000000 // 15
};
static const unsigned char PROGMEM icon_bmp_2[] =
{ B00000000, B00000000, // 0
B00000000, B00000000, // 1
B00000000, B01100000, // 2
B00000000, B01110000, // 3
B00000000, B11110000, // 4
B00011001, B11100000, // 5
B00011111, B11100000, // 6
B00111111, B11110000, // 7
B00111111, B10111000, // 8
B00111111, B00111000, // 9
B00011100, B00011000, // 10
B00011100, B00111000, // 11
B00000000, B01110000, // 12
B00000000, B11100000, // 13
B00000001, B10000000, // 14
B00000000, B00000000 // 15
};
int i = 0;
int frame = 0;
void drawBitMap(int x, int y)
{
frame = i%2;
switch (frame) {
case 0: display.drawBitmap(x, y, icon_bmp_1, 16, 16, 1);
break;
case 1: display.drawBitmap(x, y, icon_bmp_2, 16, 16, 1);
break;
}
i = i + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment