Skip to content

Instantly share code, notes, and snippets.

@themakshter
Last active April 26, 2020 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themakshter/1396a7482b06aefeaf9e6db3b9508283 to your computer and use it in GitHub Desktop.
Save themakshter/1396a7482b06aefeaf9e6db3b9508283 to your computer and use it in GitHub Desktop.
function generateDummyReadings(){
return {
peep: getRandomValue(10),
peakPressure: getRandomValue(100, 100),
patientRate: getRandomValue(220),
vte: getRandomValue(700),
inspiratoryTime: getRandomValue(3),
expiratoryTime: getRandomValue(5),
oxygen: getRandomValue(100),
flow: getRandomValue(30, 10)
}
}
function getRandomValue(range, valueToSubtract = 0){
return (Math.random() * range) - valueToSubtract;
}
// HomeScreen.js
export default function HomeScreen() {
const [readings, setReadings] = useState({});
React.useEffect(() => {
const interval = setInterval(() => {
const newReadings = generateDummyReadings();
setReadings(newReadings);
}, 2000);
return () => clearInterval(interval);
}, [])
return (
<View style={styles.container}>
<View style={styles.peakpressure}>
<PeepPressure></PeepPressure>
</View>
<View
style={{ flex: 5, height: "100%", backgroundColor: "white" }}
></View>
</View>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment