Skip to content

Commit c3b7a71

Browse files
committed
A few optimizations and some deleted obsolete code.
1 parent 0f67779 commit c3b7a71

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/FPS_GT511C3.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,12 +1162,12 @@ void FPS_GT511C3::GetData(uint16_t length)
11621162
Data_Packet dp(firstdata);
11631163

11641164
uint16_t numberPacketsNeeded = (length-4) / 64;
1165-
bool smallLastPacket = false;
11661165
uint8_t lastPacketSize = (length-4) % 64;
1167-
if(lastPacketSize != 0)
1168-
{
1169-
numberPacketsNeeded++;
1170-
smallLastPacket = true;
1166+
if(lastPacketSize != 0) numberPacketsNeeded++;
1167+
else {
1168+
// Last packet requires special treatment, so you don't want it to pass over the main loop
1169+
numberPacketsNeeded--;
1170+
lastPacketSize = 64;
11711171
}
11721172

11731173
uint8_t data[64];
@@ -1237,16 +1237,7 @@ bool FPS_GT511C3::ReturnData(uint16_t length, uint8_t data[])
12371237
while (_serial.available() == false) delay(10);
12381238
firstdata[i]= (uint8_t) _serial.read();
12391239
}
1240-
Data_Packet dp(firstdata);
1241-
1242-
uint16_t numberPacketsNeeded = (length-4) / 64;
1243-
bool smallLastPacket = false;
1244-
uint8_t lastPacketSize = (length-4) % 64;
1245-
if(lastPacketSize != 0)
1246-
{
1247-
numberPacketsNeeded++;
1248-
smallLastPacket = true;
1249-
}
1240+
Data_Packet dp(firstdata); // Not needed
12501241

12511242
for (uint16_t i=0; i < length-4; i++)
12521243
{

0 commit comments

Comments
 (0)