99 lines
1.6 KiB
C++
99 lines
1.6 KiB
C++
#include "Arduino.h"
|
|
#include "SegDisp.h"
|
|
|
|
SegDisp::SegDisp(int pins[8])
|
|
{
|
|
for (int i = 0; i < 8; i++){
|
|
pinMode(pins[i], OUTPUT);
|
|
_pins[i]=pins[i];
|
|
}
|
|
}
|
|
|
|
void SegDisp::zero(int state)
|
|
{
|
|
int leds[6] = {0,1,2,4,5,6};
|
|
for (int i = 0; i < 6; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::one(int state)
|
|
{
|
|
int leds[2] = {2,6};
|
|
for (int i = 0; i < 2; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::two(int state)
|
|
{
|
|
int leds[5] = {0,1,3,5,6};
|
|
for (int i = 0; i < 5; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::three(int state)
|
|
{
|
|
int leds[5] = {1,2,3,5,6};
|
|
for (int i = 0; i < 5; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::four(int state)
|
|
{
|
|
int leds[4] = {2,3,4,6};
|
|
for (int i = 0; i < 4; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::five(int state)
|
|
{
|
|
int leds[5] = {1,2,3,4,5};
|
|
for (int i = 0; i < 5; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::six(int state)
|
|
{
|
|
int leds[6] = {0,1,2,3,4,5};
|
|
for (int i = 0; i < 6; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::seven(int state)
|
|
{
|
|
int leds[3] = {2,5,6};
|
|
for (int i = 0; i < 3; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::eight(int state)
|
|
{
|
|
int leds[7] = {0,1,2,3,4,5,6};
|
|
for (int i = 0; i < 7; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::nine(int state)
|
|
{
|
|
int leds[6] = {1,2,3,4,5,6};
|
|
for (int i = 0; i < 6; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|
|
|
|
void SegDisp::dot(int state)
|
|
{
|
|
int leds[1] = {7};
|
|
for (int i = 0; i < 1; i++){
|
|
digitalWrite(_pins[led[i]], state);
|
|
}
|
|
}
|