-
Notifications
You must be signed in to change notification settings - Fork 39
add set_gas_heater(); Was available on arduino but not CircuitPython #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
all checks passed. took three attempts. |
adafruit_bme680.py
Outdated
@@ -45,10 +97,34 @@ | |||
except ImportError: | |||
pass | |||
|
|||
__version__ = "0.0.0+auto.0" | |||
__version__ = "3.4.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version should stay the way it was. All of our libraries have this placeholder value that gets filled in by the actions when releases are made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes by all means; was not sure how to do this !!
Thanks for adding this additional functionality. Can you link to the code or project that you worked from where you got the license that was added? I think the format for it needs to be a bit different, but I'm not positive, will bring it up to some others for input. |
github adafruit bme680 arduino code including Bosch library Bosch code includes Bosch license. My code is just a translation of the relevant parts of the Bosch library (the open source part) from C to Python. USE AT YOUR OWN RISK. I tried it and it runs. Since it is a heater I am not sure how to test if it works !!!! NOTE the adafruit python defaults were the same as the C arduino defaults but until now we had no easy way to change them. |
BSD should be REUSE compliant, for what it's worth. You can add multiple licenses to files by adding the license to I can also take a look at some of the typing here, and I think the syntax and exact implementation can be made to conform more to the other those of the other libraries due to implementation differences. For example, I see casts to float where I don't believe they're necessary because CircuitPython division of int and float always results in float so there's no need to cast. |
Yes the casts to float were more of a form of documentation. |
We discussed this in the weeds during 4/24 meeting. Conclusion was that it is okay to bring in BSD-3 licensed code. I'll work on getting the attribution lines setup and revert the version back to 0s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit moves the BSD license over to it's own file and is now re-use compliant and passing actions.
The changes look good to me, but I don't have the right hardware for testing the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a quick look, but I also don't have hardware I think. I think I'd like to take a second look at this once some of these points have been resolved just to see if there's anything I missed. I appreciate everyone's work!
@file bme68x_defs.h | ||
@date 2021-05-24 | ||
@version v4.4.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
@@ -14,6 +16,10 @@ | |||
|
|||
* Author(s): Limor Fried | |||
|
|||
|
|||
original Adafruit_BME680 with addition of set_gas_heater(). Other new members are private. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, I think we can just use the GitHub release to announce things similar to a changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
* @brief Enable and configure gas reading + heater | ||
* @param heater_temp | ||
* Desired temperature in degrees Centigrade | ||
* @param heater_time | ||
* Time to keep heater on in milliseconds | ||
* @return True on success, False on failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the Arduino-style docstrings, so instances of these will need to be converted to the typical style for sphinx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
INT32 = int | ||
INT16 = int | ||
INT8 = int | ||
UINT32 = int | ||
UINT16 = int | ||
UINT8 = int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using int
in all applicable places is fine since there isn't really a distinct "typewise" within Python. If needed, docstrings should explain limits (e.g., 0 - 255). That will save us using type aliases where not strictly needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
@@ -116,6 +152,43 @@ | |||
) | |||
|
|||
|
|||
# garberw added begin =========================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed since it's a contextual comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few comments like these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they were just meant to highlight changes. remove them for sure.
return (reg_data & ~bitname_msk) | (data & bitname_msk) | ||
|
||
|
||
class GasHeaterException(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a hyperspecific exception that could just be replaced with something like OSError
, most likely.
if (heater_temp == 0) or (heater_time == 0): | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be:
if (heater_temp == 0) or (heater_time == 0): | |
return False | |
if not heater_temp or not heater_time: | |
return False |
op_mode: UINT8 = _BME68X_FORCED_MODE | ||
# restrict to enable = True | ||
enable: bool = True | ||
nb_conv: UINT8 = 0 | ||
hctrl: UINT8 = _BME68X_ENABLE_HEATER | ||
run_gas: UINT8 = 0 | ||
ctrl_gas_data_0: UINT8 = 0 | ||
ctrl_gas_data_1: UINT8 = 0 | ||
ctrl_gas_addr_0: UINT8 = _BME68X_REG_CTRL_GAS_0 | ||
ctrl_gas_addr_1: UINT8 = _BME68X_REG_CTRL_GAS_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is using a lot of local variables where using what they equate to might be more efficient. This comment holds for the other methods as well.
# SPDX-FileCopyrightText: 2017 ladyada for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
Contributors to Adafruit_CircuitPython_BME680_modified | ||
============================================================= | ||
|
||
Limor (Ladyada) Fried | ||
|
||
William Garber | ||
many others |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth just adding contributors' names to the SPDX headers as opposed to using a contribuitors file (for consistency reason).
except GasHeaterException as exc: | ||
raise exc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the exception is just being passed through, I don't think there's a need to try
the above block. There's another instance of this below as well.
+# garberw added begin ===========================
these were just meant to be equivalent to doing a diff.
go ahead and remove them.
Who is making the changes listed below, me or someone else?
…On 6/5/23 2:06 PM, Alec Delaney wrote:
***@***.**** requested changes on this pull request.
Took a quick look, but I also don't have hardware I think. I think I'd
like to take a second look at this once some of these points have been
resolved just to see if there's anything I missed. I appreciate
everyone's work!
------------------------------------------------------------------------
In LICENSES/BSD-3-Clause.txt
<#61 (comment)>:
> ***@***.*** bme68x_defs.h
***@***.*** 2021-05-24
***@***.*** v4.4.6
I think these should be removed.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> @@ -14,6 +16,10 @@
* Author(s): Limor Fried
+
+original Adafruit_BME680 with addition of set_gas_heater(). Other new members are private.
This can be removed, I think we can just use the GitHub release to
announce things similar to a changelog.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + * @brief Enable and configure gas reading + heater
+ * @param heater_temp
+ * Desired temperature in degrees Centigrade
+ * @param heater_time
+ * Time to keep heater on in milliseconds
+ * @return True on success, False on failure
Looks like the Arduino-style docstrings, so instances of these will
need to be converted to the typical style for sphinx.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> +INT32 = int
+INT16 = int
+INT8 = int
+UINT32 = int
+UINT16 = int
+UINT8 = int
I think using |int| in all applicable places is fine since there isn't
really a distinct "typewise" within Python. If needed, docstrings
should explain limits (e.g., 0 - 255). That will save us using type
aliases where not strictly needed.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> @@ -116,6 +152,43 @@
)
+# garberw added begin ===========================
This should be removed since it's a contextual comment.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + Macro to set bits
+ data2 = data << bitname_pos
+ set masked bits from data2 in reg_data
+ """
+ return (reg_data & ~bitname_msk) | ((data << bitname_pos) & bitname_msk)
+
+
+def bme_set_bits_pos_0(reg_data, bitname_msk, data):
+ """
+ Macro to set bits starting from position 0
+ set masked bits from data in reg_data
+ """
+ return (reg_data & ~bitname_msk) | (data & bitname_msk)
+
+
+class GasHeaterException(Exception):
This looks like a hyperspecific exception that could just be replaced
with something like |OSError|, most likely.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + if (heater_temp == 0) or (heater_time == 0):
+ return False
This could be:
⬇️ Suggested change
- if (heater_temp == 0) or (heater_time == 0):
- return False
+ if not heater_temp or not heater_time:
+ return False
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + op_mode: UINT8 = _BME68X_FORCED_MODE
+ # restrict to enable = True
+ enable: bool = True
+ nb_conv: UINT8 = 0
+ hctrl: UINT8 = _BME68X_ENABLE_HEATER
+ run_gas: UINT8 = 0
+ ctrl_gas_data_0: UINT8 = 0
+ ctrl_gas_data_1: UINT8 = 0
+ ctrl_gas_addr_0: UINT8 = _BME68X_REG_CTRL_GAS_0
+ ctrl_gas_addr_1: UINT8 = _BME68X_REG_CTRL_GAS_1
I think this is using a lot of local variables where using what they
equate to might be more efficient. This comment holds for the other
methods as well.
------------------------------------------------------------------------
In contributors.md
<#61 (comment)>:
> +# SPDX-FileCopyrightText: 2017 ladyada for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+Contributors to Adafruit_CircuitPython_BME680_modified
+=============================================================
+
+Limor (Ladyada) Fried
+
+William Garber
+many others
It might be worth just adding contributors' names to the SPDX headers
as opposed to using a contribuitors file (for consistency reason).
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + except GasHeaterException as exc:
+ raise exc
Since the exception is just being passed through, I don't think
there's a need to |try| the above block. There's another instance of
this below as well.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> @@ -116,6 +152,43 @@
)
+# garberw added begin ===========================
There's a few comments like these.
—
Reply to this email directly, view it on GitHub
<#61 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKX5GECXQBGG673ZB6DXBH3XJZC6FANCNFSM6AAAAAAV4Z3FHQ>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
new to git how to update if you would like me to change it. pull
request is closed ?
…On 6/5/23 2:06 PM, Alec Delaney wrote:
***@***.**** requested changes on this pull request.
Took a quick look, but I also don't have hardware I think. I think I'd
like to take a second look at this once some of these points have been
resolved just to see if there's anything I missed. I appreciate
everyone's work!
------------------------------------------------------------------------
In LICENSES/BSD-3-Clause.txt
<#61 (comment)>:
> ***@***.*** bme68x_defs.h
***@***.*** 2021-05-24
***@***.*** v4.4.6
I think these should be removed.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> @@ -14,6 +16,10 @@
* Author(s): Limor Fried
+
+original Adafruit_BME680 with addition of set_gas_heater(). Other new members are private.
This can be removed, I think we can just use the GitHub release to
announce things similar to a changelog.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + * @brief Enable and configure gas reading + heater
+ * @param heater_temp
+ * Desired temperature in degrees Centigrade
+ * @param heater_time
+ * Time to keep heater on in milliseconds
+ * @return True on success, False on failure
Looks like the Arduino-style docstrings, so instances of these will
need to be converted to the typical style for sphinx.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> +INT32 = int
+INT16 = int
+INT8 = int
+UINT32 = int
+UINT16 = int
+UINT8 = int
I think using |int| in all applicable places is fine since there isn't
really a distinct "typewise" within Python. If needed, docstrings
should explain limits (e.g., 0 - 255). That will save us using type
aliases where not strictly needed.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> @@ -116,6 +152,43 @@
)
+# garberw added begin ===========================
This should be removed since it's a contextual comment.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + Macro to set bits
+ data2 = data << bitname_pos
+ set masked bits from data2 in reg_data
+ """
+ return (reg_data & ~bitname_msk) | ((data << bitname_pos) & bitname_msk)
+
+
+def bme_set_bits_pos_0(reg_data, bitname_msk, data):
+ """
+ Macro to set bits starting from position 0
+ set masked bits from data in reg_data
+ """
+ return (reg_data & ~bitname_msk) | (data & bitname_msk)
+
+
+class GasHeaterException(Exception):
This looks like a hyperspecific exception that could just be replaced
with something like |OSError|, most likely.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + if (heater_temp == 0) or (heater_time == 0):
+ return False
This could be:
⬇️ Suggested change
- if (heater_temp == 0) or (heater_time == 0):
- return False
+ if not heater_temp or not heater_time:
+ return False
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + op_mode: UINT8 = _BME68X_FORCED_MODE
+ # restrict to enable = True
+ enable: bool = True
+ nb_conv: UINT8 = 0
+ hctrl: UINT8 = _BME68X_ENABLE_HEATER
+ run_gas: UINT8 = 0
+ ctrl_gas_data_0: UINT8 = 0
+ ctrl_gas_data_1: UINT8 = 0
+ ctrl_gas_addr_0: UINT8 = _BME68X_REG_CTRL_GAS_0
+ ctrl_gas_addr_1: UINT8 = _BME68X_REG_CTRL_GAS_1
I think this is using a lot of local variables where using what they
equate to might be more efficient. This comment holds for the other
methods as well.
------------------------------------------------------------------------
In contributors.md
<#61 (comment)>:
> +# SPDX-FileCopyrightText: 2017 ladyada for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+
+Contributors to Adafruit_CircuitPython_BME680_modified
+=============================================================
+
+Limor (Ladyada) Fried
+
+William Garber
+many others
It might be worth just adding contributors' names to the SPDX headers
as opposed to using a contribuitors file (for consistency reason).
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> + except GasHeaterException as exc:
+ raise exc
Since the exception is just being passed through, I don't think
there's a need to |try| the above block. There's another instance of
this below as well.
------------------------------------------------------------------------
In adafruit_bme680.py
<#61 (comment)>:
> @@ -116,6 +152,43 @@
)
+# garberw added begin ===========================
There's a few comments like these.
—
Reply to this email directly, view it on GitHub
<#61 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKX5GECXQBGG673ZB6DXBH3XJZC6FANCNFSM6AAAAAAV4Z3FHQ>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Ah, I apologize, I did not realize at the time that this wasn't a request for review, but the merging. No worriies, if you'd like to address it, I would open a new PR. Otherwise, it can be a TODO for later :) |
I am new to github so I do not know how this works.
…On 6/5/23 5:15 PM, Alec Delaney wrote:
Ah, I apologize, I did not realize at the time that this wasn't a
request for review, but the merging. No worriies, if you'd like to
address it, I would open a new PR. Otherwise, it can be a TODO for
later :)
—
Reply to this email directly, view it on GitHub
<#61 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKX5GEFOC4SNSSBJUKXVRADXJZZDRANCNFSM6AAAAAAV4Z3FHQ>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.5.0 from 3.4.13: > Merge pull request adafruit/Adafruit_CircuitPython_BME680#61 from garberw/main Updating https://github.com/adafruit/Adafruit_CircuitPython_Crickit to 2.3.15 from 2.3.14: > Merge pull request adafruit/Adafruit_CircuitPython_Crickit#37 from OptionalLion411/main Updating https://github.com/adafruit/Adafruit_CircuitPython_MatrixKeypad to 1.2.14 from 1.2.13: > Merge pull request adafruit/Adafruit_CircuitPython_MatrixKeypad#16 from gtbcoding/isssue/13-type-annotation Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Sorry for the confusion on this one, I can make a follow up PR with those suggested changes |
translated Bosch code from .cpp to python. Not sure about license.
Having trouble with code checks in pull request and how to fix them and resubmit.