Author: Paul_R
Date: 2008-06-23 15:13:51 +0200 (Mon, 23 Jun 2008)
New Revision: 1248

Modified:
   software/tuxgi/trunk/tuxgi.py
   software/tuxgi/trunk/tuxgi2.glade
Log:
* Added the sound flash functions.
  The functions for the microphone aren't implemented yet

* Fix a bug with the led function


Modified: software/tuxgi/trunk/tuxgi.py
===================================================================
--- software/tuxgi/trunk/tuxgi.py       2008-06-23 12:32:00 UTC (rev 1247)
+++ software/tuxgi/trunk/tuxgi.py       2008-06-23 13:13:51 UTC (rev 1248)
@@ -324,7 +324,6 @@
 # -----------------------------------------------------------------------------
 # Tab "main" events
 # -----------------------------------------------------------------------------
-
     #--------------------------------------------------------------------------
     # On left led checkbox toggled
     #--------------------------------------------------------------------------
@@ -351,12 +350,9 @@
     # On flash leds button clicked
     #--------------------------------------------------------------------------
     def on_flash_bt_clicked(self, widget, *args):
-        def _funct():
-            num_sb=self.get_widget("spinbutton1")
-            # XXX New command with counter
-            tux.led.both.blinkAsync(SPV_NORMAL, 1.0)
+        num_sb=self.get_widget("spinbutton1").get_value()
+        tux.led.both.blinkAsync(SPV_NORMAL, int(num_sb))
 
-        thread.start_new_thread(_funct,())
 
     #--------------------------------------------------------------------------
     # On eyes open radiobutton toggled
@@ -562,224 +558,154 @@
     # On "play" external wave file button clicked
     #--------------------------------------------------------------------------
     def on_wave_external_play_bt_clicked(self, widget, *args):
-        print "FIXME :: play external : not implemented yet"
-        '''
         if str(self.get_widget("filechooserbutton1").get_filename())=="None": 
return
-        tux.sys.shell_free("aplay -D %s %s"% (soundcard,
-        self.get_widget("filechooserbutton1").get_filename()))
-        '''
+        tux.wav.play(self.get_widget("filechooserbutton1").get_filename())
+    
     #--------------------------------------------------------------------------
     # On select original sounds
     #--------------------------------------------------------------------------
     def on_incl_orig_toggled(self, widget, *args):
-        print "FIXME :: Original waves : not implemented yet"
-        '''
-        st_wav_paths = wavs.wav_paths
         if widget.get_active():
-            wavs.wav_paths=[]
-            wavs.wav_sizes=[]
+            self.wav_list = []
             for i in range(17):
-                
wavs.add_wav_path('/opt/tuxdroid/apps/tuxgi/sounds/%d.wav'%(i+1))
-            for path in st_wav_paths:
-                wavs.add_wav_path(path)
+                self.wav_list.append('/opt/tuxdroid/tuxgi/sounds/%d.wav'%(i+1))
         else:
-            if len(st_wav_paths) > 17:
+            if len(self.wav_list) > 17:
                 for i in range(17):
-                    wavs.wav_sizes.pop(0)
-                    wavs.wav_paths.pop(0)
+                    self.wav_list.pop(0)
             else:
-                wavs.wav_paths=[]
-                wavs.wav_sizes=[]
+                self.wav_list = []
         self.refresh_wav_list()
-        '''
 
     #--------------------------------------------------------------------------
     # On select internal wave file event
     #--------------------------------------------------------------------------
     def on_wave_internal_changed(self, widget, *args):
-        print "FIXME :: Internal waves : not implemented yet"
-        '''
         filename=widget.get_filename()
         ext=len(filename)-filename.find(".wav")
         if ext != 4 :
             widget.unselect_filename(filename)
-        '''
 
     #--------------------------------------------------------------------------
     # On "add" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_add_bt_clicked(self, widget, *args):
-        print "FIXME :: Add sound : not implemented yet"
-        '''
         if str(self.get_widget("filechooserbutton2").get_filename())=="None": 
return
-        wavs.add_wav_path(self.get_widget("filechooserbutton2").get_filename())
+        
self.wav_list.append(self.get_widget("filechooserbutton2").get_filename())
         self.refresh_wav_list()
-        '''
+        
 
     #--------------------------------------------------------------------------
     # On "remove" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_remove_bt_clicked(self, widget, *args):
