Skip to content

Instantly share code, notes, and snippets.

@themakshter
Created May 9, 2020 19:03
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/1e1d5b000569a19dbe6864afd854e23b to your computer and use it in GitHub Desktop.
Save themakshter/1e1d5b000569a19dbe6864afd854e23b to your computer and use it in GitHub Desktop.
Ventilation Mode Parser
const VentilationModes = ['VCV', 'PCV', 'AC-VCV', 'AC-PCV', 'CPAP'];
const ventilationMode = getVentilationMode(Data[29]);
function getVentilationMode(valueToParse: number): string {
// 0x1C is 00011100 so we find the values contain in bits 2-4
// we also want the index to retrieve the correct mode from our array
// so we shift the bits to the end to get the actual value
const ventilationModeIndex = (valueToParse & 0x1C) >> 2;
return VentilationModes[ventilationModeIndex];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment