[chronojump] Fixed chronopic problems



commit 678aaa897ae614175db3b469b366b51af3771e43
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri May 27 15:57:48 2016 +0200

    Fixed chronopic problems

 .../chronopic-firmware-multitest.c                 |   12 +-
 src/chronopicDetect.cs                             |    4 +-
 src/gui/chronopic.cs                               |  190 ++++++++++++--------
 src/gui/reactionTime.cs                            |    4 +-
 4 files changed, 121 insertions(+), 89 deletions(-)
---
diff --git a/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c 
b/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
index e83bad9..6b6c3c8 100644
--- a/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
+++ b/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
@@ -34,7 +34,7 @@ History:
              modify ISR and MAIN LOOP's if --> else if
              limit COUNTDEBOUNCE overflow in INTERRUPT(isr)
             assembler is more efficient than C
-  2012-04-19 if PC send command 'J' for port scanning, Chronopic will return 'J'  2014-08-30 if PC send 
command 'n' for getting version, ex: 2.1\n
+  2012-04-19 if PC send command 'J' for port scanning, Chronopic will return 'J'  2014-08-30 if PC send 
command 'V' for getting version, ex: 2.1\n
             if PC send command 'a' get debounce time , ex:0x01
             if PC send command 'bx' for setting debounce time, x is from byte value 0~255(\x0 ~ \xFF) 
   2015-02-19 
@@ -123,7 +123,7 @@ unsigned char my_char;
 unsigned char i = 0, j = 0;
 unsigned char option = 0;     // option: 0 button enable, 1 encoder enable
 unsigned char command_port_scanning = 'J';     // for port scanning, it will return 'J'
-unsigned char command_get_version = 'n';       // for getting version, it will return '2.1'
+unsigned char command_get_version = 'V';       // for getting version, it will return '2.1'
 unsigned char command_get_debounce_time = 'a'; // for getting debounce time, it will return x:0~255(HEX)
 unsigned char command_set_debounce_time = 'b'; // for setting debounce time, pc send two unsigned char, 'Sx' 
-- x:0~255
 unsigned char command_reaction_time_animation_light = 'l';
@@ -133,7 +133,7 @@ unsigned char command_reaction_time_disc_red                = 'r';
 unsigned char command_reaction_time_disc_yellow        = 's';
 unsigned char command_reaction_time_disc_green                 = 't';
 unsigned char command_reaction_time_disc_red_yellow    = 'u';
-unsigned char command_reaction_time_disc_red_green     = 'v';
+unsigned char command_reaction_time_disc_red_green     = 'y';
 unsigned char command_reaction_time_disc_yellow_green  = 'w';
 unsigned char command_reaction_time_disc_all           = 'x';
 
@@ -141,7 +141,7 @@ unsigned char command_reaction_time_disc_red_bz     = 'R';
 unsigned char command_reaction_time_disc_yellow_bz     = 'S';
 unsigned char command_reaction_time_disc_green_bz      = 'T';
 unsigned char command_reaction_time_disc_red_yellow_bz = 'U';
-unsigned char command_reaction_time_disc_red_green_bz  = 'V';
+unsigned char command_reaction_time_disc_red_green_bz  = 'Y';
 unsigned char command_reaction_time_disc_yellow_green_bz= 'W';
 unsigned char command_reaction_time_disc_all_bz                = 'X';
 
@@ -560,7 +560,7 @@ void reaction_time_discriminative_do()
                        //RB7 = 0; RB3 = 0; RB0 = 1; RB2 = 0; //light green
                        RB3 = 0;
                        break;
-               case 'v':       //red & green
+               case 'y':       //red & green
                        RB2 = 0;
                        RB3 = 0;
                        break;
@@ -857,7 +857,7 @@ void main(void)
                        status_serv();
                else if (my_char == command_port_scanning)      // 'J'
                        sci_sendchar(command_port_scanning);
