Making pio.* accept a table of pins as well as a list

classic Classic list List threaded Threaded
8 messages Options
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Making pio.* accept a table of pins as well as a list

One of our users thought they might be able to say:

> local columns = { c1, c2, c3, c4, c5, c6, c7, c8 }
>     pio.pin.setlow( columns )

and I had to tell them to use

> local columns = { c1, c2, c3, c4, c5, c6, c7, c8 }
>     pio.pin.sethigh(unpack(columns))

I've tried coding this change, and it added another 100 bytes of object code.
Fortunately, eLua's pio code is structured is such that it only has to
be done in one place and automatically applies
to all the pio.pin.set* functions.
Is this worth applying to make their Lua coding simpler, or should
they just use unpack() to keep our code simpler?

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

Hi,

On Mon, Oct 10, 2011 at 5:01 PM, Martin Guy <[hidden email]> wrote:
One of our users thought they might be able to say:

> local columns = { c1, c2, c3, c4, c5, c6, c7, c8 }
>     pio.pin.setlow( columns )

and I had to tell them to use

> local columns = { c1, c2, c3, c4, c5, c6, c7, c8 }
>     pio.pin.sethigh(unpack(columns))

I've tried coding this change, and it added another 100 bytes of object code.
Fortunately, eLua's pio code is structured is such that it only has to
be done in one place and automatically applies
to all the pio.pin.set* functions.
Is this worth applying to make their Lua coding simpler, or should
they just use unpack() to keep our code simpler?

I'd leave it as it is now. It forces people to learn a bit more Lua and I think this is generally a good thing :)

Best,
Bogdan


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

On 10 October 2011 16:05, Bogdan Marinescu <[hidden email]> wrote:
> I'd leave it as it is now. It forces people to learn a bit more Lua and I
> think this is generally a good thing :)

Ok. And you know how I feel about keeping the code size small...

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
jbsnyder jbsnyder
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

I've added a Recipes page where we can put examples like this in the
future.  There are plenty of other things that could be added there,
and I'll try to remember to put them in when I run across them:
http://wiki.eluaproject.net/Recipes

On Mon, Oct 10, 2011 at 9:09 AM, Martin Guy <[hidden email]> wrote:

> On 10 October 2011 16:05, Bogdan Marinescu <[hidden email]> wrote:
>> I'd leave it as it is now. It forces people to learn a bit more Lua and I
>> think this is generally a good thing :)
>
> Ok. And you know how I feel about keeping the code size small...
>
>    M
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
>
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
sweetlilmre sweetlilmre
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

Could I suggest that the code change for the 'auto-unpack' be kept somewhere as a reference as well?

I would certainly be interested in looking at it and it might be useful in future.

On Oct 10, 2011 5:56 PM, "James Snyder" <[hidden email]> wrote:
I've added a Recipes page where we can put examples like this in the
future.  There are plenty of other things that could be added there,
and I'll try to remember to put them in when I run across them:
http://wiki.eluaproject.net/Recipes

On Mon, Oct 10, 2011 at 9:09 AM, Martin Guy <[hidden email]> wrote:
> On 10 October 2011 16:05, Bogdan Marinescu <[hidden email]> wrote:
>> I'd leave it as it is now. It forces people to learn a bit more Lua and I
>> think this is generally a good thing :)
>
> Ok. And you know how I feel about keeping the code size small...
>
>    M
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
>
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
jbsnyder jbsnyder
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

On Mon, Oct 10, 2011 at 3:29 PM, Peter Edwards <[hidden email]> wrote:
> Could I suggest that the code change for the 'auto-unpack' be kept somewhere
> as a reference as well?

If you want, you could take a look at the ADC code (src/modules/adc.c)
and look at the adc_sample function, you'll find an example of how to
unpack a table.

-jsnyder

>
> I would certainly be interested in looking at it and it might be useful in
> future.
>
> On Oct 10, 2011 5:56 PM, "James Snyder" <[hidden email]> wrote:
>>
>> I've added a Recipes page where we can put examples like this in the
>> future.  There are plenty of other things that could be added there,
>> and I'll try to remember to put them in when I run across them:
>> http://wiki.eluaproject.net/Recipes
>>
>> On Mon, Oct 10, 2011 at 9:09 AM, Martin Guy <[hidden email]> wrote:
>> > On 10 October 2011 16:05, Bogdan Marinescu <[hidden email]>
>> > wrote:
>> >> I'd leave it as it is now. It forces people to learn a bit more Lua and
>> >> I
>> >> think this is generally a good thing :)
>> >
>> > Ok. And you know how I feel about keeping the code size small...
>> >
>> >    M
>> > _______________________________________________
>> > eLua-dev mailing list
>> > [hidden email]
>> > https://lists.berlios.de/mailman/listinfo/elua-dev
>> >
>> _______________________________________________
>> eLua-dev mailing list
>> [hidden email]
>> https://lists.berlios.de/mailman/listinfo/elua-dev
>
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
>
>
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

In reply to this post by sweetlilmre
On 10 October 2011 22:29, Peter Edwards <[hidden email]> wrote:
> Could I suggest that the code change for the 'auto-unpack' be kept somewhere
> as a reference as well?

Erm, I deleted it when I saw that it was unneeded complexity as far as
eLua's objectives are concerned. I can probably redo it without much
trouble and post it as a patch

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: Making pio.* accept a table of pins as well as a list

In reply to this post by jbsnyder
> If you want, you could take a look at the ADC code (src/modules/adc.c)
> and look at the adc_sample function, you'll find an example of how to
> unpack a table.

That's the example I copied it from :) tho' functionally I think it's
better with a switch statement on the object type - that way on bad
values it reports "expected number, table or string" instead of
"expected string".  But 20 extra bytes are 20 extra bytes... :)

   M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev