importing definitions with an HT16k33 and segment displays

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Tusabez
 
Posts: 9
Joined: Mon Nov 08, 2021 8:32 am

importing definitions with an HT16k33 and segment displays

Post by Tusabez »

Hello all, I'm using an HT16k33 matrix board along with several 7 segment displays. Because there isn't a library to display beyond 4 numbers, I mapped out segments using the matrix function. My question is how can I tell CircuitPython to import definitions saved as definition.py file into the main code.py. For example here is a definition for 0.

Code: Select all

def zero():
    matrix[x,0] = 1
    matrix[x,1] = 1
    matrix[x,2] = 1
    matrix[x,3] = 1
    matrix[x,4] = 1
    matrix[x,5] = 1
I can't import directly because I'll get an error that says 'matrix' is not defined in the definition.py while 'matrix' is defined in code.py. I want to separate definitions from the main program so it won't be excessively long. If I leave the definitions in the main program, everything works just fine.

User avatar
alpierce
 
Posts: 207
Joined: Mon May 13, 2013 2:44 am

Re: importing definitions with an HT16k33 and segment displays

Post by alpierce »

What you are doing with def is defining or declaring a function. Check out information about using functions in Circuitpython, or Python. I’m not sure it is possible to separate code in the way you are attempting, maybe someone else can suggest something.

I suppose you could store your matrices in external Fram and access them that way, but you would still have to include the library to support the Fram. What processor are you using that you are having memory constraint problems with? Also, there might be an easier way to achieve what you are trying to do.

There is a weekly YouTube video series done by John Park called JP’s Product Pick. He recently covered the Adafruit 14 segment alphanumeric displays and showed how to use multiple displays as one large display. I don’t know if that can be done with the 7 segment displays, but it might be worth checking out for ideas.

User avatar
Tusabez
 
Posts: 9
Joined: Mon Nov 08, 2021 8:32 am

Re: importing definitions with an HT16k33 and segment displays

Post by Tusabez »

Thanks. In the end, I just kept the segment definitions in the original code. I had one 3 digit alphanumeric display and ten 7 segment displays working as a clock connected to a Pico.

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

Return to “Adafruit CircuitPython”