-               else if (my_char == command_get_version)        // 'n'
+               else if (my_char == command_get_version)        // 'V'
                        send_version();
                else if (my_char == command_get_debounce_time)  // 'a'
                        sci_sendline(DEBOUNCE_TIME + '0');      //if DEBOUNCE is 50ms (0x05), returns a 5 (5 
* 10ms = 50ms)
diff --git a/src/chronopicDetect.cs b/src/chronopicDetect.cs
index e67c8c3..d6070d6 100644
--- a/src/chronopicDetect.cs
+++ b/src/chronopicDetect.cs
@@ -443,7 +443,7 @@ public class ChronopicAutoCheck : ChronopicAuto
                IsChronopicAuto = ( (char) sp.ReadByte() == 'J');
                if (IsChronopicAuto) 
                {
-                       sp.Write("n");
+                       sp.Write("V");
                        int major = (char) sp.ReadByte() - '0'; 
                        sp.ReadByte();          //.
                        int minor = (char) sp.ReadByte() - '0'; 
@@ -549,7 +549,7 @@ public class ChronopicStartReactionTimeAnimation : ChronopicAuto
                                b = 0x74;
                        else if(CharToSend == "T") //green and buzzer
                                b = 0x54;
-                       else if(CharToSend == "v") //red green
+                       else if(CharToSend == "y") //red green
                                b = 0x76;
                        else if(CharToSend == "Z")
                                b = 0x5A;
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index fe520a1..6fe1234 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -266,7 +266,8 @@ public class ChronopicWindow
                ChronopicWindowBox.setEncoderPort(encoderPort); 
 
                //ports info comes from gui/chronojump.cs to Create mehod
-               ChronopicWindowBox.info();
+               if(! ChronopicWindowBox.connected)
+                       ChronopicWindowBox.connectingInfoShow();
 
                ChronopicWindowBox.chronopic_window.Show();
                ChronopicWindowBox.chronopic_window.Present();
@@ -406,6 +407,15 @@ public class ChronopicWindow
                        ChronopicWindowBox.createComboWindows();
                else
                        ChronopicWindowBox.createComboLinux();
+       
+               if(connected) {
+                       int num = 1;
+                       foreach(ChronopicPortData a in cpd) {
+                               if(a.Connected)
+                                       connectionSucceded(num, false); //don't playSound
+                               num ++;
+                       }
+               }
        }
 
        //private void createComboWindows(string myPort, Gtk.ComboBox myCombo) {
@@ -552,13 +562,16 @@ public class ChronopicWindow
                }
        }
        
