Created
December 8, 2023 05:17
-
-
Save mohitbhoite/8b03bea715351038dd35b32b1b216d98 to your computer and use it in GitHub Desktop.
Running simple animations on 128x32 OLED display connected to Particle Photon
This file contains hidden or 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
// This #include statement was automatically added by the Particle IDE. | |
#include "Adafruit_CCS811.h" | |
// This #include statement was automatically added by the Particle IDE. | |
#include <Adafruit_SSD1306_RK.h> | |
// #include <SPI.h> | |
// #include <Wire.h> | |
#include <Adafruit_GFX.h> | |
//SYSTEM_MODE(MANUAL); | |
#define PIXEL_PIN D6 | |
#define PIXEL_COUNT 1 | |
#define PIXEL_TYPE WS2812B | |
int count =0; | |
//Adafruit_NeoPixel dot(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); | |
Adafruit_SSD1306 display(128, 32, -1); | |
Adafruit_CCS811 ccs; | |
#define NUMFLAKES 10 | |
#define XPOS 0 | |
#define YPOS 1 | |
#define DELTAY 2 | |
#define LOGO16_GLCD_HEIGHT 16 | |
#define LOGO16_GLCD_WIDTH 16 | |
const int c = 261; | |
const int d = 294; | |
const int e = 329; | |
const int f = 349; | |
const int g = 391; | |
const int gS = 415; | |
const int a = 440; | |
const int aS = 455; | |
const int b = 466; | |
const int cH = 523; | |
const int cSH = 554; | |
const int dH = 587; | |
const int dSH = 622; | |
const int eH = 659; | |
const int fH = 698; | |
const int fSH = 740; | |
const int gH = 784; | |
const int gSH = 830; | |
const int aH = 880; | |
const int buzzerPin = TX; | |
const int ledPin1 = A0; | |
const int ledPin2 = A4; | |
int counter = 0; | |
const unsigned char darth [] = { | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFD, 0xBF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFD, 0xBF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFD, 0xBF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFD, 0xBF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE1, 0x87, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x81, 0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x80, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x83, 0xC1, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFE, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xFE, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xFD, 0xBF, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0xD9, 0x9B, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x35, 0xAC, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xE5, 0xA7, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xD5, 0xAB, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x02, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
static const unsigned char PROGMEM logo16_glcd_bmp[] = | |
{ B00000000, B11000000, | |
B00000001, B11000000, | |
B00000001, B11000000, | |
B00000011, B11100000, | |
B11110011, B11100000, | |
B11111110, B11111000, | |
B01111110, B11111111, | |
B00110011, B10011111, | |
B00011111, B11111100, | |
B00001101, B01110000, | |
B00011011, B10100000, | |
B00111111, B11100000, | |
B00111111, B11110000, | |
B01111100, B11110000, | |
B01110000, B01110000, | |
B00000000, B00110000 }; | |
const unsigned char smile [] = { | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x00, 0x01, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xE0, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0x80, 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
const unsigned char sad1 [] = { | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFF, 0xF8, 0x1F, 0xFF, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xF8, 0x0F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
const unsigned char sad2 [] = { | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2F, 0xF8, 0x1F, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xFF, 0xF8, 0x1F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x01, 0x7F, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xF8, 0x0F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
const unsigned char sad3 [] = { | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xF8, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5F, 0xF8, 0x1F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xF8, 0x1F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x01, 0x7F, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x2F, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xF8, 0x0F, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
const unsigned char blush [] = { | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x02, 0xAA, 0xA0, 0x00, 0x00, 0x0A, 0xAA, 0x80, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFC, 0x00, 0x00, 0x7F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0x07, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xF0, 0x0F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xF0, 0x0F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xF8, 0x1F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x0F, 0xFE, 0xA0, 0xBF, 0xF8, 0x1F, 0xFA, 0x82, 0xFF, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x78, 0x1F, 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x38, 0x08, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
}; | |
char incomingByte; | |
int x1=20; | |
int x2=80; | |
// Used to keep track of the last time we published data | |
long lastPublish = 0; | |
uint8_t oldday,oldhour,oldminute,oldsecond = 0; | |
void setup() { | |
Time.zone(-8); | |
pinMode(buzzerPin, OUTPUT); | |
Serial.begin(115200); | |
// if(!ccs.begin()){ | |
// Serial.println("Failed to start sensor! Please check your wiring."); | |
// while(1); | |
// } | |
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!) | |
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) | |
display.display(); | |
delay(500); | |
// Clear the buffer. | |
display.clearDisplay(); | |
display.display(); | |
//calibrate temperature sensor | |
// while(!ccs.available()); | |
// float temp = ccs.calculateTemperature(); | |
// ccs.setTempOffset(temp - 25.0); | |
Serial.println("IO test"); | |
// text display tests | |
display.setRotation(3); | |
display.setTextColor(WHITE); | |
// display.println("Hello"); | |
// display.println("World"); | |
// display.println(""); | |
// display.display(); | |
// display.println(Time.hour()); | |
// display.println(Time.minute()); | |
// display.println(Time.second()); | |
// display.display(); | |
//Wire.setSpeed(400000); | |
//soundExcited(); | |
//catcall(); | |
//aniBlink(); | |
} | |
void loop() { | |
displayTime(); | |
delay(100); | |
// if (millis()-lastPublish > 30000) | |
// { | |
// //soundExcited(); | |
// // Remember when we published | |
// lastPublish = millis(); | |
// aniBlink(); | |
// aniConfused(); | |
// delay(500); | |
// } | |
// aniConfused(); | |
// delay(1000); | |
// aniExcited(); | |
// delay(500); | |
// aniBlink(); | |
// aniSmile(); | |
// delay(1000); | |
// aniBlush(); | |
// delay(1000); | |
// aniConfused(); | |
// delay(1000); | |
// aniExcited(); | |
// delay(1000); | |
// //catcall(); | |
// aniSad(); | |
// delay(1000); | |
// aniSmile(); | |
// delay(1000); | |
// aniBlush(); | |
// delay(1000); | |
// // send data only when you receive data: | |
// if (Serial.available() > 0) { | |
// // read the incoming byte: | |
// incomingByte = Serial.read(); | |
// // say what you got: | |
// Serial.print("I received: "); | |
// Serial.println(incomingByte, DEC); | |
// processSerial(incomingByte); | |
// } | |
// delay(100); | |
// delay(1000); | |
// display.setCursor(0,5); | |
// if(ccs.available()){ | |
// display.clearDisplay(); | |
// float temp = ccs.calculateTemperature(); | |
// if(!ccs.readData()){ | |
// display.println(""); | |
// display.print(" eCO2: "); | |
// Serial.print(" eCO2: "); | |
// float eCO2 = ccs.geteCO2(); | |
// display.print(eCO2); | |
// Serial.print(eCO2); | |
// display.print("\n TVOC: "); | |
// Serial.print(" ppm, TVOC: "); | |
// float TVOC = ccs.getTVOC(); | |
// display.print(TVOC); | |
// Serial.print(TVOC); | |
// //Serial.print(" ppb Temp:"); | |
// //display.print(" ppb\n Temp: "); | |
// //Serial.println(temp); | |
// //display.println(temp); | |
// display.display(); | |
// } | |
// else{ | |
// Serial.println("ERROR!"); | |
// while(1); | |
// } | |
// } | |
} | |
void displayTime(void) | |
{ | |
uint8_t hour = Time.hourFormat12(); | |
uint8_t minute = Time.minute(); | |
uint8_t second = Time.second(); | |
uint8_t weekday = Time.weekday(); | |
uint8_t day = Time.day(); | |
uint16_t year = Time.year(); | |
uint8_t month = Time.month(); | |
display.setTextColor(WHITE, BLACK); | |
//display.setTextSize(1); | |
//display.setCursor(0,20); | |
//display.setTextWrap(true); | |
//display.println("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. "); | |
display.setTextSize(2); | |
display.drawLine(0,15,25,15,WHITE); | |
display.display(); | |
display.setCursor(1,25); | |
if (hour < 10) display.print("0"); | |
display.println(hour); | |
display.setCursor(1,45); | |
if (minute < 10) display.print("0"); | |
display.println(minute); | |
display.setCursor(1,65); | |
if (second < 10) display.print("0"); | |
display.println(second); | |
display.println(" "); | |
display.drawLine(0,88,25,88,WHITE); | |
display.setCursor(1,6); | |
display.setTextSize(1); | |
if(Time.isPM()) display.println(" PM"); | |
else display.println(" AM"); | |
display.setTextSize(1); | |
display.setCursor(1,88); | |
switch(weekday) | |
{ | |
case 1: | |
display.println("SUN"); | |
break; | |
case 2: | |
display.println("MON"); | |
break; | |
case 3: | |
display.println("TUE"); | |
break; | |
case 4: | |
display.println("WED"); | |
break; | |
case 5: | |
display.println("THU"); | |
break; | |
case 6: | |
display.println("FRI"); | |
break; | |
case 7: | |
display.println("SAT"); | |
break; | |
default: | |
display.println("NULL"); | |
} | |
switch(month) | |
{ | |
case 1: | |
display.println("JAN"); | |
break; | |
case 2: | |
display.println("FEB"); | |
break; | |
case 3: | |
display.println("MAR"); | |
break; | |
case 4: | |
display.println("APR"); | |
break; | |
case 5: | |
display.println("MAY"); | |
break; | |
case 6: | |
display.println("JUN"); | |
break; | |
case 7: | |
display.println("JUL"); | |
break; | |
case 8: | |
display.println("AUGU"); | |
break; | |
case 9: | |
display.println("SEP"); | |
break; | |
case 10: | |
display.println("OCT"); | |
break; | |
case 11: | |
display.println("NOV"); | |
break; | |
case 12: | |
display.println("DEC"); | |
break; | |
default: | |
display.println("NULL"); | |
} | |
display.println(day); | |
display.println(year); | |
display.display(); | |
} | |
void soundExcited() | |
{ | |
int i = 0; | |
while(i<8000) | |
{ | |
analogWrite(buzzerPin, 125, 3000+i); | |
delay(5); | |
i = i+200; | |
} | |
analogWrite(buzzerPin, 0, 1000); | |
} | |
void catcall() { | |
for (int i=2000; i<5000; i=i*1.05) { | |
beep(buzzerPin,i,10); | |
} | |
delay(300); | |
for (int i=2000; i<3000; i=i*1.03) { | |
beep(buzzerPin,i,10); | |
} | |
for (int i=3000; i>1000; i=i*.97) { | |
beep(buzzerPin,i,10); | |
} | |
} | |
void processSerial(char data) | |
{ | |
display.clearDisplay(); | |
display.display(); | |
switch(data) | |
{ | |
case 'c': | |
display.clearDisplay(); | |
display.display(); | |
break; | |
case '1': | |
display.fillRoundRect(10, 10, 40,20,10, WHITE); | |
display.fillRoundRect(80, 10, 40,20,10, WHITE); | |
display.display(); | |
break; | |
case '2': | |
display.fillCircle(40, 20, 10, WHITE); | |
display.fillCircle(40, 30, 10, BLACK); | |
display.fillCircle(85, 20, 10, WHITE); | |
display.fillCircle(85, 30, 10, BLACK); | |
display.display(); | |
break; | |
case '3': | |
display.fillCircle(40, 20, 10, WHITE); | |
display.fillCircle(85, 20, 10, WHITE); | |
display.display(); | |
break; | |
case '4': | |
display.fillRoundRect(20,10,30,20,5, WHITE); | |
display.fillRoundRect(80,10,30,20,5, WHITE); | |
display.display(); | |
x1=20; | |
x2=80; | |
break; | |
case '5': | |
display.fillRoundRect(x1+5,15,30,15,5, WHITE); | |
display.fillRoundRect(x2+5,10,30,20,5, WHITE); | |
//x1=x1+10; | |
//x2=x2+10; | |
display.display(); | |
break; | |
case '6': | |
display.fillRoundRect(x1-5,10,30,20,5, WHITE); | |
display.fillRoundRect(x2-5,15,30,15,5, WHITE); | |
//x1=x1-10; | |
//x2=x2-10; | |
display.display(); | |
break; | |
case '7': | |
display.fillCircle(30, 16, 16, WHITE); | |
display.fillCircle(95, 16, 16, WHITE); | |
display.display(); | |
break; | |
case 'q': | |
display.fillRoundRect(20,10,30,20,0, WHITE); | |
display.fillRoundRect(80,10,30,20,0, WHITE); | |
display.display(); | |
break; | |
case 'w': | |
display.fillRoundRect(20,10,30,2,0, BLACK); | |
//delay(5); | |
display.display(); | |
display.fillRoundRect(20,10,30,5,0, BLACK); | |
//delay(5); | |
display.display(); | |
display.fillRoundRect(20,10,30,10,0, BLACK); | |
display.display(); | |
display.fillRoundRect(80,10,30,20,0, WHITE); | |
display.display(); | |
break; | |
case 'e': | |
display.fillRoundRect(80,10,30,2,0, BLACK); | |
//delay(5); | |
display.display(); | |
display.fillRoundRect(80,10,30,5,0, BLACK); | |
//delay(5); | |
display.display(); | |
display.fillRoundRect(80,10,30,10,0, BLACK); | |
display.fillRoundRect(20,10,30,20,0, WHITE); | |
display.display(); | |
break; | |
default: | |
break; | |
} | |
} | |
void aniBlink() | |
{ | |
display.clearDisplay(); | |
display.fillRoundRect(30,5,30,26,5, WHITE); | |
display.fillRoundRect(70,5,30,26,5, WHITE); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
display.fillRoundRect(30,10,30,21,5, WHITE); | |
display.fillRoundRect(70,10,30,21,5, WHITE); | |
display.display(); | |
display.clearDisplay(); | |
display.fillRoundRect(30,15,30,15,5, WHITE); | |
display.fillRoundRect(70,15,30,15,5, WHITE); | |
display.display(); | |
display.clearDisplay(); | |
display.fillRoundRect(25,15,80,3,0, WHITE); | |
//display.fillRoundRect(70,15,30,15,5, WHITE); | |
display.display(); | |
delay(100); | |
} | |
void aniExcited() | |
{ | |
display.clearDisplay(); | |
display.fillRoundRect(30,10,30,20,5, WHITE); | |
display.fillRoundRect(70,10,30,20,5, WHITE); | |
display.display(); | |
delay(200); | |
display.clearDisplay(); | |
display.fillRoundRect(10,5,35,25,10, WHITE); | |
display.fillRoundRect(85,5,35,25,10, WHITE); | |
display.display(); | |
delay(50); | |
display.fillRoundRect(10,2,35,25,5, WHITE); | |
display.fillRoundRect(85,2,35,25,5, WHITE); | |
display.display(); | |
delay(50); | |
display.clearDisplay(); | |
display.fillRoundRect(10,5,35,25,10, WHITE); | |
display.fillRoundRect(85,5,35,25,10, WHITE); | |
display.display(); | |
//delay(1000); | |
} | |
void aniConfused() | |
{ | |
display.clearDisplay(); | |
display.fillRoundRect(20,10,30,20,5, WHITE); | |
display.fillRoundRect(80,10,30,20,5, WHITE); | |
display.display(); | |
//delay(100); | |
display.clearDisplay(); | |
display.fillRoundRect(45,13,30,17,5, WHITE); | |
display.fillRoundRect(85,5,35,25,5, WHITE); | |
display.display(); | |
delay(1000); | |
display.clearDisplay(); | |
display.fillRoundRect(20,10,30,20,5, WHITE); | |
display.fillRoundRect(80,10,30,20,5, WHITE); | |
display.display(); | |
//delay(100); | |
display.clearDisplay(); | |
display.fillRoundRect(15,5,35,25,5, WHITE); | |
display.fillRoundRect(60,13,30,17,5, WHITE); | |
display.display(); | |
delay(1000); | |
} | |
void aniSmile() | |
{ | |
display.clearDisplay(); | |
display.drawBitmap(0, 0, smile, 128, 32, 1); | |
display.display(); | |
} | |
void aniSad() | |
{ | |
display.clearDisplay(); | |
display.drawBitmap(0, 0, sad1, 128, 32, 1); | |
display.display(); | |
display.clearDisplay(); | |
display.drawBitmap(0, 0, sad2, 128, 32, 1); | |
display.display(); | |
display.clearDisplay(); | |
display.drawBitmap(0, 0, sad3, 128, 32, 1); | |
display.display(); | |
} | |
void aniBlush() | |
{ | |
display.clearDisplay(); | |
display.drawBitmap(0, 0, blush, 128, 32, 1); | |
display.display(); | |
} | |
void oledTest() | |
{ | |
// draw a single pixel | |
display.drawPixel(10, 10, WHITE); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw many lines | |
testdrawline(); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw rectangles | |
testdrawrect(); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw multiple rectangles | |
testfillrect(); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw mulitple circles | |
testdrawcircle(); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw a white circle, 10 pixel radius | |
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
testdrawroundrect(); | |
delay(2000); | |
display.clearDisplay(); | |
testfillroundrect(); | |
delay(2000); | |
display.clearDisplay(); | |
testdrawtriangle(); | |
delay(2000); | |
display.clearDisplay(); | |
testfilltriangle(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw the first ~12 characters in the font | |
testdrawchar(); | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
// draw scrolling text | |
testscrolltext(); | |
delay(2000); | |
display.clearDisplay(); | |
// text display tests | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
display.setCursor(0,0); | |
display.print("BATT VOLTAGE: "); | |
display.setTextColor(BLACK, WHITE); // 'inverted' text | |
display.println(3.141592); | |
display.setTextSize(2); | |
display.setTextColor(WHITE); | |
display.print("0x"); display.println(0xDEADBEEF, HEX); | |
display.display(); | |
delay(2000); | |
// miniature bitmap display | |
display.clearDisplay(); | |
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); | |
display.display(); | |
// invert the display | |
display.invertDisplay(true); | |
delay(1000); | |
display.invertDisplay(false); | |
delay(1000); | |
} | |
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) { | |
uint8_t icons[NUMFLAKES][3]; | |
// initialize | |
for (uint8_t f=0; f< NUMFLAKES; f++) { | |
icons[f][XPOS] = random(display.width()); | |
icons[f][YPOS] = 0; | |
icons[f][DELTAY] = random(5) + 1; | |
Serial.print("x: "); | |
Serial.print(icons[f][XPOS], DEC); | |
Serial.print(" y: "); | |
Serial.print(icons[f][YPOS], DEC); | |
Serial.print(" dy: "); | |
Serial.println(icons[f][DELTAY], DEC); | |
} | |
while (1) { | |
// draw each icon | |
for (uint8_t f=0; f< NUMFLAKES; f++) { | |
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE); | |
} | |
display.display(); | |
delay(200); | |
// then erase it + move it | |
for (uint8_t f=0; f< NUMFLAKES; f++) { | |
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK); | |
// move it | |
icons[f][YPOS] += icons[f][DELTAY]; | |
// if its gone, reinit | |
if (icons[f][YPOS] > display.height()) { | |
icons[f][XPOS] = random(display.width()); | |
icons[f][YPOS] = 0; | |
icons[f][DELTAY] = random(5) + 1; | |
} | |
} | |
} | |
} | |
void testdrawchar(void) { | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
display.setCursor(0,0); | |
for (uint8_t i=0; i < 168; i++) { | |
if (i == '\n') continue; | |
display.write(i); | |
if ((i > 0) && (i % 21 == 0)) | |
display.println(); | |
} | |
display.display(); | |
} | |
void testdrawcircle(void) { | |
for (int16_t i=0; i<display.height(); i+=2) { | |
display.drawCircle(display.width()/2, display.height()/2, i, WHITE); | |
display.display(); | |
} | |
} | |
void testfillrect(void) { | |
uint8_t color = 1; | |
for (int16_t i=0; i<display.height()/2; i+=3) { | |
// alternate colors | |
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2); | |
display.display(); | |
color++; | |
} | |
} | |
void testdrawtriangle(void) { | |
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) { | |
display.drawTriangle(display.width()/2, display.height()/2-i, | |
display.width()/2-i, display.height()/2+i, | |
display.width()/2+i, display.height()/2+i, WHITE); | |
display.display(); | |
} | |
} | |
void testfilltriangle(void) { | |
uint8_t color = WHITE; | |
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) { | |
display.fillTriangle(display.width()/2, display.height()/2-i, | |
display.width()/2-i, display.height()/2+i, | |
display.width()/2+i, display.height()/2+i, WHITE); | |
if (color == WHITE) color = BLACK; | |
else color = WHITE; | |
display.display(); | |
} | |
} | |
void testdrawroundrect(void) { | |
for (int16_t i=0; i<display.height()/2-2; i+=2) { | |
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE); | |
display.display(); | |
} | |
} | |
void testfillroundrect(void) { | |
uint8_t color = WHITE; | |
for (int16_t i=0; i<display.height()/2-2; i+=2) { | |
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color); | |
if (color == WHITE) color = BLACK; | |
else color = WHITE; | |
display.display(); | |
} | |
} | |
void testdrawrect(void) { | |
for (int16_t i=0; i<display.height()/2; i+=2) { | |
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE); | |
display.display(); | |
} | |
} | |
void testdrawline() { | |
for (int16_t i=0; i<display.width(); i+=4) { | |
display.drawLine(0, 0, i, display.height()-1, WHITE); | |
display.display(); | |
} | |
for (int16_t i=0; i<display.height(); i+=4) { | |
display.drawLine(0, 0, display.width()-1, i, WHITE); | |
display.display(); | |
} | |
delay(250); | |
display.clearDisplay(); | |
for (int16_t i=0; i<display.width(); i+=4) { | |
display.drawLine(0, display.height()-1, i, 0, WHITE); | |
display.display(); | |
} | |
for (int16_t i=display.height()-1; i>=0; i-=4) { | |
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE); | |
display.display(); | |
} | |
delay(250); | |
display.clearDisplay(); | |
for (int16_t i=display.width()-1; i>=0; i-=4) { | |
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE); | |
display.display(); | |
} | |
for (int16_t i=display.height()-1; i>=0; i-=4) { | |
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE); | |
display.display(); | |
} | |
delay(250); | |
display.clearDisplay(); | |
for (int16_t i=0; i<display.height(); i+=4) { | |
display.drawLine(display.width()-1, 0, 0, i, WHITE); | |
display.display(); | |
} | |
for (int16_t i=0; i<display.width(); i+=4) { | |
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE); | |
display.display(); | |
} | |
delay(250); | |
} | |
void testscrolltext(void) { | |
display.setTextSize(2); | |
display.setTextColor(WHITE); | |
display.setCursor(10,0); | |
display.clearDisplay(); | |
display.println("scroll"); | |
display.display(); | |
display.startscrollright(0x00, 0x0F); | |
delay(2000); | |
display.stopscroll(); | |
delay(1000); | |
display.startscrollleft(0x00, 0x0F); | |
delay(2000); | |
display.stopscroll(); | |
delay(1000); | |
display.startscrolldiagright(0x00, 0x07); | |
delay(2000); | |
display.startscrolldiagleft(0x00, 0x07); | |
delay(2000); | |
display.stopscroll(); | |
} | |
// void rainbow(uint8_t wait) { | |
// uint16_t i, j; | |
// for(j=0; j<256; j++) { | |
// for(i=0; i<dot.numPixels(); i++) { | |
// dot.setPixelColor(i, Wheel((i+j) & 255)); | |
// } | |
// dot.show(); | |
// delay(wait); | |
// } | |
// } | |
// // Input a value 0 to 255 to get a color value. | |
// // The colours are a transition r - g - b - back to r. | |
// uint32_t Wheel(byte WheelPos) { | |
// WheelPos = 255 - WheelPos; | |
// if(WheelPos < 85) { | |
// return dot.Color(255 - WheelPos * 3, 0, WheelPos * 3); | |
// } | |
// if(WheelPos < 170) { | |
// WheelPos -= 85; | |
// return dot.Color(0, WheelPos * 3, 255 - WheelPos * 3); | |
// } | |
// WheelPos -= 170; | |
// return dot.Color(WheelPos * 3, 255 - WheelPos * 3, 0); | |
// } | |
void beep (int speakerPin, float noteFrequency, long noteDuration) | |
{ | |
int x; | |
// Convert the frequency to microseconds | |
float microsecondsPerWave = 1000000/noteFrequency; | |
// Calculate how many HIGH/LOW cycles there are per millisecond | |
float millisecondsPerCycle = 1000/(microsecondsPerWave * 2); | |
// Multiply noteDuration * number or cycles per millisecond | |
float loopTime = noteDuration * millisecondsPerCycle; | |
// Play the note for the calculated loopTime. | |
for (x=0;x<loopTime;x++) | |
{ | |
digitalWrite(speakerPin,HIGH); | |
delayMicroseconds(microsecondsPerWave); | |
digitalWrite(speakerPin,LOW); | |
delayMicroseconds(microsecondsPerWave); | |
} | |
} | |
// void beep(int note, int duration) | |
// { | |
// //Play tone on buzzerPin | |
// tone(buzzerPin, note, duration); | |
// //Play different LED depending on value of 'counter' | |
// if(counter % 2 == 0) | |
// { | |
// digitalWrite(ledPin1, HIGH); | |
// delay(duration); | |
// digitalWrite(ledPin1, LOW); | |
// // dot.setPixelColor(0, Wheel(random(0, 255) & 255)); | |
// //dot.setPixelColor(0, 0,0,0); | |
// //dot.show(); | |
// }else | |
// { | |
// digitalWrite(ledPin2, HIGH); | |
// delay(duration); | |
// digitalWrite(ledPin2, LOW); | |
// //dot.setPixelColor(0, Wheel(random(0, 255) & 255)); | |
// //dot.setPixelColor(0, 0,0,0); | |
// //dot.show(); | |
// } | |
// //Stop tone on buzzerPin | |
// noTone(buzzerPin); | |
// delay(50); | |
// //Increment counter | |
// counter++; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment