Can't reuse device drivers

28 views
Skip to first unread message

Scott Erholm

unread,
Feb 10, 2017, 12:40:49 PM2/10/17
to zetta-discuss
Maybe I'm missing something, or maybe I'm trying to stretch zetta beyond its capabilities...

I'd like to hook up several devices of the same type to the hub, and all would therefore use the same driver.  However, since each hardware device would have its own electrical pins and such parameters, the drivers need to be initialized with their own options.  This is where I'm running into problems.

Let's say I have three LEDs hooked up.  It would be nice to do something like this:

const zetta = require('zetta');
const led   = require('zetta-led-scout');

zetta()
   .use(led, {"name":"LED1", "pin":"32"})
   .use(led, {"name":"LED2", "pin":"57"})
   .use(led, {"name":"LED3", "pin":"14"})
   .listen(1137);


Once the scout's init function is called, the options have been overwritten on the first two instantiations, so every LED is named 'LED3' and uses pin 14.

What is the best way to instantiate multiple devices of the same kind with different parameters in zetta?

Thanks,
Scott

Matthew Dobson

unread,
Feb 10, 2017, 12:45:41 PM2/10/17
to Scott Erholm, zetta-discuss
Would you be able to .use() just the LED driver? That would accomplish what you're looking to do.

--
Matthew Dobson | apigee m: +1.734.634.5472 | twitter @mdobs @apigee | Apigee Community for answers, ideas and support!

--
You received this message because you are subscribed to the Google Groups "zetta-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zetta-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to zetta-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zetta-discuss/91a876d2-2b2e-4577-ae06-1a6bb4bb1df0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott Erholm

unread,
Feb 10, 2017, 2:07:30 PM2/10/17
to zetta-discuss, sc...@agilatech.com
Yes, that would work, but I'm wanting to go through the scout.

While your answer wasn't exactly what I wanted, it did get me to try some completely different methods.  Creating a new device in the scout's constructor function is working as desired.
Sorry to post a kinda dumb question, but thanks for the quick response.


On Friday, February 10, 2017 at 10:45:41 AM UTC-7, Matthew Dobson wrote:
Would you be able to .use() just the LED driver? That would accomplish what you're looking to do.

--
Matthew Dobson | apigee m: +1.734.634.5472 | twitter @mdobs @apigee | Apigee Community for answers, ideas and support!

On Fri, Feb 10, 2017 at 12:40 PM, Scott Erholm <sc...@agilatech.com> wrote:
Maybe I'm missing something, or maybe I'm trying to stretch zetta beyond its capabilities...

I'd like to hook up several devices of the same type to the hub, and all would therefore use the same driver.  However, since each hardware device would have its own electrical pins and such parameters, the drivers need to be initialized with their own options.  This is where I'm running into problems.

Let's say I have three LEDs hooked up.  It would be nice to do something like this:

const zetta = require('zetta');
const led   = require('zetta-led-scout');

zetta()
   .use(led, {"name":"LED1", "pin":"32"})
   .use(led, {"name":"LED2", "pin":"57"})
   .use(led, {"name":"LED3", "pin":"14"})
   .listen(1137);


Once the scout's init function is called, the options have been overwritten on the first two instantiations, so every LED is named 'LED3' and uses pin 14.

What is the best way to instantiate multiple devices of the same kind with different parameters in zetta?

Thanks,
Scott

--
You received this message because you are subscribed to the Google Groups "zetta-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zetta-discus...@googlegroups.com.

Matthew Dobson

unread,
Feb 10, 2017, 2:18:32 PM2/10/17
to Scott Erholm, zetta-discuss
Not dumb at all. Thanks for posting!

-Matt

--
Matthew Dobson | apigee m: +1.734.634.5472 | twitter @mdobs @apigee | Apigee Community for answers, ideas and support!

To unsubscribe from this group and stop receiving emails from it, send an email to zetta-discuss+unsubscribe@googlegroups.com.

To post to this group, send email to zetta-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages