diff --git a/feedingwebapp/package.json b/feedingwebapp/package.json index dfadddd3..17da2f27 100644 --- a/feedingwebapp/package.json +++ b/feedingwebapp/package.json @@ -26,6 +26,7 @@ "styled-components": "^5.3.9", "web-vitals": "^2.1.4", "webpack": "^5.82.1", + "nosleep.js" : "^0.12.0", "zustand": "^4.0.0-rc.1" }, "scripts": { diff --git a/feedingwebapp/src/Pages/Home/MealStates/BiteSelection.jsx b/feedingwebapp/src/Pages/Home/MealStates/BiteSelection.jsx index 30a12441..3992f09c 100644 --- a/feedingwebapp/src/Pages/Home/MealStates/BiteSelection.jsx +++ b/feedingwebapp/src/Pages/Home/MealStates/BiteSelection.jsx @@ -6,7 +6,6 @@ import { View } from 'react-native' // PropTypes is used to validate that the used props are in fact passed to this // Component import PropTypes from 'prop-types' - // Local Imports import '../Home.css' import { useROS, createROSActionClient, callROSAction, destroyActionClient } from '../../../ros/ros_helpers' diff --git a/feedingwebapp/src/Pages/Home/MealStates/RobotMotion.jsx b/feedingwebapp/src/Pages/Home/MealStates/RobotMotion.jsx index d64f3135..4f8008ed 100644 --- a/feedingwebapp/src/Pages/Home/MealStates/RobotMotion.jsx +++ b/feedingwebapp/src/Pages/Home/MealStates/RobotMotion.jsx @@ -5,6 +5,8 @@ import Button from 'react-bootstrap/Button' import { View } from 'react-native' // PropTypes is used to validate that the used props are in fact passed to this Component import PropTypes from 'prop-types' +// External Library Imports +import NoSleep from 'nosleep.js' // Local Imports import { useROS, createROSActionClient, callROSAction, cancelROSAction, destroyActionClient } from '../../../ros/ros_helpers' import Footer from '../../Footer/Footer' @@ -69,6 +71,8 @@ const RobotMotion = (props) => { let waitingTextFontSize = isPortrait ? '4.5vh' : '9vh' // Motion text font size let motionTextFontSize = isPortrait ? '3vh' : '6vh' + // NoSleep object creation + let noSleep = useMemo(() => new NoSleep(), []) /** * Create the ROS Action Client. This is re-created every time props.mealState @@ -182,6 +186,7 @@ const RobotMotion = (props) => { */ useEffect(() => { callRobotMotionAction(feedbackCallback, responseCallback) + noSleep.enable() // keep the screen on! /** * In practice, because the values passed in in the second argument of * useEffect will not change on re-renders, this return statement will @@ -189,8 +194,10 @@ const RobotMotion = (props) => { */ return () => { destroyActionClient(robotMotionAction) + noSleep.disable() // let the screen turn off. + setActionStatus({ actionStatus: ROS_ACTION_STATUS_ABORT }) } - }, [callRobotMotionAction, robotMotionAction, feedbackCallback, responseCallback]) + }, [callRobotMotionAction, robotMotionAction, feedbackCallback, responseCallback, noSleep]) /** * Callback function for when the resume button is pressed. It calls the