Skip to content

Commit 60253be

Browse files
authored
Add files via upload
1 parent 84d2c3f commit 60253be

File tree

2 files changed

+171
-0
lines changed

2 files changed

+171
-0
lines changed

BT_Display.cpp

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// --------------------------------------------------------------
2+
//
3+
// B O O M Y T E C H
4+
//
5+
// SNAPPING DISPLAY
6+
//
7+
// YouTube: https://www.youtube.com/@boomytech7504
8+
//
9+
// YOTUBE LINK TO THE VIDEO: https://youtu.be/Mb3xCe2Co3A
10+
//
11+
// EMail: boomytech@gmail.com
12+
//
13+
// --------------------------------------------------------------
14+
// Segment sequence
15+
// aaaaa
16+
// f b
17+
// f b
18+
// ggggg
19+
// e c
20+
// e c
21+
// ddddd
22+
// dp
23+
//
24+
#include <Adafruit_NeoPixel.h>
25+
#include "Arduino.h"
26+
#include "BT_Display.h"
27+
28+
Adafruit_NeoPixel pixel;
29+
30+
// USER DEFINE PARAMETERS (must be defined in source file)
31+
// --------------------------------------------
32+
byte digit_Brightness = 255; // Brightness
33+
unsigned int digit_Color = 3000; // HSV Digit Color
34+
byte digit_Active // Active Digit
35+
unsigned int totLedPerDigit; // led in a single digit
36+
37+
// LED SCHEMA DEFINED BY USER (must be defined in source file)
38+
// --------------------------------------------
39+
String _a,_b,_c,_d,_e,_f,_g,_dp;
40+
//eg.
41+
//disp._a = "3,4,5";
42+
//disp._b = "0,1,2";
43+
//disp._c = "12,13,14";
44+
//disp._d = "16,17,18";
45+
//disp._e = "19,20,21";
46+
//disp._f = "6,7,8";
47+
//disp._g = "9,10,11";
48+
//disp._dp = "15";
49+
// --------------------------------------------
50+
51+
52+
53+
54+
// ----------------------------------------
55+
// INIT
56+
// ----------------------------------------
57+
void BTDisplay::init(int maxDisplays, int pinControl, unsigned int totLedPerDigit) {
58+
// Initialize neopixel library
59+
totLedPerDigit = totLedPerDigit;
60+
pixel = Adafruit_NeoPixel(maxDisplays*(totLedPerDigit), pinControl, NEO_GRB + NEO_KHZ800);
61+
pixel.begin();
62+
}
63+
64+
void BTDisplay::show() {
65+
pixel.show();
66+
}
67+
68+
// ----------------------------------------
69+
// // SWITCH-ON/OFF A SINGLE SEGMENT
70+
// ----------------------------------------
71+
void BTDisplay::ShowSeg(String segment, bool is_ON) {
72+
int pointer=0;
73+
int nextPointer=-1;
74+
String str="";
75+
do {
76+
pointer=nextPointer+1;
77+
nextPointer = segment.indexOf(",",pointer);
78+
str = segment.substring(pointer, nextPointer).toInt();
79+
pixel.setPixelColor(str.toInt()+(digit_Active * totLedPerDigit), pixel.ColorHSV(digit_Color, 255, is_ON ? digit_Brightness : 0 ));
80+
} while (nextPointer > 0);
81+
}
82+
83+
84+
85+
86+
// ----------------------------------------
87+
// // SWITCH-ON SEGMENTS TO COMPOSE DIGIT
88+
// ----------------------------------------
89+
void BTDisplay::digit_1() { ShowSeg(_a,0); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,0); ShowSeg(_e,0); ShowSeg(_f,0); ShowSeg(_g,0);}
90+
void BTDisplay::digit_2() { ShowSeg(_a,1); ShowSeg(_b,1); ShowSeg(_c,0); ShowSeg(_d,1); ShowSeg(_e,1); ShowSeg(_f,0); ShowSeg(_g,1);}
91+
void BTDisplay::digit_3() { ShowSeg(_a,1); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,1); ShowSeg(_e,0); ShowSeg(_f,0); ShowSeg(_g,1);}
92+
void BTDisplay::digit_4() { ShowSeg(_a,0); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,0); ShowSeg(_e,0); ShowSeg(_f,1); ShowSeg(_g,1);}
93+
void BTDisplay::digit_5() { ShowSeg(_a,1); ShowSeg(_b,0); ShowSeg(_c,1); ShowSeg(_d,1); ShowSeg(_e,0); ShowSeg(_f,1); ShowSeg(_g,1);}
94+
void BTDisplay::digit_6() { ShowSeg(_a,1); ShowSeg(_b,0); ShowSeg(_c,1); ShowSeg(_d,1); ShowSeg(_e,1); ShowSeg(_f,1); ShowSeg(_g,1);}
95+
void BTDisplay::digit_7() { ShowSeg(_a,1); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,0); ShowSeg(_e,0); ShowSeg(_f,0); ShowSeg(_g,0);}
96+
void BTDisplay::digit_8() { ShowSeg(_a,1); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,1); ShowSeg(_e,1); ShowSeg(_f,1); ShowSeg(_g,1);}
97+
void BTDisplay::digit_9() { ShowSeg(_a,1); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,1); ShowSeg(_e,0); ShowSeg(_f,1); ShowSeg(_g,1);}
98+
void BTDisplay::digit_0() { ShowSeg(_a,1); ShowSeg(_b,1); ShowSeg(_c,1); ShowSeg(_d,1); ShowSeg(_e,1); ShowSeg(_f,1); ShowSeg(_g,0);}
99+
void BTDisplay::digit_null() { ShowSeg(_a,0); ShowSeg(_b,0); ShowSeg(_c,0); ShowSeg(_d,0); ShowSeg(_e,0); ShowSeg(_f,0); ShowSeg(_g,0);
100+
}
101+
102+
103+
// ----------------------------------------
104+
// SHOW RIGHT NUMBER ON SELECTED DIGIT (--display_Number--)
105+
// ----------------------------------------
106+
void BTDisplay::digit(String str_digit) {
107+
if (str_digit == "") digit_null();
108+
if (str_digit == "0") digit_0();
109+
if (str_digit == "1") digit_1();
110+
if (str_digit == "2") digit_2();
111+
if (str_digit == "3") digit_3();
112+
if (str_digit == "4") digit_4();
113+
if (str_digit == "5") digit_5();
114+
if (str_digit == "6") digit_6();
115+
if (str_digit == "7") digit_7();
116+
if (str_digit == "8") digit_8();
117+
if (str_digit == "9") digit_9();
118+
119+
}
120+
121+
// SWITCH OFF ALL SEGMENTS
122+
void BTDisplay::digit_ALL_off() { for (int i=0; i<=totLedPerDigit; i++) pixel.setPixelColor(i, pixel.ColorHSV(0,0,0)); }

