Simulate a PWM (Pulse Width Modulation) driver configuration function using C++ default arguments.
Implement a function that configures PWM parameters and prints the resulting configuration.
Function Requirements:
Create a function setPWM with the following parameters:
duty (required): integer duty-cycle percentage0–100frequency (optional): PWM frequency in Hz10001–100000deadtime (optional): dead-time in microseconds00–1000⚠️ Rules:
Output Format:
The function must print the PWM configuration exactly as:
duty frequency deadtimeValues must be separated by a single space.
No additional text should be printed.
In main():
duty and modemode determines which parameters are provided:mode == 0setPWM(duty)mode == 1frequencysetPWM(duty, frequency)mode == 2frequency and deadtimesetPWM(duty, frequency, deadtime)You may assume all input values are valid and within the specified ranges.
Example 1
Input:
50 0Output:
50 1000 0
Example 2
Input:
70 1 2000Output:
70 2000 0
Example 3
Input:
90 2 5000 10Output:
90 5000 10
Constraints:
0 ≤ duty ≤ 1001 ≤ frequency ≤ 1000000 ≤ deadtime ≤ 1000mode ∈ {0, 1, 2}
Input
50 0
Expected Output
50 1000 0