Skip to content

Commit 1a16661

Browse files
committed
Debug methods won't use that much memory anymore (they were spending over 800 bytes in the SRAM). Instead, they are now saved in flash memory.
1 parent c3b7a71 commit 1a16661

File tree

2 files changed

+59
-59
lines changed

2 files changed

+59
-59
lines changed

src/FPS_GT511C3.cpp

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ Command_Packet::Command_Packet()
9292
// creates and parses a response packet from the finger print scanner
9393
Response_Packet::Response_Packet(uint8_t* buffer)
9494
{
95-
CheckParsing(buffer[0], RESPONSE_START_CODE_1, RESPONSE_START_CODE_1, "RESPONSE_START_CODE_1");
96-
CheckParsing(buffer[1], RESPONSE_START_CODE_2, RESPONSE_START_CODE_2, "RESPONSE_START_CODE_2");
97-
CheckParsing(buffer[2], RESPONSE_DEVICE_ID_1, RESPONSE_DEVICE_ID_1, "RESPONSE_DEVICE_ID_1");
98-
CheckParsing(buffer[3], RESPONSE_DEVICE_ID_2, RESPONSE_DEVICE_ID_2, "RESPONSE_DEVICE_ID_2");
99-
CheckParsing(buffer[8], 0x30, 0x31, "AckNak_LOW");
95+
CheckParsing(buffer[0], RESPONSE_START_CODE_1, RESPONSE_START_CODE_1, F("RESPONSE_START_CODE_1"));
96+
CheckParsing(buffer[1], RESPONSE_START_CODE_2, RESPONSE_START_CODE_2, F("RESPONSE_START_CODE_2"));
97+
CheckParsing(buffer[2], RESPONSE_DEVICE_ID_1, RESPONSE_DEVICE_ID_1, F("RESPONSE_DEVICE_ID_1"));
98+
CheckParsing(buffer[3], RESPONSE_DEVICE_ID_2, RESPONSE_DEVICE_ID_2, F("RESPONSE_DEVICE_ID_2"));
99+
CheckParsing(buffer[8], 0x30, 0x31, F("AckNak_LOW"));
100100
if (buffer[8] == 0x30) ACK = true; else ACK = false;
101-
CheckParsing(buffer[9], 0x00, 0x00, "AckNak_HIGH");
101+
CheckParsing(buffer[9], 0x00, 0x00, F("AckNak_HIGH"));
102102

103103
uint16_t checksum = CalculateChecksum(buffer, 10);
104104
uint8_t checksum_low = GetLowByte(checksum);
105105
uint8_t checksum_high = GetHighByte(checksum);
106-
CheckParsing(buffer[10], checksum_low, checksum_low, "Checksum_LOW");
107-
CheckParsing(buffer[11], checksum_high, checksum_high, "Checksum_HIGH");
106+
CheckParsing(buffer[10], checksum_low, checksum_low, F("Checksum_LOW"));
107+
CheckParsing(buffer[11], checksum_high, checksum_high, F("Checksum_HIGH"));
108108

109109
Error = ErrorCodes::ParseFromBytes(buffer[5], buffer[4]);
110110

@@ -169,19 +169,19 @@ uint32_t Response_Packet::FromParameter()
169169
}
170170

