Small flip digit library
Project description
FlipDigitPython
Description
This library has for goal to control the Small 7-segment displays by alfazeta.
Requirement
The only library needed for this to work is pyserial. Basic installation can be made like so:
pip3 install pyserial
or by using the provided requirments.txt file:
pip3 install -r requirments.txt
How to use
Simple digit
You can simply declare a FlipDigit like so:
from flipdigit import *
# myDigit = FlipDigit('/dev/tty0') # Linux com port
myDigit = FlipDigit('COM6') # Windows com port
This use the default configuration of a digit: 9600 baud with adress set as 0xFF.
Then you can either send the data code to enable or not a segment following the pattern shown there:
The code is then going from a for the lsb to g for the msb
As example, a 0 is 0b111111 or 0x3F:
myDigit.set_segments(0x3F)
or you can directly send the number you want like so:
myDigit.set_number(0)
Examples:
Configuration
You can easily change the configuration of a digit like so:
myDigit = FlipDigit('COM6') #we use a digit with default configuration
myDigit.set_serial_speed(SerialSpeed.S_115200)
myDigit.set_address(0x01)
The digit has now the address '1' and the baudrate is set to 115200 bauds.
Now the digit need to be used like so:
myDigit1 = FlipDigit('COM6',SerialSpeed.S_115200,0x01)
Examples:
Multiple digit
You can easily use multiple digit since they share a static serial attribute. Be careful, only the first digit serial configuration will be taken in account!
myDigit1 = FlipDigit('COM6',SerialSpeed.S_115200,0x01)
myDigit2 = FlipDigit('COM6',SerialSpeed.S_115200,0x02)
myDigit1.set_number(1)
myDigit2.set_number(2)
Examples:
Multiple digit in sync
In the previous example, the set_number is not made in sync. It is possible to send the set_number or set_segments and then have all the digit refreshed at the same time using the SyncMultipleFlipDigits object like so:
myDigit1 = FlipDigit('COM6',SerialSpeed.S_115200,0x01)
myDigit2 = FlipDigit('COM6',SerialSpeed.S_115200,0x02)
mySyncDigits = SyncMultipleFlipDigits([myDigit1, myDigit2])
# now that the digits are part of a SyncMultipleFlipDigits, they won't be refreshed automatically
myDigit1.set_number(i)
sleep(1)
myDigit2.set_number((i+1)%10)
sleep(1)
mySyncDigits.sync_refresh() # myDigit1 and myDigit2 are refreshed only here!
Examples:
License
Under MIT license. Please see License File for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for flipdigit-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4374b1cbb88309ac416a954938cfaf01a36cd5822238984485448639eb8d7af3 |
|
MD5 | b285e26bb9345bd05290db46eb18da0e |
|
BLAKE2b-256 | 784b8689e65c38a188354ff93471b34b42dab5dc35ace24e32a31f7c479e4830 |