X-Git-Url: https://git.llucax.com/z.facultad/66.09/etherled.git/blobdiff_plain/fae303596327eb5c23ce9649a2d93994fc2b7748..cf711545839c42cd01d385f5d474099a590b7cfd:/cliente/cetherled.py?ds=inline diff --git a/cliente/cetherled.py b/cliente/cetherled.py index dfc15f7..7f41608 100755 --- a/cliente/cetherled.py +++ b/cliente/cetherled.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: iso-8859-1 -*- # vim: set expandtab tabstop=4 shiftwidth=4 : #---------------------------------------------------------------------------- # Etherled @@ -28,8 +27,9 @@ import os import gtk from simplegladeapp import SimpleGladeApp from simplegladeapp import bindtextdomain -from dispatcher import Dispatcher +#from dispatcher import Dispatcher from led import Led +import etherled app_name = "cetherled" app_version = "1.0" @@ -38,12 +38,12 @@ locale_dir = "" bindtextdomain(app_name, locale_dir) - class MainWindow(SimpleGladeApp): def __init__(self, path="cetherled.glade", root="main_window", domain=app_name, **kwargs): #notificar = Dispatcher(self.actualizar) + self.device = etherled.NetworkedDevice() path = os.path.join(glade_dir, path) SimpleGladeApp.__init__(self, path, root, domain, **kwargs) @@ -52,7 +52,7 @@ class MainWindow(SimpleGladeApp): for i in xrange(16): for j in xrange(16): led = Led() - self.table_leds.attach(led, i, i+1, j, j+1) + self.table_leds.attach(led, j, j+1, i, i+1) led.show() self.tabla[i,j] = led @@ -60,38 +60,25 @@ class MainWindow(SimpleGladeApp): self.quit() def on_btn_enviar_clicked(self, widget, *args): - print self.tabla_a_stream() + self.device.matrix = self.leds2matrix() + + def on_btn_recibir_clicked(self, widget, *args): + matrix = self.device.matrix + for row in xrange(16): + for col in xrange(16): + self.tabla[row,col].prendido = matrix[row,col] + etherled.protocol._print_matrix(matrix) def on_main_window_delete_event(self, widget, event, *args): self.quit() - def imprimir_tabla(self, rotada=False): - rango = xrange(16) - if rotada: - rango = xrange(15, -1, -1) - for col in rango: - for row in xrange(16): - print int(self.tabla[col,row].prendido), - print - print - - def imprimir_stream(self, stream): - for i in stream: - print '0x%02x' % i - - def tabla_a_stream(self): - stream = [] - for col in xrange(15, -1, -1): - i = 0 - for row in xrange(8): - i += int(self.tabla[col,row].prendido) << row - stream.append(i) - i = 0 - for row in xrange(8, 16): - i += int(self.tabla[col,row].prendido) << row - stream.append(i) - return stream - + def leds2matrix(self): + matrix = {} + for row in xrange(16): + for col in xrange(16): + matrix[row,col] = int(self.tabla[row,col].prendido) + etherled.protocol._print_matrix(matrix) + return matrix def main(): gtk.threads_init() @@ -100,7 +87,6 @@ def main(): main_window.run() gtk.threads_leave() - if __name__ == '__main__': main()