BT_Display.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
#include <Arduino.h>
3+
#include <Adafruit_NeoPixel.h> // Neopixel Library
4+
5+
6+
7+
class BTDisplay {
8+
public:
9+
10+
byte digit_Brightness; // Brightness
11+
unsigned int digit_Color ; // HSV Digit Color
12+
byte digit_Active; // Active Digit
13+
String _a,_b,_c,_d,_e,_f,_g,_dp;
14+
15+
void ShowSeg(String segment, bool is_ON);
16+
void init(int maxDisplays, int pinControl,unsigned int totLedPerDigit);
17+
void setBrightness(byte value);
18+
void setDigitColor(unsigned int value);
19+
void setDigitActive(byte value);
20+
21+
void show();
22+
void segment_a(bool is_ON);
23+
void segment_b(bool is_ON);
24+
void segment_c(bool is_ON);
25+
void segment_d(bool is_ON);
26+
void segment_e(bool is_ON);
27+
void segment_f(bool is_ON);
28+
void segment_g(bool is_ON);
29+
void segment_dp(bool is_ON);
30+
31+
void digit_0();
32+
void digit_1();
33+
void digit_2();
34+
void digit_3();
35+
void digit_4();
36+
void digit_5();
37+
void digit_6();
38+
void digit_7();
39+
void digit_8();
40+
void digit_9();
41+
void digit_null();
42+
43+
void digit(String str_digit); // show number passed in str_digit
44+
void digit_ALL_off() ; // Turn off all leds
45+
46+
47+
private:
48+
49+
};

0 commit comments

Comments
 (0)