Skip to content

Commit 0502b1b

Browse files
committed
Update to support 1.0.1
1 parent 5ab7ef9 commit 0502b1b

File tree

7 files changed

+66
-27
lines changed

7 files changed

+66
-27
lines changed

animatedledstrip/als_http_client.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
if TYPE_CHECKING:
2929
from animatedledstrip.animation_info import AnimationInfo
3030
from animatedledstrip.animation_to_run_params import AnimationToRunParams
31+
from animatedledstrip.new_animation_group_info import NewAnimationGroupInfo
3132
from animatedledstrip.running_animation_params import RunningAnimationParams
3233
from animatedledstrip.section import Section
3334
from animatedledstrip.strip_info import StripInfo
@@ -58,9 +59,6 @@ def _delete_data(self, url: str) -> Any:
5859
def get_animation_info(self, anim_name: str) -> 'AnimationInfo':
5960
return self.decoder.decode_object_with_type(self._get_data('/animation/' + anim_name), 'AnimationInfo')
6061

61-
def get_supported_animations_names(self) -> List[str]:
62-
return json.loads(self._get_data('/animations/names'))
63-
6462
def get_supported_animations(self) -> List['AnimationInfo']:
6563
return self.decoder.decode_list_with_type(self._get_data('/animations'), 'AnimationInfo')
6664

@@ -70,6 +68,12 @@ def get_supported_animations_map(self) -> Dict[str, 'AnimationInfo']:
7068
def get_supported_animations_dict(self) -> Dict[str, 'AnimationInfo']:
7169
return self.get_supported_animations_map()
7270

71+
def get_supported_animations_names(self) -> List[str]:
72+
return json.loads(self._get_data('/animations/names'))
73+
74+
def create_new_group(self, new_group: 'NewAnimationGroupInfo'):
75+
return self.decoder.decode_object_with_type(self._post_data('/animations/newGroup', new_group), 'AnimationInfo')
76+
7377
def get_running_animations(self) -> Dict[str, 'RunningAnimationParams']:
7478
return self.decoder.decode_map_with_type(self._get_data('/running'), 'RunningAnimationParams')
7579

@@ -82,36 +86,36 @@ def get_running_animation_params(self, anim_id: str) -> 'RunningAnimationParams'
8286
def end_animation(self, anim_id: str) -> 'RunningAnimationParams':
8387
return self.decoder.decode_object_with_type(self._delete_data('/running/' + anim_id), 'RunningAnimationParams')
8488

85-
def end_animation_from_params(self, anim_params: 'RunningAnimationParams') -> 'RunningAnimationParams':
86-
return self.end_animation(anim_params.anim_id)
89+
def get_section(self, section_name: str) -> 'Section':
90+
return self.decoder.decode_object_with_type(self._get_data('/sections/' + section_name), 'Section')
8791

8892
def get_sections(self) -> List['Section']:
8993
return self.decoder.decode_list_with_type(self._get_data('/sections'), 'Section')
9094

95+
def create_new_section(self, new_section: 'Section') -> 'Section':
96+
return self.decoder.decode_object_with_type(self._post_data('/sections', new_section), 'Section')
97+
9198
def get_sections_map(self) -> Dict[str, 'Section']:
9299
return self.decoder.decode_map_with_type(self._get_data('/sections/map'), 'Section')
93100

94101
def get_sections_dict(self) -> Dict[str, 'Section']:
95102
return self.get_sections_map()
96103

97-
def get_section(self, section_name: str) -> 'Section':
98-
return self.decoder.decode_object_with_type(self._get_data('/sections/' + section_name), 'Section')
99-
100-
def get_full_strip_section(self) -> 'Section':
101-
return self.get_section('fullStrip')
102-
103-
def create_new_section(self, new_section: 'Section') -> 'Section':
104-
return self.decoder.decode_object_with_type(self._post_data('/sections', new_section), 'Section')
105-
106104
def start_animation(self, anim_params: 'AnimationToRunParams') -> 'RunningAnimationParams':
107105
return self.decoder.decode_object_with_type(self._post_data('/start', anim_params), 'RunningAnimationParams')
108106

