otoh wrote:6by9 wrote:Why not just drive your leds via digital outputs, rather than convert from digital from the Pi, to analogue for the lm3914, which then converts it back to digital for the leds? That seems a rather overengineered solution.
Thanks for the reply. I guess because the LM3914 has some nice logic built in re lighting the bars, and providing differing modes of filled bars vs dot mode... I figure making it easier to code on the Pi side if I can just send it a number and let it do the work!
Dot/bar mode selection is pretty trivial in code too. To make the maths easy, assuming a 0-99 input value to 10 LEDs:
Dot:
Code: Select all
unsigned int output = 0;
if(value>90)
output|=1<<9;
else if(value>80)
output|=1<<8;
else if(value>70)
output|=1<<7;
...
else if(value>10)
output|=1<<1;
For bar mode, replace all the "else if(" with "if(".
(I know I've blundered there and will never light the bottom LED, but you get the idea. I don't know the size of your input data and that would affect all the numbers anyway)
Alternatively make a lookup table of input value to output bitmask - it costs more in memory (which isn't normally a limit on a Pi), but is faster to lookup.
Either method also allows you to apply non-linear representations to your bargraphs - switch between a virtual LM3914, LM3915, and LM3916 at will, or dream up your own.
otoh wrote:But as you suggest, if not, I can drive them digitally. Not sure what the best IC is - I have some MAX7219s that I guess should be able to do it?
Yes, at a quick glance the MAX7219 with the BCD decode mode bypassed would work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.