Bump versions - add file writer for USB keyboard
This commit is contained in:
parent
07d64d32c4
commit
7910c7e029
115
colorchord2/DisplayFileWrite.c
Normal file
115
colorchord2/DisplayFileWrite.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
|
||||
|
||||
#include "outdrivers.h"
|
||||
#include "notefinder.h"
|
||||
#include <stdio.h>
|
||||
#include "parameters.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "color.h"
|
||||
#include "DrawFunctions.h"
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h> /* For mode constants */
|
||||
#include <fcntl.h> /* For O_* constants */
|
||||
#include <unistd.h>
|
||||
|
||||
extern struct NoteFinder * nf;
|
||||
|
||||
#ifndef O_DIRECT
|
||||
#define O_DIRECT 00040000
|
||||
#endif
|
||||
|
||||
struct FileWriteDriver
|
||||
{
|
||||
int lights_file;
|
||||
int total_leds;
|
||||
int inflate_to_u32;
|
||||
int asynchronous;
|
||||
uint32_t pass_buffer[MAX_LEDS];
|
||||
og_thread_t rt_thread;
|
||||
};
|
||||
|
||||
static void * LightsWrite( void * v )
|
||||
{
|
||||
struct FileWriteDriver * d = (struct FileWriteDriver *)v;
|
||||
while(1)
|
||||
{
|
||||
|
||||
|
||||
if( d->lights_file > 0 )
|
||||
{
|
||||
int btos = ((d->inflate_to_u32)?4:3)*d->total_leds;
|
||||
int r = write( d->lights_file, d->pass_buffer, btos );
|
||||
if( r != btos ) goto fail_write;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char * lightsfile = GetParameterS( "lightsfile", 0 );
|
||||
if( lightsfile )
|
||||
{
|
||||
d->lights_file = open( lightsfile, O_WRONLY );
|
||||
if( d->lights_file <= 0 )
|
||||
{
|
||||
fprintf( stderr, "Error: Can't open \"%s\" (%d)\n", lightsfile, d->lights_file );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "File %s opened OK\n", lightsfile );
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
fail_write:
|
||||
fprintf( stderr, "File writing fault\n" );
|
||||
close( d->lights_file );
|
||||
d->lights_file = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void FileWriteUpdate(void * id, struct NoteFinder*nf)
|
||||
{
|
||||
struct FileWriteDriver * d = (struct FileWriteDriver*)id;
|
||||
|
||||
|
||||
if( !d->inflate_to_u32 )
|
||||
{
|
||||
memcpy( d->pass_buffer, OutLEDs, d->total_leds*3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < d->total_leds; i++ )
|
||||
{
|
||||
uint8_t * ol = &OutLEDs[i*3];
|
||||
d->pass_buffer[i] = ol[0] | (ol[1]<<8) | (ol[2]<<16) | 0xff000000;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void FileWriteParams(void * id )
|
||||
{
|
||||
struct FileWriteDriver * d = (struct FileWriteDriver*)id;
|
||||
|
||||
d->total_leds = 300; RegisterValue( "leds", PAINT, &d->total_leds, sizeof( d->total_leds ));
|
||||
d->inflate_to_u32 = 1; RegisterValue( "inflate_to_u32", PAINT, &d->inflate_to_u32, sizeof( d->inflate_to_u32 ));
|
||||
d->asynchronous = 1; RegisterValue( "file_async", PAINT, &d->asynchronous, sizeof( d->asynchronous ));
|
||||
}
|
||||
|
||||
static struct DriverInstances * DisplayFileWrite(const char * parameters)
|
||||
{
|
||||
struct DriverInstances * ret = malloc( sizeof( struct DriverInstances ) );
|
||||
struct FileWriteDriver * d = ret->id = malloc( sizeof( struct FileWriteDriver ) );
|
||||
memset( d, 0, sizeof( struct FileWriteDriver ) );
|
||||
ret->Func = FileWriteUpdate;
|
||||
ret->Params = FileWriteParams;
|
||||
FileWriteParams( d );
|
||||
printf( "Loaded DisplayFileWrite\n" );
|
||||
d->rt_thread = OGCreateThread( LightsWrite, d );
|
||||
return ret;
|
||||
}
|
||||
|
||||
REGISTER_OUT_DRIVER(DisplayFileWrite);
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ 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 DisplaySHM.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 DisplayFileWrite.o
|
||||
|
||||
WINGCC:= i686-w64-mingw32-gcc
|
||||
|
||||
|
|
59
colorchord2/keyboard_rgb_test.conf
Normal file
59
colorchord2/keyboard_rgb_test.conf
Normal file
|
@ -0,0 +1,59 @@
|
|||
# This is the keyboard test for Clevo and PowerSpec 1510 and 1710 laptops, using the kernel module found here:
|
||||
# https://github.com/cnlohr/clevo_xsm_wmi
|
||||
|
||||
cpu_autolimit = 1
|
||||
headless=0
|
||||
|
||||
#General GUI properties.
|
||||
title = PA Test
|
||||
set_screenx = 720
|
||||
set_screeny = 480
|
||||
in_amplitude = 1.0
|
||||
|
||||
sample_channel = -1
|
||||
sourcename = alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
|
||||
#bluez_sink.40_EF_4C_CA_A4_5D.monitor
|
||||
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
|
||||
## alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||
# alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2.monitor (On desktop)
|
||||
|
||||
|
||||
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
|
||||
#default
|
||||
# alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor << New laptop
|
||||
#use pactl list | grep pci- | grep monitor
|
||||
|
||||
|
||||
#How many bins a note can jump from frame to frame to be considered a slide.
|
||||
#this is used to prevent notes from popping in and out a lot.
|
||||
note_combine_distance = 0.5000
|
||||
note_jumpability = 1.8000
|
||||
note_minimum_new_distribution_value = 0.0200
|
||||
note_out_chop = 0.05000
|
||||
|
||||
#compress_coefficient = 4.0
|
||||
#compress_exponent = .5
|
||||
|
||||
|
||||
#=======================================================================
|
||||
#Outputs
|
||||
|
||||
|
||||
#DisplayArray
|
||||
outdrivers = OutputCells, DisplayFileWrite, DisplayArray
|
||||
|
||||
lightsfile = /sys/devices/platform/clevo_xsm_wmi/kb_rgb
|
||||
inflate_to_u32 = 1
|
||||
lightx = 1
|
||||
lighty = 3
|
||||
fromsides = 1
|
||||
leds = 3
|
||||
qtyamp = 20
|
||||
|
||||
satamp = 4.800
|
||||
amppow = 2.510
|
||||
distpow = 1.500
|
||||
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PAINT );
|
|||
float cpu_autolimit_interval = 0.016; REGISTER_PARAM( cpu_autolimit_interval, PAFLOAT );
|
||||
int sample_channel = -1;REGISTER_PARAM( sample_channel, PAINT );
|
||||
int showfps = 0; REGISTER_PARAM( showfps, PAINT );
|
||||
float in_amplitude = 1; REGISTER_PARAM( in_amplitude, PAFLOAT );
|
||||
|
||||
struct NoteFinder * nf;
|
||||
|
||||
|
@ -133,7 +134,7 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
|||
}
|
||||
|
||||
fo /= channelin;
|
||||
sound[soundhead] = fo;
|
||||
sound[soundhead] = fo*in_amplitude;
|
||||
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
||||
}
|
||||
else
|
||||
|
@ -147,7 +148,7 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
|||
|
||||
|
||||
//printf( "Sound fault B %d/%d\n", i, samplesr );
|
||||
sound[soundhead] = f;
|
||||
sound[soundhead] = f*in_amplitude;
|
||||
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
||||
|
||||
}
|
||||
|
@ -353,7 +354,6 @@ int main(int argc, char ** argv)
|
|||
int thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
||||
for( i = 0; i < screenx; i++ )
|
||||
{
|
||||
if( thisy < 0 || thisy > 256 ) printf( "%d/%d\n", thisy,thissoundhead );
|
||||
CNFGTackSegment( i, lasty, i+1, thisy );
|
||||
lasty = thisy;
|
||||
thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
||||
|
|
|
@ -5,9 +5,12 @@ headless=1
|
|||
title = PA Test
|
||||
set_screenx = 720
|
||||
set_screeny = 480
|
||||
in_amplitude = 3.0
|
||||
|
||||
sample_channel = -1
|
||||
sourcename =alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||
sourcename = bluez_sink.40_EF_4C_CA_A4_5D.monitor
|
||||
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
|
||||
## alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||
# alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2.monitor (On desktop)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue