diff --git a/colorchord2/DisplaySHM.c b/colorchord2/DisplaySHM.c new file mode 100644 index 0000000..554759d --- /dev/null +++ b/colorchord2/DisplaySHM.c @@ -0,0 +1,77 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + +#include "outdrivers.h" +#include "notefinder.h" +#include +#include "parameters.h" +#include +#include +#include +#include "color.h" +#include "DrawFunctions.h" +#include +#include /* For mode constants */ +#include /* For O_* constants */ +#include + +struct SHMDriver +{ + int lights_file; + //int dft_file; //Not available. + //uint8_t * dft_ptr; + uint8_t * lights_ptr; + //int total_dft; + int total_leds; +}; + + +static void SHMUpdate(void * id, struct NoteFinder*nf) +{ + struct SHMDriver * d = (struct SHMDriver*)id; + + + if( !d->lights_file ) + { + const char * shm_lights = GetParameterS( "shm_lights", 0 ); + //const char * shm_dft = GetParameterS( "shm_dft", 0 ); // Not available. + + if( shm_lights ) + { + d->lights_file = shm_open(shm_lights, O_CREAT | O_RDWR, 0644); + ftruncate( d->lights_file, 16384 ); + d->lights_ptr = mmap(0,16384, PROT_READ | PROT_WRITE, MAP_SHARED, d->lights_file, 0); + } + + printf( "Got SHM: %s->%d [%p]\n", shm_lights, d->lights_file, d->lights_ptr ); + } + + + if( d->lights_ptr ) + { + memcpy( d->lights_ptr, &d->total_leds, 4 ); + memcpy( d->lights_ptr + 4, OutLEDs, d->total_leds*3 ); + } + +} + +static void SHMParams(void * id ) +{ + struct SHMDriver * d = (struct SHMDriver*)id; + + d->total_leds = 300; RegisterValue( "leds", PAINT, &d->total_leds, sizeof( d->total_leds )); +} + +static struct DriverInstances * DisplaySHM(const char * parameters) +{ + struct DriverInstances * ret = malloc( sizeof( struct DriverInstances ) ); + struct SHMDriver * d = ret->id = malloc( sizeof( struct SHMDriver ) ); + memset( d, 0, sizeof( struct SHMDriver ) ); + ret->Func = SHMUpdate; + ret->Params = SHMParams; + SHMParams( d ); + return ret; +} + +REGISTER_OUT_DRIVER(DisplaySHM); + + diff --git a/colorchord2/Makefile b/colorchord2/Makefile index 5a7c35b..97b2fcf 100644 --- a/colorchord2/Makefile +++ b/colorchord2/Makefile @@ -3,14 +3,14 @@ all : colorchord RAWDRAW:=DrawFunctions.o XDriver.o SOUND:=sound.o sound_alsa.o sound_pulse.o sound_null.o -OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o +OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o DisplaySHM.o WINGCC:= i686-w64-mingw32-gcc WINGCCFLAGS:= -g -DICACHE_FLASH_ATTR= -I../embeddedcommon -I. -O1 #-O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext -LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev +LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev -lrt CFLAGS:=-g -Os -flto -Wall -ffast-math -I../embeddedcommon -I. -DICACHE_FLASH_ATTR=