|
11 | 11 | Button, Label, Loop, If, Elif, Else, KeyPress, Ref,\ |
12 | 12 | Parallel, Slider, MouseCursor, Rectangle, Meanwhile,\ |
13 | 13 | Serial, Debug, Screenshot, Questionnaire, UpdateWidget |
| 14 | +from smile.clock import clock |
14 | 15 | from smile.lsl import init_lsl_outlet, LSLPush |
15 | 16 | from smile.scale import scale as s |
16 | 17 | from supreme_demo import Demographics |
@@ -217,22 +218,38 @@ def ToOut(message, exp, post_urlFULL): |
217 | 218 | top=sld.bottom - s(250), font_size=s(CogBatt_config.HAPPY_FONT_SIZE)) |
218 | 219 |
|
219 | 220 | with UntilDone(): |
| 221 | + exp.happy_start_time = Ref(clock.now) |
| 222 | + exp.last_check = exp.happy_start_time |
| 223 | + exp.happy_dur = 0.0 |
| 224 | + exp.HAPPY_SPEED = CogBatt_config.HAPPY_INC_BASE |
220 | 225 | exp.first_press_time = None |
221 | 226 | with Loop(): |
222 | 227 | ans = KeyPress(keys=CogBatt_config.RESP_HAPPY) |
223 | 228 | with If(exp.first_press_time == None): |
224 | 229 | exp.first_press_time = ans.press_time |
| 230 | + with If(ans.press_time['time'] - exp.last_check < |
| 231 | + CogBatt_config.NON_PRESS_INT): |
| 232 | + exp.HAPPY_SPEED = (CogBatt_config.HAPPY_INC_BASE * (Ref(clock.now) - |
| 233 | + exp.happy_start_time) * CogBatt_config.HAPPY_MOD) + CogBatt_config.HAPPY_INC_START |
| 234 | + |
| 235 | + with Else(): |
| 236 | + exp.HAPPY_SPEED = CogBatt_config.HAPPY_INC_START |
| 237 | + exp.happy_start_time = Ref(clock.now) |
| 238 | + exp.last_check = Ref(clock.now) |
| 239 | + Debug(a=exp.HAPPY_SPEED, b=exp.happy_start_time, c=ans.press_time['time'], |
| 240 | + d=ans.press_time['time'] - exp.happy_start_time < CogBatt_config.NON_PRESS_INT) |
225 | 241 | with If(ans.pressed == CogBatt_config.RESP_HAPPY[0]): |
226 | | - with If(sld.value - CogBatt_config.HAPPY_SPEED <= -10): |
227 | | - UpdateWidget(sld, value=-10) |
| 242 | + with If(sld.value - exp.HAPPY_SPEED <= (-1 * CogBatt_config.HAPPY_RANGE)): |
| 243 | + UpdateWidget(sld, value=(-1 * CogBatt_config.HAPPY_RANGE)) |
228 | 244 | with Else(): |
229 | | - UpdateWidget(sld, value=sld.value - CogBatt_config.HAPPY_SPEED) |
| 245 | + UpdateWidget(sld, value=sld.value - exp.HAPPY_SPEED) |
230 | 246 | with Elif(ans.pressed == CogBatt_config.RESP_HAPPY[1]): |
231 | | - with If(sld.value + CogBatt_config.HAPPY_SPEED >= 10): |
232 | | - UpdateWidget(sld, value=10) |
| 247 | + with If(sld.value + exp.HAPPY_SPEED >= CogBatt_config.HAPPY_RANGE): |
| 248 | + UpdateWidget(sld, value=CogBatt_config.HAPPY_RANGE) |
233 | 249 | with Else(): |
234 | | - UpdateWidget(sld, value=sld.value + CogBatt_config.HAPPY_SPEED) |
235 | | - Wait(.05) |
| 250 | + UpdateWidget(sld, value=sld.value + exp.HAPPY_SPEED) |
| 251 | + |
| 252 | + #Wait(.005) |
236 | 253 | with UntilDone(): |
237 | 254 | submit = KeyPress(keys=['SPACEBAR']) |
238 | 255 | Log(name="happy", |
|
0 commit comments