openpixelcontrol icon indicating copy to clipboard operation
openpixelcontrol copied to clipboard

Added gamma correction to tcl server.

Open devries opened this issue 12 years ago • 11 comments

I decided to try to address the gamma correction issue with TCL pixels the way I had in the elinux-tcl library. I basically create a lookup table for each color (right now that's not really used, but it could potentially come in handy) and I create the gamma correction table before the server starts.

I'm working on some other arduino based LED projects, so I don't have a test harness set up for this at the moment, but I hope it's not buggy.

devries avatar Aug 09 '13 00:08 devries

Hi Chris, thanks for writing this. Could you make the gamma values configurable on the command line? I think the default should be 1, so that existing lighting projects aren't affected by this change.

Also, some style nits: one space after commas and semicolons, one space before and after low-precedence binary operators (+, -, and anything of lower precedence). Thanks!

zestyping avatar Aug 14 '13 19:08 zestyping

OK, makes sense. I will work on the changes in my repo and submit them to you, but probably not before burning man.

devries avatar Aug 14 '13 22:08 devries

I tried this out with the latest build of OPC. It compiled fine on my mac, but threw errors on the BeagleBoneBlack. This is my first post on GitHub, so do let me know if there is a better/formal process for posting things of this nature.

gcc -o bin/tcl_server src/tcl_server.c src/opc_server.c src/spi.c src/tcl_server.c: In function 'set_gamma': src/tcl_server.c:60:36: warning: incompatible implicit declaration of built-in function 'pow' [enabled by default] /tmp/ccFHNAgO.o: In function set_gamma': tcl_server.c:(.text+0x2c0): undefined reference topow' tcl_server.c:(.text+0x364): undefined reference to pow' tcl_server.c:(.text+0x404): undefined reference topow' collect2: error: ld returned 1 exit status make: *** [bin/tcl_server] Error 1

... update ...

I had to add the -lm flag to gcc on the BBB. Huh, wonder why it isn't necessary in OSX.

hunson-abadeer avatar Aug 15 '13 01:08 hunson-abadeer

Re: the compiling errors, I need to include the math.h library and add -lm to link to it in the gcc line.

I saw that you typedefed u8 to unsigned 8-bit int. I used it on several of the values I added, but I notice I didn't modify it on the casting calls.

I'll set up a test bed after burning man, but right now I don't have a system I can debug on, so I'll defer the changes.

devries avatar Aug 15 '13 13:08 devries

No rush! Thanks!

On Thu, Aug 15, 2013 at 6:56 AM, Christopher De Vries < [email protected]> wrote:

Re: the compiling errors, I need to include the math.h library and add -lm to link to it in the gcc line.

I saw that you typedefed u8 to unsigned 8-bit int. I used it on several of the values I added, but I notice I didn't modify it on the casting calls.

I'll set up a test bed after burning man, but right now I don't have a system I can debug on, so I'll defer the changes.

— Reply to this email directly or view it on GitHubhttps://github.com/zestyping/openpixelcontrol/pull/14#issuecomment-22704203 .

zestyping avatar Aug 15 '13 16:08 zestyping

Thanks @solidgold! I merged another pull request that added the missing -lm flag.

zestyping avatar Oct 19 '13 01:10 zestyping

hi all, this is exactly what I was looking to implement. Is there anything I can do to help it along?

mbustosorg avatar Jun 29 '16 23:06 mbustosorg

@devries @mbustosorg I made this configurable using the environment variable TCL_GAMMA. The merged change is in the branch devries-master https://github.com/zestyping/openpixelcontrol/tree/devries-master . Would either of you be able to test that branch on a Beaglebone? Once it's confirmed that it works, I can merge it.

zestyping avatar Mar 24 '17 18:03 zestyping

Unfortunately I don't have a working Beaglebone at the moment to do any testing. I had a similar routine in another piece of code I wrote, and it had an issue writing a 257th byte to a 256 byte long buffer. I think this one was simpler so it might not include that bug.

devries avatar Mar 24 '17 21:03 devries

I have one available that I can test with this weekend.

mbustosorg avatar Mar 24 '17 21:03 mbustosorg

Hey sorry for the delay. The gamma correction works. Please add #include <math.h> to remove the compiler issue. Please also check availability of the env TCL_GAMMA before trying to do the atof.

Let me know if you need anything else.

mbustosorg avatar Apr 24 '17 04:04 mbustosorg