Skip to content

Commit 5b31b95

Browse files
authored
Merge pull request #5 from Windham-High-School/4-add-battery-level-datapoint-to-api-wrapper
Added BatteryLevel datapoint
2 parents e3c208c + 2af8b8f commit 5b31b95

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

servercom/implementations/circuitpy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def basic_auth_str(user: str, pwd: str) -> str:
2525
HUMIDITY = "humidity",
2626
PRESSURE = "pressure",
2727
LIGHT_INTENSITY = "light intensity",
28-
COMMENT = "comment"
28+
COMMENT = "comment",
29+
BATTERY = "remaining battery"
2930
)
3031

3132
class DataPoint():
@@ -84,6 +85,12 @@ class Text(DataPoint):
8485
def __init__(self, value: str):
8586
super().__init__(DataClass.COMMENT, value)
8687

88+
class BatteryLevel(DataPoint):
89+
"""A class reserved for DataPoints that are intended as an indication of battery level"""
90+
UNIT="%" # No unit for regular strings of text
91+
def __init__(self, value: int):
92+
super().__init__(DataClass.BATTERY, value)
93+
8794
class ConnectionError(Exception):
8895
"""Indicates an issue with the server connection"""
8996

servercom/implementations/cpy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DataClass(str, Enum):
2121
PRESSURE = "pressure"
2222
LIGHT_INTENSITY = "light intensity"
2323
COMMENT = "comment"
24+
BATTERY = "remaining battery"
2425

2526
class DataPoint():
2627
"""A class for storing and handling datapoints"""
@@ -78,6 +79,12 @@ class Text(DataPoint):
7879
def __init__(self, value: str):
7980
super().__init__(DataClass.COMMENT, value)
8081

82+
class BatteryLevel(DataPoint):
83+
"""A class reserved for DataPoints that are intended as an indication of battery level"""
84+
UNIT="%" # No unit for regular strings of text
85+
def __init__(self, value: int):
86+
super().__init__(DataClass.BATTERY, value)
87+
8188
class ConnectionError(Exception):
8289
"""Indicates an issue with the server connection"""
8390

0 commit comments

Comments
 (0)