171171
// checks to see if the byte is the proper value, and logs it to the serial channel if not
172-
bool Response_Packet::CheckParsing(uint8_t b, uint8_t propervalue, uint8_t alternatevalue, const char* varname)
172+
bool Response_Packet::CheckParsing(uint8_t b, uint8_t propervalue, uint8_t alternatevalue, const String varname)
173173
{
174174
bool retval = (b != propervalue) && (b != alternatevalue);
175175
#if FPS_DEBUG
176176
if (retval)
177177
{
178-
Serial.print("Response_Packet parsing error ");
178+
Serial.print(F("Response_Packet parsing error "));
179179
Serial.print(varname);
180-
Serial.print(" ");
180+
Serial.print(F(" "));
181181
Serial.print(propervalue, HEX);
182-
Serial.print(" || ");
182+
Serial.print(F(" || "));
183183
Serial.print(alternatevalue, HEX);
184-
Serial.print(" != ");
184+
Serial.print(F(" != "));
185185
Serial.println(b, HEX);
186186
}
187187
#endif
@@ -220,10 +220,10 @@ uint8_t Response_Packet::GetLowByte(uint16_t w)
220220
Data_Packet::Data_Packet(uint8_t* buffer)
221221
{
222222
#if FPS_DEBUG
223-
CheckParsing(buffer[0], DATA_START_CODE_1, DATA_START_CODE_1, "DATA_START_CODE_1");
224-
CheckParsing(buffer[1], DATA_START_CODE_2, DATA_START_CODE_2, "DATA_START_CODE_2");
225-
CheckParsing(buffer[2], DATA_DEVICE_ID_1, DATA_DEVICE_ID_1, "DATA_DEVICE_ID_1");
226-
CheckParsing(buffer[3], DATA_DEVICE_ID_2, DATA_DEVICE_ID_2, "DATA_DEVICE_ID_2");
223+
CheckParsing(buffer[0], DATA_START_CODE_1, DATA_START_CODE_1, F("DATA_START_CODE_1"));
224+
CheckParsing(buffer[1], DATA_START_CODE_2, DATA_START_CODE_2, F("DATA_START_CODE_2"));
225+
CheckParsing(buffer[2], DATA_DEVICE_ID_1, DATA_DEVICE_ID_1, F("DATA_DEVICE_ID_1"));
226+
CheckParsing(buffer[3], DATA_DEVICE_ID_2, DATA_DEVICE_ID_2, F("DATA_DEVICE_ID_2"));
227227

228228
this->checksum = CalculateChecksum(buffer, 4);
229229
#endif
@@ -247,25 +247,25 @@ void Data_Packet::GetLastData(uint8_t buffer[], uint16_t length)
247247
this->checksum = CalculateChecksum(buffer, length-2);
248248
uint8_t checksum_low = GetLowByte(this->checksum);
249249
uint8_t checksum_high = GetHighByte(this->checksum);
250-
CheckParsing(buffer[length-2], checksum_low, checksum_low, "Checksum_LOW");
251-
CheckParsing(buffer[length-1], checksum_high, checksum_high, "Checksum_HIGH");
250+
CheckParsing(buffer[length-2], checksum_low, checksum_low, F("Checksum_LOW"));
251+
CheckParsing(buffer[length-1], checksum_high, checksum_high, F("Checksum_HIGH"));
252252
#endif
253253
}
254254

255255
// checks to see if the byte is the proper value, and logs it to the serial channel if not
256-
bool Data_Packet::CheckParsing(uint8_t b, uint8_t propervalue, uint8_t alternatevalue, const char* varname)
256+
bool Data_Packet::CheckParsing(uint8_t b, uint8_t propervalue, uint8_t alternatevalue, const String varname)
257257
{
258258
bool retval = (b != propervalue) && (b != alternatevalue);
259259
#if FPS_DEBUG
260260
if(retval)
261261
{
262-
Serial.print("\nData_Packet parsing error ");
262+
Serial.print(F("\nData_Packet parsing error "));
263263
Serial.print(varname);
264-
Serial.print(" ");
264+
Serial.print(F(" "));
265265
Serial.print(propervalue, HEX);
266-
Serial.print(" || ");
266+
Serial.print(F(" || "));
267267
Serial.print(alternatevalue, HEX);
268-
Serial.print(" != ");
268+
Serial.print(F(" != "));
269269
Serial.println(b, HEX);
270270
}
271271
#endif
@@ -335,7 +335,7 @@ bool FPS_GT511C3::Open()
335335
{
336336
if (!Started) Start();
337337
#if FPS_DEBUG
338-
Serial.println("FPS - Open");
338+
Serial.println(F("FPS - Open"));
339339
#endif
340340
Command_Packet* cp = new Command_Packet();
341341
cp->Command = Command_Packet::Commands::Open;
@@ -359,7 +359,7 @@ bool FPS_GT511C3::Open()
359359
void FPS_GT511C3::Close()
360360
{
361361
#if FPS_DEBUG
362-
Serial.println("FPS - Close");
362+
Serial.println(F("FPS - Close"));
363363
#endif
364364
Command_Packet* cp = new Command_Packet();
365365
cp->Command = Command_Packet::Commands::Close;
@@ -385,14 +385,14 @@ bool FPS_GT511C3::SetLED(bool on)
385385
if (on)
386386
{
387387
#if FPS_DEBUG
388-
Serial.println("FPS - LED on");
388+
Serial.println(F("FPS - LED on"));
389389
#endif
390390
cp->Parameter[0] = 0x01;
391391
}
392392
else
393393
{
394394
#if FPS_DEBUG
395-
Serial.println("FPS - LED off");
395+
Serial.println(F("FPS - LED off"));
396396
#endif
397397
cp->Parameter[0] = 0x00;
398398
}
@@ -419,7 +419,7 @@ bool FPS_GT511C3::ChangeBaudRate(uint32_t baud)
419419
if ((baud == 9600) || (baud == 19200) || (baud == 38400) || (baud == 57600) || (baud == 115200))
420420
{
421421
#if FPS_DEBUG
422-
Serial.println("FPS - ChangeBaudRate");
422+
Serial.println(F("FPS - ChangeBaudRate"));
423423
#endif
424424
Command_Packet* cp = new Command_Packet();
425425
cp->Command = Command_Packet::Commands::ChangeBaudRate;
@@ -442,7 +442,7 @@ bool FPS_GT511C3::ChangeBaudRate(uint32_t baud)
442442
uint16_t FPS_GT511C3::GetEnrollCount()
443443
{
444444
#if FPS_DEBUG
445-
Serial.println("FPS - GetEnrolledCount");
445+
Serial.println(F("FPS - GetEnrolledCount"));
446446
#endif
447447
Command_Packet* cp = new Command_Packet();
448448
cp->Command = Command_Packet::Commands::GetEnrollCount;
@@ -467,7 +467,7 @@ uint16_t FPS_GT511C3::GetEnrollCount()
467467
bool FPS_GT511C3::CheckEnrolled(uint16_t id)
468468
{
469469
#if FPS_DEBUG
470-
Serial.println("FPS - CheckEnrolled");
470+
Serial.println(F("FPS - CheckEnrolled"));
471471
#endif
472472
Command_Packet* cp = new Command_Packet();
473473
cp->Command = Command_Packet::Commands::CheckEnrolled;
@@ -494,7 +494,7 @@ bool FPS_GT511C3::CheckEnrolled(uint16_t id)
494494
uint8_t FPS_GT511C3::EnrollStart(uint16_t id)
495495
{
496496
#if FPS_DEBUG
497-
Serial.println("FPS - EnrollStart");
497+
Serial.println(F("FPS - EnrollStart"));
498498
#endif
499499
Command_Packet* cp = new Command_Packet();
500500
cp->Command = Command_Packet::Commands::EnrollStart;
@@ -524,7 +524,7 @@ uint8_t FPS_GT511C3::EnrollStart(uint16_t id)
524524
uint8_t FPS_GT511C3::Enroll1()
525525
{
526526
#if FPS_DEBUG
527-
Serial.println("FPS - Enroll1");
527+
Serial.println(F("FPS - Enroll1"));
528528
#endif
529529
Command_Packet* cp = new Command_Packet();
530530
cp->Command = Command_Packet::Commands::Enroll1;
@@ -555,7 +555,7 @@ uint8_t FPS_GT511C3::Enroll1()
555555
uint8_t FPS_GT511C3::Enroll2()
556556
{
557557
#if FPS_DEBUG
558-
Serial.println("FPS - Enroll2");
558+
Serial.println(F("FPS - Enroll2"));
559559
#endif
560560
Command_Packet* cp = new Command_Packet();
561561
cp->Command = Command_Packet::Commands::Enroll2;
@@ -587,7 +587,7 @@ uint8_t FPS_GT511C3::Enroll2()
587587
uint8_t FPS_GT511C3::Enroll3()
588588
{
589589
#if FPS_DEBUG
590-
Serial.println("FPS - Enroll3");
590+
Serial.println(F("FPS - Enroll3"));
591591
#endif
592592
Command_Packet* cp = new Command_Packet();
593593
cp->Command = Command_Packet::Commands::Enroll3;
@@ -614,7 +614,7 @@ uint8_t FPS_GT511C3::Enroll3()
614614
bool FPS_GT511C3::IsPressFinger()
615615
{
616616
#if FPS_DEBUG
617-
Serial.println("FPS - IsPressFinger");
617+
Serial.println(F("FPS - IsPressFinger"));
618618
#endif
619619
Command_Packet* cp = new Command_Packet();
620620
cp->Command = Command_Packet::Commands::IsPressFinger;
@@ -636,7 +636,7 @@ bool FPS_GT511C3::IsPressFinger()
636636
bool FPS_GT511C3::DeleteID(uint16_t id)
637637
{
638638
#if FPS_DEBUG
639-
Serial.println("FPS - DeleteID");
639+
Serial.println(F("FPS - DeleteID"));
640640
#endif
641641
Command_Packet* cp = new Command_Packet();
642642
cp->Command = Command_Packet::Commands::DeleteID;
@@ -656,7 +656,7 @@ bool FPS_GT511C3::DeleteID(uint16_t id)
656656
bool FPS_GT511C3::DeleteAll()
657657
{
658658
#if FPS_DEBUG
659-
Serial.println("FPS - DeleteAll");
659+
Serial.println(F("FPS - DeleteAll"));
660660
#endif
661661
Command_Packet* cp = new Command_Packet();
662662
cp->Command = Command_Packet::Commands::DeleteAll;
@@ -681,7 +681,7 @@ bool FPS_GT511C3::DeleteAll()
681681
uint8_t FPS_GT511C3::Verify1_1(uint16_t id)
682682
{
683683
#if FPS_DEBUG
684-
Serial.println("FPS - Verify1_1");
684+
Serial.println(F("FPS - Verify1_1"));
685685
#endif
686686
Command_Packet* cp = new Command_Packet();
687687
cp->Command = Command_Packet::Commands::Verify1_1;
@@ -714,7 +714,7 @@ uint8_t FPS_GT511C3::Verify1_1(uint16_t id)
714714
uint16_t FPS_GT511C3::Identify1_N()
715715
{
716716
#if FPS_DEBUG
717-
Serial.println("FPS - Identify1_N");
717+
Serial.println(F("FPS - Identify1_N"));
718718
#endif
719719
Command_Packet* cp = new Command_Packet();
720720
cp->Command = Command_Packet::Commands::Identify1_N;
@@ -738,7 +738,7 @@ uint16_t FPS_GT511C3::Identify1_N()
738738
bool FPS_GT511C3::CaptureFinger(bool highquality)
739739
{
740740
#if FPS_DEBUG
741-
Serial.println("FPS - CaptureFinger");
741+
Serial.println(F("FPS - CaptureFinger"));
742742
#endif
743743
Command_Packet* cp = new Command_Packet();
744744
cp->Command = Command_Packet::Commands::CaptureFinger;
@@ -772,7 +772,7 @@ bool FPS_GT511C3::CaptureFinger(bool highquality)
772772
bool FPS_GT511C3::GetImage(bool patched)
773773
{
774774
#if FPS_DEBUG
775-
Serial.println("FPS - GetImage");
775+
Serial.println(F("FPS - GetImage"));
776776
#endif
777777
Command_Packet* cp = new Command_Packet();
778778
cp->Command = Command_Packet::Commands::GetImage;
@@ -816,7 +816,7 @@ bool FPS_GT511C3::GetImage(bool patched)
816816
bool FPS_GT511C3::GetRawImage()
817817
{
818818
#if FPS_DEBUG
819-
Serial.println("FPS - GetRawImage");
819+
Serial.println(F("FPS - GetRawImage"));
820820
#endif
821821
Command_Packet* cp = new Command_Packet();
822822
cp->Command = Command_Packet::Commands::GetRawImage;
@@ -840,7 +840,7 @@ bool FPS_GT511C3::GetRawImage()
840840
uint8_t FPS_GT511C3::GetTemplate(uint16_t id)
841841
{
842842
#if FPS_DEBUG
843-
Serial.println("FPS - GetTemplate");
843+
Serial.println(F("FPS - GetTemplate"));
844844
#endif
845845
Command_Packet* cp = new Command_Packet();
846846
cp->Command = Command_Packet::Commands::GetTemplate;
@@ -873,7 +873,7 @@ uint8_t FPS_GT511C3::GetTemplate(uint16_t id)
873873
uint8_t FPS_GT511C3::GetTemplate(uint16_t id, uint8_t data[])
874874
{
875875
#if FPS_DEBUG
876-
Serial.println("FPS - GetTemplate");
876+
Serial.println(F("FPS - GetTemplate"));
877877
#endif
878878
Command_Packet* cp = new Command_Packet();
879879
cp->Command = Command_Packet::Commands::GetTemplate;
@@ -910,7 +910,7 @@ uint8_t FPS_GT511C3::GetTemplate(uint16_t id, uint8_t data[])
910910
uint16_t FPS_GT511C3::SetTemplate(byte* tmplt, uint16_t id, bool duplicateCheck)
911911
{
912912
#if FPS_DEBUG
913-
Serial.println("FPS - SetTemplate");
913+
Serial.println(F("FPS - SetTemplate"));
914914
#endif
915915
Command_Packet* cp = new Command_Packet();
916916
cp->Command = Command_Packet::Commands::SetTemplate;
@@ -994,7 +994,7 @@ void FPS_GT511C3::Start()
994994
for(uint8_t i = 0; i<5; i++) // Trying to find FPS baud rate
995995
{
996996
#if FPS_DEBUG
997-
Serial.print("Establishing connection with FPS at baud rate: ");
997+
Serial.print(F("Establishing connection with FPS at baud rate: "));
998998
Serial.print(BaudRates[i]);
999999
Serial.println();
10001000
#endif
@@ -1050,7 +1050,7 @@ void FPS_GT511C3::Start()
10501050
}
10511051

10521052
#if FPS_DEBUG
1053-
Serial.print("Connection established succesfully. FPS baud rate was: ");
1053+
Serial.print(F("Connection established succesfully. FPS baud rate was: "));
10541054
Serial.print(actualBaud);
10551055
Serial.println();
10561056
Serial.println();
@@ -1059,7 +1059,7 @@ void FPS_GT511C3::Start()
10591059
if (actualBaud == 0) while(true)
10601060
{
10611061
#if FPS_DEBUG
1062-
Serial.print("EXCEPTION: FPS didn't answer to communications. Code execution stopped.");
1062+
Serial.print(F("EXCEPTION: FPS didn't answer to communications. Code execution stopped."));
10631063
Serial.println();
10641064
#endif
10651065
delay(1000); // Something went terribly wrong with the FPS, and you aren't allowed to leave
@@ -1068,7 +1068,7 @@ void FPS_GT511C3::Start()
10681068
if (actualBaud != baud)
10691069
{
10701070
#if FPS_DEBUG
1071-
Serial.print("Undesired baud rate. Changing baud rate to: ");
1071+
Serial.print(F("Undesired baud rate. Changing baud rate to: "));
10721072
Serial.print(baud);
10731073
Serial.println();
10741074
Serial.println();
@@ -1083,7 +1083,7 @@ void FPS_GT511C3::SendCommand(uint8_t cmd[], uint16_t length)
10831083
{
10841084
_serial.write(cmd, length);
10851085
#if FPS_DEBUG
1086-
Serial.print("FPS - SEND: ");
1086+
Serial.print(F("FPS - SEND: "));
10871087
SendToSerial(cmd, length);
10881088
Serial.println();
10891089
#endif
@@ -1179,16 +1179,16 @@ void FPS_GT511C3::GetData(uint16_t length)
11791179
if(_serial.overflow())
11801180
{
11811181
#if FPS_DEBUG
1182-
Serial.println("Overflow! Data download stopped");
1183-
Serial.println("Cleaning serial buffer...");
1182+
Serial.println(F("Overflow! Data download stopped"));
1183+
Serial.println(F("Cleaning serial buffer..."));
11841184
#endif
11851185
for (uint16_t j = 0; j<length; j++)
11861186
{
11871187
_serial.read();
11881188
delay(1);
11891189
}
11901190
#if FPS_DEBUG
1191-
Serial.println("Done!");
1191+
Serial.println(F("Done!"));
11921192
#endif
11931193
return;
11941194
}
@@ -1245,16 +1245,16 @@ bool FPS_GT511C3::ReturnData(uint16_t length, uint8_t data[])
12451245
if(_serial.overflow())
12461246
{
12471247
#if FPS_DEBUG
1248-
Serial.println("Overflow! Data download stopped");
1249-
Serial.println("Cleaning serial buffer...");
1248+
Serial.println(F("Overflow! Data download stopped"));
1249+
Serial.println(F("Cleaning serial buffer..."));
12501250
#endif
12511251
for (uint16_t j = 0; j<length; j++)
12521252
{
12531253
_serial.read();
12541254
delay(1);
12551255
}
12561256
#if FPS_DEBUG
1257-
Serial.println("Done!");
1257+
Serial.println(F("Done!"));
12581258
#endif
12591259
return false;
12601260
}

0 commit comments

Comments
 (0)