Sorry
I know it has been a long time since I have posted. I have been meaning to post Part 2 to the Raspberry Pi camera server that I had blogged about earlier, and I promise that will be completed soon. However, I have been working on many projects and websites since then and I haven't had much time to post. Anyways, with that said, here's something unrelated to the aforementioned camera server which I hope will be useful to at least some of you.
So What is it?
My new project is about a new Node.js module that I have developed. It is controller software that is used to display numbers and some letters on a 2 digit, 7 segment LED display which is attached to the Raspberry Pi. If you would like to see a demo of it, view my Github repository or my NPM package.
Installation
Installation is super simple (assuming you have NPM installed). All you need to do is navigate to your project directory via the command line and execute this command:
npm install pi-displayViola! Now you have PiDisplay installed! Now onto...
How do I Use it?
You can find a usage example in the two aforementioned links in the "So What is it?" section. You'll definitely want to read through the readme file in either of the two links as there is some crucial information that I am leaving out of this blog for brevity's sake. It includes information on how to wire up the display and how to reassign the pins if you do not use the same pins as I did. Anyways, I shall give a brief example of how to program the display in this blog post.
test.js
// Don't forget the extra parentheses to call the constructor function! var piDisplay = require("pi-display")(); // Displays E7 on the LED display. piDisplay.displayChars("E7"); // Displays 85. piDisplay.displayChars(85); // Scrolls the given string across the display. It looks more natural to scroll // if you have spaces at either end of the string, but they are not mandatory. // The second argument is the milliseconds to display each character. piDisplay.scrollChars(" HI HELLO 1234567890 ", 400);
So as you can see, you must require() the package, then immediately after call it's constructor function. You may pass two arguments to the constructor function, ledPins and cathodePins. For information on how to format these objects, please see the documentation on either the NPM module description or the Github readme file.
Next, we use the displayChars() method. This method accepts one argument, chars. chars is a string or number not more than two characters in length. This method displays the argument that is passed to it on the LED display, assuming that the string or number is acceptable. The next line does the same thing, but instead of passing a string to the method, a number is passed. An important note about displayChars() is that it keeps Node.js running as long as the method is executing. To stop the execution of displayChars(), execute the method clearDisplay().
Lastly, the method scrollChars() scrolls a string (first argument) across the LED display, one characters at a time. Only certain letters are allowed; again, see the NPM module description or the Github readme file for more information on which letters are allowed. The second argument is the speed at which to display each individual character on the display (in milliseconds).
That's All Folks
So now you know how to use my PiDisplay module. If I have left any bugs or errors in the code, don't hesitate to submit an Issue to my Github repository. And if you have any feature requests or want to contribute, submit a Pull Request on Github.
Thanks for reading! You can also post questions on this page of course!