]> git.llucax.com Git - z.facultad/66.09/etherled.git/commitdiff
Se parsea la matriz de leds convirtiendola a un stream de bytes.
authorLeandro Lucarella <llucax@gmail.com>
Sat, 29 Oct 2005 03:57:29 +0000 (03:57 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Sat, 29 Oct 2005 03:57:29 +0000 (03:57 +0000)
cliente/cetherled.glade [moved from cliente/etherled.glade with 100% similarity]
cliente/cetherled.py [moved from cliente/etherled.py with 69% similarity]

similarity index 69%
rename from cliente/etherled.py
rename to cliente/cetherled.py
index d76676862f3440dd9f6fbae87e0bee44f1a19f90..dfc15f72396f0e7a4f18fcf0d527732d523f01ae 100755 (executable)
@@ -31,7 +31,7 @@ from simplegladeapp import bindtextdomain
 from dispatcher import Dispatcher
 from led import Led
 
-app_name = "etherled"
+app_name = "cetherled"
 app_version = "1.0"
 glade_dir = ""
 locale_dir = ""
@@ -41,25 +41,56 @@ bindtextdomain(app_name, locale_dir)
 
 class MainWindow(SimpleGladeApp):
 
-    def __init__(self, path="etherled.glade", root="main_window",
+    def __init__(self, path="cetherled.glade", root="main_window",
             domain=app_name, **kwargs):
         #notificar = Dispatcher(self.actualizar)
         path = os.path.join(glade_dir, path)
         SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
 
     def new(self):
+        self.tabla = {}
         for i in xrange(16):
             for j in xrange(16):
                 led = Led()
                 self.table_leds.attach(led, i, i+1, j, j+1)
                 led.show()
+                self.tabla[i,j] = led
 
     def on_btn_salir_clicked(self, widget, *args):
         self.quit()
 
+    def on_btn_enviar_clicked(self, widget, *args):
+        print self.tabla_a_stream()
+
     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 main():