bigjosh / SimpleNeoPixelDemo

A demonstration showing how easy it can be to drive WS2812 NeoPixels
MIT License
223 stars 59 forks source link

compilation issue #1

Closed hotelzululima closed 9 years ago

hotelzululima commented 10 years ago

following error messages were elicited when I attempted to compile the demo program

Arduino: nightly (Mac OS X), Board: "Arduino Duemilanove or Diecimila, ATmega328"

sketch_may20b.ino: In function 'void sendBit(bool)': sketch_may20b:56: error: 'builtin_avr_delay_cycles' was not declared in this scope sketch_may20b:66: error: 'builtin_avr_delay_cycles' was not declared in this scope sketch_may20b.ino: In function 'void show()': sketch_may20b:126: error: '__builtin_avr_delay_cycles' was not declared in this scope

putting in the following at prior to line 42 fixes same:

ifndef __builtin_avr_delay_cycles

void __builtin_avr_delay_cycles(unsigned long n) { while(n) __n--; }

endif

hotelzululima commented 10 years ago

ps thanx for your research.. its made my use of neopixels a lot less problematic as I am looking for multicopter landing lights and this will work perfect with an old jeenode(duemanilove) v4 I have laying around(actually several).

  hzl
bigjosh commented 10 years ago

I do not think a simple for() loop will compile to exactly the right number of cycles, so you really want to use the built-in function. I wonder why you are not getting that function - it is part of the GCC compiler used by the Arduino IDE and it works on ever machine I have. Are you sure you are using the latest version of the IDE, currently 1.5.6-r2? Have you modified any of the GCC options in the install? Thanks!

hotelzululima commented 10 years ago

just tried a fresh 1.5.6-r2 and eliciting the same error message. hmm no includes in your example? I could use asm nops inline instead to define __builtin_avr_delay_cycles but I want to do this properly :) have not altered the GCC options to my knowledge..

bigjosh commented 10 years ago

No includes needed - Arduino IDE adds necessary includes at the top of every file automatically. The actual definition is in \arduino-1.5.6-r2\hardware\tools\avr\avr\include\avr\builtins.h. You could try adding "#include <\avr\builtins.h>" at top of file just to see if it works, but should not be needed. LMK.

You could manually add a whole bunch of asm("nop") s but you'd need to count carefully and you would loose the ability to easily change any of the #defined delays so not a great solution. If pressed, you could always just add a line to define the function like this...

extern void __builtin_avr_delay_cycles(unsigned long __n);

... but, again, I'd rather figure out why you are seeing this problem than cover it up.

Thanks, josh

hotelzululima commented 10 years ago

tried the include and NO relief???wtf fresh copy of ardiono.app used forward instead of reverse slashes(this is osx) but still having this issue hmm got fooled went from :+1: neopixel_driver_ino.ino: In function 'void sendBit(bool)': neopixel_driver_ino.ino:58: error: 'builtin_avr_delay_cycles' was not declared in this scope neopixel_driver_ino.ino:68: error: '__builtin_avr_delay_cycles' was not declared in this scope neopixel_driver_ino.ino: In function 'void show()': neopixel_driver_ino.ino:128: error: 'builtin_avr_delay_cycles' was not declared in this scope

TO: /var/folders/1y/9dx7kgy536dbp_v17n14rs3c0000gn/T/build5978779052290926128.tmp/neopixel_driver_ino.cpp.o: In function show()': /Applications/neopixel_driver_ino.ino:128: undefined reference tobuiltin_avr_delay_cycles' /var/folders/1y/9dx7kgy536dbp_v17n14rs3c0000gn/T/build5978779052290926128.tmp/neopixel_driver_ino.cpp.o: In function sendBit(bool)': /Applications/neopixel_driver_ino.ino:58: undefined reference tobuiltin_avr_delay_cycles' /Applications/neopixel_driver_ino.ino:68: undefined reference to __builtin_avr_delay_cycles' /Applications/neopixel_driver_ino.ino:74: undefined reference to__builtin_avr_delay_cycles'

once: extern void __builtin_avr_delay_cycles(unsigned long __n); defined...(from builtins.h definition for same)

bigjosh commented 10 years ago

Hmm... Somehow Arduino on IDE might be using a different GNU compiler version? I will try to find a mac to test on. Thanks.

hotelzululima commented 10 years ago

the neopixel lib from adafruit does compile up correctly so using that for now...as only 144 leds involved well within 168 range for the app

bigjosh commented 9 years ago

I just updated the code so it now compiles and works correctly under OSX with the Arduino 1.6.1 IDE. I should also work with any past or future version since I am no longer using the problematic _delay_cycles() function.