Skip to content

Instantly share code, notes, and snippets.

@matham
Created April 20, 2017 22:57
Show Gist options
  • Save matham/60292ff82021bdfc848e42bfb150965b to your computer and use it in GitHub Desktop.
Save matham/60292ff82021bdfc848e42bfb150965b to your computer and use it in GitHub Desktop.
from os import environ
environ['KIVY_CLOCK'] = 'interrupt'
environ['SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS'] = '0'
from time import clock
from kivy.uix.label import Label
from kivy.app import App
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.graphics import Color, Point, Fbo, Rectangle
from kivy.graphics.texture import Texture
from kivy.graphics.opengl import glEnable, GL_DITHER, glDisable
from pypixxlib.propixx import PROPixx
from pypixxlib.propixx import PROPixxCTRL
class MyApp(App):
t = clock()
count = 0
label = None
flip = 0
def build(self):
Clock.schedule_interval(self.tick, 0)
Window.fbind('on_flip', self.flippy)
self.label = Label(text='0')
with self.label.canvas:
Color(1, 1, 1, 1)
tex = self.tex = Texture.create(size=(1, 1))
tex.mag_filter = 'nearest'
tex.min_filter = 'nearest'
Rectangle(texture=tex, pos=(0, 1080 - 1), size=(1, 1))
Clock.schedule_once(self.laters, 5)
return self.label
def laters(self, *largs):
glDisable(GL_DITHER)
glDisable(0x809D)
Window.left = -1000
Window.maximize()
Window.size = 1920, 1080
Window.fullscreen = True
Window.clearcolor = (0, 0, 0, 1)
def tick(self, *largs):
t = clock()
#self.tex.blit_buffer(
# bytearray([self.count % 16, self.count % 2, 0]), colorfmt='rgb', bufferfmt='ubyte')
val = (self.count % 16) + (self.count % 2 << 8)
ctrl.dout.setBitValue(val, 0xFFFFFF)
ctrl.updateRegisterCache()
self.count += 1
self.label.text = str(int(self.label.text) + 1)
if t - self.t >= 1:
#print(self.count / (t - self.t), self.count - self.flip)
self.t = t
self.flip = 0
self.count = 0
def flippy(self, *largs):
self.flip += 1
if __name__ == '__main__':
dev = PROPixx()
ctrl = PROPixxCTRL()
ctrl.dout.disablePixelMode()
#ctrl.dout.enablePixelMode()
#ctrl.updateRegisterCache()
MyApp().run()
ctrl.close()
dev.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment