mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
I2C diagnostics
Pending removal of Wire.h
This commit is contained in:
parent
20eef04ba7
commit
04d7b82c0d
|
@ -77,18 +77,19 @@ bool PWMServoDriver::setup(int board) {
|
||||||
* @brief Sets the PWM output to a servo
|
* @brief Sets the PWM output to a servo
|
||||||
*/
|
*/
|
||||||
void PWMServoDriver::setServo(byte servoNum, uint16_t value) {
|
void PWMServoDriver::setServo(byte servoNum, uint16_t value) {
|
||||||
DIAG(F("\nsetServo %d %d\n"),servoNum,value);
|
|
||||||
int board=servoNum/16;
|
int board=servoNum/16;
|
||||||
int pin=servoNum%16;
|
int pin=servoNum%16;
|
||||||
|
|
||||||
if (setup(board)) {
|
if (setup(board)) {
|
||||||
|
DIAG(F("\nSetServo %d %d\n"),servoNum,value);
|
||||||
Wire.beginTransmission(PCA9685_I2C_ADDRESS + board);
|
Wire.beginTransmission(PCA9685_I2C_ADDRESS + board);
|
||||||
Wire.write(PCA9685_FIRST_SERVO + 4 * pin); // 4 registers per pin
|
Wire.write(PCA9685_FIRST_SERVO + 4 * pin); // 4 registers per pin
|
||||||
Wire.write(0);
|
Wire.write(0);
|
||||||
Wire.write(0);
|
Wire.write(0);
|
||||||
Wire.write(value);
|
Wire.write(value);
|
||||||
Wire.write(value >> 8);
|
Wire.write(value >> 8);
|
||||||
Wire.endTransmission();
|
byte error=Wire.endTransmission();
|
||||||
|
if (error!=0) DIAG(F("\nSetServo error %d\n"),error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user