From: Cliff Rosson Date: 2013-03-13T12:49:35+09:00 Subject: Re: Extending Ruby. Little help or guidance if you are willing! --20cf300fb05f47fc7c04d7c64bca Content-Type: text/plain; charset=ISO-8859-1 Josh you added quite a bit of good information. I don't know about your device, but is there actually value to writing low > at all? Could that cause it to flicker? Maybe I just need to revisit this. Having to extend in C slowed me down quite a bit. If possible I just like to stay in ruby since I am comfortable there. After all I am not developing guru! :) On Tue, Mar 12, 2013 at 8:03 PM, tamouse mailing lists < tamouse.lists@gmail.com> wrote: > On Tue, Mar 12, 2013 at 4:35 PM, Josh Cheek wrote: > > On Tue, Mar 12, 2013 at 4:05 PM, tamouse mailing lists > > wrote: > >> > >> On Tue, Mar 12, 2013 at 12:28 AM, Josh Cheek > wrote: > >> > 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 < > cliff.rosson@gmail.com> > >> > 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 > >> > > >> > > >> > >> Why case (plus num.to_s) instead of just an array? > >> > > > > Oh, I was playing with the idea > https://gist.github.com/JoshCheek/5144076 > > and at one point had started to implement characters, too, so this just > > allowed me to use digits or character representations of digits. But > then I > > realized characters like "B" look like "8", and didn't feel like adding > more > > pins to make it all work, so I took it back out. > > > > -Josh > > Ah, no worries, just wondering... > > -- vizualize.me/cliffrosson --20cf300fb05f47fc7c04d7c64bca Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Josh you added quite a bit of good information.=A0
I don't kno= w about your device, but is there actually value to writing low at all? Cou= ld that cause it to flicker?

Maybe I just need to revisit this. Having to extend in C slowed me down qui= te a bit. If possible I just like to stay in ruby since I am comfortable th= ere. After all I am not developing guru! :)


On Tue, Mar 12, 2013 at 8:03 PM, tamouse= mailing lists <tamouse.lists@gmail.com> wrote:
On Tue, Mar 12, 2013 at 4:35 PM, Jo= sh Cheek <josh.cheek@gmail.com> wrote:
> On Tue, Mar 12, 2013 at 4:05 PM, tamouse mailing lists
> <
tamouse.lists@gmail.com= > wrote:
>>
>> On Tue, Mar 12, 2013 at 12:28 AM, Josh Cheek <josh.cheek@gmail.com> wrote:
>> > Rereading this, I suspect that you might have mis-analyzed th= e issue. I
>> > don't know how the profiler works, but if it's just l= ooking 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
>> >
>> > =A0 io.write(power, HIGH)
>> > =A0 sleep delay
>> > =A0 io.write(power, LOW)
>> >
>> > I don't know about your device, but is there actually val= ue to writing
>> > low
>> > at all? Could that cause it to flicker?
>> >
>> >
>> > On Mon, Mar 11, 2013 at 10:44 AM, Cliff Rosson <cliff.rosson@gmail.com>
>> > wrote:
>> >>
>> >> Got ya. So it doesn't really matter if I convert thin= gs 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), o= r 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 eac= h 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' then 0b1011011
>> > =A0 =A0 when '6' then 0b1011111
>> > =A0 =A0 when '7' then 0b1110000
>> > =A0 =A0 when '8' then 0b1111111
>> > =A0 =A0 when '9' then 0b1110011
>> > =A0 =A0 end
>> >
>> >
>>
>> Why case (plus num.to_s) instead of just an array?
>>
>
> Oh, I was playing with the idea https://gist.github.com/JoshCheek/5144076=
> and at one point had started to implement characters, too, so this jus= t
> allowed me to use digits or character representations of digits. But t= hen I
> realized characters like "B" look like "8", and di= dn't feel like adding more
> pins to make it all work, so I took it back out.
>
> -Josh

Ah, no worries, just wondering...




--
--20cf300fb05f47fc7c04d7c64bca--