Open kepon85 opened 4 years ago
Ho it's now ok (I do not know why ...)
Will this library be ported to python 3?
This error continue but not important for me :
root@raspberrypi(rw):/opt/rpi-TM1638# python test/test_TM.py
Traceback (most recent call last):
File "test/test_TM.py", line 25, in <module>
TM.leds = (True, False, True) # set the three first leds
AttributeError: can't set attribute
Thank's, David
Hello It's been a long time since I made this. So, let's see how to answer your questions :
DIO = 19
CLK = 13
STB = 26
Since you only have one TM1638, you can only use segments 0 to 8, and leds 0 to 7
TM.leds = (True, False, True) # set the three first leds
it's my bad. I have remove the setter of the leds (I can't remember why...) in the previous commit
@leds.setter def leds(self, values): """setter TM.leds = value where value is a list/tuple of booleans Performs TM.leds[i] = value[i] for all i""" for i, v in enumerate(values): self._leds[i] = v
You can i) add the setter ii) or just use the appropriate function for the leds
TM.leds[0] = True TM.leds[1] = False TM.leds[2] = False
I am sorry, I have written this module years ago for my own purpuse, but finally switch the control of my TM1638s to another board (to an ATMEL that is now controlled by the Raspberry Pi). That's the reason why the tests are not consistent with the code
I did not try to use Python 3, but it should run on it (if not, tell me and I can try to fix it)
The module is not finished since the switches are not managed (but it is quite straightforward to finish it, since the low level part is working, only the TMBoard interface is missing)
* "_I have just one TM1638 on PIN 26, does your library work for only 1?_" -> Yes, just give one value (instead of a list) to STB. In your case:
DIO = 19 CLK = 13 STB = 26
No... :
Traceback (most recent call last):
File "/opt/rpi-TM1638/test/test_TM.py", line 12, in <module>
TM = TMBoards(DIO, CLK, STB, 0)
File "/usr/local/lib/python2.7/dist-packages/rpi_TM1638-0.1-py2.7.egg/rpi_TM1638/TMBoards.py", line 19, in __init__
self._nbBoards = len(stb)
TypeError: object of type 'int' has no len()
But not importent
For python 3, install ok :
root@raspberrypi(rw):/opt/rpi-TM1638# python3 setup.py install
running install
running bdist_egg
running egg_info
writing rpi_TM1638.egg-info/PKG-INFO
writing dependency_links to rpi_TM1638.egg-info/dependency_links.txt
writing requirements to rpi_TM1638.egg-info/requires.txt
writing top-level names to rpi_TM1638.egg-info/top_level.txt
reading manifest file 'rpi_TM1638.egg-info/SOURCES.txt'
writing manifest file 'rpi_TM1638.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv6l/egg
running install_lib
running build_py
creating build/bdist.linux-armv6l/egg
creating build/bdist.linux-armv6l/egg/rpi_TM1638
copying build/lib/rpi_TM1638/TM1638s.py -> build/bdist.linux-armv6l/egg/rpi_TM1638
copying build/lib/rpi_TM1638/__init__.py -> build/bdist.linux-armv6l/egg/rpi_TM1638
copying build/lib/rpi_TM1638/Font.py -> build/bdist.linux-armv6l/egg/rpi_TM1638
copying build/lib/rpi_TM1638/TMBoards.py -> build/bdist.linux-armv6l/egg/rpi_TM1638
byte-compiling build/bdist.linux-armv6l/egg/rpi_TM1638/TM1638s.py to TM1638s.cpython-37.pyc
byte-compiling build/bdist.linux-armv6l/egg/rpi_TM1638/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-armv6l/egg/rpi_TM1638/Font.py to Font.cpython-37.pyc
byte-compiling build/bdist.linux-armv6l/egg/rpi_TM1638/TMBoards.py to TMBoards.cpython-37.pyc
creating build/bdist.linux-armv6l/egg/EGG-INFO
copying rpi_TM1638.egg-info/PKG-INFO -> build/bdist.linux-armv6l/egg/EGG-INFO
copying rpi_TM1638.egg-info/SOURCES.txt -> build/bdist.linux-armv6l/egg/EGG-INFO
copying rpi_TM1638.egg-info/dependency_links.txt -> build/bdist.linux-armv6l/egg/EGG-INFO
copying rpi_TM1638.egg-info/not-zip-safe -> build/bdist.linux-armv6l/egg/EGG-INFO
copying rpi_TM1638.egg-info/requires.txt -> build/bdist.linux-armv6l/egg/EGG-INFO
copying rpi_TM1638.egg-info/top_level.txt -> build/bdist.linux-armv6l/egg/EGG-INFO
creating 'dist/rpi_TM1638-0.1-py3.7.egg' and adding 'build/bdist.linux-armv6l/egg' to it
removing 'build/bdist.linux-armv6l/egg' (and everything under it)
Processing rpi_TM1638-0.1-py3.7.egg
removing '/usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg' (and everything under it)
creating /usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg
Extracting rpi_TM1638-0.1-py3.7.egg to /usr/local/lib/python3.7/dist-packages
rpi-TM1638 0.1 is already the active version in easy-install.pth
Installed /usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg
Processing dependencies for rpi-TM1638==0.1
Searching for RPi.GPIO==0.7.0
Best match: RPi.GPIO 0.7.0
Adding RPi.GPIO 0.7.0 to easy-install.pth file
Using /usr/local/lib/python3.7/dist-packages
Finished processing dependencies for rpi-TM1638==0.1
But :
root@raspberrypi(rw):/opt/rpi-TM1638# python3 test/test_TM.py
Traceback (most recent call last):
File "test/test_TM.py", line 3, in <module>
from rpi_TM1638 import TMBoards
File "/usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg/rpi_TM1638/__init__.py", line 1, in <module>
from TMBoards import TMBoards
ModuleNotFoundError: No module named 'TMBoards'
The module is not finished since the switches are not managed (but it is quite straightforward to finish it, since the low level part is working, only the TMBoard interface is missing)
I am surprised at this because with the following code I get to have the state of the buttons:
while True:
a=TM.getData(0)
print(a)
For example, I press the first button :
root@raspberrypi(rw):/opt/PvMonit/domo# python tm1638.py
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[1, 0, 0, 0]
[1, 0, 0, 0]
Ok for leds I use the right function, it works! Thank you
At first, I was quite surprized, because this case was supported in the code. And then I realized that my last modifications (done two or three years ago) were never pushed...
And this should (I do not have the hardware with me to test) work with Python 3 (the import
line has been changed for this purpose)
For the button, of course there is the getData
method, but the updateSwitches
is not finished (quite easy to do), and was supposed to give only the values that have changed since last update (because, most of the time, this is what we are doing with a board like that: polling and wait for changes in the buttons)
If needed, I can finish that part (but without device to check)
At first, I was quite surprized, because this case was supported in the code. And then I realized that my last modifications (done two or three years ago) were never pushed...
And this should (I do not have the hardware with me to test) work with Python 3 (the import line has been changed for this purpose)
Install ok, but in python 3 it's not permit :
root@raspberrypi(rw):/tmp/rpi-TM1638# python3 test/test_TM.py
File "test/test_TM.py", line 8
STB = 06, 26
^
SyntaxError: invalid token
And if i change to
STB = 26
root@raspberrypi(rw):/tmp/rpi-TM1638# python3 test/test_TM.py
Traceback (most recent call last):
File "test/test_TM.py", line 18, in <module>
TM.leds[12] = True # turn on led 12 (5th led of the 2nd board, since there is 8 leds per board)
File "/usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg/rpi_TM1638/TMBoards.py", line 69, in __setitem__
self._TM.sendData((index % 8) * 2 + 1, 1 if value else 0, index // 8)
File "/usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg/rpi_TM1638/TM1638s.py", line 111, in sendData
self._setStb(False, TMindex)
File "/usr/local/lib/python3.7/dist-packages/rpi_TM1638-0.1-py3.7.egg/rpi_TM1638/TM1638s.py", line 153, in _setStb
GPIO.output(self._stb[TMindex], value)
IndexError: tuple index out of range
For the button, of course there is the getData method, but the updateSwitches is not finished (quite easy to do), and was supposed to give only the values that have changed since last update (because, most of the time, this is what we are doing with a board like that: polling and wait for changes in the buttons) If needed, I can finish that part (but without device to check)
I can do the tester without problem if you want!
STB = 06, 26
is invalid, because integers starting with 0 are not supported yet (they were octal numbers in Python2, see [https://stackoverflow.com/questions/11620151/what-do-numbers-starting-with-0-mean-in-python])
And if you change it to STB=26
, then TM.leds[12] = True
could not work since the led #12 doesn't exist if you only have one TM1638...
A new test_TM.py has been pushed (but you can now create your own test file according to your needs)
Yes sorry I tested quickly ... I confirm that it is functional under Python 3! I allowed myself to propose a test script compatible with the repository (comment on the function TM.leds = (True, False, True) and I modified for the use of a single TM1638 in priority (while leaving for 2) because it seems to me the most "common" to use 1 ... (to avoid issues for other noobs like me ... ;-)
Yes, sure, feel free to propose any improvement, I will consider your pull request
For the button, of course there is the getData method, but the updateSwitches is not finished (quite easy to do), and was supposed to give only the values that have changed since last update (because, most of the time, this is what we are doing with a board like that: polling and wait for changes in the buttons) If needed, I can finish that part (but without device to check)
If you intend to do it in ~ the month that arrives I can wait and test your code if you wish, otherwise I will tinker as I can with the getData ... But tell me (so that I can plan my dev ...) it is for a free solar electro monitoring project: https://github.com/kepon85/PvMonit/blob/
Yes, sure, feel free to propose any improvement, I will consider your pull request
My python is not really good for the moment so I dare to suggest things in a bookstore ... but if I see something happen I do not hesitate!
Hello,
Thank's for your code !
I have no display on my TM1638.
Test python 2.7 :
test_TM.py paramètre is :
Launch test script :
If i comment TM.leds ligne :
Launch :
I have no display on the TM1638, only the Power LED is red
Have I wired correctly?
I have just one TM1638 on PIN 26, does your library work for only 1?
In python3 say :
Thank you in advance for your help,