/**************************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x32 pixel display using I2C to communicate
3 pins are required to interface (two I2C and one reset).
Adafruit invests time and resources providing this open
source code, please support Adafruit and open-source
hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries,
with contributions from the open source community.
BSD license, check license.txt for more information
All text above, and the splash screen below must be
included in any redistribution.
**************************************************************************/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// 'Temp_9x17px', 9x13px
const unsigned char Temp_9x17px [] PROGMEM = {
0x08, 0x00, 0x14, 0x00, 0x20, 0x00, 0x2b, 0x80, 0x20, 0x00, 0x2b, 0x00, 0x20, 0x00, 0x28, 0x00,
0x22, 0x00, 0x41, 0x00, 0x80, 0x80, 0x82, 0x80, 0x82, 0x80
};
// '%_8x8px', 9x13px
const unsigned char dot_8x8px [] PROGMEM = {
0x41, 0x00, 0xa2, 0x00, 0x44, 0x00, 0x08, 0x00, 0x10, 0x00, 0x22, 0x00, 0x45, 0x00, 0x82, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'Celcius_10x11px', 9x13px
const unsigned char Celcius_10x11px [] PROGMEM = {
0x03, 0x80, 0x44, 0x00, 0xa8, 0x00, 0x48, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00,
0x08, 0x00, 0x04, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00
};
// 'Humid_9x13px', 9x13px
const unsigned char Humid_9x13px [] PROGMEM = {
0x08, 0x00, 0x14, 0x00, 0x22, 0x00, 0x41, 0x00, 0x41, 0x00, 0x80, 0x80, 0x82, 0x80, 0x82, 0x80,
0x82, 0x80, 0x82, 0x80, 0x84, 0x80, 0x41, 0x00, 0x3e, 0x00
};
// 'mid', 128x32p// 'eight', 128x32px
const unsigned char num_eight [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x4f, 0xe4, 0xe0, 0x0e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe7, 0xce, 0x4f, 0xe4, 0x1f, 0xf0, 0x4f, 0xe4, 0xe7, 0xce,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe0, 0x0e,
0x4f, 0xe4, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// 'five', 128x32px
const unsigned char num_five [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x4f, 0xe0, 0xe0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00,
0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xe7, 0xc0, 0x4f, 0xe0, 0x1f, 0xf0, 0x0f, 0xe4, 0x07, 0xce,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e,
0x0f, 0xe4, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// 'four', 128x32px
const unsigned char num_four [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0xe0, 0x0e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe7, 0xce, 0x4f, 0xe4, 0x1f, 0xf0, 0x0f, 0xe4, 0x07, 0xce,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e,
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'nine', 128x32px
const unsigned char num_nine [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x4f, 0xe4, 0xe0, 0x0e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe7, 0xce, 0x4f, 0xe4, 0x1f, 0xf0, 0x0f, 0xe4, 0x07, 0xce,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e,
0x0f, 0xe4, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// 'one', 128x32px
const unsigned char num_one [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0e,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e,
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'seven', 128x32px
const unsigned char num_seven [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe4, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0e,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e,
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'six', 128x32px
const unsigned char num_six [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x4f, 0xe0, 0xe0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00,
0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xe7, 0xc0, 0x4f, 0xe0, 0x1f, 0xf0, 0x4f, 0xe4, 0xe7, 0xce,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe0, 0x0e,
0x4f, 0xe4, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// 'three', 128x32px
const unsigned char num_three [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe4, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x07, 0xce, 0x0f, 0xe4, 0x1f, 0xf0, 0x0f, 0xe4, 0x07, 0xce,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x0e,
0x0f, 0xe4, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// 'two', 128x32px
const unsigned char num_two [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xe4, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e,
0x00, 0x1e, 0x00, 0x1e, 0x00, 0x1e, 0x07, 0xce, 0x0f, 0xe4, 0x1f, 0xf0, 0x4f, 0xe0, 0xe7, 0xc0,
0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xe0, 0x00,
0x4f, 0xe0, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// 'zero', 128x32px
const unsigned char num_zero [] PROGMEM = {
0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x4f, 0xe4, 0xe0, 0x0e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe0, 0x0e, 0x40, 0x04, 0x00, 0x00, 0x40, 0x04, 0xe0, 0x0e,
0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xf0, 0x1e, 0xe0, 0x0e,
0x4f, 0xe4, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 5280)
const int num_allArray_LEN = 10;
const unsigned char* num_allArray[10] = {
num_eight,
num_five,
num_four,
num_nine,
num_one,
num_seven,
num_six,
num_three,
num_two,
num_zero
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 192)
const int epd_bitmap_allArray_LEN = 4;
const unsigned char* epd_bitmap_allArray[4] = {
Celcius_10x11px,
Humid_9x13px,
Temp_9x17px,
dot_8x8px
};
bool blinkFlag = false;
unsigned long lastTimeBlink = 0;
unsigned long ms10 = 0;
const int timer = 200;
int count;
int msec,ldng,h,m,h1,h2,m1,m2;
byte a[5],numb,segm,i,t,disp;
int progress = 0;//крок смужки завантаження
int mrgFram = 1;//відступ від країв
int countLoad = 0;
void setup() {
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
while (progress <= (SCREEN_WIDTH-20)){
progress++;
loading();//Завантаження
}
}
void loop() {
display.display();
if(countLoad>0){
display.clearDisplay();
countTime();
}
}
void loading() {
//display.clearDisplay();
//display.display();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(40,5);
display.println("BEARDED_i");
display.drawRect(1, 1, 126, 30, 1);//по розміру в пікселях
display.drawRect(10,15, 108,8,1);//по розміру в пікселях
display.fillRect(10,15, progress,8,1);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(10,5);
display.println(countLoad);
}
void countTime(){
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(46,2);
disp=0;
display.println(h1);
display.setCursor(64,2);
disp=1;
display.println(h2);
display.setCursor(93,2);
disp=2;
display.println(m1);
display.setCursor(111,2);
disp=3;
display.println(m2);
if (numb>8){
numb=0;
}
delay(500);
numb++;
}
void number(){
switch(numb){
case 0: zero();break; //zero
case 1: one(); break; //one
case 2: two(); break; //two
case 3: three(); break; //three
case 4: four(); break; //four
case 5: five(); break; //five
case 6: six(); break; //six
case 7: seven(); break; //seven
case 8: eight(); break; //eight
case 9: nine();break; //nine
}
}
void digit(){
switch(disp){
case 0: numb=h1; number(); break; //display1
case 1: numb=h2; number(); break; //display2
case 2: numb=m1; number(); break; //display3
case 3: numb=m2; number(); break; //display4
}
}
void zero(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_zero, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_zero, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_zero, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_zero, 15,28, WHITE); break;
}
}
void one(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_one, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_one, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_one, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_one, 15,28, WHITE); break;
}
}
void two(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_two, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_two, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_two, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_two, 15,28, WHITE); break;
}
}
void three(){
display.clearDisplay();
switch(disp){
case 0: display.drawBitmap(46, 2, num_three, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_three, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_three, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_three, 15,28, WHITE); break;
}
display.display();
}
void four(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_four, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_four, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_four, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_four, 15,28, WHITE); break;
}
}
void five(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_five, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_five, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_five, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_five, 15,28, WHITE); break;
}
}
void six(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_six, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_six, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_six, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_six, 15,28, WHITE); break;
}
}
void seven(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_seven, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_seven, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_seven, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_seven, 15,28, WHITE); break;
}
}
void eight(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_eight, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_eight, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_eight, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_eight, 15,28, WHITE); break;
}
}
void nine(){
switch(disp){
case 0: display.drawBitmap(46, 2, num_nine, 15,28, WHITE); break;
case 1: display.drawBitmap(64, 2, num_nine, 15,28, WHITE); break;
case 2: display.drawBitmap(93, 2, num_nine, 15,28, WHITE); break;
case 3: display.drawBitmap(111, 2, num_nine, 15,28, WHITE); break;
}
}
void sensors(){
display.drawBitmap(0, 0, Temp_9x17px, 9,17, WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(13,3);
display.println("24");
display.drawBitmap(28, 3, Celcius_10x11px, 10,11, WHITE);
display.drawBitmap(0, 19, Humid_9x13px, 9,13, WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(13,22);
display.println("95 %");
display.drawBitmap(30, 21, dot_8x8px, 8,8, WHITE);
}