Skip to content

Commit 055b1f4

Browse files
authored
Merge pull request #7 from dastels/master
Add support for changing cursor bitmap.
2 parents 123d348 + c8020dc commit 055b1f4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

adafruit_cursorcontrol/cursorcontrol.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ def __init__(self, display=None, display_group=None, bmp=None, is_hidden=False,
7373
self._is_hidden = is_hidden
7474
self._display_grp = display_group
7575
self._disp_sz = display.height - 1, display.width - 1
76+
self._cur_sprite = None
7677
if bmp is None:
77-
bmp = self._default_cursor_bitmap()
78+
self._cursor_bitmap = self._default_cursor_bitmap()
79+
else:
80+
self._cursor_bitmap = bmp
7881
self.generate_cursor(bmp)
7982
# pylint: enable=too-many-arguments,line-too-long
8083

@@ -208,6 +211,23 @@ def _default_cursor_bitmap(self):
208211
return bmp
209212
#pylint:enable=no-self-use
210213

214+
@property
215+
def cursor_bitmap(self):
216+
"""Return the cursor bitmap."""
217+
return self._cursor_bitmap
218+
219+
@cursor_bitmap.setter
220+
def cursor_bitmap(self, bmp):
221+
"""Set a new cursor bitmap.
222+
223+
:param bmp: A Bitmap to use for the cursor
224+
"""
225+
self._cursor_bitmap = bmp
226+
self._cursor_grp.remove(self._cur_sprite)
227+
self._cur_sprite = displayio.TileGrid(bmp,
228+
pixel_shader=self._cur_palette)
229+
self._cursor_grp.append(self._cur_sprite)
230+
211231
def generate_cursor(self, bmp):
212232
"""Generates a cursor icon"""
213233
self._is_deinited()

0 commit comments

Comments
 (0)