changeset 1198:971462233d15

fix screen timing corruption, hopefully. add py client Ignore-this: 53f42a30bbc5d9047658fef6ff79637c darcs-hash:91af2c8b3b8fce208c5a0eb460de095754a80424
author drewp <drewp@bigasterisk.com>
date Sat, 19 Jan 2019 12:12:06 -0800
parents d8acab2b01f5
children 87283af13f15
files service/tinyScreen/Dockerfile service/tinyScreen/makefile service/tinyScreen/requirements.txt service/tinyScreen/tiny_screen.py
diffstat 4 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/service/tinyScreen/Dockerfile	Sat Jan 19 12:08:59 2019 -0800
+++ b/service/tinyScreen/Dockerfile	Sat Jan 19 12:12:06 2019 -0800
@@ -4,6 +4,7 @@
 
 COPY requirements.txt ./
 RUN pip install -r requirements.txt
+RUN pip install pygame
 
 COPY font ./font
 COPY anim ./anim
--- a/service/tinyScreen/makefile	Sat Jan 19 12:08:59 2019 -0800
+++ b/service/tinyScreen/makefile	Sat Jan 19 12:12:06 2019 -0800
@@ -4,8 +4,10 @@
 TAG=bang6:5000/${JOB}_x86:latest
 TAG_PI=bang6:5000/${JOB}_pi:latest
 
-push:
+push_x86:
 	docker push ${TAG}
+push_pi:
+	docker push ${TAG_PI}
 
 build_x86:
 	rm -rf tmp_ctx
@@ -14,7 +16,7 @@
 	docker build --network=host -t ${TAG} tmp_ctx
 	rm -rf tmp_ctx
 
-build_image: build_x86 push
+build_image: build_x86 push_x86
 
 build_pi:
 	rm -rf tmp_ctx
@@ -23,10 +25,12 @@
 	docker build -f Dockerfile.pi --network=host -t ${TAG_PI} tmp_ctx
 	rm -rf tmp_ctx
 
-build_image_pi: build_pi push
+build_image_pi: build_pi push_pi
 
 shell:
 	docker run --rm -it --cap-add SYS_PTRACE --net=host $(TAG) /bin/sh
 
 local_run: build_x86
 	docker run --rm -it --net=host -e DISPLAY=$(DISPLAY) -e HOME=$(HOME) -v $(HOME):$(HOME) -v /tmp/.X11-unix:/tmp/.X11-unix -v `pwd`/index.html:/opt/index.html bang6:5000/tiny_screen_x86:latest python ./tiny_screen.py -v -x
+
+# try pi kernel 20181112-1
--- a/service/tinyScreen/requirements.txt	Sat Jan 19 12:08:59 2019 -0800
+++ b/service/tinyScreen/requirements.txt	Sat Jan 19 12:12:06 2019 -0800
@@ -3,4 +3,3 @@
 cyclone
 https://projects.bigasterisk.com/rdfdb/rdfdb-0.6.0.tar.gz
 rdflib-jsonld==0.3
-pygame
--- a/service/tinyScreen/tiny_screen.py	Sat Jan 19 12:08:59 2019 -0800
+++ b/service/tinyScreen/tiny_screen.py	Sat Jan 19 12:12:06 2019 -0800
@@ -18,13 +18,19 @@
     def __init__(self, spiDevice=1, rotation=0):
         self._initOutput(spiDevice, rotation)
         self.news = ""
+        self.goalState = None
         self.animateTo(ROOM['boot'])
 
     def _stateImage(self, state):
         return Image.open('anim/%s.png' % state.rsplit('/')[-1])
         
     def _initOutput(self, spiDevice, rotation):
-        self._dev = ssd1331(spi(device=spiDevice, port=0), rotation=rotation)
+        self._dev = ssd1331(spi(device=spiDevice, port=0,
+                                # lots of timeouts on the 12288-byte transfer without this
+                                transfer_size=64,
+                                bus_speed_hz=16000000,
+                                gpio_RST=None),
+                            rotation=rotation)
         
     def setContrast(self, contrast):
         """0..255"""
@@ -38,7 +44,7 @@
         self._dev.show()
 
     def display(self, img):
-        self._dev.display(img)
+        self._dev.display(img.convert(self._dev.mode))
 
     def animateTo(self, state):
         """
@@ -48,12 +54,16 @@
         lockedUnknownKey
         unlockNews
         """
+        if self.goalState == state:
+            return
         self.goalState = state
         self.display(self._stateImage(state))
         if state == ROOM['unlockNews']:
             self.renderNews()
 
     def setNews(self, text):
+        if self.news == text:
+            return
         self.news = text
         if self.goalState == ROOM['unlockNews']:
             # wrong during animation
@@ -71,7 +81,7 @@
         self.display(bg)
         
 class ScreenSim(Screen):
-    def _initOutput(self, spiDevice, rotation):
+    def _initOutput(self):
         self.windowScale = 2
         import pygame
         self.pygame = pygame