mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-27 08:18:28 +02:00
0059a6de46
* 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
22 lines
667 B
Python
22 lines
667 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import spi, pn532
|
|
from esphome.const import CONF_ID
|
|
|
|
AUTO_LOAD = ['pn532']
|
|
CODEOWNERS = ['@OttoWinter', '@jesserockz']
|
|
DEPENDENCIES = ['spi']
|
|
|
|
pn532_spi_ns = cg.esphome_ns.namespace('pn532_spi')
|
|
PN532Spi = pn532_spi_ns.class_('PN532Spi', pn532.PN532, spi.SPIDevice)
|
|
|
|
CONFIG_SCHEMA = cv.All(pn532.PN532_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(PN532Spi),
|
|
}).extend(spi.spi_device_schema(cs_pin_required=True)))
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
yield pn532.setup_pn532(var, config)
|
|
yield spi.register_spi_device(var, config)
|