This looks *really* good for a guy who started with asking questions about hexadecimal numbers
. Hopefully that proves that Python is really easy to program with, no matter how much background one has.
That said, there's yet some way to go for that module to have really "professional" look. Few issues immediately catching an eye:
1. Naming. Stuff like "UP()", "UT()", "T()", "p()" is really confusing. I bet you yourself, if looking at the code which uses this module in a year, won't be able to tell what they mean. And other people will have that trouble immediately. So, please consider using more detailed names. They sure should not be too long either. Finding good and consistent naming is kind of art (yeah, like poetry). Ses also suggestion below.
2. Code is vividly not compliant with PEP8 code style guidelines. For example, there's no (or inconsistent) spaces around operators and in function argument lists. Also, PEP8 doesn't appreciate following usage of if/else:
Code: Select all
if B7 < 0x80000000: p = (B7*2)/B4
else: p = (B7/B4)*2
It should be instead (if you trust PEP8, and you should in general, because most other Python programmers trust PEP8, so if you won't trust PEP8, they won't trust your code):
Code: Select all
if B7 < 0x80000000:
p = (B7*2)/B4
else:
p = (B7/B4)*2
Anyway once again, this looks very good for v0.5. Btw, did you notice another guy's module for another temperature sensor:
http://forum.micropython.org/viewtopic.php?f=5&t=154 ? What would be really cool if you guys communicated and came to a common naming conventions on which method names to use to get temperature, etc. - in other words, established an interface which temperature and other sensor modules should provide to be compatible and be able to substitute one another. That would be true Pythonic way and allowed people to write great apps which would work with any hardware easily.