-
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
0 parents
commit 701831e
Showing
12 changed files
with
2,976 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,44 @@ | ||
# NixieStix Library | ||
|
||
By [stephan.com](mailto://[email protected]) | ||
shamelessly stolen from [McOrts/M5StickC_Nixie_tube_Clock](https://github.com/McOrts/M5StickC_Nixie_tube_Clock) | ||
|
||
This library allows for the display of integers in the style of a [Nixie tube](https://en.wikipedia.org/wiki/Nixie_tube). It is designed to work only with the wonderful [M5StickC](https://m5stack.com/products/stick-c) ESP32 protyping system, which includes a screen, buttons, wifi, bluetooth, accelerometer and more for around $10. It's small enough to be worn as a wristwatch. | ||
|
||
## Documentation | ||
|
||
Simply include the library with | ||
```cpp | ||
#include "NixieStix.h" | ||
``` | ||
and you may now include a sequence of Nixie tubes your application by declaring it like so: | ||
```cpp | ||
NixieStix <[tubetype], [digits]> [varname]([xstart],[ypos],[space]); | ||
``` | ||
Where `tubetype` is either `SmallNixie` (18x34) or `BigNixie` (35x67), `digits` is the number of digits in the set, `xstart` and `ypos` are where to begin drawing, and `space` is how many pixels to leave between digits. For example, to get a long counter - big enough to fill the M5StickC screen horizontally - you might use: | ||
```cpp | ||
NixieStix <SmallNixie, 8> Counter(1, 23, 2); | ||
``` | ||
Which creates an 8 digit string of small tubes, which starts drawing at (1,23) with a 2-pixel space between tubes. | ||
Then, elsewhere in your code, you would do: | ||
```cpp | ||
Counter.draw(12345); | ||
``` | ||
and the tubes would show "00012345" | ||
|
||
You may also use tubes individually, or create your own sets by inheriting from the `NixieTube` class. This could be generalized to work with any display of image-based digits. | ||
|
||
## Dependencies | ||
|
||
* [M5StickC](https://github.com/m5stack/M5StickC) | ||
|
||
## Update the Nixie Tube Images | ||
|
||
[McOrts original repo](https://github.com/McOrts/M5StickC_Nixie_tube_Clock) includes the lcd-image-converter.exe program used to convert the images - I don't want to steal his thunder from having done the hard work of this, I just refactored it into a handy library. If you're interested, I'd recommend starting there, which also contains further instructions on getting things running for the M5StickC. | ||
|
||
## Future expansion | ||
|
||
* todo "blank" tube | ||
* todo "negative" tube for signed integers | ||
* todo support TTGO or other platforms |
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,23 @@ | ||
####################################### | ||
# Syntax Coloring Map For NixieStix | ||
####################################### | ||
|
||
####################################### | ||
# Datatypes (KEYWORD1) | ||
####################################### | ||
|
||
NixieStix KEYWORD1 | ||
NixieTube KEYWORD1 | ||
BigNixie KEYWORD1 | ||
SmallNixie KEYWORD1 | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) | ||
####################################### | ||
|
||
draw KEYWORD2 | ||
init KEYWORD2 | ||
digitImage KEYWORD2 | ||
width KEYWORD2 | ||
height KEYWORD2 | ||
|
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,11 @@ | ||
name=NixieStix | ||
version=0.1.0 | ||
author=stephan.com <[email protected]>,Carlos Orts <[email protected]> | ||
maintainer=stephan.com <[email protected]> | ||
sentence=Nixie Tube Library for M5StickC | ||
paragraph=permits you to display a string of nixie tubes representing an integer | ||
category=Display | ||
url=https://github.com/stephancom/NixieStix.git | ||
architectures=esp32 | ||
depends=M5StickC | ||
includes=NixieStix.h |
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,23 @@ | ||
// 888~~\ ,e, / ~~~888~~~ 888 | ||
// 888 | " e88~88e 888 888 888 888-~88e e88~~8e | ||
// 888 _/ 888 888 888 888 888 888 888 888b d888 88b | ||
// 888 \ 888 "88_88" 888 888 888 888 8888 8888__888 | ||
// 888 | 888 / 888 888 888 888 888P Y888 , | ||
// 888__/ 888 Cb 888 "88_-888 888-_88" "88___/ | ||
// Y8""8D | ||
// | ||
// Representing a large nixie tube, 35x67 pixels | ||
|
||
#include "BigNixie.h" | ||
#include "Tubes/vfd_35x67.c" | ||
|
||
const uint8_t *BigNixie::TubeFont[] = { | ||
vfd_35x67_0,vfd_35x67_1,vfd_35x67_2,vfd_35x67_3,vfd_35x67_4, | ||
vfd_35x67_5,vfd_35x67_6,vfd_35x67_7,vfd_35x67_8,vfd_35x67_9 | ||
}; | ||
|
||
int BigNixie::width() { return 35; } | ||
int BigNixie::height() { return 67; } | ||
uint16_t *BigNixie::digitImage(unsigned int digit) { | ||
return (uint16_t *)TubeFont[digit%10]; | ||
} |
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,28 @@ | ||
// 888~~\ ,e, / ~~~888~~~ 888 | ||
// 888 | " e88~88e 888 888 888 888-~88e e88~~8e | ||
// 888 _/ 888 888 888 888 888 888 888 888b d888 88b | ||
// 888 \ 888 "88_88" 888 888 888 888 8888 8888__888 | ||
// 888 | 888 / 888 888 888 888 888P Y888 , | ||
// 888__/ 888 Cb 888 "88_-888 888-_88" "88___/ | ||
// Y8""8D | ||
// | ||
// Representing a large nixie tube, 35x67 pixels | ||
#pragma once | ||
|
||
#include "NixieTube.h" | ||
|
||
#ifndef BigNixie_h | ||
#define BigNixie_h | ||
|
||
class BigNixie : public NixieTube { | ||
public: | ||
int width(); | ||
int height(); | ||
uint16_t *digitImage(unsigned int n); | ||
private: | ||
static const int www; | ||
static const int hhh; | ||
static const uint8_t *TubeFont[]; | ||
}; | ||
|
||
#endif |
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,47 @@ | ||
// 888b | ,e, ,e, ,d88~~\ d8 ,e, | ||
// |Y88b | " Y88b / " e88~~8e 8888 _d88__ " Y88b / | ||
// | Y88b | 888 Y88b/ 888 d888 88b `Y88b 888 888 Y88b/ | ||
// | Y88b | 888 Y88b 888 8888__888 `Y88b, 888 888 Y88b | ||
// | Y88b| 888 /Y88b 888 Y888 , 8888 888 888 /Y88b | ||
// | Y888 888 / Y88b 888 "88___/ \__88P' "88_/ 888 / Y88b | ||
// | ||
// Representing an integer comprised of nixie tubes | ||
|
||
#pragma once | ||
|
||
#include "BigNixie.h" | ||
#include "SmallNixie.h" | ||
|
||
#ifndef NixieStix_h | ||
#define NixieStix_h | ||
|
||
template <class T, int N> | ||
class NixieStix { | ||
public: | ||
NixieStix(unsigned int _x = 0, unsigned int _y = 0, unsigned int _space = 1):x(_x),y(_y),space(_space) { | ||
width = tubes[0].width(); | ||
int xpos = x; | ||
// An amusing insanity - building the tubes from last to first positioned left to right | ||
// which makes this for loop looks so cool, and makes the math easier later. | ||
for(int i=N ; i-- ;) { | ||
tubes[i].init(xpos, y); | ||
xpos += tubes[i].width() + space; | ||
} | ||
}; | ||
void draw(int number) { | ||
for(int i=0 ; i<N ; i++) { | ||
tubes[i].draw(number%10); | ||
number /= 10; | ||
} | ||
}; | ||
|
||
protected: | ||
T tubes[N]; | ||
unsigned int x; | ||
unsigned int y; | ||
unsigned int space; | ||
unsigned int width; | ||
}; | ||
|
||
#endif | ||
|
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,19 @@ | ||
// 888b | ,e, ,e, ~~~888~~~ 888 | ||
// |Y88b | " Y88b / " e88~~8e 888 888 888 888-~88e e88~~8e | ||
// | Y88b | 888 Y88b/ 888 d888 88b 888 888 888 888 888b d888 88b | ||
// | Y88b | 888 Y88b 888 8888__888 888 888 888 888 8888 8888__888 | ||
// | Y88b| 888 /Y88b 888 Y888 , 888 888 888 888 888P Y888 , | ||
// | Y888 888 / Y88b 888 "88___/ 888 "88_-888 888-_88" "88___/ | ||
// | ||
// Abstract base class representing a Nixie tube | ||
|
||
#include "NixieTube.h" | ||
|
||
void NixieTube::init(int _xpos, int _ypos) { | ||
xpos = _xpos; | ||
ypos = _ypos; | ||
} | ||
|
||
void NixieTube::draw(unsigned int digit) { | ||
M5.Lcd.pushImage(xpos, ypos, width(), height(), digitImage(digit)); | ||
} |
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,30 @@ | ||
// 888b | ,e, ,e, ~~~888~~~ 888 | ||
// |Y88b | " Y88b / " e88~~8e 888 888 888 888-~88e e88~~8e | ||
// | Y88b | 888 Y88b/ 888 d888 88b 888 888 888 888 888b d888 88b | ||
// | Y88b | 888 Y88b 888 8888__888 888 888 888 888 8888 8888__888 | ||
// | Y88b| 888 /Y88b 888 Y888 , 888 888 888 888 888P Y888 , | ||
// | Y888 888 / Y88b 888 "88___/ 888 "88_-888 888-_88" "88___/ | ||
// | ||
// Abstract base class representing a Nixie tube | ||
#pragma once | ||
|
||
#include <M5StickC.h> | ||
|
||
#ifndef NixieTube_h | ||
#define NixieTube_h | ||
|
||
class NixieTube { | ||
public: | ||
void init(int xpos, int ypos); | ||
virtual int width() = 0; | ||
virtual int height() = 0; | ||
virtual void draw(unsigned int digit); | ||
virtual uint16_t *digitImage(unsigned int n); | ||
|
||
protected: | ||
NixieTube() {}; | ||
unsigned int xpos; | ||
unsigned int ypos; | ||
}; | ||
|
||
#endif |
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,23 @@ | ||
// ,d88~~\ 888 888 ~~~888~~~ 888 | ||
// 8888 888-~88e-~88e /~~~8e 888 888 888 888 888 888-~88e e88~~8e | ||
// `Y88b 888 888 888 88b 888 888 888 888 888 888 888b d888 88b | ||
// `Y88b, 888 888 888 e88~-888 888 888 888 888 888 888 8888 8888__888 | ||
// 8888 888 888 888 C888 888 888 888 888 888 888 888 888P Y888 , | ||
// \__88P' 888 888 888 "88_-888 888 888 888 "88_-888 888-_88" "88___/ | ||
// | ||
// Representing a small nixie tube, 18x34 pixels | ||
|
||
#include "SmallNixie.h" | ||
#include "Tubes/vfd_18x34.c" | ||
|
||
const uint8_t *SmallNixie::TubeFont[] = { | ||
vfd_18x34_0,vfd_18x34_1,vfd_18x34_2,vfd_18x34_3,vfd_18x34_4, | ||
vfd_18x34_5,vfd_18x34_6,vfd_18x34_7,vfd_18x34_8,vfd_18x34_9 | ||
}; | ||
|
||
int SmallNixie::width() { return 18; } | ||
int SmallNixie::height() { return 34; } | ||
uint16_t *SmallNixie::digitImage(unsigned int digit) { | ||
return (uint16_t *)TubeFont[digit%10]; | ||
} | ||
|
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,27 @@ | ||
// ,d88~~\ 888 888 ~~~888~~~ 888 | ||
// 8888 888-~88e-~88e /~~~8e 888 888 888 888 888 888-~88e e88~~8e | ||
// `Y88b 888 888 888 88b 888 888 888 888 888 888 888b d888 88b | ||
// `Y88b, 888 888 888 e88~-888 888 888 888 888 888 888 8888 8888__888 | ||
// 8888 888 888 888 C888 888 888 888 888 888 888 888 888P Y888 , | ||
// \__88P' 888 888 888 "88_-888 888 888 888 "88_-888 888-_88" "88___/ | ||
// | ||
// Representing a small nixie tube, 18x34 pixels | ||
#pragma once | ||
|
||
#include "NixieTube.h" | ||
|
||
#ifndef SmallNixie_h | ||
#define SmallNixie_h | ||
|
||
class SmallNixie : public NixieTube { | ||
public: | ||
int width(); | ||
int height(); | ||
uint16_t *digitImage(unsigned int n); | ||
private: | ||
static const int www; | ||
static const int hhh; | ||
static const uint8_t *TubeFont[]; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.