Guest User

Wiley's badge

a guest
May 27th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 25.37 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <Adafruit_GFX.h>
  3. #include <Adafruit_SSD1325.h>
  4.  
  5. #define OLED_CS 11
  6. #define OLED_RESET 10
  7. #define OLED_DC 12
  8. Adafruit_SSD1325 display(OLED_DC,OLED_RESET,OLED_CS);
  9.  
  10. //61x64 Frost logo
  11. static const unsigned char PROGMEM img_logo[] = {0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x77,0xf0,0x0,0x0,0x0,0x0,0x0,0x7,0xf3,0xff,0x0,0x0,0x0,0x0,0x0,0x3d,0x90,0x87,0xe0,0x0,0x0,0x0,0x0,0xfc,0x88,0x40,0xf8,0x0,0x0,0x0,0x1,0xe4,0x48,0x20,0x3c,0x0,0x0,0x0,0x7,0xc4,0x48,0x18,0x1f,0x0,0x0,0x0,0xf,0x4,0x28,0xc,0x7,0x80,0x0,0x0,0x3e,0x4,0x18,0x6,0x3,0xe0,0x0,0x0,0x7c,0x4,0xc,0x83,0x1,0xf0,0x0,0x0,0xf8,0x4,0xc,0x41,0x80,0xf8,0x0,0x1,0xf0,0x42,0x4,0x60,0x80,0xfc,0x0,0x1,0xf0,0x63,0x84,0x20,0x40,0x7c,0x0,0x3,0xe0,0x5b,0x82,0x30,0x60,0x3e,0x0,0x7,0xc4,0x47,0xc2,0x78,0x20,0x1f,0x0,0xf,0xc6,0x20,0xfe,0x38,0x10,0x1f,0x80,0xf,0x8b,0x90,0x1,0x14,0x10,0xf,0x80,0x1f,0x8f,0x98,0x1,0x3c,0x10,0xf,0xc0,0x1f,0x80,0x70,0x0,0xbe,0x8,0xf,0xc0,0x3f,0x0,0xc0,0x0,0x9a,0xc,0x7,0xe0,0x3f,0x1,0x0,0x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c0,0x1f,0xfe,0x0,0x1,0xff,0x0,0x0,0x40,0x1f,0xfc,0x0,0x1,0xff,0xc0,0x0,0x80,0x1f,0xfc,0x0,0x0,0xff,0xe0,0x7,0x0,0x3f,0xf8,0x0,0x0,0x7f,0xf8,0x6,0x0,0xff,0xf0,0x0,0x0,0x3f,0xff,0x6,0x7,0xff,0xe0,0x0,0x0,0xf,0xff,0xf6,0x7f,0xff,0x80,0x0,0x0,0x7,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xfe,0x0,0x0,0x0,0x0,0xff,0xff,0xff,0xf8,0x0,0x0,0x0,0x0,0x3f,0xff,0xff,0xe0,0x0,0x0,0x0,0x0,0x7,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xf8,0x0,0x0,0x0};
  12.  
  13. #define BG_X (-1)
  14. #define BG_Y 22
  15. #define BG_WIDTH 68
  16. #define BG_HEIGHT 84
  17. static const unsigned char PROGMEM img_bg[] = {0x0,0x0,0x0,0x0,0x0,0x3,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1f,0xf0,0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x1f,0xf8,0x0,0x0,0x0,0x0,0x0,0x1e,0x0,0x1f,0xf8,0x0,0x0,0x0,0x0,0x0,0x3f,0x0,0x3f,0xfc,0x0,0x0,0x0,0x0,0x0,0x7f,0x80,0x3f,0xfe,0x0,0x0,0x0,0x0,0x0,0x7f,0xc0,0x7f,0xfe,0x0,0x0,0x0,0x0,0x0,0xff,0xe3,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0xff,0xe7,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0xff,0xff,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0xff,0xff,0xff,0xff,0xc0,0x0,0x0,0x0,0x1,0xff,0xff,0xff,0xff,0xc0,0x0,0x0,0x0,0x1,0xff,0xff,0xff,0xff,0xe0,0x0,0x0,0x0,0x1,0xff,0xff,0xff,0xff,0xe0,0x0,0x0,0x0,0x1,0xff,0xff,0xff,0xff,0xe0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0x7,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0x7,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x0,0xf,0xff,0xff,0xff,0xff,0xf8,0x0,0x0,0x0,0xf,0xff,0xff,0xff,0xff,0xfc,0x0,0x0,0x0,0xf,0xff,0xff,0xff,0xff,0xfc,0x0,0x0,0x6,0xf,0xff,0xff,0xff,0xff,0xfc,0x0,0x3,0xcf,0xdf,0xff,0xff,0xff,0xff,0xfc,0x0,0x7,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0xe,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x4,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xfe,0x0,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xfe,0x0,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xf0,0x0,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xe7,0xc0,0x3e,0x1f,0xff,0xff,0xff,0xff,0xff,0xcf,0xe0,0x7f,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xbf,0xff,0xff,0xff,0xff,0xff,0xff,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xf,0xff,0xfb,0xff,0xff,0xff,0xff,0xff,0x0,0x7,0xff,0xf9,0xff,0xff,0xff,0xff,0xff,0x0,0x7,0xff,0xf9,0xff,0xff,0xff,0xff,0xff,0x0,0x3,0xff,0xf1,0xff,0xff,0xff,0xff,0xff,0x0,0x3,0xff,0xf1,0xff,0xff,0xff,0xff,0xff,0x0,0x1,0xff,0xe1,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0xf3,0xc0,0xff,0xff,0xff,0xfc,0xfe,0x0,0x0,0x61,0x80,0x7f,0xff,0xff,0xf8,0x7c,0x0};
  18.  
  19. #define FG_X (-2)
  20. #define FG_Y 21
  21. #define FG_WIDTH 70
  22. #define FG_HEIGHT 86
  23. static const unsigned char PROGMEM img_fg[] = {0x0,0x0,0x0,0x0,0x0,0x1,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x9,0xc8,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x13,0x64,0x0,0x0,0x0,0x0,0x0,0x9,0x0,0x12,0xb2,0x0,0x0,0x0,0x0,0x0,0x10,0x80,0x13,0x52,0x0,0x0,0x0,0x0,0x0,0x26,0x40,0x26,0xa9,0x0,0x0,0x0,0x0,0x0,0x4d,0x20,0x25,0x54,0x80,0x0,0x0,0x0,0x0,0x4a,0x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,0xd5,0x32,0x0,0x0,0x24,0x0,0x70,0x1a,0xaa,0xbf,0x7,0xe0,0x1f,0x24,0x3,0x90,0x15,0x55,0x6a,0xc,0x10,0x20,0x92,0x3c,0x10,0x1a,0x80,0x0,0x18,0x8,0x40,0x51,0xc0,0x0,0x1,0x3f,0xff,0xc3,0xc8,0x9f,0x24,0x1f,0x7c,0xf8,0x40,0x6,0x24,0x48,0x90,0x8a,0x21,0x42,0x88,0x40,0x5,0x18,0x90,0x90,0x89,0x21,0x42,0x88,0x40,0x5,0x0,0x90,0x48,0x50,0xc2,0x42,0x88,0x41,0xfc,0x80,0x90,0x48,0x60,0x2,0x42,0x88,0x42,0x0,0x81,0x20,0x26,0xaa,0xac,0x6a,0xa8,0x6b,0xfc,0x6b,0x20,0x25,0x55,0x54,0x56,0xd8,0x35,0x54,0x56,0x40,0x12,0xaa,0xa8,0x6a,0xa8,0x2a,0xac,0x2a,0x40,0x13,0x55,0x58,0x56,0xd8,0x35,0x54,0x36,0x40,0x9,0xaa,0xa8,0x6a,0xa8,0x2b,0xfc,0x2a,0x40,0x9,0xff,0xf2,0x7e,0xf8,0x3e,0x0,0x3e,0x40,0x4,0xff,0xf3,0x3e,0xff,0x7f,0xfc,0x3e,0x40,0x4,0xf9,0xf3,0x3e,0xff,0x7f,0xfe,0x3e,0x40,0x2,0x79,0xe5,0x3e,0xff,0x7f,0xfe,0x3e,0x40,0x2,0x78,0xe5,0x3e,0xff,0x7f,0xfe,0x3e,0x40,0x1,0x30,0xc9,0x3e,0xff,0x3f,0xfc,0x3e,0x40,0x0,0x86,0x10,0x80,0x0,0x0,0x1,0x80,0x80,0x0,0x49,0x20,0x40,0x0,0x0,0x2,0x41,0x0,0x0,0x30,0xc0,0x3f,0xff,0xff,0xfc,0x3e,0x0};
  24.  
  25. #define LOGO_X 8
  26. #define LOGO_Y 30
  27. #define LOGO_WIDTH 48
  28. #define LOGO_HEIGHT 48
  29. //telegram
  30. static const unsigned char PROGMEM logo_tg[] = {0x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0x60,0x0,0x7f,0x0,0x0,0x0,0x0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0xf,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
  31. //instagram
  32. static const unsigned char PROGMEM logo_ig[] = {0x0,0x4f,0xff,0xff,0xff,0x0,0x2,0x4f,0xff,0xff,0xff,0xc0,0x2,0x4f,0xff,0xff,0xff,0xf0,0x12,0x4f,0xff,0xff,0xff,0xf8,0x32,0x4f,0xff,0xff,0xf0,0x3c,0x32,0x4f,0xff,0xff,0xe0,0x1c,0x72,0x4f,0xff,0xff,0xe0,0x1e,0x72,0x4f,0xff,0xff,0xe0,0x1e,0xf2,0x4f,0xff,0xff,0xe0,0x1f,0xf2,0x4f,0xff,0xff,0xe0,0x1f,0xf2,0x4f,0xff,0xff,0xe0,0x1f,0xf2,0x4f,0xff,0xff,0xf0,0x3f,0xff,0xff,0xf0,0xf,0xff,0xff,0xff,0xff,0xc0,0x3,0xff,0xff,0xff,0xff,0x0,0x0,0xff,0xff,0x0,0x0,0x7,0xe0,0x0,0x0,0x0,0x0,0x1f,0xf8,0x0,0x0,0xff,0xfc,0x3f,0xfc,0x3f,0xff,0xff,0xf8,0x7c,0x3e,0x1f,0xff,0xff,0xf8,0xf0,0xf,0x1f,0xff,0xff,0xf0,0xe0,0x7,0xf,0xff,0xff,0xf1,0xe0,0x7,0x8f,0xff,0xff,0xf1,0xc0,0x3,0x8f,0xff,0xff,0xf1,0xc0,0x3,0x8f,0xff,0xff,0xf1,0xc0,0x3,0x8f,0xff,0xff,0xf1,0xc0,0x3,0x8f,0xff,0xff,0xf1,0xe0,0x7,0x8f,0xff,0xff,0xf0,0xe0,0x7,0xf,0xff,0xff,0xf8,0xf0,0xf,0x1f,0xff,0xff,0xf8,0x7c,0x3e,0x1f,0xff,0xff,0xfc,0x3f,0xfc,0x3f,0xff,0xff,0xfc,0x1f,0xf8,0x3f,0xff,0xff,0xfe,0x7,0xe0,0x7f,0xff,0xff,0xff,0x0,0x0,0xff,0xff,0xff,0xff,0xc0,0x3,0xff,0xff,0xff,0xff,0xf0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xff,0xff,0xff,0xff,0xfe,0x7f,0xff,0xff,0xff,0xff,0xfe,0x3f,0xff,0xff,0xff,0xff,0xfc,0x3f,0xff,0xff,0xff,0xff,0xfc,0x1f,0xff,0xff,0xff,0xff,0xf8,0xf,0xff,0xff,0xff,0xff,0xf0,0x3,0xff,0xff,0xff,0xff,0xc0,0x0,0xff,0xff,0xff,0xff,0x0};
  33. //furaffinity
  34. static const unsigned char PROGMEM logo_fa[] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0xff,0xff,0xfe,0x7f,0xff,0x3,0xff,0xff,0xfe,0x7f,0xff,0xf,0xff,0xff,0xfe,0x7f,0xff,0x1f,0xff,0xff,0xfe,0x7,0xfe,0x3f,0xff,0xff,0xff,0x3,0xfe,0x3f,0xff,0xff,0xff,0xf3,0xfe,0x7f,0xff,0xff,0xff,0xf3,0xfc,0xff,0xe0,0x0,0xff,0xf3,0xfc,0xff,0x80,0x0,0x3f,0xf3,0xfc,0xff,0x80,0x0,0x1f,0xf0,0x7c,0xff,0x80,0x0,0x1f,0xf8,0x3c,0x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xff,0xff,0xf8,0x7f,0xf8,0x1,0xff,0xff,0xe0,0x3f,0xff,0x1,0xff,0xff,0xe0,0x3f,0xff,0xf9,0xff,0xff,0xe0,0x1f,0xff,0xff,0xff,0xff,0xe0,0x8f,0xff,0xff,0xff,0xff,0xe0,0xf7,0xff,0xff,0xff,0xff,0xe0,0xff,0xff,0xff,0xff,0xff,0xe0,0x7f,0xff,0xff,0xff,0xff,0xe0,0x3f,0xff,0xff,0xff,0xff,0xc0,0x3f,0xff,0xff,0xff,0xff,0xc0,0x1f,0xff,0xff,0xff,0xff,0xc0,0x1f,0xff,0xff,0xff,0xff,0xc0,0xf,0xff,0xff,0xff,0xff,0x80,0x3,0xff,0xff,0xff,0xff,0x80,0x0,0xff,0xff,0xff,0xff,0x0,0x7,0xff,0xff,0xff,0xff,0x0,0x7,0xff,0xff,0xff,0xfe,0x0,0x3,0xff,0xff,0xff,0xfe,0x0,0x3,0xff,0xff,0xff,0xfc,0x0,0x1,0xff,0xff,0xff,0xf8,0x0,0x0,0x7f,0xff,0xff,0xf0,0x0,0x0,0x1f,0xff,0xff,0xf0,0x0,0x0,0x7,0xff,0xff,0xe0,0x0,0x0,0x1f,0xff,0xff,0xc0,0x0,0x0,0x7f,0xff,0xff,0x80,0x0,0x3,0xff,0xff,0xfe,0x0,0x0,0xff,0xff,0xff,0xfc,0x0,0x0,0x3f,0xff,0xff,0xf0,0x0,0x0,0xf,0xff,0xff,0xc0,0x0,0x0,0x3,0xff,0xfe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
  37.  
  38. //sprites for background animation
  39. #define SPRITE_WIDTH 16
  40. #define SPRITE_HEIGHT 16
  41. #define SPRITE_PADDING 8
  42. #define SPRITE_SIZE (SPRITE_PADDING+SPRITE_WIDTH)
  43. static const unsigned char PROGMEM sprite_1up[] = {0x7,0xe0,0x1e,0x78,0x2e,0x74,0x4c,0x32,0x60,0x6,0xf3,0xcf,0xf7,0xef,0xf7,0xef,0xe3,0xc7,0x80,0x1,0x8f,0xf1,0x9d,0xb9,0x7d,0xbe,0x3f,0xfc,0x3f,0xfc,0x1f,0xf8};
  44. static const unsigned char PROGMEM sprite_block[] = {0x7f,0xfe,0x80,0x1,0xa0,0x5,0x87,0xc1,0x8c,0x61,0x8c,0x61,0x8c,0x61,0x80,0xe1,0x81,0x81,0x81,0x81,0x80,0x1,0x81,0x81,0x81,0x81,0xa0,0x5,0x80,0x1,0xff,0xff};
  45. static const unsigned char PROGMEM sprite_coin[] = {0x0,0x0,0x7,0xe0,0x8,0x30,0xb,0x30,0x14,0x98,0x14,0x98,0x14,0x98,0x14,0x98,0x14,0x98,0x14,0x98,0x14,0x98,0x14,0x98,0xb,0x30,0x8,0x30,0x7,0xe0,0x0,0x0};
  46. static const unsigned char PROGMEM sprite_goomba[] = {0x3,0xc0,0x7,0xe0,0xf,0xf0,0x1f,0xf8,0x27,0xe4,0x73,0xce,0x74,0x2e,0xf5,0xaf,0xf1,0x8f,0xff,0xff,0x7f,0xfe,0x8,0x10,0x8,0x1c,0x18,0x3e,0x1f,0xfe,0xe,0x7c};
  47. static const unsigned char PROGMEM sprite_mario[] = {0x7,0xc0,0xf,0xf8,0x9,0xa0,0x1b,0xb8,0x19,0xdc,0x1f,0x80,0x7,0xf0,0xf,0xd0,0x12,0x48,0x23,0xc4,0x35,0xac,0x37,0xec,0x37,0xec,0xe,0x70,0x14,0x28,0x3c,0x3c};
  48. static const unsigned char PROGMEM sprite_mushroom[] = {0x3,0xc0,0x4,0x60,0x8,0xf0,0x10,0xf8,0x20,0x74,0x5c,0x2,0x7e,0x2,0xbe,0xd,0xbe,0xf,0x9c,0x7,0x80,0x1,0x77,0xee,0xf,0xf0,0xf,0xd0,0xf,0xd0,0x7,0xa0};
  49. static const unsigned char PROGMEM sprite_shell[] = {0x0,0x0,0x7,0xe0,0xb,0xd0,0x14,0x28,0x18,0x18,0x30,0xc,0x28,0x14,0x44,0x22,0x43,0xc2,0xe4,0x27,0xf8,0x1f,0x18,0x18,0xc,0x30,0x7,0xe0,0x3,0xc0,0x0,0x0};
  50. static const unsigned char PROGMEM sprite_star[] = {0x1,0x80,0x1,0x80,0x3,0xc0,0x3,0xc0,0x7,0xe0,0x7f,0xfe,0x7d,0xbe,0x3d,0xbc,0x1d,0xb8,0xf,0xf0,0xf,0xf0,0x1f,0xf8,0x1f,0xf8,0x1e,0x78,0x38,0x1c,0x30,0xc};
  51.  
  52. //battery, 27*5
  53. static const unsigned char PROGMEM bmp_battery[] = {0xce,0xee,0xee,0xa0,0xaa,0x44,0x8a,0xa0,0xce,0x44,0xcc,0x40,0xaa,0x44,0x8a,0x40,0xca,0x44,0xea,0x40};
  54. //sleep icon, 34*35
  55. static const unsigned char PROGMEM bmp_sleep[] = {0x0,0x1,0xe0,0x0,0x0,0x0,0x3,0xf0,0x0,0x0,0x0,0x3,0xf0,0x0,0x0,0x0,0x3,0xf0,0x0,0x0,0x0,0x3,0xf0,0x0,0x0,0x1,0xe3,0xf1,0xe0,0x0,0x3,0xe3,0xf1,0xf0,0x0,0x7,0xe3,0xf1,0xf8,0x0,0xf,0xe3,0xf1,0xfc,0x0,0x1f,0xc3,0xf0,0xfe,0x0,0x3f,0x83,0xf0,0x7f,0x0,0x3f,0x3,0xf0,0x3f,0x0,0x7e,0x3,0xf0,0x1f,0x80,0x7e,0x3,0xf0,0x1f,0x80,0x7c,0x3,0xf0,0xf,0x80,0xfc,0x3,0xf0,0xf,0xc0,0xf8,0x3,0xf0,0x7,0xc0,0xf8,0x3,0xf0,0x7,0xc0,0xf8,0x3,0xf0,0x7,0xc0,0xf8,0x1,0xe0,0x7,0xc0,0xf8,0x0,0x0,0x7,0xc0,0xf8,0x0,0x0,0x7,0xc0,0xfc,0x0,0x0,0xf,0xc0,0x7c,0x0,0x0,0xf,0x80,0x7e,0x0,0x0,0x1f,0x80,0x7e,0x0,0x0,0x1f,0x80,0x3f,0x0,0x0,0x3f,0x0,0x3f,0x80,0x0,0x7e,0x0,0x1f,0xc0,0x0,0xfe,0x0,0xf,0xf0,0x3,0xfc,0x0,0x7,0xff,0xff,0xf8,0x0,0x3,0xff,0xff,0xf0,0x0,0x1,0xff,0xff,0xe0,0x0,0x0,0x7f,0xff,0x80,0x0,0x0,0x1f,0xfe,0x0,0x0};
  56.  
  57. #define BUTTON 5
  58. #define ANIM_STEPS 9
  59. #define NUM_SLIDES 3
  60.  
  61. int8_t anim_x = 0;
  62. int8_t anim_y = 0;
  63. int8_t anim_xvel = 1;
  64. int8_t anim_yvel = 1;
  65. byte anim_spritesx[4] = {0,1,2,3};
  66. byte anim_spritesy[7] = {0,1,2,3,4,5,6};
  67.  
  68. #define TABLE_SIZE 64
  69. #define FLOAT_SIZE 10
  70. byte acceltable[TABLE_SIZE];
  71. int8_t floattable[] = {0,1,2,2,1,0,-1,-2,-2,-1};
  72.  
  73. #define SLEEP_TIME (5*24*60*1000)
  74.  
  75. byte image = 0;
  76. unsigned long starttime,progstarttime,sleepstarttime;
  77. byte sleeping = 0;
  78. byte timeout = 0;
  79. byte offsetindex = 0;
  80. int8_t offset = 0;
  81.  
  82. #define BKG_NONE 0
  83. #define BKG_STARS 1
  84. #define BKG_GRID 2
  85. byte bkg_anim = BKG_STARS;
  86.  
  87. #define VOLT_LOW 3.5
  88.  
  89. byte prevstate = 0;
  90.  
  91. void setup()
  92. {
  93.   Serial.begin(112500);
  94.  
  95.  
  96.   pinMode(BUTTON,INPUT_PULLUP);
  97.   display.begin();
  98.   display.setRotation(3);
  99.   display.clearDisplay();
  100.   display.setTextColor(1);
  101.   display.setTextSize(1);
  102.   display.setTextWrap(false);
  103.  
  104.   display.drawBitmap(2,31,img_logo,61,64,1);
  105.   display.setTextColor(0);
  106.   display.display();
  107.  
  108.   for(byte i = 0; i < TABLE_SIZE; i++)
  109.   {
  110.     float curpos = float(map(i,0,TABLE_SIZE - 1,0,100)) / 100.0;
  111.     acceltable[i] = pow(curpos,2) * 255;
  112.   }
  113.  
  114.   delay(1000);
  115.  
  116.   display.clearDisplay();
  117.   progstarttime = millis();
  118.   sleepstarttime = millis();
  119.  
  120.   Serial.begin(112500);
  121. }
  122.  
  123. void loop()
  124. {
  125.   while(sleeping)
  126.   {
  127.     if(getButton())
  128.     {
  129.       while(getButton()) { delay(5); }
  130.       sleeping = 0;
  131.       sleepstarttime = millis();
  132.       image = 0;
  133.       prevstate = 0;
  134.     }
  135.   }
  136.  
  137.   smoothAnimation(63,0,offset,image,1,0); //image enter animation
  138.   unsigned long floattime = millis();
  139.   unsigned long starttime = millis();
  140.   unsigned long presstime = 0;
  141.   byte cont = 0;
  142.  
  143.   while(!cont)
  144.   {
  145.     if(getButton() > prevstate) { presstime = millis(); }
  146.     else if(getButton() < prevstate) { cont = 1; }
  147.     prevstate = getButton();
  148.    
  149.     if(millis() - starttime > SLEEP_TIME || (millis() - presstime > 3000 && getButton()))
  150.     {
  151.       sleepMode();
  152.       return;
  153.     }
  154.    
  155.     display.clearDisplay();
  156.     updateAndDrawBkg(); //draw background animation
  157.     drawImage(0,offset,image); //draw image overtop of animation
  158.     display.display();
  159.     if(millis() - floattime > 150)
  160.     {
  161.       offsetindex++;
  162.       if(offsetindex > 9) { offsetindex = 0; }
  163.       offset = floattable[offsetindex];
  164.       floattime = millis();
  165.     }
  166.  
  167.     if(image > 0) { image = ((millis() - starttime) / 1500) % 2 + 1; }
  168.   }
  169.  
  170.   smoothAnimation(0,-63,offset,image,1,1); //image exit animation
  171.   image = !image > 0;
  172. }
  173.  
  174. void sleepMode()
  175. {
  176.   sleeping = 1;
  177.  
  178.   for(byte i = 0; i < 64; i += 8)
  179.   {
  180.     display.fillRect(0,i,64,8,0);
  181.     display.fillRect(0,128 - i,64,8,0);
  182.     display.display();
  183.   }
  184.  
  185.   display.clearDisplay();
  186.   display.drawBitmap(15,47,bmp_sleep,34,35,1);
  187.  
  188.   const byte barwidth = 30;
  189.   byte xpos = (64 - barwidth) / 2;
  190.   display.drawBitmap(19,116,bmp_battery,27,5,1);
  191.   display.drawRect(xpos,122,barwidth,6,1);
  192.   display.fillRect(xpos + 2,124,map(getBatteryLevel(),0,101,1,barwidth - 3),2,1);
  193.  
  194.   display.display();
  195.   display.setTextColor(0);
  196.   delay(1000);
  197.   while(getButton()) { delay(5); }
  198.   display.clearDisplay();
  199.   display.display();
  200. }
  201.  
  202. void drawImage(int x,int y,byte image)
  203. {
  204.   if(image == 0) //draw badge
  205.   {
  206.     display.drawBitmap(x + BG_X,y + BG_Y,img_bg,BG_WIDTH,BG_HEIGHT,1);  //background
  207.     display.drawBitmap(x + FG_X,y + FG_Y,img_fg,FG_WIDTH,FG_HEIGHT,0);  //foreground
  208.   }
  209.   else //draw a logo
  210.   {
  211.     display.fillRoundRect(x + 3,y + 24,58,78,8,1);
  212.     display.drawRoundRect(x + 2,y + 23,60,80,9,0);
  213.    
  214.     switch(image)
  215.     {
  216.       case 1: //telegram
  217.         display.drawBitmap(x + LOGO_X,y + LOGO_Y,logo_tg,LOGO_WIDTH,LOGO_HEIGHT,0);
  218.         break;
  219.        
  220.       case 2: //twitter
  221.         display.drawBitmap(x + LOGO_X,y + LOGO_Y,logo_tw,LOGO_WIDTH,LOGO_HEIGHT,0);
  222.         break;
  223.     }
  224.    
  225.     display.setCursor(x + getCenterX(7) - 1,y + 81); display.print(F("username"));
  226.     display.setCursor(x + getCenterX(7) + 2,y + 90); display.print(F("put here"));
  227.   }
  228. }
  229.  
  230. void smoothAnimation(int fromx,int tox,int yoffset,byte image,byte stars,byte accel)
  231. {
  232.   for(int i = 0; i < ANIM_STEPS; i++)
  233.   {
  234.     display.clearDisplay();
  235.     if(stars) { updateAndDrawBkg(); }
  236.     int xpos = smoothCurve(map(i,0,ANIM_STEPS - 1,fromx,tox),fromx,tox,accel);
  237.     drawImage(xpos,yoffset,image);
  238.     display.display();
  239.   }
  240. }
  241.  
  242. void updateAndDrawBkg()
  243. {
  244.   byte max_draw = 7 * SPRITE_SIZE;
  245.   int draw_x,draw_y;
  246.   byte draw_spr;
  247.   for(byte x = 0; x < 4; x++)
  248.   {
  249.     for(byte y = 0; y < 7; y++)
  250.     {
  251.       draw_x = (anim_x - SPRITE_SIZE) + (SPRITE_SIZE * x);
  252.       draw_y = (anim_y - SPRITE_SIZE) + (SPRITE_SIZE * y);
  253.       draw_spr = (anim_spritesx[x] + anim_spritesy[y]) % 8;
  254.       drawSprite(draw_x,draw_y,draw_spr);
  255.     }
  256.   }
  257.  
  258.   anim_x += anim_xvel;
  259.   if(anim_x >= SPRITE_SIZE)
  260.   {
  261.     for(int i = 3; i >= 1; i--) { anim_spritesx[i] = anim_spritesx[i-1]; }
  262.     anim_spritesx[0] = anim_spritesx[1] - 1;
  263.     if(anim_spritesx[0] > 7) { anim_spritesx[0] = 7; }
  264.     anim_x %= SPRITE_SIZE;
  265.   }
  266.  
  267.   anim_y += anim_yvel;
  268.   if(anim_y >= SPRITE_SIZE)
  269.   {
  270.     for(int i = 6; i >= 1; i--) { anim_spritesy[i] = anim_spritesy[i-1]; }
  271.     anim_spritesy[0] = anim_spritesy[1] - 1;
  272.     if(anim_spritesy[0] > 7) { anim_spritesy[0] = 7; }
  273.     anim_y %= SPRITE_SIZE;
  274.   }
  275. }
  276.  
  277. void drawSprite(int x,int y,byte s)
  278. {
  279.   switch(s)
  280.   {
  281.     case 0: display.drawBitmap(x,y,sprite_1up,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  282.     case 1: display.drawBitmap(x,y,sprite_block,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  283.     case 2: display.drawBitmap(x,y,sprite_coin,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  284.     case 3: display.drawBitmap(x,y,sprite_goomba,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  285.     case 4: display.drawBitmap(x,y,sprite_mario,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  286.     case 5: display.drawBitmap(x,y,sprite_mushroom,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  287.     case 6: display.drawBitmap(x,y,sprite_shell,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  288.     case 7: display.drawBitmap(x,y,sprite_star,SPRITE_WIDTH,SPRITE_HEIGHT,1); break;
  289.   }
  290. }
  291.  
  292. byte getButton()
  293. {
  294.   return !digitalRead(BUTTON);
  295. }
  296. void waitForButtonUp()
  297. {
  298.   while(getButton()) { delay(5); }
  299. }
  300. float getVoltage()
  301. {
  302.   float measuredvbat = analogRead(A7);
  303.   measuredvbat *= 2;    // we divided by 2, so multiply back
  304.   measuredvbat *= 3.3;  // Multiply by 3.3V, our reference voltage
  305.   measuredvbat /= 1024; // convert to voltage
  306.   return measuredvbat;
  307. }
  308. byte getBatteryLevel()
  309. {
  310.   const byte tablesize = 3;
  311.   const int leveltable[3] = {320,370,420};
  312.   const byte target[3] = {5,50,100};
  313.   for(byte i = 0; i < tablesize - 1; i++)
  314.   {
  315.     int volt = getVoltage() * 100.0;
  316.     if(volt < leveltable[i + 1])
  317.     {
  318.       return constrain(map(volt,leveltable[i],leveltable[i + 1] - 1,target[i],target[i + 1]),0,100);
  319.     }
  320.   }
  321.   return 100;
  322. }
  323.  
  324. int smoothCurve(int cur,int lower,int upper,byte accel)
  325. {
  326.   int pos;
  327.   byte curvevalue;
  328.   if(accel)
  329.   {
  330.     pos = map(cur,lower,upper,0,TABLE_SIZE - 1);
  331.     curvevalue = acceltable[pos];
  332.   }
  333.   else
  334.   {
  335.     pos = map(cur,lower,upper,TABLE_SIZE - 1,0);
  336.     curvevalue = 255 - acceltable[pos];
  337.   }
  338.   return map(curvevalue,0,255,lower,upper);
  339. }
  340. int getCenterX(byte chars)
  341. {
  342.   return (64 - (chars * 6)) / 2;
  343. }
Advertisement
Add Comment
Please, Sign In to add comment