[chronojump] Reaction time discriminative done
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Reaction time discriminative done
- Date: Tue, 3 May 2016 20:36:57 +0000 (UTC)
commit afb310dec1cfaf5e41bebac18e4118016247a82e
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue May 3 22:33:56 2016 +0200
Reaction time discriminative done
.../chronopic-firmware-multitest.c | 31 ++++++++++++++++---
src/chronopicDetect.cs | 4 ++
src/execute/event.cs | 2 +-
src/execute/reactionTime.cs | 4 +-
src/gui/reactionTime.cs | 14 +++++++--
5 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
b/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
index 453dbc5..e83bad9 100644
--- a/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
+++ b/chronopic-firmware/chronopic-firmware-c/chronopic-firmware-multitest.c
@@ -549,17 +549,31 @@ void reaction_time_discriminative_do()
//2nd fire signal
switch(discriminative_light_signal) {
case 'r':
- RB7 = 0; RB3 = 1; RB0 = 0; RB2 = 0; //light red
+ //RB7 = 0; RB3 = 1; RB0 = 0; RB2 = 0; //light red
+ RB2 = 0;
break;
case 's':
- RB7 = 0; RB3 = 0; RB0 = 1; RB2 = 1; //light yellow
+ //RB7 = 0; RB3 = 0; RB0 = 1; RB2 = 1; //light yellow
+ RB0 = 0;
break;
case 't':
- RB7 = 0; RB3 = 0; RB0 = 1; RB2 = 0; //light green
+ //RB7 = 0; RB3 = 0; RB0 = 1; RB2 = 0; //light green
+ RB3 = 0;
+ break;
+ case 'v': //red & green
+ RB2 = 0;
+ RB3 = 0;
+ break;
+ case 'T': //green and buzzer
+ //RB7 = 0; RB3 = 0; RB0 = 1; RB2 = 0; //light green
+ RB3 = 0;
+ RB7 = 0;
break;
case 'Z':
- RB7 = 0; RB3 = 0; RB0 = 0; RB2 = 1; //buzzer
+ //RB7 = 0; RB3 = 0; RB0 = 0; RB2 = 1; //buzzer
+ RB7 = 0;
break;
+ //TODO if none of this green is lighted. Fix it
}
//3rd don't call this again
@@ -567,7 +581,8 @@ void reaction_time_discriminative_do()
}
void reaction_time_discriminative_stop()
{
- RB7 = 0; RB3 = 0; RB0 = 0; RB2 = 0;
+ RB7 = 1; RB3 = 1; RB0 = 1; RB2 = 1;
+ discriminative_running = 0;
}
//*****************************************************
@@ -766,6 +781,12 @@ void main(void)
//-- Update led with the stable status of input variable
update_led();
+ //-------------
+ //for discriminative. Attention: this is because currently Ferran hardware is reversed. Change this soon!
+ //RB7 = 0; RB3 = 0; RB0 = 0; RB2 = 0; //OFF
+ RB7 = 1; RB3 = 1; RB0 = 1; RB2 = 1; //OFF
+ //-------------
+
//--------------------------
//- Interruption TIMER 0
//--------------------------
diff --git a/src/chronopicDetect.cs b/src/chronopicDetect.cs
index 65a40a3..e8eca04 100644
--- a/src/chronopicDetect.cs
+++ b/src/chronopicDetect.cs
@@ -546,6 +546,10 @@ public class ChronopicStartReactionTimeAnimation : ChronopicAuto
b = 0x73;
else if(CharToSend == "t")
b = 0x74;
+ else if(CharToSend == "T") //green and buzzer
+ b = 0x54;
+ else if(CharToSend == "v") //red green
+ b = 0x76;
else if(CharToSend == "Z")
b = 0x5A;
else
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 8420620..82db9f3 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -155,7 +155,7 @@ public class EventExecute
//on animation lights and discriminative should be false
public bool StartIn = true;
public string DiscriminativeCharToSend;
- public int DiscriminativeStartTime;
+ public double DiscriminativeStartTime;
public SerialPort SP;
diff --git a/src/execute/reactionTime.cs b/src/execute/reactionTime.cs
index ead7fe0..ef4e2c9 100644
--- a/src/execute/reactionTime.cs
+++ b/src/execute/reactionTime.cs
@@ -159,11 +159,11 @@ public class ReactionTimeExecute : EventExecute
protected override void waitEvent ()
{
if(DiscriminativeCharToSend != "") {
- Thread.Sleep(DiscriminativeStartTime * 1000); //TODO: this hangs the interface, find
a better way. Now should work (PulseGTK has been called)
+ Thread.Sleep(Convert.ToInt32(DiscriminativeStartTime * 1000)); //in ms
ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
cs.CharToSend = DiscriminativeCharToSend;
- cs.Write(SP, DiscriminativeStartTime);
+ cs.Write(SP, 0);
LogB.Information("opening port");
SP.Open();
diff --git a/src/gui/reactionTime.cs b/src/gui/reactionTime.cs
index 220feac..5548720 100644
--- a/src/gui/reactionTime.cs
+++ b/src/gui/reactionTime.cs
@@ -177,7 +177,8 @@ public partial class ChronoJumpWindow
}
private string discriminativeCharToSend;
- private int discriminativeStartTime;
+ private double discriminativeStartTime;
+ private Random rnd;
private void on_button_discriminative_lights_start_clicked (object o, EventArgs args)
{
@@ -233,8 +234,15 @@ public partial class ChronoJumpWindow
discriminativeCharToSend = "t"; //green
}
}
-
- discriminativeStartTime = Convert.ToInt32(spinbutton_discriminative_lights_minimum.Value);
+
+ rnd = new Random();
+ double rndDouble = rnd.NextDouble(); //double between 0 and 1
+ int range = Convert.ToInt32(spinbutton_discriminative_lights_maximum.Value) -
+ Convert.ToInt32(spinbutton_discriminative_lights_minimum.Value);
+ discriminativeStartTime = (rndDouble * range) +
Convert.ToInt32(spinbutton_discriminative_lights_minimum.Value);
+
+ LogB.Information("discriminativeStartTime");
+ LogB.Information(discriminativeStartTime.ToString());
LogB.Information("discriminativeCharToSend");
LogB.Information(discriminativeCharToSend);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]