-        print "FIXME :: Remove sound : not implemented yet"
-        '''
         index=int(self.get_widget("spinbutton8").get_value())
-        if index>len(wavs.wav_paths):return
-        wavs.wav_sizes.pop(index-1)
-        wavs.wav_paths.pop(index-1)
+        if index>len(self.wav_list):return
+        self.wav_list.pop(index-1)
         self.refresh_wav_list()
-        '''
 
     #--------------------------------------------------------------------------
     # Refreshing wave list function
     #--------------------------------------------------------------------------
     def refresh_wav_list(self):
-        print "FIXME :: Clear list : not implemented yet"
-        '''
         wav_te=self.get_widget("textview3")
         wav_buffer=wav_te.get_buffer()
         wav_buffer.set_text("")
         i=1
-        for wavfile in wavs.wav_paths:
+        for wavfile in self.wav_list:
             filename=wavfile[wavfile.rfind('/')+1:]
             wav_buffer.insert(wav_buffer.get_end_iter(),"%.2d : %s\n" 
%(i,filename))
             i=i+1
-        '''
 
     #--------------------------------------------------------------------------
     # On "clear" internal wave file list button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_clist_bt_clicked(self, widget, *args):
-        print "FIXME :: Internal sounds : not implemented yet"
-        '''
-        wavs.wav_sizes=[]
-        wavs.wav_paths=[]
+        self.wav_list = []
         self.get_widget("checkbutton4").set_active(False)
         self.refresh_wav_list()
-        '''
 
     #--------------------------------------------------------------------------
     # On "store" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_store_bt_clicked(self, widget, *args):
-        print "FIXME :: Store waves : not implemented yet"
-        #thread.start_new_thread(self.sound_storing,())
+        thread.start_new_thread(self.sound_storing,())
 
     #--------------------------------------------------------------------------
     # Store sound function
     #--------------------------------------------------------------------------
     def sound_storing(self):
-        print "FIXME :: Sound storing : not implemeted yet"
-        '''
-        if tux.status.rf_state() == 0: return
-        if len(wavs.wav_sizes)==0: return
-        wav_te=self.get_widget("textview3")
-        wav_buffer=wav_te.get_buffer()
-        if not wavs.wavs_merging("merged.wav"):
-            print wav_buffer.insert(wav_buffer.get_end_iter(),
-            "Sound storing : Error : file merged is too big\n")
-            return
-        wav_buffer.insert(wav_buffer.get_end_iter(),
-        "Sound storing : Erase flash\n")
-        tux.cmd.sound_storing(len(wavs.wav_sizes))
-        tux.sys.wait(10)
-        current_pos=0x0400
-        tux.sys.wait(0.1)
-        wav_buffer.insert(wav_buffer.get_end_iter(),
-        "Sound storing : Indexes\n")
-        tux.cmd.sound_store_index(0x00,0x04,0x00)
-        for size in wavs.wav_sizes:
-            current_pos=current_pos+size
-            tux.sys.wait(0.1)
-            tux.cmd.sound_store_index((current_pos & 0xFF0000)>>16,
-            (current_pos & 0x00FF00)>>8,current_pos & 0x0000FF)
-        wav_buffer.insert(wav_buffer.get_end_iter(),"Sound storing : Record\n")
-        tux.sys.shell("aplay -D %s merged.wav"%soundcard)
-        wav_buffer.insert(wav_buffer.get_end_iter(),
-        "Sound storing : Storage done.\n")
-        tux.sys.wait(0.3)
-        '''
+        if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_CRITICAL):
+            tux.soundFlash.reflash(self.wav_list)
+        tux.access.release()
+
     #--------------------------------------------------------------------------
     # On "play" flash sound button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play_bt_clicked(self, widget, *args):
-        print "FIXME :: Play internal wave %d : Not implemented yet" \
-                %(self.get_widget("spinbutton7").get_value())
-        '''
-        def _funct():
-            index=self.get_widget("spinbutton7").get_value()
-            tux.cmd.sound_play(int(index),0)
+        index=self.get_widget("spinbutton7").get_value()
+        tux.soundFlash.playAsync(int(index))
 
-        thread.start_new_thread(_funct,())
-        '''
+        
     #--------------------------------------------------------------------------
     # On "play flash sound number 1" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play1_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(1,0,))
