/*
0(abcdef)
1(bc)
2(abdeg)
3(abcdg)
4(bcfg)
5(acdfg)
6(cdefg)
7(abc)
8(abcdefg)
9(abcfg)
*/
#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);
#define segR 3
#define sh 22 //short line segment (22 - defult)
#define lg 56 //long line segment (56 - defult)
#define thk 6 //thick line segment (5 - defult)
#define disp1 3
#define disp2 5
#define disp3 6
#define disp4 9
int disp1St;
int disp2St;
int disp3St;
int disp4St;
const int timer = 1000;
const int count = 6;
const int dispCount = 4;
const int button1Pin = 2; // the number of the pushbutton pin
const int led1Pin = disp1; // the number of the LED pin
int button1State = 0; // variable for reading the pushbutton status
const int button2Pin = 4; // the number of the pushbutton pin
const int led2Pin = disp2; // the number of the LED pin
int button2State = 0; // variable for reading the pushbutton status
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Default OLED address, usually
// initialize the LED pin as an output:
pinMode(led1Pin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(button1Pin, INPUT);
// initialize the LED pin as an output:
pinMode(led2Pin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(button2Pin, INPUT);
pinMode(disp1, OUTPUT);
pinMode(disp2, OUTPUT);
pinMode(disp3, OUTPUT);
pinMode(disp4, OUTPUT);
digitalWrite(disp1, LOW);
digitalWrite(disp2, LOW);
digitalWrite(disp3, LOW);
digitalWrite(disp4, LOW);
Serial.begin(9600);
for (int ldng=0; ldng<=count; ldng++){
loading();
display.clearDisplay();
}
//errMs();
}
void loop() {
numZero();
numOne();
numTwo();
numThree();
numFour();
numFive();
numSix();
numSeven();
numEight();
numNine();
}
void loading(){
display.clearDisplay();
segD();
delay(100);
display.display();
display.clearDisplay();
segE();
delay(100);
display.display();
display.clearDisplay();
segF();
delay(100);
display.display();
display.clearDisplay();
segA();
delay(100);
display.display();
display.clearDisplay();
segB();
delay(100);
display.display();
display.clearDisplay();
segC();
delay(100);
display.display();
}
void errMs(){
display.clearDisplay();
segA();
segB();
segC();
segD();
segG();
display.display();
display.clearDisplay();
segB();
segG();
display.display();
display.clearDisplay();
segB();
segG();
display.display();
}
void numZero(){
display.clearDisplay();
segA();
segB();
segC();
segD();
segE();
segF();
delay(timer);
display.display();
}
void numOne(){
display.clearDisplay();
segE();
segF();
delay(timer);
display.display();
}
void numTwo(){
display.clearDisplay();
segA();
segB();
segD();
segE();
segG();
delay(timer);
display.display();
}
void numThree(){
display.clearDisplay();
segA();
segD();
segE();
segF();
segG();
delay(timer);
display.display();
}
void numFour(){
display.clearDisplay();
segC();
segE();
segF();
segG();
delay(timer);
display.display();
}
void numFive(){
display.clearDisplay();
segA();
segC();
segD();
segF();
segG();
delay(timer);
display.display();
}
void numSix(){
display.clearDisplay();
segA();
segC();
segD();
segB();
segF();
segG();
delay(timer);
display.display();
}
void numSeven(){
display.clearDisplay();
segD();
segE();
segF();
delay(timer);
display.display();
}
void numEight(){
display.clearDisplay();
segA();
segB();
segC();
segD();
segE();
segF();
segG();
delay(timer);
display.display();
}
void numNine(){
display.clearDisplay();
segA();
segC();
segD();
segE();
segF();
segG();
delay(timer);
display.display();
}
void segA(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (0, 5, thk, sh, segR, SSD1306_INVERSE);
}
void segB(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (5, 0, lg,thk, segR , SSD1306_INVERSE);
}
void segC(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (67, 0, lg, thk, segR, SSD1306_INVERSE);
}
void segD(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (123, 5, thk, sh, segR, SSD1306_INVERSE);
}
void segE(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (67, 27, lg, thk, segR, SSD1306_INVERSE);
}
void segF(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (5, 27, lg, thk, segR , SSD1306_INVERSE);
}
void segG(){
// The INVERSE color is used so round-rects alternate white/black
display.fillRoundRect (61, 5, 6, sh, segR, SSD1306_INVERSE);
}