From: Josh Cheek Date: 2013-03-12T14:28:49+09:00 Subject: Re: Extending Ruby. Little help or guidance if you are willing! --f46d042c64b930fb6704d7b390bd Content-Type: text/plain; charset=ISO-8859-1 Rereading this, I suspect that you might have mis-analyzed the issue. I don't know how the profiler works, but if it's just looking at total time, then it should see you spend a lot in this method, because it has both IO, and a sleep statement inside of it. The 10-20% could just be what it takes to run the Ruby runtime. The flickering could be due to io.write(power, HIGH) sleep delay io.write(power, LOW) I don't know about your device, but is there actually value to writing low at all? Could that cause it to flicker? On Mon, Mar 11, 2013 at 10:44 AM, Cliff Rosson wrote: > Got ya. So it doesn't really matter if I convert things to ID and compare > on that basis or keep things a symbol. Thanks Bartosz. > > That's true if you mean to just swap them straight over, to avoid creating lots of throw-away arrays and iterating over them. There isn't enough code here to know what you can do (e.g. do you have control over the representation shown by display.segments), or to play with it (or, for me, to even really understand how the pieces fit together) but if your low-level lib takes something like a number where each digit or each bit represents the value of a pin in that position, then you could just deal with ints like this: case num.to_s when '0' then 0b1111110 when '1' then 0b0110000 when '2' then 0b1101101 when '3' then 0b1111001 when '4' then 0b0110011 when '5' then 0b1011011 when '6' then 0b1011111 when '7' then 0b1110000 when '8' then 0b1111111 when '9' then 0b1110011 end --f46d042c64b930fb6704d7b390bd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Rereading this, I suspect that y= ou might have mis-analyzed the issue. I don't know how the profiler wor= ks, but if it's just looking at total time, then it should see you spen= d a lot in this method, because it has both IO, and a sleep statement insid= e of it.=A0The= 10-20% could just be what it takes to run the Ruby runtime.=A0The f= lickering could be due to

=A0 io.write(power, HIGH)
=A0 slee= p delay
=A0 = io.write(power, LOW)
I don't know about y= our device, but is there actually value to writing low at all? Could that c= ause it to flicker?


On Mon, Mar 1= 1, 2013 at 10:44 AM, Cliff Rosson <cliff.rosson@gmail.com> wrote:
= Got ya. So it doesn't really matter if I convert things to ID and compa= re on that basis or keep things a symbol. Thanks Bartosz.


That's true if you mean to just swap them= straight over, to avoid creating lots of throw-away arrays and iterating o= ver them.

There isn't enough code here to know what you can d= o (e.g. do you have control over the representation shown by display.segmen= ts), or to play with it (or, for me, to even really understand how the piec= es fit together) but if your low-level lib takes something like a number wh= ere each digit or each bit represents the value of a pin in that position, = then you could just deal with ints like this:

=A0 =A0 case num.to_s
=A0 =A0 when '= 0' then 0b1111110
=A0 =A0 when '1' then 0b0110000
=A0 =A0 when '2' then 0b1101101
=A0 =A0 when '= 3' then 0b1111001
=A0 =A0 when '4' then 0b0110011
=A0 =A0 when '5&= #39; then 0b1011011
=A0 =A0 when '6' then 0b1011111
=
=A0 =A0 when '7' then 0b1110000
=A0 =A0 when '8&= #39; then 0b1111111
=A0 =A0 when '9' then 0b1110011
=A0 =A0 end


--f46d042c64b930fb6704d7b390bd--