+        tux.soundFlash.playAsync(1)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 2" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play2_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(2,0,))
+        tux.soundFlash.playAsync(2)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 3" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play3_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(3,0,))
+        tux.soundFlash.playAsync(3)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 4" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internat_play4_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(4,0,))
+        tux.soundFlash.playAsync(4)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 5" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play5_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(5,0,))
+        tux.soundFlash.playAsync(5)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 6" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play6_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(6,0,))
+        tux.soundFlash.playAsync(6)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 7" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play7_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(7,0,))
+        tux.soundFlash.playAsync(7)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 8" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play8_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(8,0,))
+        tux.soundFlash.playAsync(8)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 9" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play9_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(9,0,))
+        tux.soundFlash.playAsync(9)
 
     #--------------------------------------------------------------------------
     # On "play flash sound number 10" button clicked
     #--------------------------------------------------------------------------
     def on_wave_internal_play10_clicked(self, widget, *args):
-        pass
-        #thread.start_new_thread(tux.cmd.sound_play,(10,0,))
+        tux.soundFlash.playAsync(10)
 
     #--------------------------------------------------------------------------
     # On "Play recorded wave file" button clicked
@@ -827,26 +753,6 @@
     def on_window2_destroy(self, widget, *args):
         print "closed"
 
-    #--------------------------------------------------------------------------
-    # On "Send command" button clicked
-    #--------------------------------------------------------------------------
-    def on_sendcommand_bt_clicked(self, widget, *args):
-        commandst=self.get_widget("entry1").get_text()
-        commands=commandst.split(" ")
-        if len(commands)<4:
-            return
-        else:
-            commandp=[0,0,0,0]
-            for i in range(len(commands)):
-                if commands[i].find("0x")!=-1:
-                    commandp[i]=int(commands[i][2:],16)
-                else:
-                    commandp[i]=int(commands[i])
-            print "FIXME :: Raw command : This function isn't implemented yet"
-            #tux.cmd.raw(int(commandp[0]),int(commandp[1]),int(commandp[2]),
-            #int(commandp[3]))
-
-
 #------------------------------------------------------------------------------
 # Main
 #------------------------------------------------------------------------------

Modified: software/tuxgi/trunk/tuxgi2.glade
===================================================================
--- software/tuxgi/trunk/tuxgi2.glade   2008-06-23 12:32:00 UTC (rev 1247)
+++ software/tuxgi/trunk/tuxgi2.glade   2008-06-23 13:13:51 UTC (rev 1248)
@@ -70,7 +70,7 @@
                          <property name="visible">True</property>
 
                          <child>
-                           <widget class="GtkImage" id="image2">
+                           <widget class="GtkImage" id="image4">
                              <property name="width_request">21</property>
                              <property name="height_request">21</property>
                              <property name="visible">True</property>
@@ -83,12 +83,12 @@
                            </widget>
                            <packing>
                              <property name="x">192</property>
-                             <property name="y">0</property>
+                             <property name="y">39</property>
                            </packing>
                          </child>
 
                          <child>
-                           <widget class="GtkImage" id="image3">
+                           <widget class="GtkImage" id="image2">
                              <property name="width_request">21</property>
                              <property name="height_request">21</property>
                              <property name="visible">True</property>
@@ -101,60 +101,16 @@
                            </widget>
                            <packing>
                              <property name="x">192</property>
-                             <property name="y">24</property>
+                             <property name="y">10</property>
                            </packing>
                          </child>
 
                          <child>
-                           <widget class="GtkImage" id="image4">
-                             <property name="width_request">21</property>
-                             <property name="height_request">21</property>
-                             <property name="visible">True</property>
-                             <property name="stock">gtk-cancel</property>
-                             <property name="icon_size">4</property>
-                             <property name="xalign">0.5</property>
-                             <property name="yalign">0.5</property>
-                             <property name="xpad">0</property>
-                             <property name="ypad">0</property>
-                           </widget>
-                           <packing>
-                             <property name="x">192</property>
-                             <property name="y">48</property>
-                           </packing>
-                         </child>
-
-                         <child>
-                           <widget class="GtkLabel" id="label27">
-                             <property name="width_request">166</property>
-                             <property name="height_request">20</property>
-                             <property name="visible">True</property>
-                             <property name="label" translatable="yes">Radio 
connection</property>
-                             <property name="use_underline">False</property>
-                             <property name="use_markup">False</property>
-                             <property 
name="justify">GTK_JUSTIFY_LEFT</property>
-                             <property name="wrap">True</property>
-                             <property name="selectable">False</property>
-                             <property name="xalign">0.5</property>
-                             <property name="yalign">0.5</property>
-                             <property name="xpad">0</property>
-                             <property name="ypad">0</property>
-                             <property 
name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-                             <property name="width_chars">-1</property>
-                             <property name="single_line_mode">False</property>
-                             <property name="angle">0</property>
-                           </widget>
-                           <packing>
-                             <property name="x">0</property>
-                             <property name="y">48</property>
-                           </packing>
-                         </child>
-
-                         <child>
                            <widget class="GtkLabel" id="label9">
                              <property name="width_request">136</property>
                              <property name="height_request">20</property>
                              <property name="visible">True</property>
