Skip to content

Commit

Permalink
fixed the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Hurumy committed Aug 23, 2023
1 parent 011b566 commit 79340ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions src/CatGFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ CatPrinter::CatPrinter(uint16_t h):
SERVICE_UUID("0000AE30-0000-1000-8000-00805F9B34FB"),
CHAR_UUID_DATA("0000AE01-0000-1000-8000-00805F9B34FB")
{
strcpy(this->printer_names[0], "GT01");
strcpy(this->printer_names[1], "GB01");
strcpy(this->printer_names[2], "GB02");
strcpy(this->printer_names[3], "MX09");
strcpy(this->printer_names[4], "");
if (this->NAME_ARRAY_SIZE >= 5)
{
strcpy(this->printerNames[0], "GT01");
strcpy(this->printerNames[1], "GB01");
strcpy(this->printerNames[2], "GB02");
strcpy(this->printerNames[3], "MX09");
for (int i = 4; i < this->NAME_ARRAY_SIZE; i ++)
strcpy(this->printerNames[i], "");
}
else if (this->NAME_ARRAY_SIZE >= 1)
strcpy(this->printerNames[0], "");
}

void CatPrinter::begin(byte *buffer, uint16_t size) {
Expand Down Expand Up @@ -123,8 +129,8 @@ void CatPrinter::printBuffer(void) {
void CatPrinter::onResult(BLEAdvertisedDevice advertisedDevice) {
uint8_t i = 0;

while (i < this->NAME_ARRAY_SIZE && strcmp(this->printer_names[i], "") != 0){
if (strcmp(advertisedDevice.getName().c_str(), this->printer_names[i]) == 0) {
while (i < this->NAME_ARRAY_SIZE && strcmp(this->printerNames[i], "") != 0){
if (strcmp(advertisedDevice.getName().c_str(), this->printerNames[i]) == 0) {
blePrinterAddress = new BLEAddress(advertisedDevice.getAddress());
Serial.print("Found Printer: ");
Serial.println(blePrinterAddress->toString().c_str());
Expand Down Expand Up @@ -206,7 +212,7 @@ void CatPrinter::fillScreen(uint16_t color) {
void CatPrinter::resetNameArray(void)
{
for (uint8_t i = 0; i < this->NAME_ARRAY_SIZE; i ++)
strcpy(this->printer_names[i], "");
strcpy(this->printerNames[i], "");
}

bool CatPrinter::addNameArray(char *newname)
Expand All @@ -217,21 +223,21 @@ bool CatPrinter::addNameArray(char *newname)
return (false);
while (i < this->NAME_ARRAY_SIZE)
{
if (strcmp(this->printer_names[i], "") != 0)
if (strcmp(this->printerNames[i], "") != 0)
i ++;
else
break ;
}
if (i >= this->NAME_ARRAY_SIZE - 1)
return (false);
strcpy(this->printer_names[i], newname);
strcpy(this->printerNames[i], newname);
return (true);
}

void CatPrinter::printNameArray(void)
{
for (uint8_t i = 0; i < NAME_ARRAY_SIZE; i ++)
Serial.println(this->printer_names[i]);
Serial.println(this->printerNames[i]);
}


2 changes: 1 addition & 1 deletion src/CatGFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CatPrinter: public Adafruit_GFX, public BLEAdvertisedDeviceCallbacks {
//Indicates the end of the array with an empty string instead of NULL.
const static uint8_t NAME_ARRAY_SIZE = 6;
const static uint8_t NAME_STRING_SIZE = 8;
char printer_names[NAME_ARRAY_SIZE][NAME_STRING_SIZE];
char printerNames[NAME_ARRAY_SIZE][NAME_STRING_SIZE];

const byte LATTICE_START[11] = {0xAA, 0x55, 0x17, 0x38, 0x44, 0x5F, 0x5F, 0x5F, 0x44, 0x38, 0x2C};
const byte LATTICE_END[11] = {0xAA, 0x55, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17};
Expand Down

0 comments on commit 79340ca

Please sign in to comment.