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

Function to print char array #39

Open
m-maazi opened this issue Jul 5, 2020 · 0 comments
Open

Function to print char array #39

m-maazi opened this issue Jul 5, 2020 · 0 comments

Comments

@m-maazi
Copy link

m-maazi commented Jul 5, 2020

I don't know how to add this function to your useful library.
This is what I wrote to print a char[] array to 7segment module:

void SEVSEG_PRINT(uint8_t arg1_ID, char arg2_DATA[]) {

      uint8_t tmp_LOCATION = 0;
      bool tmp_HAS_POINT = false;

      SEVSEG_MODULE.clearDisplay(arg1_ID);
      for (uint8_t i = 0; i < strlen(arg2_DATA); i++) {
        char tmp_CHAR = arg2_DATA[strlen(arg2_DATA) - i - 1];
        char tmp_CHAR_NEXT = arg2_DATA[strlen(arg2_DATA) - i - 2];
        if (tmp_CHAR == '.') {
          if (tmp_CHAR_NEXT == '.') {
            SEVSEG_MODULE.setChar(arg1_ID, tmp_LOCATION, '.', tmp_HAS_POINT);
            tmp_LOCATION++;
            tmp_HAS_POINT = false;
          } else {
            tmp_HAS_POINT = true;
          }
        } else if (isalpha(tmp_CHAR) || tmp_CHAR == ' ') {
          SEVSEG_MODULE.setChar(arg1_ID, tmp_LOCATION, tmp_CHAR, tmp_HAS_POINT);
          tmp_LOCATION++;
          tmp_HAS_POINT = false;
        } else if (isdigit(tmp_CHAR)) {
          SEVSEG_MODULE.setDigit(arg1_ID, tmp_LOCATION, tmp_CHAR - '0', tmp_HAS_POINT);
          tmp_LOCATION++;
          tmp_HAS_POINT = false;
        }
      }
}

I hope it helps!
Try calling SEVSEG_PRINT(0, 'Hello ...');

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

No branches or pull requests

1 participant