domdfcoding / circuitpython-mfrc522 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from wendlers/micropython-mfrc522
(Micro)Python class to access the MFRC522 RFID reader
License: MIT License
This project forked from wendlers/micropython-mfrc522
(Micro)Python class to access the MFRC522 RFID reader
License: MIT License
I am trying to convert this library to work on an WS12850S that allegedly has the exact same software interface as the MFRC522 but using an I2C interface rather than SPI.
To do this, I replaced two functions:
def _wreg(self, reg: int, val):
data = bytearray([val])
self.i2c.try_lock()
self.i2c.writeto_then_readfrom(self.i2c_address, bytes([reg]), data)
self.i2c.unlock()
return data[0]
def _rreg(self, reg: int):
data = bytearray(1)
self.i2c.try_lock()
self.i2c.writeto_then_readfrom(self.i2c_address, bytes([reg]), data)
self.i2c.unlock()
return data[0]
Looks reasonable so far, for writing single bytes. I'm not sure the readback from _wreg is meaningful.
This kind of works, but I'm a little concerned about this:
def _tocard(self, cmd: int, send):
...
for c in send:
self._wreg(0x09, c)
I think the intent there is to write a string of bytes (send) but in I2C I think I would want to do that as a single transaction, similar to what I did with my _wreg but taking an array of values rather than just a single byte. Does this make sense? Do you agree, and do you see other things that would need modification?
Finally ... if this works, is it worth abstracting out the physical interface so that we can re-use your code but select the interface (SPI or I2C) like:
rdr = MFRC522( spiInterface )
rdr = MFRC522( i2cInterface )
and both those interfaces include _wreg, _rreg, and possibly _tocard (and maybe more?)
How can I fix this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.