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

add some funcs for setting the name of printers from your code. #5

Merged
merged 2 commits into from
Aug 24, 2023

Conversation

Hurumy
Copy link
Contributor

@Hurumy Hurumy commented Aug 21, 2023

Summary

Now you can set the names of printers to be scanned from your code, just using member functions.

Added private member of a CatPrinter class:

NAME_ARRAY_SIZE = 6;

Setting the max size of char* array of printer_names.

NAME_STRING_SIZE = 8;

Setting the max size of each name.

printer_names[NAME_ARRAY_SIZE][NAME_STRING_SIZE];

Reserve memory for array of names.
Indicates the end of the array with an empty string instead of NULL.
When you call the constructor of CatPrinter, this name array has default value: GT01, GB01, GB02, MX09
So you can use both new and old codes without any fixing.

Added public member of a CatPrinter class:

void resetNameArray(void);

Remove all value of printer_names.
Replace each value with empty string.

bool addNameArray(char *newname);

Add newname to the printer_names.
If the array is already fulfilled, it returns false.

void printNameArray(void);

Print the values of printer_names by Serial.println. It maybe useful for debugging.

Other fixing

Moving the implementation of the constructor

I moved the implementation of the constructor from header to .cpp, because the definition of printer_names is done below of this function.

Add these funcs to the print_demo.ino file

Users can easily find a way to set the names of catty printers to be scanned.




Thank you for your impressive work!!

Copy link
Owner

@TheNitek TheNitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution. Could you please fix the issue with the array initaliziation?

src/CatGFX.cpp Outdated Show resolved Hide resolved
src/CatGFX.h Outdated Show resolved Hide resolved
@Hurumy
Copy link
Contributor Author

Hurumy commented Aug 23, 2023

Good morning. I fixed the issue and tested, then it worked.
How about this!

@TheNitek TheNitek merged commit 798c4af into TheNitek:main Aug 24, 2023
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.

None yet

2 participants