#define FP_IRQ_PIN 3
#define FP_TX_PIN 19
#define FP_RX_PIN 18
#define FPSerial Serial1
DFRobot_ID809 fingerprint;
String desc;
//File myFile;
//#define QUARTER
#ifdef QUARTER
uint8_t data[6400]; //Quarter image
#else
uint8_t data[25600]; //Full image
#endif
int FP_x_offset = 46;
int FP_y_offset = 77;
int FP_x_width = 82;
int FP_y_height = 82;
bool fingerprint_captured = false;
bool FP_first_pass = true;
bool setup_FP()
{
int retest_loop = 0;
pinMode(FP_IRQ_PIN,INPUT);
/*Init FPSerial*/
FPSerial.begin(115200);
/*Take FPSerial as communication port of fingerprint module */
fingerprint.begin(FPSerial);
while((fingerprint.isConnected() == false) && (retest_loop < 5))
{
Serial.println("Communication with device failed, please check connection");
/*Get error code information */
desc = fingerprint.getErrorDescription();
Serial.println(desc);
delay(1000);
++ retest_loop;
}
if (retest_loop < 5)
return(true);
else
return(false);
}
void FP_Reset()
{
fingerprint_captured = false;
FP_first_pass = true;
}
void FP_Frame()
{
int box_top = FP_y_offset;
int box_bottom = box_top + FP_y_height;
int box_left = FP_x_offset;
int box_right = box_left + FP_x_width;
int box_width = FP_x_width;
int box_height = FP_y_height;
int p_x, p_y, p_i, p_data, p_temp;
if (FP_first_pass)
{
DrawScreenCompartment(box_left,box_top,box_width,box_height,COMMON_BLACK,COMMON_MAGENTA);
fingerprint.ctrlLED(/*LEDMode = */fingerprint.eBreathing, /*LEDColor = */fingerprint.eLEDRed, /*blinkCount = */0);
DrawScreenText(box_left+4, box_top+4,"Place Finger",COMMON_WHITE,COMMON_BLACK);
DrawScreenText(box_left+4, box_top+16,"on Scanner",COMMON_WHITE,COMMON_BLACK);
FP_first_pass = false;
}
if ((fingerprint.detectFinger()) && (!fingerprint_captured))
{
DrawScreenText(box_left+4, box_top+4,"Keep Finger ",COMMON_WHITE,COMMON_BLACK);
DrawScreenText(box_left+4, box_top+16,"on Scanner",COMMON_WHITE,COMMON_BLACK);
fingerprint.getFingerImage(data);
fingerprint.ctrlLED(/*LEDMode = */fingerprint.eKeepsOn, /*LEDColor = */fingerprint.eLEDGreen, /*blinkCount = */0);
for (p_x=0; p_x < 80; ++p_x)
for (p_y=0; p_y < 80; ++p_y)
{
p_temp = (p_x * 2);
p_temp = p_temp + (p_y * 160);
p_data = data[p_temp]/4; // image element
p_temp = p_temp + 1;
p_data = p_data + data[p_temp]/4; // image element to the right
p_temp = (p_x * 2);
p_temp = p_temp + ((p_y + 1) * 160);
p_data = p_data + data[p_temp]/4; // image element below
p_temp = (p_x + 1) * 2;
p_temp = p_temp + ((p_y + 1) * 160);
p_data = p_data + data[p_temp]/4; // image element to the right, one element down
p_data = p_data/4;
DrawScreenBlock(box_left + 1 + p_x, box_top + 1 + p_y, 1, 1, p_data<<5);
}
}
}
Pseudo-Medical_Monitor_Code#Custom_Includes