add some funcs for setting the name of printers from your code. #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
bySerial.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!!