/* Conditions: 4 Exit points: 4 M = 4 - 4 + 2 = 2 Cyclomatic complexity 2 */ uint32_t fp_session_open(void) { uint32_t gt511Ret = 0; uint32_t id = 0; BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 3 / 2, (uint8_t*)"Authenticate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 5 / 2, (uint8_t*)"Existing user", CENTER_MODE); // Turn on the scanner backlight gt511Ret = GT511C1R_LED(>511, 1); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 7 / 2, (uint8_t*)"Identify", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 9 / 2, (uint8_t*)"Please place finger", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 11 / 2, (uint8_t*)"on reader", CENTER_MODE); // Wait for finger down fp_wait_finger(1, 50); do { // Send CaptureFinger gt511Ret = GT511C1R_CaptureFingerprint(>511, 1); } while (gt511Ret == GT511C1R_ErrorCode_NoFinger); // Send CaptureFinger //gt511Ret = GT511C1R_CaptureFingerprint(>511, 1); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } // Send Identify gt511Ret = GT511C1R_VerifyAny(>511); id = gt511Ret; // Turn off the scanner backlight gt511Ret = GT511C1R_LED(>511, 0); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } // id is error, display to user // Wait for finger up fp_wait_finger(0, 50); return id; }
/* Conditions: 7 Exit points: 1 M = 7 - 1 + 2 = 8 Cyclomatic complexity 8 */ uint32_t fp_session_start(void) { uint32_t id = 0; TickType_t lastWake = 0; uint32_t action = 0; TS_StateTypeDef ts; GUI_Button_t newID, existing; gui_button_init(&newID); newID.XPosition = 20; newID.YPosition = 100; newID.Height = 75; newID.Width = 200; newID.BorderWidth = 2; newID.BorderColor = LCD_COLOR_BLACK; newID.FillColor = LCD_COLOR_WHITE; newID.TextColor = LCD_COLOR_BLACK; newID.Text = (uint8_t*)"New user"; gui_button_init(&existing); existing.XPosition = 20; existing.YPosition = 200; existing.Height = 75; existing.Width = 200; existing.BorderWidth = 2; existing.BorderColor = LCD_COLOR_BLACK; existing.FillColor = LCD_COLOR_WHITE; existing.TextColor = LCD_COLOR_BLACK; existing.Text = (uint8_t*)"Existing user"; lastWake = xTaskGetTickCount(); BSP_LCD_Clear(LCD_COLOR_WHITE); /* Display buttons to user 1. New ID 2. Existing */ BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 3 / 2, (uint8_t*)"Authenticate", CENTER_MODE); gui_button_draw(&newID); gui_button_draw(&existing); // Wait for user selection while (1) { // If canceled, // Abort BSP_TS_GetState(&ts); if (gui_button_check_touch(&newID, &ts) == GUI_Button_Error_Yes) { action = 1; break; } else if (gui_button_check_touch(&existing, &ts) == GUI_Button_Error_Yes) { action = 2; break; } vTaskDelayUntil(&lastWake, 100); } //__asm__("bkpt #1"); switch (action) { // On New ID, case 1: // Call fp_session_new id = fp_session_new(); break; // On Existing, case 2: // Call fp_session_open id = fp_session_open(); break; default: id = fp_error_session_not_started; break; } if (id < 20) { Session_ActivityStamps[id] = fp_get_rtc_time(); } return id; }
/* Conditions: 6 Exit points: 5 M = 6 - 5 + 2 = 3 Cyclomatic complexity 3 */ uint32_t fp_session_new(void) { uint32_t id = 0; uint32_t gt511Ret = 0; BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 3 / 2, (uint8_t*)"Authenticate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 5 / 2, (uint8_t*)"New user", CENTER_MODE); id = fp_find_unused_id(); gt511Ret = fp_enroll_start(id); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 7 / 2, (uint8_t*)"Enrollment step 1", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 9 / 2, (uint8_t*)"Please place finger", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 11 / 2, (uint8_t*)"on reader", CENTER_MODE); gt511Ret = fp_enroll_step_1(); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 3 / 2, (uint8_t*)"Authenticate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 5 / 2, (uint8_t*)"New user", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 7 / 2, (uint8_t*)"Enrollment step 2", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 9 / 2, (uint8_t*)"Please place finger", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 11 / 2, (uint8_t*)"on reader", CENTER_MODE); do { gt511Ret = fp_enroll_step_2(); } while (gt511Ret == GT511C1R_ErrorCode_NoFinger); //gt511Ret = fp_enroll_step_2(); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 3 / 2, (uint8_t*)"Authenticate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 5 / 2, (uint8_t*)"New user", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 7 / 2, (uint8_t*)"Enrollment step 3", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 9 / 2, (uint8_t*)"Please place finger", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 11 / 2, (uint8_t*)"on reader", CENTER_MODE); do { gt511Ret = fp_enroll_step_3(); } while (gt511Ret == GT511C1R_ErrorCode_NoFinger); //gt511Ret = fp_enroll_step_3(); if (gt511Ret != 0) { __asm__("bkpt #0"); return gt511Ret; } BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 3 / 2, (uint8_t*)"Authenticate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 5 / 2, (uint8_t*)"New user", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetFont()->Height * 7 / 2, (uint8_t*)"Enrollment done", CENTER_MODE); return id; }
sFONT *LCD_DISCO_F469NI::GetFont(void) { return BSP_LCD_GetFont(); }