-
Notifications
You must be signed in to change notification settings - Fork 88
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
Re-Enable the battery monitoring on Enviro! 🥳 #146
Open
PascalKern
wants to merge
7
commits into
pimoroni:main
Choose a base branch
from
PascalKern:my_develop/fix_vsys_sensing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
96a4013
Adds utils and new impl. of battery voltage collecting (plus cpu temp…
e7b88c4
Adds feature toggle for sending the battery voltage and cpu temperatu…
893e587
Moves the feature toggles in the config file to a little "better" pos…
3ebd780
Removes code not related to the vsys sensing (this branch)
57944ae
Removes not yet implemented (and not fully related to this branch) fu…
16d240c
Removes overseen code pieces from other branches/tries not related to…
85914fa
Removes issue comment and fixes lost (rebasing) config backwards comp…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import machine | ||
|
||
ADC_VOLT_CONVERSATION = 3.3 / 65535 | ||
|
||
|
||
def set_pad(gpio, value): | ||
machine.mem32[0x4001c000 | (4 + (4 * gpio))] = value | ||
|
||
|
||
def get_pad(gpio): | ||
return machine.mem32[0x4001c000 | (4 + (4 * gpio))] | ||
|
||
|
||
def get_battery_voltage(): | ||
old_pad = get_pad(29) | ||
set_pad(29, 128) # no pulls, no output, no input | ||
|
||
sample_count = 10 | ||
battery_voltage = 0 | ||
for i in range(0, sample_count): | ||
battery_voltage += _read_vsys_voltage() | ||
battery_voltage /= sample_count | ||
battery_voltage = round(battery_voltage, 3) | ||
set_pad(29, old_pad) | ||
return battery_voltage | ||
|
||
|
||
def _read_vsys_voltage(): | ||
adc_Vsys = machine.ADC(3) | ||
return adc_Vsys.read_u16() * 3.0 * ADC_VOLT_CONVERSATION |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
(And below, appears to be a sneaky typo. :) I hope this gets merged for v0.0.11!)