diff --git a/package-lock.json b/package-lock.json index 1e314732..ef50c0d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,18 @@ { "name": "honeycomb", - "version": "3.4.0", + "version": "3.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "honeycomb", - "version": "3.4.0", + "version": "3.4.1", "hasInstallScript": true, "license": "MIT", "dependencies": { "@fortawesome/fontawesome-free": "^6.4.2", "@jspsych/plugin-audio-keyboard-response": "^1.1.3", + "@jspsych/plugin-call-function": "^1.1.0", "@jspsych/plugin-fullscreen": "^1.2.0", "@jspsych/plugin-html-button-response": "^1.1.1", "@jspsych/plugin-html-keyboard-response": "^1.1.1", @@ -6510,6 +6511,14 @@ "jspsych": ">=7.1.0" } }, + "node_modules/@jspsych/plugin-call-function": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@jspsych/plugin-call-function/-/plugin-call-function-1.1.3.tgz", + "integrity": "sha512-3+sIav7+e3Ie/jNZQAZZL3M0uvZT69fvpP3JBUhnH8eB23sLbCPEUHbGj9C7gdslJ9gjrJo3rMdgTRuWC0w3MA==", + "peerDependencies": { + "jspsych": ">=7.1.0" + } + }, "node_modules/@jspsych/plugin-fullscreen": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@jspsych/plugin-fullscreen/-/plugin-fullscreen-1.2.1.tgz", diff --git a/package.json b/package.json index 7a659e62..ee5f0024 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^6.4.2", "@jspsych/plugin-audio-keyboard-response": "^1.1.3", + "@jspsych/plugin-call-function": "^1.1.0", "@jspsych/plugin-fullscreen": "^1.2.0", "@jspsych/plugin-html-button-response": "^1.1.1", "@jspsych/plugin-html-keyboard-response": "^1.1.1", diff --git a/src/experiment/honeycomb.js b/src/experiment/honeycomb.js index 28a6bfaf..dc8c15ff 100644 --- a/src/experiment/honeycomb.js +++ b/src/experiment/honeycomb.js @@ -53,8 +53,8 @@ export function buildHoneycombTimeline(jsPsych) { const timeline = [ startProcedure, - countdownTrial, preloadTrial, + countdownTrial, instructionsTrial, honeycombProcedure, debriefTrial, diff --git a/src/experiment/procedures/startProcedure.js b/src/experiment/procedures/startProcedure.js index 6483ebd7..8d1465f4 100644 --- a/src/experiment/procedures/startProcedure.js +++ b/src/experiment/procedures/startProcedure.js @@ -6,6 +6,7 @@ import { holdUpMarkerTrial } from "../trials/holdUpMarker"; import { nameTrial } from "../trials/name"; import { initPhotodiodeTrial } from "../trials/initPhotodiode"; import { introductionTrial } from "../trials/introduction"; +import { buildCallFunctionTrial } from "../trials/callFunction"; /** * Builds the block of trials needed to start and setup the experiment @@ -24,6 +25,11 @@ export function buildStartProcedure(jsPsych) { // Conditionally add the photodiode setup trials if (config.USE_PHOTODIODE) { procedure.push(holdUpMarkerTrial); + procedure.push( + buildCallFunctionTrial(() => { + window.electronAPI.checkSerialPort(); + }) + ); procedure.push(initPhotodiodeTrial); } diff --git a/src/experiment/trials/callFunction.js b/src/experiment/trials/callFunction.js new file mode 100644 index 00000000..04820266 --- /dev/null +++ b/src/experiment/trials/callFunction.js @@ -0,0 +1,14 @@ +import callFunction from "@jspsych/plugin-call-function"; + +/** + * Trial to execute the callback function passed in + * + * @param {function} func callback function to execute + * @returns JS object as a trial + */ +export function buildCallFunctionTrial(func) { + return { + type: callFunction, + func: func, + }; +} diff --git a/src/experiment/trials/holdUpMarker.js b/src/experiment/trials/holdUpMarker.js index 0f384fc9..6a1848ea 100644 --- a/src/experiment/trials/holdUpMarker.js +++ b/src/experiment/trials/holdUpMarker.js @@ -1,32 +1,14 @@ import htmlButtonResponse from "@jspsych/plugin-html-button-response"; - -import { config, LANGUAGE } from "../../config/main"; -import { eventCodes } from "../../config/trigger"; -import { pdSpotEncode, photodiodeGhostBox } from "../../lib/markup/photodiode"; -import { div, h1, p } from "../../lib/markup/tags"; +import { LANGUAGE } from "../../config/main"; +import { h1 } from "../../lib/markup/tags"; +import { photodiodeGhostBox } from "../../lib/markup/photodiode"; // TODO @brown-ccv #330: Custom extension for EEG - this is initializeTriggerBox // TODO @brown-ccv #330: Need to ping the serial part - this isn't doing anything yet -// TODO @brown-ccv: Prevent user from pressing continue until pdSpotEncode finishes (need to use jsPsych.pluginAPI.setTimeout) export const holdUpMarkerTrial = { type: htmlButtonResponse, - stimulus: function () { - const eventMarkerMarkup = h1(LANGUAGE.trials.eventMarker.connected, { - style: "color: green;", - }); - return div(eventMarkerMarkup); - }, - prompt: function () { - let holdUpMarkerPrompt = p(LANGUAGE.trials.holdUpMarker); - - // Conditionally add the photodiodeGhostBox - if (config.USE_PHOTODIODE) holdUpMarkerPrompt += photodiodeGhostBox; - - return holdUpMarkerPrompt; - }, + stimulus: + h1(LANGUAGE.trials.holdUpMarker) + + photodiodeGhostBox, choices: [LANGUAGE.prompts.continue.button], - on_load: function () { - // Conditionally flash the photodiode when the trial first loads - if (config.USE_PHOTODIODE) pdSpotEncode(eventCodes.test_connect); - }, };