### begin() usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Creates a DFRobot_GP8XXX_PWM_SINGLE instance on pin 9 and calls begin() in setup(). ```cpp DFRobot_GP8XXX_PWM_SINGLE pwm(9); void setup() { pwm.begin(); } ``` -------------------------------- ### GP8600 I2C setup example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Initializes a GP8600 I2C at address 0x58, sets output range to 12V, and writes full-scale 16-bit data. ```cpp DFRobot_GP8600_I2C gp8600(&Wire, 0x58); void setup() { while (gp8600.begin() != 0) { delay(1000); } gp8600.setDACOutRange(gp8600.eOutputRange12V); gp8600.setDACOutData(65535); // 16-bit full scale } ``` -------------------------------- ### Dual-channel GP8501 setup example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Example of initializing a dual-channel GP8501 device. Creates a DFRobot_GP8501 object with pins 9 and 10, then in setup() calls begin() and setDACOutVoltage(255, 2) to set both channels to full scale. ```cpp DFRobot_GP8501 gp8501(9, 10); // dual-channel GP8501 void setup() { gp8501.begin(); gp8501.setDACOutVoltage(255, 2); // both channels at full scale } ``` -------------------------------- ### DFRobot_GP8403 setup example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Initializes a GP8403 at address 0x58, sets output range to 5V, outputs 2000 mV on channel 2, and stores the voltage for power-loss recovery. ```cpp DFRobot_GP8403 gp8403(0x58); void setup() { while (gp8403.begin() != 0) { Serial.println("Communication with the device failed."); delay(1000); } gp8403.setDACOutRange(gp8403.eOutputRange5V); gp8403.setDACOutVoltage(2000, 2); delay(1000); gp8403.store(); // persist the last voltage for power-loss recovery } ``` -------------------------------- ### Single-channel GP8101 setup example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Example of initializing a single-channel GP8101 device built from the same base. Creates a DFRobot_GP8101 object with pin 9, then in setup() calls begin() and setDACOutVoltage(255) to set channel 0 only. ```cpp // Single-channel device built from the same base DFRobot_GP8101 gp8101(9); void setup() { gp8101.begin(); gp8101.setDACOutVoltage(255); // channel 0 only } ``` -------------------------------- ### Arduino configuration example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/configuration.md Shows how to instantiate DFRobot_GP8403, DFRobot_GP8600_I2C, and DFRobot_GP8501 objects with default device addresses and bus settings. Use this as a starting point for Arduino projects. ```cpp // Arduino: selected default device & Wire bus DFRobot_GP8403 gp8403(0x58); DFRobot_GP8600_I2C gp8600(&Wire, 0x5A, RESOLUTION_16_BIT); DFRobot_GP8501 gp8501(9, 10); // PWM, two channels ``` -------------------------------- ### DFRobot_GP8501 DAC initialization and begin example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Shows how to instantiate a DFRobot_GP8501 DAC object with pins 17 and 18, then call begin() to initialize. This is the typical setup before setting output voltage. ```python DAC = DFRobot_GP8501(pin0=17, pin1=18) DAC.begin() ``` -------------------------------- ### Python configuration example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/configuration.md Shows how to instantiate DFRobot_GP8403 and DFRobot_GP8600_PWM objects on a Raspberry Pi using BCM pins and software I2C. Use this as a starting point for Python projects. ```python # Raspberry Pi (BCM pins, software I2C) DAC = DFRobot_GP8403(i2c_sda=17, i2c_scl=27, i2c_addr=0x58) PWM = DFRobot_GP8600_PWM(pin0=13) ``` -------------------------------- ### DFRobot_GP8512 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Shows basic usage: create a DFRobot_GP8512 object, call begin() in setup, and set a raw 15-bit voltage value on channel 0. ```cpp DFRobot_GP8512 gp8512; void setup() { gp8512.begin(); gp8512.setDACOutVoltage(2000); // channel 0, raw 15-bit value } ``` -------------------------------- ### Basic usage of begin() with DFRobot_GP8403 Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-dfrobot-gp8xxx.md Shows basic usage of begin() through a concrete product class. Creates a DFRobot_GP8403 object and calls begin() in setup(). ```cpp // Basic usage through a concrete product class DFRobot_GP8403 gp8403(); void setup() { gp8403.begin(); } ``` -------------------------------- ### Clamping example for set_dac_out_voltage Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Example showing that values above the resolution are clamped and never sent to the chip. ```python # Clamping: values above the resolution are never sent DAC.set_dac_out_voltage(100000) # clamped to _resolution (e.g. 4095) ``` -------------------------------- ### DFRobot_GP8413 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Creates a DFRobot_GP8413 object with address 0x5A, initializes it in setup, and sets DAC output voltage to 2000 mV on channel 2. ```cpp DFRobot_GP8413 gp8413(0x5A); // address selected by the module's A0/A1/A2 jumpers void setup() { while (gp8413.begin() != 0) { delay(1000); } gp8413.setDACOutVoltage(2000, 2); } ``` -------------------------------- ### DFRobot_GP8600_PWM usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Shows how to instantiate DFRobot_GP8600_PWM on pin 9, call begin(), and set DAC output data to 255. ```cpp DFRobot_GP8600_PWM gp8600(9); void setup() { gp8600.begin(); gp8600.setDACOutData(255); } ``` -------------------------------- ### Instantiate DFRobot_GP8403 with BCM pins Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Shows a typical wiring example for the GP8403 module using BCM-encoded pins. This is the shipped example. ```python # BCM-encoded pins for a typical wiring; the shipped GP8403 example sets DAC = DFRobot_GP8403(i2c_sda=17, i2c_scl=27, i2c_addr=0x58) ``` -------------------------------- ### DFRobot_GP8503 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Initializes the GP8503 DAC, calls begin(), and sets output voltage to 4095 on channel 2. ```python DAC = DFRobot_GP8503(i2c_sda=17, i2c_scl=27) DAC.begin() DAC.set_dac_out_voltage(4095, 2) ``` -------------------------------- ### DFRobot_GP8600_PWM usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Shows how to instantiate a DFRobot_GP8600_PWM object, initialize it, and set the DAC output data to 100 (duty cycle percent). ```python DAC = DFRobot_GP8600_PWM(pin0=13) DAC.begin() DAC.set_dac_out_data(100) ``` -------------------------------- ### begin() usage with error checking Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-base.md Example of using begin() with a DFRobot_GP8403 instance. The if statement checks the return value; a non-zero result means the probe failed, indicating the device is absent or the address is wrong. Use this pattern to verify the module is reachable before proceeding. ```cpp DFRobot_GP8403 gp8403(); void setup() { if (gp8403.begin() != 0) { // probe failed — device absent or wrong address } } ``` -------------------------------- ### DFRobot_GP8512 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Initializes the GP8512 DAC and sets a raw 15-bit output voltage of 2000. ```python DAC = DFRobot_GP8512(i2c_sda=17, i2c_scl=27) DAC.begin() DAC.set_dac_out_voltage(2000) # raw 15-bit value ``` -------------------------------- ### Persist voltage with store() Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Example call to persist the current voltage in the chip using the store() method. ```python DAC.store() # persist the current voltage in the chip ``` -------------------------------- ### DFRobot_GP8XXX_PWM.begin Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Initializes the PWM hardware. Sets the GPIO mode to BCM, configures the specified pins as outputs, and starts PWM at 100 Hz with a 0% duty cycle. ```APIDOC ## DFRobot_GP8XXX_PWM.begin ### Description Initializes the PWM function. Sets the GPIO mode to BCM, configures each enabled pin as an output, and starts PWM at 100 Hz with an initial duty cycle of 0%. ### Method begin ### Parameters None ### Return Value - **int** - Always returns 1. ### Request Example ```python DAC = DFRobot_GP8501(pin0=17, pin1=18) DAC.begin() ``` ``` -------------------------------- ### DFRobot_GP8630N_PWM usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Shows how to instantiate the DFRobot_GP8630N_PWM on pin 13, begin communication, and set DAC output data to 85. ```python DAC = DFRobot_GP8630N_PWM(pin0=13) DAC.begin() DAC.set_dac_out_data(85) ``` -------------------------------- ### setDACOutData() usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Creates a DFRobot_GP8XXX_PWM_SINGLE instance on pin 9, calls begin(), then sets output to 255 (full scale on Arduino Uno). ```cpp DFRobot_GP8XXX_PWM_SINGLE pwm(9); void setup() { pwm.begin(); pwm.setDACOutData(255); // full scale on Arduino Uno } ``` -------------------------------- ### DFRobot_GP8403 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Initializes the GP8403 DAC, waits for begin() to succeed, sets output range to 10V, sets output voltage to 2000 on channel 2, and stores the configuration. ```python DAC = DFRobot_GP8403(i2c_sda=17, i2c_scl=27, i2c_addr=0x58) while DAC.begin() != 0: print("Communication with the device failed. Please check the connection.") time.sleep(1) DAC.set_dac_outrange(DAC.OUTPUT_RANGE_10V) DAC.set_dac_out_voltage(2000, 2) DAC.store() ``` -------------------------------- ### startSignal() and stopSignal() Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-base.md Software I2C bus start and stop handshake. ```APIDOC ## startSignal() and stopSignal() ### Description Software-I2C bus start/stop handshake using `_scl`/`_sda` with `I2C_CYCLE_*` microsecond timings. These are protected members for subclasses. ### Signatures ```cpp void startSignal(void); void stopSignal(void); ``` ### Parameters None. ### Return Type `void` ``` -------------------------------- ### Arduino C++ include and instantiation Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/README.md Shows how to include the DFRobot_GP8XXX.h header and instantiate I2C and PWM product classes. The I2C product (GP8403) uses the default I2C address, while the PWM product (GP8101) requires a PWM pin number (9 in this example). ```cpp #include DFRobot_GP8403 gp8403(); // I2C product DFRobot_GP8101 gp8101(9); // PWM product ``` -------------------------------- ### DFRobot_GP8503 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Shows how to instantiate and use DFRobot_GP8503. Calls begin() and setDACOutVoltage() with 12-bit full scale (4095) on both channels. ```cpp DFRobot_GP8503 gp8503(); void setup() { gp8503.begin(); gp8503.setDACOutVoltage(4095, 2); // 12-bit full scale, both channels } ``` -------------------------------- ### DFRobot_GP8413 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Initializes the GP8413 DAC with a custom address, waits for begin() to succeed, then sets output voltage to 2000 on channel 2. ```python DAC = DFRobot_GP8413(i2c_sda=17, i2c_scl=27, i2c_addr=0x5A) while DAC.begin() != 0: time.sleep(1) DAC.set_dac_out_voltage(2000, 2) ``` -------------------------------- ### DFRobot_GP8101 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Shows how to instantiate DFRobot_GP8101 on pin 9, begin communication, and set output voltage to 200 (about 78% duty cycle). ```cpp DFRobot_GP8101 gp8101(9); void setup() { gp8101.begin(); gp8101.setDACOutVoltage(200); // ~78% duty cycle } ``` -------------------------------- ### Set DAC voltage on both channels Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Example call to set the DAC voltage on both channels using channel parameter 2. ```python DAC.set_dac_out_voltage(2000, 2) # both channels ``` -------------------------------- ### DFRobot_GP8101S usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Shows how to instantiate DFRobot_GP8101S on pin 9, begin communication, and set output voltage to 255 (full scale 0-5V or 0-10V depending on module switch). ```cpp DFRobot_GP8101S gp8101s(9); void setup() { gp8101s.begin(); gp8101s.setDACOutVoltage(255); // full scale 0-5V or 0-10V per the module switch } ``` -------------------------------- ### DFRobot_GP8211S usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Initializes the GP8211S DAC, sets output range to 5V, and sets output voltage to 32767. ```python DAC = DFRobot_GP8211S(i2c_sda=17, i2c_scl=27) DAC.begin() DAC.set_dac_outrange(DAC.OUTPUT_RANGE_5V) DAC.set_dac_out_voltage(32767) ``` -------------------------------- ### DFRobot_GP8600_I2C usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Shows how to instantiate DFRobot_GP8600_I2C with I2C pins 17 and 27, wait for the module to be ready, set the output range to 12V, and write a 16-bit full-scale value of 65535. ```python DAC = DFRobot_GP8600_I2C(i2c_sda=17, i2c_scl=27, i2c_addr=0x58) while DAC.begin() != 0: time.sleep(1) DAC.set_dac_outrange(DAC.OUTPUT_RANGE_12V) DAC.set_dac_out_data(65535) # 16-bit full scale ``` -------------------------------- ### DFRobot_GP8211S usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Shows how to instantiate and use DFRobot_GP8211S. Initializes serial, retries begin() until I2C probe passes, sets output range to 5V, and sets 15-bit full scale voltage. ```cpp DFRobot_GP8211S gp8211s; void setup() { Serial.begin(9600); while (gp8211s.begin() != 0) { delay(1000); } // retry until I2C probe passes gp8211s.setDACOutRange(gp8211s.eOutputRange5V); gp8211s.setDACOutVoltage(32767); // 15-bit full scale } ``` -------------------------------- ### Usage example for DFRobot_GP8630N_I2C DAC Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Shows how to instantiate DFRobot_GP8630N_I2C with I2C pins 17 and 27, begin communication, set the output range to 0-20mA, and write a DAC data value of 65535. ```python DAC = DFRobot_GP8630N_I2C(i2c_sda=17, i2c_scl=27) DAC.begin() DAC.set_dac_outrange(DAC.OUTPUT_RANGE_20MA) DAC.set_dac_out_data(65535) ``` -------------------------------- ### DFRobot_GP8302 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Shows how to instantiate DFRobot_GP8302 with I2C pins 17 and 27, begin communication, and set a 12-bit current output value of 2048. ```python DAC = DFRobot_GP8302(i2c_sda=17, i2c_scl=27) DAC.begin() DAC.set_dac_out_electric_current(2048) ``` -------------------------------- ### DFRobot_GP8630N_PWM usage example with 4-20 mA comment Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Shows how to instantiate DFRobot_GP8630N_PWM on pin 9, call begin(), and set DAC output data to 212. Includes a comment about 4-20 mA over 0-255 pulse width on a 24 mA-configured GP8630N. ```cpp // 4-20 mA over 0-255 pulse width on a 24 mA-configured GP8630N: // GP8630N.setDACOutData(max(data*0.83, 42.5)); (per the shipped example comment) DFRobot_GP8630N_PWM gp8630n(9); void setup() { gp8630n.begin(); gp8630n.setDACOutData(212); } ``` -------------------------------- ### DFRobot_GP8XXX_PWM class definition Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-products.md Defines the DFRobot_GP8XXX_PWM class with __init__, begin, and set_dac_out_voltage methods. The begin method initializes GPIO in BCM mode, sets up PWM at 100 Hz, and starts with 0% duty cycle. set_dac_out_voltage clamps data to 0-100 and applies duty cycle to selected channels. ```python class DFRobot_GP8XXX_PWM(DFRobot_GP8XXX): def __init__(self,pin0=-1,pin1=-1): '''! @brief PWM class initialization @param pin 0 PWM channel 0 corresponds to the pin @param pin corresponding to pin1 PWM channel 1 ''' self._pin0 = pin0 self._pin1 = pin1 def begin(self): '''! @brief Initialize the function @return 0 ''' GPIO.setwarnings(False) # Block warnings GPIO.setmode(GPIO.BCM) # Set the pin mode BCM if self._pin0 != -1 : GPIO.setup(self._pin0, GPIO.OUT) # Set pin R0 direction output self._PWM0 = GPIO.PWM(self._pin0, 100) self._PWM0.start(0) if self._pin1 != -1 : GPIO.setup(self._pin1, GPIO.OUT) # Set pin R1 direction output self._PWM1 = GPIO.PWM(self._pin1,100) self._PWM1.start(0) return 1 def set_dac_out_voltage(self, data, channel=0): '''! @brief Set different channel output DAC values @param data pwm pulse width @param channel output channel @n 0: Channel 0 (valid when PWM0 output is configured) @n 1: Channel 1 (effective when PWM1 output is configured) @n 2: All channels (valid when configuring dual channel outputs) @return NONE ''' if data > 100: data = 100 if data < 0: data = 0 if (channel == 0) and (self._pin0 != -1) : self._PWM0.ChangeDutyCycle(data) elif (channel == 1) and (self._pin1 != -1) : self._PWM1.ChangeDutyCycle(data) elif (channel == 2) and (self._pin0 != -1) and (self._pin1 != -1) : self._PWM0.ChangeDutyCycle(data) self._PWM1.ChangeDutyCycle(data) ``` -------------------------------- ### DFRobot_GP8XXX::begin() Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-dfrobot-gp8xxx.md Pure virtual initialization function. Must be implemented by subclasses. Returns 0 on success, non-zero on failure. ```APIDOC ## begin() ### Description Initialization function for the GP8XXX device. Pure virtual; implemented by subclasses. ### Method begin() ### Parameters None ### Return Value - **int** - 0 on success; non-zero indicates failure (implementation-dependent). ### Throws Never throws; failures are returned. ### Example ```cpp // Basic usage through a concrete product class DFRobot_GP8403 gp8403(); void setup() { gp8403.begin(); } ``` ```cpp // Error handling: retry until the I2C probe succeeds DFRobot_GP8413 gp8413(0x58); void setup() { Serial.begin(9600); while (gp8413.begin() != 0) { Serial.println("Communication with the device failed. Check connection or device address."); delay(1000); } } ``` ``` -------------------------------- ### int begin(void) Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-base.md Initializes the I2C communication and probes the device address. Returns 0 on success, non-zero on failure. ```APIDOC ## Method: int begin(void) ### Description Probes the I2C device at the configured address to verify communication. Returns 0 if the device is present and communication is successful, non-zero otherwise. ### Method begin ### Signature cpp int begin(void); ### Parameters None ### Return Value - **int** - Result of the final `Wire.endTransmission()` probe to `_deviceAddr`: `0` = success, non-zero = failure (implementation `DFRobot_GP8XXX.cpp:14-19`). ### Throws Never throws. ### Example cpp DFRobot_GP8403 gp8403(); void setup() { if (gp8403.begin() != 0) { // probe failed — device absent or wrong address } } ``` -------------------------------- ### Initialize GP8403 and retry until acknowledged Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Calls begin() in a loop, retrying while the return value is non-zero. Prints a failure message and sleeps 1 second between attempts. ```python DAC = DFRobot_GP8403(i2c_sda=17, i2c_scl=27, i2c_addr=0x58) while DAC.begin() != 0: print("Communication with the device failed. Check the connection.") time.sleep(1) ``` -------------------------------- ### GP8630N I2C usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Example usage of the DFRobot_GP8630N_I2C class: creates an instance, initializes it, sets the output range to 0-20mA, and writes a DAC value of 65535. ```cpp DFRobot_GP8630N_I2C gp8630n(&Wire, 0x58); void setup() { while (gp8630n.begin() != 0) { delay(1000); } gp8630n.setDACOutRange(gp8630n.eOutputRange20MA); gp8630n.setDACOutData(65535); } ``` -------------------------------- ### DFRobot_GP8403::begin() Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Initializes communication with the GP8403 device. Returns 0 on success and non-zero on failure. ```APIDOC ## DFRobot_GP8403::begin() ### Description Initializes communication with the GP8403 device. Returns 0 on success and non-zero on failure. ### Method begin() ### Endpoint int begin() ### Parameters None ### Request Example ```cpp while (gp8403.begin() != 0) { Serial.println("Communication with the device failed."); delay(1000); } ``` ### Response #### Success Response (0) - **return** (int) - 0 on success, non-zero on failure. ``` -------------------------------- ### begin() method signature Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Signature for the begin() method. It takes no parameters and returns an int acknowledgement signal. ```python def begin(self): ``` -------------------------------- ### begin() method declaration Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-pwm-classes.md Declares the begin() method. Returns int, always 0. Initializes the pin and sets PWM resolution. ```cpp int begin(); ``` -------------------------------- ### DFRobot_GP8302 usage example Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Creates a DFRobot_GP8302 object, initializes it, and sets the DAC output electric current to mid-scale (2048). ```cpp DFRobot_GP8302 gp8302; void setup() { gp8302.begin(); gp8302.setDACOutElectricCurrent(2048); // mid-scale current value } ``` -------------------------------- ### DFRobot_GP8600_I2C::begin() Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-products.md Initializes communication with the GP8600 device. Re-exported from the base class. ```APIDOC ## DFRobot_GP8600_I2C::begin() ### Description Initializes communication with the GP8600 device. Re-exported from the base class. ### Method begin() ### Endpoint int begin() ### Parameters None ### Request Example ```cpp while (gp8600.begin() != 0) { delay(1000); } ``` ### Response #### Success Response (0) - **return** (int) - 0 on success, non-zero on failure. ``` -------------------------------- ### setDACOutRange() usage with GP8403 Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-base.md Example of setting the output range to 0-5V on a GP8403 module using the eOutputRange5V enum value. ```cpp GP8403.setDACOutRange(GP8403.eOutputRange5V); // 0-5 V ``` -------------------------------- ### begin() pure virtual declaration Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-dfrobot-gp8xxx.md The pure virtual begin() method returns an int, contractually 0 on success. It never throws; failures are returned. Implemented by DFRobot_GP8XXX_IIC::begin() and DFRobot_GP8XXX_PWM::begin(). ```cpp virtual int begin(void) =0; ``` -------------------------------- ### Import pattern for DFRobot_GP8XXX Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/python-core.md Import pattern used by the shipped examples to add the parent directory to sys.path and import the DFRobot_GP8XXX module. ```python import sys, os sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from DFRobot_GP8XXX import * ``` -------------------------------- ### setDACOutVoltage() usage with GP8413 Source: https://github.com/dfrobot/dfrobot_gp8xxx/blob/master/_autodocs/api-reference/arduino-iic-base.md Example of setting DAC output voltage on a GP8413 module with 15-bit resolution. The value 40000 is clamped internally to 32767. ```cpp DFRobot_GP8413 gp8413(0x58); // 15-bit resolution void setup() { gp8413.begin(); gp8413.setDACOutVoltage(40000); // clamped internally to 32767 } ```