Adafruit 4-Digit 7-Segment Display Backpack on raspberry pi

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dam2k
 
Posts: 2
Joined: Wed Apr 02, 2014 10:23 am

Adafruit 4-Digit 7-Segment Display Backpack on raspberry pi

Post by dam2k »

I created a simple userspace C library for the Adafruit 4 digit 7 segment display on raspberry pi.
It's apache v2 licensed (can be used in closed, commercial and open environments).

Code sample:

Code: Select all

/* prepare the backpack driver
(the first parameter is the raspberry pi i2c master controller attached to the HT16K33, the second is the i2c selection jumper)
The i2c selection address can be one of HT16K33_ADDR_01 to HT16K33_ADDR_08
*/
HT16K33 led_backpack1 = HT16K33_INIT(1, HT16K33_ADDR_01);

/* initialize the backpack */
rc = HT16K33_OPEN(&led_backpack1);

/* power on the ht16k33 */
HT16K33_ON(&led_backpack1);

/* make it shining bright */
HT16K33_BRIGHTNESS(&led_backpack1, 0x0F);

/* make it not blinking */
HT16K33_BLINK(&led_backpack1, HT16K33_BLINK_OFF);

/* power on the display */
HT16K33_DISPLAY(&led_backpack1, HT16K33_DISPLAY_ON);

/* Say hello */
HT16K33_UPDATE_DIGIT(&led_backpack1, 0, ‘H’, 0); // first digit
HT16K33_UPDATE_DIGIT(&led_backpack1, 1, ‘E’, 0); // second digit
// turn off the colon sign in the middle of the 4 digits
HT16K33_UPDATE_DIGIT(&led_backpack1, 2, HT16K33_COLON_OFF, 0);
HT16K33_UPDATE_DIGIT(&led_backpack1, 3, ‘#’, 0); // third digit
HT16K33_UPDATE_DIGIT(&led_backpack1, 4, ‘o’, 0); // fourth digit
HT16K33_COMMIT(&led_backpack1); // commit to the display memory

// call this if you want to shut down the device (power saving mode)
// HT16K33_OFF(&led_backpack1);

/* close things (the display remains in the conditions left) */
HT16K33_CLOSE(&led_backpack1);
If you like, you can download it from here: http://dino.ciuffetti.info/2014/04/adaf ... y-pi-in-c/

Ciao, Dino Ciuffetti.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”