1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-26 04:28:17 +00:00
Jesse Hills 0059a6de46
Pn532 upgrades (#1302)
* Move pn532 -> pn532_spi
Add pn532_i2c

* Update i2c address

* Always wait for ready byte before reading

* Generalise the pn532 a bit more so less code in i2c and spi implementations

* clang

* Add pn532_i2c to test1

* Try to get setup working

* Fixes

* More updates

* Command consts

* A few upgrades

* Change text back to include 'new'

* Fix data reading
2020-10-31 19:55:48 -03:00

22 lines
651 B
Python

import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c, pn532
from esphome.const import CONF_ID
AUTO_LOAD = ['pn532']
CODEOWNERS = ['@OttoWinter', '@jesserockz']
DEPENDENCIES = ['i2c']
pn532_i2c_ns = cg.esphome_ns.namespace('pn532_i2c')
PN532I2C = pn532_i2c_ns.class_('PN532I2C', pn532.PN532, i2c.I2CDevice)
CONFIG_SCHEMA = cv.All(pn532.PN532_SCHEMA.extend({
cv.GenerateID(): cv.declare_id(PN532I2C),
}).extend(i2c.i2c_device_schema(0x24)))
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield pn532.setup_pn532(var, config)
yield i2c.register_i2c_device(var, config)