Re: Ruby method parameters troubles

3 views
Skip to first unread message

Sophie

unread,
Dec 5, 2009, 6:27:35 PM12/5/09
to ruby-arduino...@googlegroups.com
OK, I added a dummy integer addition, and the type hint seemed to work.

def short_long(pin, ms)
1 + pin
blink pin, ms
blink pin, 2*ms
end


On Dec 5, 2009, at 5:03 PM, Sophie wrote:

> I tried this:
>
> class Hello2 < ArduinoSketch
>
> output_pin 13, :as => :led
>
> def short_long(pin, ms)
> blink pin, ms
> blink pin, 2 * ms
> end
>
> def loop
> short_long (led, 30)
> end
>
> end
>
> And I get
> hello2.cpp:122: error: initializing argument 1 of 'void
> short_long(void*, long int)'
> make: *** [hello2.elf] Error 1
>
> Somewhere Rad or ruby2C it is defaulting to void* parameter types.
> Can I tell it otherwise?
>
> How do I factor my Ruby methods using parameters?
>
> Thanks!

Sophie

unread,
Dec 5, 2009, 6:03:26 PM12/5/09
to ruby-arduino...@googlegroups.com

Ron Evans

unread,
Dec 6, 2009, 9:53:31 AM12/6/09
to ruby-arduino...@googlegroups.com
This is a more typical RAD way to accomplish this:

class Blinktest < ArduinoSketch

output_pin 13, :as => :led

def fancy_blink(ms)
led.blink ms
led.blink 2 * ms
end

def loop
fancy_blink 30
end
end
> --
>
> You received this message because you are subscribed to the Google Groups "Ruby Arduino Development" group.
> To post to this group, send email to ruby-arduino...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-arduino-devel...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ruby-arduino-development?hl=en.
>
>
>



--
Ron Evans
310-597-1013
ron....@gmail.com

Sophie

unread,
Dec 11, 2009, 8:40:42 AM12/11/09
to ruby-arduino...@googlegroups.com
Sure, but I had 5 pins I wanted to fancy_blink :-)

Thanks
Reply all
Reply to author
Forward
0 new messages