-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// -------------------------------------------------------------- | ||
// | ||
// B O O M Y T E C H | ||
// | ||
// SNAPPING DISPLAY | ||
// | ||
// YouTube: https://www.youtube.com/@boomytech7504 | ||
// | ||
// YOTUBE LINK TO THE VIDEO: https://youtu.be/Mb3xCe2Co3A | ||
// | ||
// EMail: boomytech@gmail.com | ||
// | ||
// -------------------------------------------------------------- | ||
// Segment sequence | ||
// aaaaa | ||
// f b | ||
// f b | ||
// ggggg | ||
// e c | ||
// e c | ||
// ddddd | ||
// dp | ||
// | ||
#include <Adafruit_NeoPixel.h> | ||
#include "Arduino.h" | ||
#include "BT_Display.h" | ||
|
||
Adafruit_NeoPixel pixel; | ||
|
||
// USER DEFINE PARAMETERS (must be defined in source file) | ||
// -------------------------------------------- | ||
byte digit_Brightness = 255; // Brightness | ||
unsigned int digit_Color = 3000; // HSV Digit Color | ||
byte digit_Active // Active Digit | ||
unsigned int totLedPerDigit; // led in a single digit | ||
|
||
// LED SCHEMA DEFINED BY USER (must be defined in source file) | ||
// -------------------------------------------- | ||
String _a,_b,_c,_d,_e,_f,_g,_dp; | ||
//eg. | ||
//disp._a = "3,4,5"; | ||
//disp._b = "0,1,2"; | ||
//disp._c = "12,13,14"; | ||
//disp._d = "16,17,18"; | ||
//disp._e = "19,20,21"; | ||
//disp._f = "6,7,8"; | ||
//disp._g = "9,10,11"; | ||
//disp._dp = "15"; | ||
// -------------------------------------------- | ||
|
||
|
||
|
||
|
||
// ---------------------------------------- | ||
// INIT | ||
// ---------------------------------------- | ||
void BTDisplay::init(int maxDisplays, int pinControl, unsigned int totLedPerDigit) { | ||
// Initialize neopixel library | ||
totLedPerDigit = totLedPerDigit; | ||
pixel = Adafruit_NeoPixel(maxDisplays*(totLedPerDigit), pinControl, NEO_GRB + NEO_KHZ800); | ||
pixel.begin(); | ||
} | ||
|
||
void BTDisplay::show() { | ||
pixel.show(); | ||
} | ||
|
||
// ---------------------------------------- | ||
// // SWITCH-ON/OFF A SINGLE SEGMENT | ||
// ---------------------------------------- | ||
void BTDisplay::ShowSeg(String segment, bool is_ON) { | ||
int pointer=0; | ||
int nextPointer=-1; | ||
String str=""; | ||
do { | ||
pointer=nextPointer+1; | ||
nextPointer = segment.indexOf(",",pointer); | ||
str = segment.substring(pointer, nextPointer).toInt(); | ||
pixel.setPixelColor(str.toInt()+(digit_Active * totLedPerDigit), pixel.ColorHSV(digit_Color, 255, is_ON ? digit_Brightness : 0 )); | ||
} while (nextPointer > 0); | ||
} | ||
|
||
|
||
|
||
|
||
// ---------------------------------------- | ||
// // SWITCH-ON SEGMENTS TO COMPOSE DIGIT | ||
// ---------------------------------------- | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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);} | ||
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); | ||
} | ||
|
||
|
||
// ---------------------------------------- | ||
// SHOW RIGHT NUMBER ON SELECTED DIGIT (--display_Number--) | ||
// ---------------------------------------- | ||
void BTDisplay::digit(String str_digit) { | ||
if (str_digit == "") digit_null(); | ||
if (str_digit == "0") digit_0(); | ||
if (str_digit == "1") digit_1(); | ||
if (str_digit == "2") digit_2(); | ||
if (str_digit == "3") digit_3(); | ||
if (str_digit == "4") digit_4(); | ||
if (str_digit == "5") digit_5(); | ||
if (str_digit == "6") digit_6(); | ||
if (str_digit == "7") digit_7(); | ||
if (str_digit == "8") digit_8(); | ||
if (str_digit == "9") digit_9(); | ||
|
||
} | ||
|
||
// SWITCH OFF ALL SEGMENTS | ||
void BTDisplay::digit_ALL_off() { for (int i=0; i<=totLedPerDigit; i++) pixel.setPixelColor(i, pixel.ColorHSV(0,0,0)); } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
#include <Arduino.h> | ||
#include <Adafruit_NeoPixel.h> // Neopixel Library | ||
|
||
|
||
|
||
class BTDisplay { | ||
public: | ||
|
||
byte digit_Brightness; // Brightness | ||
unsigned int digit_Color ; // HSV Digit Color | ||
byte digit_Active; // Active Digit | ||
String _a,_b,_c,_d,_e,_f,_g,_dp; | ||
|
||
void ShowSeg(String segment, bool is_ON); | ||
void init(int maxDisplays, int pinControl,unsigned int totLedPerDigit); | ||
void setBrightness(byte value); | ||
void setDigitColor(unsigned int value); | ||
void setDigitActive(byte value); | ||
|
||
void show(); | ||
void segment_a(bool is_ON); | ||
void segment_b(bool is_ON); | ||
void segment_c(bool is_ON); | ||
void segment_d(bool is_ON); | ||
void segment_e(bool is_ON); | ||
void segment_f(bool is_ON); | ||
void segment_g(bool is_ON); | ||
void segment_dp(bool is_ON); | ||
|
||
void digit_0(); | ||
void digit_1(); | ||
void digit_2(); | ||
void digit_3(); | ||
void digit_4(); | ||
void digit_5(); | ||
void digit_6(); | ||
void digit_7(); | ||
void digit_8(); | ||
void digit_9(); | ||
void digit_null(); | ||
|
||
void digit(String str_digit); // show number passed in str_digit | ||
void digit_ALL_off() ; // Turn off all leds | ||
|
||
|
||
private: | ||
|
||
}; |