-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor hw initialization so that we can shut down the digipot as so…
…on as the app is launched, fixes #4
- Loading branch information
Showing
3 changed files
with
36 additions
and
29 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
|
||
os.environ["BLINKA_MCP2221"] = "1" | ||
|
||
try: | ||
import board | ||
import busio | ||
except RuntimeError: | ||
print("Titler not conneted to USB!") | ||
|
||
|
||
def hardware_setup(): | ||
# from adafruit_blinka.microcontroller.mcp2221 import mcp2221 | ||
# mcp2221.mcp2221.gp_set_mode(3, 0b001) # turn LED_I2C on | ||
from adafruit_bus_device.i2c_device import I2CDevice | ||
i2c = busio.I2C(board.SCL, board.SDA) | ||
pot = I2CDevice(i2c, 0x2C) | ||
return pot | ||
|
||
|
||
def write_to_pot(value, pot): | ||
pot.write(bytes([0x00 & 0xff, value & 0xff])) | ||
|
||
|
||
def shutdown_pot(pot): | ||
pot.write(bytes([0x20 & 0xff, 0 & 0xff])) |
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