Created
December 17, 2015 22:33
-
-
Save polygondoor/ada118a557953751636a to your computer and use it in GitHub Desktop.
animation Play 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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