How to write "C"character on 7segment _LEDPACK

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
malkowki
 
Posts: 6
Joined: Wed Dec 14, 2016 9:21 am

How to write "C"character on 7segment _LEDPACK

Post by malkowki »

Dear,

I am running the following code and I would like to write a "C" character to the 3rd digit on the display? I was wondering to C in hex is "12" but this is bot working with this library.

Code: Select all

import Adafruit_BBIO.ADC as ADC
import time
import datetime
from Adafruit_LED_Backpack  import SevenSegment

segment = SevenSegment.SevenSegment(address=0x70, busnum=2)

# Initialize the display. Must be called once before using the display.
segment.begin()
print "Press CTRL+Z to exit"

sensor_pin = 'P9_39'

ADC.setup()

while(True):
    reading = ADC.read(sensor_pin)
    millivolts = reading * 1800
    temp_c = (millivolts - 500) / 10

    segment.set_digit(0, int(temp_c / 10))
    segment.set_digit(1, int(temp_c % 10))
    segment.set_digit(3, 1) [color=#FF0040]#How to write "C"?[/color]
    segment.set_colon(1)

# Write the display buffer to the hardware.  This must be called to
# update the actual display LEDs.
    segment.write_display()


    time.sleep(1)


Thanks for your help.

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: How to write "C"character on 7segment _LEDPACK

Post by adafruit_support_bill »

You would use the WriteDigitRaw() function from the library, and specify which segments to light in your bitmask. Each bit in the 8-bit mask controls one segment. You can find the segment numbering in the data sheet for your display.

User avatar
malkowki
 
Posts: 6
Joined: Wed Dec 14, 2016 9:21 am

Re: How to write "C"character on 7segment _LEDPACK

Post by malkowki »

Hi,

The WriteDigitRaw() syntax is not recognized in the latest Sevensegment library from Adafruit.
I have tried segment.writeDigitRaw(3, B001110011) for instance but I have error message that the Sevensegment doesn't recognize this.

Any help?

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: How to write "C"character on 7segment _LEDPACK

Post by adafruit_support_bill »

It is there. This is the Adafruit_7segment class definition from github:
https://github.com/adafruit/Adafruit_LE ... Backpack.h

Code: Select all

class Adafruit_7segment : public Adafruit_LEDBackpack {
 public:
  Adafruit_7segment(void);
  size_t write(uint8_t c);

  void print(char, int = BYTE);
  void print(unsigned char, int = BYTE);
  void print(int, int = DEC);
  void print(unsigned int, int = DEC);
  void print(long, int = DEC);
  void print(unsigned long, int = DEC);
  void print(double, int = 2);
  void println(char, int = BYTE);
  void println(unsigned char, int = BYTE);
  void println(int, int = DEC);
  void println(unsigned int, int = DEC);
  void println(long, int = DEC);
  void println(unsigned long, int = DEC);
  void println(double, int = 2);
  void println(void);
  
  void writeDigitRaw(uint8_t x, uint8_t bitmask);
  void writeDigitNum(uint8_t x, uint8_t num, boolean dot = false);
  void drawColon(boolean state);
  void printNumber(long, uint8_t = 2);
  void printFloat(double, uint8_t = 2, uint8_t = DEC);
  void printError(void);

  void writeColon(void);
    
 private:
  uint8_t position;
};
If you post your code, we can take a look.

User avatar
malkowki
 
Posts: 6
Joined: Wed Dec 14, 2016 9:21 am

Re: How to write "C"character on 7segment _LEDPACK

Post by malkowki »

Hi,

The Adafruit_7segment class for python doesn't use writeDigitRaw rather segment.set_digit_raw(self, pos, bitmask):
So to display the C character I used the bit mask 0x39 ,

Code: Select all

 segment.set_digit_raw(2, 0X39).
It is working now.

Thanks,

User avatar
adafruit_support_bill
 
Posts: 88092
Joined: Sat Feb 07, 2009 10:11 am

Re: How to write "C"character on 7segment _LEDPACK

Post by adafruit_support_bill »

My apologies. I should have seen that you were using Python. In any case, it's good to hear you have it working. Thanks for the follow-up.

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

Return to “Beagle Bone & Adafruit Beagle Bone products”