From: tamouse mailing lists Date: 2013-03-13T12:03:16+09:00 Subject: Re: Extending Ruby. Little help or guidance if you are willing! 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 >> > 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...