Closed DeflateAwning closed 10 months ago
Nice to add, especially the example. Thanks
I'll add that it would be helpful to include a link to this graphic alongside the codes/examples, and maybe even include the graphic in the README, as it shows which segments are which: https://en.wikipedia.org/wiki/File:7_segment_display_labeled.svg
Agree,
I would use const uint8_t SEG_A = 0b00000001;
to prevent #define conflicts.
Furthermore I would add const uint8_t SEG_NONE = 0b00000000;
(SEG_EMPTY? or ???) to handle the "magix zero"
To be specific, I think those constants should be added to the library (as macros or other), as they are included in many other similar 7-seg libraries.
To be specific, I think those constants should be added to the library (as macros or other), as they are included in many other similar 7-seg libraries.
That is exactly the reason why not to use #define as other libs might have defines them already.
They will come in the .h file
wrapped the function in a sketch
//
// FILE: demo_displayRaw.ino
// AUTHOR: Rob Tillaart, DeflateAwning
// PURPOSE: demo
// URL: http://www.adafruit.com/products/1002
// URL: https://github.com/RobTillaart/HT16K33
#include "HT16K33.h"
HT16K33 display(0x70);
uint32_t start = 0;
void display_scrolling_press_start(uint32_t idle_start_time_ms)
{
const int msg_len = 14;
int offset = ((millis() - idle_start_time_ms) / 500) % (msg_len);
const uint8_t SEG_PRESS_START[] = {
SEG_A | SEG_B | SEG_F | SEG_E | SEG_G, // P
SEG_E | SEG_G, // r
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E
SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S
SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S
SEG_NONE, // [space]
SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S
SEG_F | SEG_E | SEG_G | SEG_D, // t
SEG_A | SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, // A
SEG_E | SEG_G, // r
SEG_F | SEG_E | SEG_G | SEG_D, // t
SEG_NONE, // [space]
SEG_NONE, // [space]
SEG_NONE // [space]
};
uint8_t seg1_data[] = {SEG_D, SEG_D, SEG_D, SEG_D};
// uint8_t seg2_data[] = {SEG_D, SEG_D, SEG_D, SEG_D};
for (int i = 0; i < 4; i++) {
seg1_data[i] = SEG_PRESS_START[(i + offset) % msg_len];
// seg2_data[i] = SEG_PRESS_START[(i+offset+5)%msg_len];
}
display.displayRaw(seg1_data);
}
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("HT16K33_LIB_VERSION: ");
Serial.println(HT16K33_LIB_VERSION);
Wire.begin();
Wire.setClock(100000);
display.begin();
display.displayOn();
display.setBrightness(2);
display.displayClear();
start = millis();
}
void loop()
{
display_scrolling_press_start(start);
delay(100);
}
// -- END OF FILE --
Can you verify I used it correctly?
@DeflateAwning Develop branch and Pull Request created (includes above sketch as example.
Looks good to me! Nice work!
I left a couple quick comments on the linked commit
thanks, will look into it tomorrow (fresh eyes)
The codes, copied from https://github.com/avishorp/TM1637/blob/master/TM1637Display.h
These are standard codes, and can be combined to produce messages.
A complex example of this, which could be cool to include in an example, is a scrolling "Press Start" message:
The magic numbers in the raw "elsa" example could/should be constructed with this method as well.