Computing

Methods

(static) calculateAutoMeasures() → {functions}

Description:
  • This function regroups all sub-functions needed to calculate the values we display below the oscilloscope's screen. These sub-functions won't be entirely documented, most of them are pretty self-explanatory and comments are there already to clarify their use.

Source:
Example
const measures = calculateAutoMeasures();
let minimumValue = measures.getMinValue(channelData["CH2"].points);
Returns:

Returns the following functions to use :

  • voltage_from_raw
  • getMinValue
  • getMaxValue
  • getVppValue
  • getMeanValue
  • getMiddleValue
  • getRMS
  • getAverageFrequency
  • calculateThreshold
  • getFrequenciesMaxMin
Type
functions

(static) calculateZoomFactors() → {void}

Description:
  • This function calculates the zoom factors when a user selects an area to zoom on. It also update the global object 'zoomConfig' with the new values for the current zoom if any.

Source:
Returns:
Type
void

(static) generatePoints(channelKey) → {void}

Description:
  • This function is responsible for generating the points array for the signals not received directly but generated by the user. This goes for all maths functions like +, -, fft, integral, etc. Each time this function is called for a certain channel, we check the type of operation to execute, generate the points and return immediately. The drawSignal function will then draw the signal like any other.

Source:
Parameters:
Name Type Description
channelKey string

Key to access this signal within 'channelData' (CH1, CH2, etc.).

Returns:
Type
void

(static) getMilliVoltForACursor(cursorPosition) → {number|string}

Description:
  • This function returns the equivalent in mV relative to the position of a horizontal measure cursor. It also takes into account the vertical scaling of the current channel focused. If no channel is focused then the function will just return "No channel Selected".

Source:
Example
getMilliVoltForACursor(150);
//output : { value: "687.5", scale: "mV" }
getMilliVoltForACursor(540);
//output : { value: -385, scale: "mV" }
getMilliVoltForACursor(300);//While no channel is focused.
//output : { value: "No channel", scale: "selected" }
Parameters:
Name Type Description
cursorPosition number

Position, in pixels from the top of the screen to the cursor.

Returns:

Returns the voltage (in mv) equivalent to the position of the cursor.

Type
number | string

(static) getMilliVoltsPerDiv(channelVerticalScale) → {number}

Description:
  • This function returns how many mV are within a single vertical division.

Source:
Parameters:
Name Type Description
channelVerticalScale number

Vertical scale of a specific channel we want to know the mv/div for.

Returns:

Returns the mv/div for the given channel.

Type
number

(static) getMilliVoltsRelativeToTriggerCursor(Position) → {number|string}

Description:
  • This fonction returns how much mV represents the current position of the trigger cursor (right of the screen, T icon). This function is mostly used when the user moves the trigger cursor to change the current threshold.

Source:
Example
getMilliVoltsRelativeToTriggerCursor(150);
//output : { value: 687.5, scale: "mV" }
getMilliVoltsRelativeToTriggerCursor(430);
//output : { value: -82.5, scale: "mV" }
Parameters:
Name Type Description
Position number

Position of the trigger cursor, in pixels, on its scrollbar.

Returns:

Returns the voltage (in mv) relative to the cursor's position.

Type
number | string

(static) getMillivoltsBetweenCursors(pixelsBetweenCursors) → {number|string}

Description:
  • This function, similarly to 'getTimeBetweenCursors' gets the voltage represented between the two horizontal measure cursors. It takes into account which channel we are currently focused on and its current vertical scaling.

Source:
Example
getMillivoltsBetweenCursors(254);
//output : { value: "698.5", scale: "mV" }
getMillivoltsBetweenCursors(57);
//output : { value: "156.8", scale: "mV" }
Parameters:
Name Type Description
pixelsBetweenCursors number

Number of pixels between the two cursors.

Returns:

Returns the voltage and its associated scale (mv, v, etc).

Type
number | string

(static) getPositionRelativeToTriggerCursor(milliVolts, channelKey) → {number}

Description:
  • This function is used to get the position to set the trigger cursor at relative to the threshold set by the user.

Source:
Parameters:
Name Type Description
milliVolts number

Current treshold set for the trigger in mv.

channelKey string

Object key corresponding to a certain signal saved within 'channelData'.

Returns:

Position, in pixels, of the trigger cursor along the scrollbar.

Type
number

(static) getTimeBetweenCursors(pixelsBetweenCursors) → {number|string}

Description:
  • This function is used when the user uses the vertical measure cursors on the screen. It calculates the time represented between the two vertical measure cursors.

