/** * called upon plugin load * * You should: * - do any non-hardware initialization/checking here * - register plugin properties * - fill in "privdata" if you want to use a private pointer that's passed to * the plugin in subsequent calls. * * @param privdata space for a private pointer. * @param h LedHardware descriptor belonging to this plugin * @result NFT_SUCCESS or NFT_FAILURE upon error */ static NftResult _init(void **privdata, LedHardware * h) { NFT_LOG(L_DEBUG, "Initializing LDP8806 plugin..."); /* allocate private structure */ struct priv *p; if(!(p = calloc(1, sizeof(struct priv)))) { NFT_LOG_PERROR("calloc"); return NFT_FAILURE; } /* register our config-structure */ *privdata = p; /* save our hardware descriptor */ p->hw = h; /* defaults */ p->ledcount = 0; p->spiMode = SPI_MODE_0; p->spiBPW = 8; p->spiDelay = 0; p->spiSpeed = 500000; /* * register some dynamic properties for this plugin - those will be * set/read in the _get/set_handler() from this plugin */ if(!led_hardware_plugin_prop_register (h, "spi_speed", LED_HW_CUSTOM_PROP_INT)) return NFT_FAILURE; if(!led_hardware_plugin_prop_register (h, "spi_delay", LED_HW_CUSTOM_PROP_INT)) return NFT_FAILURE; return NFT_SUCCESS; }
/** * called upon plugin load * * You should: * - do any non-hardware initialization/checking here * - register plugin properties * - fill in "privdata" if you want to use a private pointer that's passed to * the plugin in subsequent calls. * * @param privdata space for a private pointer. * @param h LedHardware descriptor belonging to this plugin * @result NFT_SUCCESS or NFT_FAILURE upon error */ static NftResult _init(void **privdata, LedHardware * h) { NFT_LOG(L_DEBUG, "Initializing arduino-max72xx plugin..."); /* allocate private structure */ struct priv *p; if(!(p = calloc(1, sizeof(struct priv)))) { NFT_LOG_PERROR("calloc"); return NFT_FAILURE; } /* register our config-structure */ *privdata = p; /* save our hardware descriptor */ p->hw = h; /* defaults */ p->ledcount = 0; p->threshold = 128; /* * register some dynamic properties for this plugin - those will be * set/read in the _get/set_handler() from this plugin */ if(!led_hardware_plugin_prop_register (h, "threshold", LED_HW_CUSTOM_PROP_INT)) return NFT_FAILURE; if(!led_hardware_plugin_prop_register (h, "scan_limit", LED_HW_CUSTOM_PROP_INT)) return NFT_FAILURE; return NFT_SUCCESS; }