Skip to content

Commit a696788

Browse files
committed
add hibernation thresh
1 parent 6c2af7d commit a696788

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

adafruit_max1704x.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,14 @@ def activity_threshold(self, threshold_voltage):
107107
raise ValueError("Activity voltage change must be between 0 and 0.31875 Volts")
108108
self._hibrt_actthr = int(threshold_voltage / 0.00125) # 1.25mV per LSB
109109

110+
111+
@property
112+
def hibernation_threshold(self):
113+
return self._hibrt_hibthr * 0.208 # 0.208% per hour
114+
115+
@hibernation_threshold.setter
116+
def hibernation_threshold(self, threshold_percent):
117+
if (not 0 <= threshold_percent <= (255 * 0.208)):
118+
raise ValueError("Activity percentage/hour change must be between 0 and 53%")
119+
self._hibrt_hibthr = int(threshold_percent / 0.208) # 0.208% per hour
120+

examples/max1704x_simpletest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616

1717
print("Found MAX1704x with chip version", hex(max17.chip_version))
1818

19-
max17.activity_threshold = 0.1
20-
print("MAX1704x activity threshold = %0.2f V" % max17.activity_threshold)
19+
#max17.activity_threshold = 0.15
20+
#print("MAX1704x activity threshold = %0.2f V" % max17.activity_threshold)
21+
22+
max17.hibernation_threshold = 5
23+
print("MAX1704x hibernation threshold = %0.2f %%" % max17.hibernation_threshold)
2124

2225

2326
while True:

0 commit comments

Comments
 (0)