Giter Site home page Giter Site logo

Comments (2)

brianrho avatar brianrho commented on July 18, 2024 1

You're welcome :-) FYI, the enroll example shows how to use that method, to scan all the flash pages, not just the first page as you're presently doing:


bool get_free_id(int16_t * fid) {
    int16_t p = -1;
    for (int page = 0; page < (params.capacity / FPM_TEMPLATES_PER_PAGE) + 1; page++) {
        p = finger.getFreeIndex(page, fid);
        switch (p) {
            case FPM_OK:
                if (*fid != FPM_NOFREEINDEX) {
                    Serial.print("Free slot at ID ");
                    Serial.println(*fid);
                    return true;
                }
                break;
            case FPM_PACKETRECIEVEERR:
                Serial.println("Communication error!");
                return false;
            case FPM_TIMEOUT:
                Serial.println("Timeout!");
                return false;
            case FPM_READ_ERROR:
                Serial.println("Got wrong PID or length!");
                return false;
            default:
                Serial.println("Unknown error!");
                return false;
        }
        yield();
    }
    
    Serial.println("No free slots!");
    return false;
}

from fpm.

TehseenHasan avatar TehseenHasan commented on July 18, 2024

I am using this code in Wemos D1 Mini with R300 Fingerprint Sensor Module.
And this function getFreeIndex worked for me. It is a clean way to do this task. It saved a lot of my time.
Thanks.

#include <SoftwareSerial.h> // espSoftwareSerial Library V6.8.3
#include <FPM.h> 

//Fingerprint Sensor Initilizations
SoftwareSerial fingerprint(D6, D7); // RX, TX
FPM finger(&fingerprint);
FPM_System_Params params;

void setup()
{
  Serial.begin(9600);
  fingerprint.begin(57600);

  if (finger.begin())
  {
    finger.readParams(&params);
    Serial.println("Found fingerprint sensor!");
    Serial.print("Capacity: "); Serial.println(params.capacity);
    Serial.print("Packet length: "); Serial.println(FPM::packet_lengths[params.packet_len]);
    Serial.println();
  }
  else
  {
    Serial.println("Did not find fingerprint sensor!!! \n");
    while (1) yield();
  }

  get_free_index();

}

//Function to find the very first available index in the Fingerprint Sensor for new fingerprint enrollment
int16_t get_free_index()
{
  int16_t index = 0;
  uint8_t page = 0;
  int16_t x = finger.getFreeIndex(page, &index);

  Serial.print("Free index is: ");
  Serial.println(index);
  return index;
}

from fpm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.