Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ASCII and string support for 7-segment backpack #41

Merged
merged 13 commits into from
Oct 6, 2021

Conversation

dmadison
Copy link
Contributor

@dmadison dmadison commented Jun 1, 2018

This swaps out the 7-segment hex-only table for a full ASCII character set, allowing the user to write alphanumeric characters and symbols in addition to hexadecimal values.

Like the alpha table, the 7-segment ASCII table is stored in flash memory. All digit display calls now pass through the writeDigitChar function, with decimal and hex characters in the pre-existing writeDigitNum now offset to their character equivalents. I've also added some overloaded print and println functions to write characters and strings to the display, left-justified. Behavior of the integer and float functions is unchanged.

This shouldn't break any pre-existing code unless it was accessing the numbertable array directly instead of through the class, as that has been replaced by the ASCII font table.

I've added a string print test to the sevenseg.ino example to demonstrate the string feature.

@K4stor
Copy link

K4stor commented Feb 18, 2019

Why u no merge this ? This awesome

@dmadison
Copy link
Contributor Author

/home/runner/work/Adafruit_LED_Backpack/Adafruit_LED_Backpack/Adafruit_LEDBackpack.cpp:161: warning: documented symbol 'static const uint16_t alphafonttable' was not declared or defined.

I'm not sure what the CI is complaining about here. The array is defined in the source file and I don't see anything of note on line 161.

just a bump to try and kick the CI to run again
@caternuson
Copy link
Contributor

@dmadison Hey, if you're still interested in working this PR, looks like the CI is failing on the doxygen part:
image

@dmadison
Copy link
Contributor Author

After some more sleuthing it looks like Doxygen is getting confused with the PROGMEM keyword. Removing the keyword from the first of the two arrays (in either order) fixes the issue. Although that's certainly not a good fix for the board's memory.

On the Doxygen side this can be fixed by enabling macro expansion and adding PROGMEM to the list of predefined keywords in the Doxyfile:

MACRO_EXPANSION        = YES
PREDEFINED             = __cdecl= \
                         PROGMEM=

Unfortunately I'm not sure there's a good way around the issue without modifying the Doxyfile in some way.

@caternuson
Copy link
Contributor

Ugh. What a weird doxy issue. I tried some stuff locally, and just relocating the PROGMEM modifer seemed to fix it as well. Try this:

static const PROGMEM uint8_t sevensegfonttable[] = {
static const PROGMEM uint16_t alphafonttable[] = {

Attempting to fix a bug with Doxygen. No functional change (hopefully).
@dmadison
Copy link
Contributor Author

Hopefully that works! I've never seen the attribute placed before the variable, but it seems to compile fine on my machine.

@caternuson
Copy link
Contributor

Now clang is unhappy. Looks like just some trailing whitespace. Here's how to install and run:
https://learn.adafruit.com/the-well-automated-arduino-library/formatting-with-clang-format

When the local clang disagrees with the CI clang... ah automation
Matching the function name in the alphanumeric backpack class
For matching function signatures between the 7 digit and alphanumeric displays
@dmadison
Copy link
Contributor Author

Are the numeric base changes for char intentional? I'm not sure how that's supposed to be interpreted.

@dmadison
Copy link
Contributor Author

dmadison commented Oct 6, 2021

Ah okay I see it - the removal of the bases for the char print types is something I changed for this pull request specifically, three years ago (2ff4d95). Merging from master reverted that change.

@caternuson
Copy link
Contributor

Looks good. Gonna merge. Thanks for continuing to work this update!

Tested with:

#include "Adafruit_LEDBackpack.h"

Adafruit_7segment seg = Adafruit_7segment();

int count = 0;

void setup() { 
  seg.begin(0x70);

  for (uint8_t i='!'; i<='z'; i++) {
    seg.writeDigitAscii(0, i);
    seg.writeDigitAscii(1, i+1);
    seg.writeDigitAscii(3, i+2);
    seg.writeDigitAscii(4, i+3);
    seg.writeDisplay();
    delay(300);
  }

  seg.print(1000, DEC); seg.writeDisplay(); delay(1000);
  seg.print(0xBEEF, HEX); seg.writeDisplay(); delay(1000);
  seg.print(12.34); seg.writeDisplay(); delay(1000);
  seg.print("7SEG"); seg.writeDisplay(); delay(1000);

  for (uint16_t counter = 0; counter < 9999; counter++) {
    seg.println(counter);
    seg.writeDisplay();
    delay(10);
  }

  seg.print("YEAH");
  seg.writeDisplay(); 
}

void loop() {
}

led_test

@caternuson caternuson merged commit a2d9473 into adafruit:master Oct 6, 2021
@dmadison dmadison deleted the 7seg_strings branch October 6, 2021 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants