ws2812 - basic program?

my frist try to code this RGB LEDs… i use http://wiki.midibox.org/doku.php?id=elo

as hardware

i searched for examples or tutorials, but did not found it… i know there is a midibox ng code, but that is to complex for my mind, better start from the ground…

so i opened the docu: http://www.midibox.org/mios32/manual/group___w_s2812.html

but i think i miss something:

#include \<mios32.h\> #include "app.h" #include \<app\_lcd.h\> #include \<glcd\_font.h\> #include \<FreeRTOS.h\> #include \<portmacro.h\> #include \<task.h\> #include \<queue.h\> #include \<semphr.h\> #include "tasks.h" #include "file.h" #include \<string.h\> #include \<stdio.h\> #include \<math.h\> #include \<wchar.h\> #define PRIORITY\_APP\_Tick ( tskIDLE\_PRIORITY + 2 ) //2 lower then midi // WS2181 #define WS2812\_BUFFER\_SIZE ((18)\*24) #define WS2812\_SUPPORTED 1 void APP\_Init(void){ WS2812\_Init (); } void APP\_Background(void){ // led should be in the range 0..WS2812\_NUM\_LEDS-1 // colour 0=R, 1=G, 2=B // value 0..255 WS2812\_LED\_SetRGB (0,0,255); //1 WS2812\_LED\_SetRGB (1,0,255); //2 WS2812\_LED\_SetRGB (2,0,255); //3 WS2812\_LED\_SetRGB (3,0,255); //4 WS2812\_LED\_SetRGB (4,0,255); //5 WS2812\_LED\_SetRGB (5,0,255); //6 WS2812\_LED\_SetRGB (6,0,255); //7 WS2812\_LED\_SetRGB (7,0,255); //8 WS2812\_LED\_SetRGB (8,2,255); //9 WS2812\_LED\_SetRGB (9,2,255); //10 WS2812\_LED\_SetRGB (10,2,255); //11 WS2812\_LED\_SetRGB (11,2,255); //12 WS2812\_LED\_SetRGB (12,2,255); //13 WS2812\_LED\_SetRGB (13,2,255); //14 WS2812\_LED\_SetRGB (14,2,255); //15 WS2812\_LED\_SetRGB (15,2,255); //16 } void APP\_Tick(void){ } void APP\_MIDI\_NotifyPackage(mios32\_midi\_port\_t port, mios32\_midi\_package\_t midi\_package){} void APP\_SRIO\_ServicePrepare(void){ } void APP\_SRIO\_ServiceFinish(void){ } void APP\_DIN\_NotifyToggle(u32 pin, u32 pin\_value){ } void APP\_ENC\_NotifyChange(u32 encoder, s32 incrementer){ } void APP\_AIN\_NotifyChange(u32 pin, u32 pin\_value){ }

 

 

A compile (stm32F4 discovery) gives me:

make
rm -f project.hex
project_build/app.o: In function `APP_Init':
/home/inet-stick/c/elo-skeleton/app.c:49: undefined reference to `WS2812_Init'
project_build/app.o: In function `APP_Background':
/home/inet-stick/c/elo-skeleton/app.c:58: undefined reference to `WS2812_LED_SetRGB'
/home/inet-stick/c/elo-skeleton/app.c:59: undefined reference to `WS2812_LED_SetRGB'
/home/inet-stick/c/elo-skeleton/app.c:60: undefined reference to `WS2812_LED_SetRGB'
/home/inet-stick/c/elo-skeleton/app.c:61: undefined reference to `WS2812_LED_SetRGB'
/home/inet-stick/c/elo-skeleton/app.c:62: undefined reference to `WS2812_LED_SetRGB'
project_build/app.o:/home/inet-stick/c/elo-skeleton/app.c:63: more undefined references to `WS2812_LED_SetRGB' follow
collect2: error: ld returned 1 exit status
/home/inet-stick/midibox/mios32/include/makefile/common.mk:144: recipe for target 'project_build/project.elf' failed
make: *** [project_build/project.elf] Error 1
inet-stick@inetstick:~/c/elo-skeleton$

 

maybe there is a missing “include”?

Did you add the module in the makefile?
 

# WS2812 RGB LED strip driver include $(MIOS32\_PATH)/modules/ws2812/ws2812.mk

 

thx, that was the missing link!

now it compiles.