Make asynchronous operation better.

This commit is contained in:
cnlohr 2018-05-20 22:24:20 -04:00
parent 7910c7e029
commit f5251a0e41
2 changed files with 12 additions and 5 deletions

View file

@ -25,8 +25,10 @@ struct FileWriteDriver
int lights_file; int lights_file;
int total_leds; int total_leds;
int inflate_to_u32; int inflate_to_u32;
int file_thread_usleep;
int asynchronous; int asynchronous;
uint32_t pass_buffer[MAX_LEDS]; uint32_t pass_buffer[MAX_LEDS];
volatile int flagchanges;
og_thread_t rt_thread; og_thread_t rt_thread;
}; };
@ -35,8 +37,9 @@ static void * LightsWrite( void * v )
struct FileWriteDriver * d = (struct FileWriteDriver *)v; struct FileWriteDriver * d = (struct FileWriteDriver *)v;
while(1) while(1)
{ {
usleep( d->file_thread_usleep );
if( !d->flagchanges ) continue;
d->flagchanges = 0;
if( d->lights_file > 0 ) if( d->lights_file > 0 )
{ {
int btos = ((d->inflate_to_u32)?4:3)*d->total_leds; int btos = ((d->inflate_to_u32)?4:3)*d->total_leds;
@ -65,6 +68,7 @@ static void * LightsWrite( void * v )
close( d->lights_file ); close( d->lights_file );
d->lights_file = 0; d->lights_file = 0;
} }
return 0;
} }
static void FileWriteUpdate(void * id, struct NoteFinder*nf) static void FileWriteUpdate(void * id, struct NoteFinder*nf)
@ -85,6 +89,7 @@ static void FileWriteUpdate(void * id, struct NoteFinder*nf)
d->pass_buffer[i] = ol[0] | (ol[1]<<8) | (ol[2]<<16) | 0xff000000; d->pass_buffer[i] = ol[0] | (ol[1]<<8) | (ol[2]<<16) | 0xff000000;
} }
} }
d->flagchanges = 1;
} }
@ -95,6 +100,7 @@ static void FileWriteParams(void * id )
d->total_leds = 300; RegisterValue( "leds", PAINT, &d->total_leds, sizeof( d->total_leds )); 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->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 )); d->asynchronous = 1; RegisterValue( "file_async", PAINT, &d->asynchronous, sizeof( d->asynchronous ));
d->file_thread_usleep = 10000; RegisterValue( "file_thread_usleep", PAINT, &d->file_thread_usleep, sizeof( d->file_thread_usleep ));
} }
static struct DriverInstances * DisplayFileWrite(const char * parameters) static struct DriverInstances * DisplayFileWrite(const char * parameters)

View file

@ -2,7 +2,7 @@
# https://github.com/cnlohr/clevo_xsm_wmi # https://github.com/cnlohr/clevo_xsm_wmi
cpu_autolimit = 1 cpu_autolimit = 1
headless=0 headless=1
#General GUI properties. #General GUI properties.
title = PA Test title = PA Test
@ -41,7 +41,7 @@ note_out_chop = 0.05000
#DisplayArray #DisplayArray
outdrivers = OutputCells, DisplayFileWrite, DisplayArray outdrivers = OutputCells, DisplayFileWrite # DisplayArray
lightsfile = /sys/devices/platform/clevo_xsm_wmi/kb_rgb lightsfile = /sys/devices/platform/clevo_xsm_wmi/kb_rgb
inflate_to_u32 = 1 inflate_to_u32 = 1
@ -50,8 +50,9 @@ lighty = 3
fromsides = 1 fromsides = 1
leds = 3 leds = 3
qtyamp = 20 qtyamp = 20
file_thread_usleep = 18000
satamp = 4.800 satamp = 3.00
amppow = 2.510 amppow = 2.510
distpow = 1.500 distpow = 1.500