-                             <property name="label" translatable="yes">Tux 
Droid daemon</property>
+                             <property name="label" translatable="yes">Tux 
HTTP Server</property>
                              <property name="use_underline">False</property>
                              <property name="use_markup">False</property>
                              <property 
name="justify">GTK_JUSTIFY_LEFT</property>
@@ -171,16 +127,16 @@
                            </widget>
                            <packing>
                              <property name="x">0</property>
-                             <property name="y">0</property>
+                             <property name="y">10</property>
                            </packing>
                          </child>
 
                          <child>
-                           <widget class="GtkLabel" id="label10">
+                           <widget class="GtkLabel" id="label27">
                              <property name="width_request">166</property>
                              <property name="height_request">20</property>
                              <property name="visible">True</property>
-                             <property name="label" translatable="yes">Text To 
Speech daemon</property>
+                             <property name="label" translatable="yes">Radio 
connection</property>
                              <property name="use_underline">False</property>
                              <property name="use_markup">False</property>
                              <property 
name="justify">GTK_JUSTIFY_LEFT</property>
@@ -197,7 +153,7 @@
                            </widget>
                            <packing>
                              <property name="x">0</property>
-                             <property name="y">24</property>
+                             <property name="y">39</property>
                            </packing>
                          </child>
                        </widget>
@@ -2320,94 +2276,4 @@
   </child>
 </widget>
 
-<widget class="GtkWindow" id="window2">
-  <property name="width_request">257</property>
-  <property name="height_request">70</property>
-  <property name="visible">True</property>
-  <property name="title" translatable="yes">Send command</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">False</property>
-  <property name="destroy_with_parent">False</property>
-  <property name="decorated">True</property>
-  <property name="skip_taskbar_hint">False</property>
-  <property name="skip_pager_hint">False</property>
-  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
-  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
-  <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
-  <signal name="destroy" handler="on_window2_destroy"/>
-
-  <child>
-    <widget class="GtkFixed" id="fixed12">
-      <property name="visible">True</property>
-
-      <child>
-       <widget class="GtkEntry" id="entry1">
-         <property name="width_request">160</property>
-         <property name="height_request">27</property>
-         <property name="visible">True</property>
-         <property name="can_focus">True</property>
-         <property name="editable">True</property>
-         <property name="visibility">True</property>
-         <property name="max_length">0</property>
-         <property name="text" translatable="yes">0x31 0 0 0</property>
-         <property name="has_frame">True</property>
-         <property name="invisible_char">•</property>
-         <property name="activates_default">False</property>
-       </widget>
-       <packing>
-         <property name="x">8</property>
-         <property name="y">32</property>
-       </packing>
-      </child>
-
-      <child>
-       <widget class="GtkLabel" id="label26">
-         <property name="width_request">149</property>
-         <property name="height_request">20</property>
-         <property name="visible">True</property>
-         <property name="label" translatable="yes">Type raw command:</property>
-         <property name="use_underline">False</property>
-         <property name="use_markup">False</property>
-         <property name="justify">GTK_JUSTIFY_LEFT</property>
-         <property name="wrap">True</property>
-         <property name="selectable">False</property>
-         <property name="xalign">0.5</property>
-         <property name="yalign">0.5</property>
-         <property name="xpad">0</property>
-         <property name="ypad">0</property>
-         <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-         <property name="width_chars">-1</property>
-         <property name="single_line_mode">False</property>
-         <property name="angle">0</property>
-       </widget>
-       <packing>
-         <property name="x">8</property>
-         <property name="y">8</property>
-       </packing>
-      </child>
-
-      <child>
-       <widget class="GtkButton" id="button35">
-         <property name="width_request">72</property>
-         <property name="height_request">27</property>
-         <property name="visible">True</property>
-         <property name="can_focus">True</property>
-         <property name="label" translatable="yes">Send</property>
-         <property name="use_underline">True</property>
-         <property name="relief">GTK_RELIEF_NORMAL</property>
-         <property name="focus_on_click">True</property>
-         <signal name="clicked" handler="on_sendcommand_bt_clicked"/>
-       </widget>
-       <packing>
-         <property name="x">176</property>
-         <property name="y">32</property>
-       </packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
 </glade-interface>


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to