-       private void info() {
+       private void connectingInfoShow() {
                textview_ports_found_explanation.Buffer = UtilGtk.TextViewPrint(
                                Catalog.GetString("If you just plugged Chronopic cable and expected port is 
not listed, close and open again this window.") + "\n" + 
                                Catalog.GetString("If you have problems connecting with Chronopic, press help 
button.")  
                                //saferPorts
                                );
        }
+       private void connectingInfoHide() {
+               textview_ports_found_explanation.Buffer = UtilGtk.TextViewPrint("");
+       }
 
        private void chronopicAtStart(object o, EventArgs args) {
                //make active menuitem chronopic, and this
@@ -826,101 +839,32 @@ public class ChronopicWindow
                        cpDoing = cp;
                        connected = chronopicInit.Do(currentCp, out cpDoing, out sp, platformState, myPort, 
out message, out success);
                        cp = cpDoing;
-                       if(success) {
-                               ((ChronopicPortData) cpd[0]).Connected=true;
-                               button_connect_cp1.Sensitive = false;
-                               image_cp1_no.Hide();
-                               image_cp1_yes.Show();
-                       
-                               if(isWindows) {
-                                       combo_windows1.Sensitive = false;
-                                       combo_windows2.Sensitive = true;
-                                       UtilGtk.ComboDelThisValue(combo_windows2, myPort);
-                                       combo_windows2.Active = 0; //first option
-                                       UtilGtk.ComboDelThisValue(combo_windows3, myPort);
-                                       combo_windows3.Active = 0;
-                                       UtilGtk.ComboDelThisValue(combo_windows4, myPort);
-                                       combo_windows4.Active = 0;
-                               } else {
-                                       combo_linux1.Sensitive = false;
-                                       combo_linux2.Sensitive = true;
-                                       UtilGtk.ComboDelThisValue(combo_linux2, myPort);
-                                       combo_linux2.Active = 0; //first option
-                                       UtilGtk.ComboDelThisValue(combo_linux3, myPort);
-                                       combo_linux3.Active = 0;
-                                       UtilGtk.ComboDelThisValue(combo_linux4, myPort);
-                                       combo_linux4.Active = 0;
-                               }
-                       }
+                       if(success)
+                               connectionSucceded(1, true);
                }
                else if(currentCp == 2) {
                        myPort = ((ChronopicPortData) cpd[1]).Port;
                        cpDoing = cp2;
                        connected = chronopicInit.Do(currentCp, out cpDoing, out sp2, platformState2, myPort, 
out message, out success);
                        cp2 = cpDoing;
-                       if(success) {
-                               ((ChronopicPortData) cpd[1]).Connected=true;
-                               button_connect_cp2.Sensitive = false;
-                               image_cp2_no.Hide();
-                               image_cp2_yes.Show();
-                       
-                               if(isWindows) {
-                                       combo_windows2.Sensitive = false;
-                                       combo_windows3.Sensitive = true;
-                                       UtilGtk.ComboDelThisValue(combo_windows3, myPort);
-                                       combo_windows3.Active = 0;
-                                       UtilGtk.ComboDelThisValue(combo_windows4, myPort);
-                                       combo_windows4.Active = 0;
-                               } else {
-                                       combo_linux2.Sensitive = false;
-                                       combo_linux3.Sensitive = true;
-                                       UtilGtk.ComboDelThisValue(combo_linux3, myPort);
-                                       combo_linux3.Active = 0;
-                                       UtilGtk.ComboDelThisValue(combo_linux4, myPort);
-                                       combo_linux4.Active = 0;
-                               }
-                       }
+                       if(success)
+                               connectionSucceded(2, true);
                }
                else if(currentCp == 3) {
                        myPort = ((ChronopicPortData) cpd[2]).Port;
                        cpDoing = cp3;
                        connected = chronopicInit.Do(currentCp, out cpDoing, out sp3, platformState3, myPort, 
out message, out success);
                        cp3 = cpDoing;
-                       if(success) {
-                               ((ChronopicPortData) cpd[2]).Connected=true;
-                               button_connect_cp3.Sensitive = false;
-                               image_cp3_no.Hide();
-                               image_cp3_yes.Show();
-                       
-                               if(isWindows) {
-                                       combo_windows3.Sensitive = false;
-                                       combo_windows4.Sensitive = true;
-                                       UtilGtk.ComboDelThisValue(combo_windows4, myPort);
-                                       combo_windows4.Active = 0;
-                               } else {
-                                       combo_linux3.Sensitive = false;
-                                       combo_linux4.Sensitive = true;
-                                       UtilGtk.ComboDelThisValue(combo_linux4, myPort);
-                                       combo_linux4.Active = 0;
-                               }
-                       }
+                       if(success)
+                               connectionSucceded(3, true);
                }
                else if(currentCp == 4) {
                        myPort = ((ChronopicPortData) cpd[3]).Port;
                        cpDoing = cp4;
                        connected = chronopicInit.Do(currentCp, out cpDoing, out sp4, platformState4, myPort, 
out message, out success);
                        cp4 = cpDoing;
-                       if(success) {
-                               ((ChronopicPortData) cpd[3]).Connected=true;
-                               button_connect_cp4.Sensitive = false;
-                               image_cp4_no.Hide();
-                               image_cp4_yes.Show();
-                       
-                               if(isWindows) 
-                                       combo_windows4.Sensitive = false;
-                               else 
-                                       combo_linux4.Sensitive = false;
-                       }
+                       if(success)
+                               connectionSucceded(4, true);
                }
                
 
@@ -942,6 +886,94 @@ public class ChronopicWindow
                needUpdateChronopicWin = true;
        }
 
+       private void connectionSucceded(int port, bool playSound)
+       {
+               string myPort = ((ChronopicPortData) cpd[port -1]).Port;
+               ((ChronopicPortData) cpd[port -1]).Connected=true;
+
+               if(port == 1) {
+                       button_connect_cp1.Sensitive = false;
+                       image_cp1_no.Hide();
+                       image_cp1_yes.Show();
+
+                       if(isWindows) {
+                               combo_windows1.Sensitive = false;
+                               combo_windows2.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_windows2, myPort);
+                               combo_windows2.Active = 0; //first option
+                               UtilGtk.ComboDelThisValue(combo_windows3, myPort);
+                               combo_windows3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
+                               combo_windows4.Active = 0;
+                       } else {
+                               combo_linux1.Sensitive = false;
+                               combo_linux2.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_linux2, myPort);
+                               combo_linux2.Active = 0; //first option
+                               UtilGtk.ComboDelThisValue(combo_linux3, myPort);
+                               combo_linux3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
+                               combo_linux4.Active = 0;
+                       }
+               }
+               else if(port == 2) {
+                       button_connect_cp2.Sensitive = false;
+                       image_cp2_no.Hide();
+                       image_cp2_yes.Show();
+
+                       if(isWindows) {
+                               combo_windows2.Sensitive = false;
+                               combo_windows3.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_windows3, myPort);
+                               combo_windows3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
+                               combo_windows4.Active = 0;
+                       } else {
+                               combo_linux2.Sensitive = false;
+                               combo_linux3.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_linux3, myPort);
+                               combo_linux3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
+                               combo_linux4.Active = 0;
+                       }
+               }
+               else if(port == 3) {
+                       button_connect_cp3.Sensitive = false;
+                       image_cp3_no.Hide();
+                       image_cp3_yes.Show();
+
+                       if(isWindows) {
+                               combo_windows3.Sensitive = false;
+                               combo_windows4.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
+                               combo_windows4.Active = 0;
+                       } else {
+                               combo_linux3.Sensitive = false;
+                               combo_linux4.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
+                               combo_linux4.Active = 0;
+                       }
+               }
+               else if(port == 4) {
+                       button_connect_cp4.Sensitive = false;
+                       image_cp4_no.Hide();
+                       image_cp4_yes.Show();
+
+                       if(isWindows) 
+                               combo_windows4.Sensitive = false;
+                       else 
+                               combo_linux4.Sensitive = false;
+               }
+                       
+
+               connectingInfoHide();
+               frame_connection.Visible = true;
+               updateChronopicWin(true, Catalog.GetString("connected"));
+               if(playSound)           
+                       Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
+               updateChronopicWinValuesState= true; //connected
+       }
+
        private void on_chronopic_connection_ended(object o, EventArgs args) {
                updateChronopicWin(updateChronopicWinValuesState, updateChronopicWinValuesMessage);
        }
diff --git a/src/gui/reactionTime.cs b/src/gui/reactionTime.cs
index 511ac6e..bc5bbaa 100644
--- a/src/gui/reactionTime.cs
+++ b/src/gui/reactionTime.cs
@@ -201,7 +201,7 @@ public partial class ChronoJumpWindow
                                                discriminativeCharToSend = "U";         //red + yellow
                                } else { //! yellow
                                        if(check_reaction_time_disc_green.Active == true)
-                                               discriminativeCharToSend = "V";         //red + green
+                                               discriminativeCharToSend = "Y";         //red + green
                                        else
                                                discriminativeCharToSend = "R";         //red
                                }
@@ -227,7 +227,7 @@ public partial class ChronoJumpWindow
                                                discriminativeCharToSend = "u";         //red + yellow
                                } else { //! yellow
                                        if(check_reaction_time_disc_green.Active == true)
-                                               discriminativeCharToSend = "v";         //red + green
+                                               discriminativeCharToSend = "y";         //red + green
                                        else
                                                discriminativeCharToSend = "r";         //red
                                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]