An ADCSensor class processes readings from an Analog-to-Digital Converter (ADC). Due to hardware circuit imperfections, the sensor signal has a permanent DC noise offset of 100 units. This means even when the input is zero, the sensor reads 100. Currently, the class exposes this calibration detail poorly. It allows users to access raw values directly or perform the subtraction manually. This often leads to bugs where users forget to handle the "negative undershoot" case (where a raw reading is slightly below the offset due to noise), resulting in invalid negative values for a unipolar sensor. Your task is to encapsulate this logic:
getCalibratedSample(int raw_val).raw < offset), it must be clamped to 0 (saturation).Program Flow:
ADCSensor (Internal offset is fixed at 100).N (number of samples).N times:raw_input (simulating a hardware register read).Input Format:
N (number of samples).N lines: Integer raw_input.Output Format:
Sample: <value>Example:
Example 1
Input:
3
250
100
50Output:
Sample: 150
Sample: 0
Sample: 0
Constraints:
N range: 1 to 20raw_input range: 0 to 4095 (Standard 12-bit ADC range)
Input
3 250 100 50
Expected Output
Sample: 150 Sample: 0 Sample: 0