/** * <summary> * Changes the parameter type (frequency/duty cycle, pulse width, or edge count) returned by the get_currentValue function and callbacks. * <para> * The edge count value is limited to the 6 lowest digits. For values greater than one million, use * get_pulseCounter(). * Remember to call the <c>saveToFlash()</c> method of the module if the modification must be kept. * </para> * <para> * </para> * </summary> * <param name="newval"> * a value among <c>YPwmInput.PWMREPORTMODE_PWM_DUTYCYCLE</c>, <c>YPwmInput.PWMREPORTMODE_PWM_FREQUENCY</c>, * <c>YPwmInput.PWMREPORTMODE_PWM_PULSEDURATION</c>, <c>YPwmInput.PWMREPORTMODE_PWM_EDGECOUNT</c>, * <c>YPwmInput.PWMREPORTMODE_PWM_PULSECOUNT</c>, <c>YPwmInput.PWMREPORTMODE_PWM_CPS</c>, * <c>YPwmInput.PWMREPORTMODE_PWM_CPM</c>, <c>YPwmInput.PWMREPORTMODE_PWM_STATE</c>, * <c>YPwmInput.PWMREPORTMODE_PWM_FREQ_CPS</c>, <c>YPwmInput.PWMREPORTMODE_PWM_FREQ_CPM</c> and * <c>YPwmInput.PWMREPORTMODE_PWM_PERIODCOUNT</c> corresponding to the parameter type * (frequency/duty cycle, pulse width, or edge count) returned by the get_currentValue function and callbacks * </param> * <para> * </para> * <returns> * <c>0</c> if the call succeeds. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public int set_pwmReportMode(int newval) { if (_func == null) { throw new YoctoApiProxyException("No PwmInput connected"); } if (newval == _PwmReportMode_INVALID) { return(YAPI.SUCCESS); } // our enums start at 0 instead of the 'usual' -1 for invalid return(_func.set_pwmReportMode(newval - 1)); }
private void configurePWMInput(YPwmInput pwmInput) { this.log("Configure PWM Input"); // Set debounce value to 5 ms pwmInput.set_debouncePeriod(5); pwmInput.set_pwmReportMode(YPwmInput.PWMREPORTMODE_PWM_PULSECOUNT); pwmInput.set_logFrequency("1/m"); pwmInput.get_module().saveToFlash(); YDataLogger dataLogger = pwmInput.get_dataLogger(); dataLogger.set_autoStart(YDataLogger.AUTOSTART_ON); dataLogger.set_recording(YDataLogger.RECORDING_ON); }