Created
April 20, 2017 22:57
-
-
Save matham/60292ff82021bdfc848e42bfb150965b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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