Skip to content

Commit

Permalink
updated to use gamma function
Browse files Browse the repository at this point in the history
reject odd-sized packets as well
  • Loading branch information
kukulski committed Nov 5, 2012
1 parent b1d8056 commit 377226b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
14 changes: 8 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ int main(int argc, const char * argv[])
exit(1);
}

set_gamma(3.0, 3.0, 3.0);

UDPListener udp(43211);

UDPListener udp(54321);
unsigned int udpBuf[100];


while(1) {
size_t amount = udp.listen(udpBuf,sizeof(udpBuf));

prepPixels(udpBuf, tclBuf);
send_buffer(fd,&tclBuf);

if(amount == sizeof(udpBuf)) {
prepPixels(udpBuf, tclBuf);
send_buffer(fd,&tclBuf);
}
}

return 0;
Expand All @@ -77,7 +79,7 @@ void prepPixels( unsigned int *raw, const tcl_buffer &tcl) {

void writePixel(unsigned int *raw, tcl_color *pixels, int row, int col) {
unsigned int px = getPixel(raw,row,col);
write_bgra(getTCLPixel(pixels,row,col),px);
write_bgra_gamma(getTCLPixel(pixels,row,col),px);
}
tcl_color *getTCLPixel(tcl_color *pixels, int row, int col) {
int phase = row & 1;
Expand Down
4 changes: 4 additions & 0 deletions tclled.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ void write_bgra(tcl_color *p, uint32_t px) {
write_color(p,(px>>8 & 255),(px>>16 & 255),(px>>24));
}

void write_bgra_gamma(tcl_color *p, uint32_t px) {

write_gamma_color(p,(px>>8 & 255),(px>>16 & 255),(px>>24));
}

void write_color(tcl_color *p, uint8_t red, uint8_t green, uint8_t blue) {
uint8_t flag;
Expand Down
2 changes: 2 additions & 0 deletions tclled.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ int spi_init(int filedes);
*/
void write_color(tcl_color *p, uint8_t red, uint8_t green, uint8_t blue);

void write_bgra(tcl_color *p, uint32_t px);
void write_bgra_gamma(tcl_color *p, uint32_t px);

void write_rgba(tcl_color *p, uint32_t color);
//void write_bgr32(tcl_color *p, uint32_t color);
Expand Down

0 comments on commit 377226b

Please sign in to comment.