Skip to content

Commit

Permalink
only update oled when new text
Browse files Browse the repository at this point in the history
  • Loading branch information
ArendJan committed Jul 1, 2024
1 parent 1bbbd04 commit 20b3aa0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mirte_telemetrix/scripts/modules/Oled.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async def start_int(self):
)
self.default_image = True
self.default_timer = rospy.Timer(rospy.Duration(10), self.show_default)
self.last_text = ""
await self.show_default_async()

async def show_default_async(self):
Expand Down Expand Up @@ -71,7 +72,11 @@ async def show_default_async(self):

async def set_oled_image_service_async(self, req):
if req.type == "text":
return await self.set_oled_text_async(req.value.replace("\\n", "\n"))
text = req.value.replace("\\n", "\n")
if text == self.last_text:
return True
self.last_text = text
return await self.set_oled_text_async(text)
if req.type == "image":
return await self.show_png(
"/usr/local/src/mirte/mirte-oled-images/images/" + req.value + ".png"
Expand Down

0 comments on commit 20b3aa0

Please sign in to comment.