Source:
Example
// /!\ Without any horizontal scaling /!\
getTimeBetweenCursors(542);
//output : { value: 4.63, scale: "µs" }
getTimeBetweenCursors(247):
//output : { value: 2.11, scale: "µs" }
Parameters:
Name Type Description
pixelsBetweenCursors number

Number of pixels between the two cursors.

Returns:

Returns the time value and the corresponding scale.

Type
number | string

(static) getTimeForACursor(cursorPosition) → {number|string}

Description:
  • Similarly to 'getMilliVoltForACursor', this function returns the equivalent time relative to the position of a vertical measure cursor. It takes into account the global horizontal scaling of the oscilloscope.

Source:
Example
getTimeForACursor(150);
//output : { value: 1.28, scale: "µs" }
getTimeForACursor(655);
//output : { value: 5.59, scale: "µs" }
Parameters:
Name Type Description
cursorPosition number

Position, in pixels, from the left of the screen to the cursor.

Returns:

Returns the time and time-scale relative to the cursor's position.

Type
number | string

(static) getTimePerDiv() → {object}

Description:
  • This function returns how much time represents 1 horizontal division on screen.

Source:
Returns:

An object with two attributes, 'value' & 'scale'.

Type
object

(static) getTimeScale(timeInSeconds) → {object}

Description:
  • This function takes a time in seconds and scales it to something that makes more sense depending on the value.

Source:
Example
getTimeScale(0.05);
//output : { value: 50, scale: "ms" }
getTimeScale(0.0004);
//output : { value: 400, scale: "µs" }
getTimeScale(0.00000154);
//output : { value: 1.54, scale: "µs" }
Parameters:
Name Type Description
timeInSeconds number

Time period in seconds.

Returns:

An object with two attributes, 'value' & 'scale'.

Type
object

(static) mapRawToVoltage(rawValue) → {number}

Description:
  • This function converts a raw value from a 14-bit ADC to the equivalent voltage.

Source:
Parameters:
Name Type Description
rawValue number

Raw value to convert.

Returns:

The correponding voltage to the raw value given.

Type
number

(static) mapVoltageToRaw(voltage) → {number}

Description:
  • This function converts a voltage to the equivalent absolute raw value of a 14-bit ADC

Source:
Parameters:
Name Type Description
voltage number

Voltage to convert.

Returns:

The corresponding raw value to the voltage given.

Type
number

(static) resetMeasurements() → {void}

Description:
  • This function resets all values within the object 'autoMeasureOptions'. It also resets the visual aspect of each button for the user to select the auto-measures.

Source:
Returns:
Type
void

(static) setScreenInformation() → {void}

Description:
  • This function displays multiple informations below the screen like Mv/div, S/div, etc etc. It also displays all the 'auto-measures' selected by the user for a specific channel like vpp, rms, etc. This function's job is more about displaying the information on screen and not so much about doing the actual calculations for each value.

Source:
Returns:
Type
void

(static) toggleMeasurement(measureKey, buttonId) → {void}

Description:
  • This function changes the status for the auto-measures, which ones to display or not. The values being changed are all stored within the global object 'autoMeasureOptions'.

Source:
Parameters:
Name Type Description
measureKey string

Key within the 'autoMeasureOptions' object representing the measure.

buttonId string

Id of the button associated to this measure.

Returns:
Type
void

(static) updateGeneratedMathSignalsData(slotChannel, channel1, channel2, operation) → {void}

Description:
  • This function is called whenever a user selects a new signal to generate via a math function. We start by creating a new slot for a channel within channelData. We then update the config and the UI components related to this channel (button, scroller). We finish by setting up the interaction for the user with the offset cursor. The new signal will then be generated and drawned within the main loop.

Source:
Example
updateGeneratedMathSignalsData("CH6", "CH2", null, "squared");
updateGeneratedMathSignalsData("CH8", "CH4", "CH1", "add");
Parameters:
Name Type Description
slotChannel string

Empty slot to use for the new signal.

channel1 string

Base signal for the generated new one.

channel2 string

Second base signal in case the operation needs two operands.

operation string

Which operation to use for the new signal.

Returns:
Type
void

(static) updateTriggerSettings(modalElement) → {void}

Description:
  • This function is used to update the current trigger settings set by the user. We had to add a few verifications in case the values entered by the user are outside the acceptable range.

Source:
Parameters:
Name Type Description
modalElement DOMElement

Modal containing the inputs relative to the trigger options.

Returns:
Type
void