Skip to content

Commit

Permalink
Merge pull request #20 from ArendJan/mirte-master-dev
Browse files Browse the repository at this point in the history
Update oled, only write on upd, fix import missing
  • Loading branch information
ArendJan authored Jul 2, 2024
2 parents 2cde993 + a6c6f4a commit d33cdd5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mirte_telemetrix/scripts/modules/Oled.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from mirte_msgs.srv import SetOLEDImage, SetOLEDImageRequest, SetOLEDImageResponse
import subprocess
import asyncio
import os

# Extended adafruit _SSD1306

Expand All @@ -26,6 +27,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 +73,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 d33cdd5

Please sign in to comment.