109-
def get_strip_info(self) -> 'StripInfo':
110-
return self.decoder.decode_object_with_type(self._get_data('/strip/info'), 'StripInfo')
107+
def clear_strip(self):
108+
# TODO: Fix 404
109+
self._post_data('/strip/clear', None)
111110

112111
def get_current_strip_color(self) -> List[int]:
113112
return json.loads(self._get_data('/strip/color'))
114113

115-
def clear_strip(self):
116-
# TODO: Fix 404
117-
self._post_data('/strip/clear', None)
114+
def get_strip_info(self) -> 'StripInfo':
115+
return self.decoder.decode_object_with_type(self._get_data('/strip/info'), 'StripInfo')
116+
117+
def end_animation_from_params(self, anim_params: 'RunningAnimationParams') -> 'RunningAnimationParams':
118+
return self.end_animation(anim_params.anim_id)
119+
120+
def get_full_strip_section(self) -> 'Section':
121+
return self.get_section('fullStrip')

animatedledstrip/animation_info.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from typing import List, Optional, Dict
2222

2323

24-
class AnimationParameter(object):
24+
class AnimationParameter:
2525
"""Specifies an animation parameter that can be sent to an animation"""
2626

2727
def __init__(self, name: str = '', description: str = '', default=None, data_type=None):
@@ -32,14 +32,13 @@ def __init__(self, name: str = '', description: str = '', default=None, data_typ
3232

3333
def json_dict(self) -> Dict:
3434
return {
35-
'type': 'AnimationParameter',
3635
'name': self.name,
3736
'description': self.description,
3837
'default': self.default,
3938
}
4039

4140

42-
class AnimationInfo(object):
41+
class AnimationInfo:
4342
"""Stores information about an animation the server can run"""
4443

4544
def __init__(self,

animatedledstrip/animation_to_run_params.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from animatedledstrip.rotation import DegreesRotation, RadiansRotation
3030

3131

32-
class AnimationToRunParams(object):
32+
class AnimationToRunParams:
3333
"""Describes the properties of an animation to run"""
3434

3535
def __init__(self,
@@ -92,7 +92,6 @@ def __init__(self,
9292

9393
def json_dict(self) -> Dict:
9494
return {
95-
"type": "AnimationToRunParams",
9695
"animation": self.animation,
9796
"colors": self.colors,
9897
"id": self.anim_id,

animatedledstrip/location.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def __init__(self,
3434

3535
def json_dict(self) -> Dict:
3636
return {
37-
'type': 'Location',
3837
'x': self.x,
3938
'y': self.y,
4039
'z': self.z,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) 2018-2021 AnimatedLEDStrip
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
from typing import Dict, List, TYPE_CHECKING
22+
23+
if TYPE_CHECKING:
24+
from animatedledstrip.animation_info import AnimationInfo
25+
26+
27+
class NewAnimationGroupInfo:
28+
"""Stores information about a new animation group to create"""
29+
30+
def __init__(self, group_type: str, group_info: 'AnimationInfo', animation_list: List[str]):
31+
self.group_type: str = group_type
32+
self.group_info: 'AnimationInfo' = group_info
33+
self.animation_list: List[str] = animation_list
34+
35+
def json_dict(self) -> Dict:
36+
return {
37+
"groupType": self.group_type,
38+
"groupInfo": self.group_info,
39+
"animationList": self.animation_list,
40+
}

animatedledstrip/running_animation_params.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def __init__(self,
9595

9696
def json_dict(self) -> Dict:
9797
return {
98-
"type": "RunningAnimationParams",
9998
"animationName": self.animation_name,
10099
"colors": self.colors,
101100
"id": self.anim_id,

animatedledstrip/section.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __init__(self,
3838

3939
def json_dict(self) -> Dict:
4040
return {
41-
'type': 'Section',
4241
'name': self.name,
4342
'pixels': self.pixels,
4443
'parentSectionName': self.parent_section_name,

0 commit comments

Comments
 (0)