Pseudo-Medical Monitor Code FingerPrint STUFF
Jump to navigation
Jump to search
#define FingerPrint_IRQ_PIN 3 #define FingerPrint_TX_PIN 19 #define FingerPrint_RX_PIN 18 #define FingerPrintSerial 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 FingerPrint_x_offset = 46; int FingerPrint_y_offset = 77; int FingerPrint_x_width = 82; int FingerPrint_y_height = 82; bool fingerprint_captured = false; bool FingerPrint_first_pass = true; bool setup_FingerPrint() { int retest_loop = 0; pinMode(FingerPrint_IRQ_PIN,INPUT); /*Init FingerPrintSerial*/ FingerPrintSerial.begin(115200); /*Take FingerPrintSerial as communication port of fingerprint module */ fingerprint.begin(FingerPrintSerial); 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 FingerPrint_Reset() { fingerprint_captured = false; FingerPrint_first_pass = true; } void FingerPrint_Frame() { int box_top = FingerPrint_y_offset; int box_bottom = box_top + FingerPrint_y_height; int box_left = FingerPrint_x_offset; int box_right = box_left + FingerPrint_x_width; int box_width = FingerPrint_x_width; int box_height = FingerPrint_y_height; int p_x, p_y, p_i, p_data, p_temp; if (FingerPrint_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); FingerPrint_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); } } }