@@ -728,19 +728,42 @@ bool FPS_GT511C3::CaptureFinger(bool highquality)
728728 // Slower speeds and the FPS will shutdown. Higher speeds and the serial buffer will overflow.
729729 // Make sure you are allocating enough CPU time for this task or you will overflow nonetheless.
730730 // Also, avoid using UseSerialDebug for this task, since it's easier to overflow.
731- bool FPS_GT511C3::GetImage ()
731+ // WARNING: This method is completely broken, but you can give it a try.
732+ // Patched method will return a 232x139 bitmap 8-bit image, 32248 bytes.
733+ // Parameter: true to ignore the documentation and get valid image data.
734+ bool FPS_GT511C3::GetImage (bool patched)
732735{
733736 if (UseSerialDebug) Serial.println (" FPS - GetImage" );
734- Command_Packet* cp = new Command_Packet ();
735- cp->Command = Command_Packet::Commands::GetImage;
736- uint8_t * packetbytes = cp->GetPacketBytes ();
737- delete cp;
738- SendCommand (packetbytes, 12 );
737+ Command_Packet* cp = new Command_Packet ();
738+ cp->Command = Command_Packet::Commands::GetImage;
739+ uint8_t * packetbytes = cp->GetPacketBytes ();
740+ delete cp;
741+ SendCommand (packetbytes, 12 );
739742 delete packetbytes;
740- Response_Packet* rp = GetResponse ();
741- bool retval = rp->ACK ;
742- delete rp;
743- GetData (52116 +6 );
743+ Response_Packet* rp = GetResponse ();
744+ bool retval = rp->ACK ;
745+ delete rp;
746+
747+ if (!patched) GetData (52116 +6 );
748+ else
749+ {
750+ // Alright, for some reason, in my GT-511C3, there are around 15000 trash bytes being sent
751+ // before the actual image is sent. The actual number is random, but the image will come
752+ // after a long block of empty bytes. Not only that, the resolution of the image is actually
753+ // 232x139 (maybe taller) and not whatever the documentation says. This wasn't fun to debug.
754+ for (uint16_t i = 0 ; i<10000 ; i++) // This goes past the initial non-zero trash block
755+ {
756+ while (!_serial.available ()) delay (10 );
757+ _serial.read ();
758+ }
759+ while (_serial.peek () <= 0 ) _serial.read (); // This looks for the actual first byte of image data
760+
761+ for (uint16_t i = 0 ; i<32248 ; i++) // Bytes for a 232x139 bitmap 8-bit image
762+ {
763+ while (!_serial.available ()) delay (10 );
764+ Serial.write ((uint8_t )_serial.read ());
765+ }
766+ }
744767 return retval;
745768}
746769
0 commit comments