zackphillips / TLC5955

Arduino library for the TI TLC5955 LED controller
MIT License
21 stars 12 forks source link

controlling 1 color LEDs? #3

Open lain-d opened 5 years ago

lain-d commented 5 years ago

Is it possible to use this library to control 1 color LEDs (1 per channel) instead of RGB Leds like in the example?

swissbyte commented 4 years ago

Yes, it is possible, as long as you modify the tlc5955.cpp file.

The follwing section contains the relevant code:

void TLC5955::setLed(uint16_t led_number, uint16_t rgb) { uint8_t chip = (uint16_t)floor(led_number / LEDS_PER_CHIP); uint8_t channel = (uint8_t)(led_number - LEDS_PER_CHIP * chip); // Turn that LED on _grayscale_data[chip][channel][2] = rgb; _grayscale_data[chip][channel][1] = rgb; _grayscale_data[chip][channel][0] = rgb; }

Basically you just need to write into the temp register directly, like this way (untested!)

void TLC5955::setLed(uint16_t led_number, uint8_t sub_channel, uint16_t PWM_Value) { uint8_t chip = (uint16_t)floor(led_number / LEDS_PER_CHIP); uint8_t channel = (uint8_t)(led_number - LEDS_PER_CHIP * chip); // Turn that LED on _grayscale_data[chip][channel][sub_channel] = PWM_Value; }

With the code above, you get the ability to use an additional parameter (sub_channel) to define which output you want to use.

lain-d commented 4 years ago

That makes sense! thanks so much. I have a couple of these chips lying around somewhere. I'll try it out when i get a chance. The project (still not done) was to make a low cost standard LED "pinball style" DMD (which traditionally was a 2-bit plasma display, later revised to led dot matrix)

A DMD display: https://virtuapin.net/index.php?main_page=product_info&cPath=6&products_id=231&zenid=aen254vof2hmnfo0v6h2iv5dt4

the resolution is usually 128x32....so I was thinking I could just use one chip but i need to figure out how to cycle through the 128 rows of LEDs.