void LED::init(uint16_t freq, uint8_t twbr) { begin(); setPWMFreq(freq); // PWM frequency (maximum 1600) TWBR = twbr; // I2C speed (12 = 400KHz) updatePWM(); }
bool motorInit() { pca9685Init(); setAdjustPowerLeveRange(DEFAULT_ADJUST_POWER_RANGE); setAdjustPowerLimit(DEFAULT_ADJUST_POWER_LIMIT); setPWMFreq(PWM_PWM_FREQ); setupAllMotorPoewrLevel(0, 0, 0, 0); setThrottlePowerLevel(MIN_POWER_LEVEL); delay(1); return true; }
// Public Methods ////////////////////////////////////////////////////////////// uint8_t Finger::attach(uint8_t dir0, uint8_t dir1, uint8_t sense, bool inv) { if (fingerIndex < MAX_FINGERS) { // configure pins pinMode(dir0, OUTPUT); // set direction1 pin to output pinMode(dir1, OUTPUT); // set direction2 pin to output pinMode(sense, INPUT); // set sense pin to input // attach all finger pins _fingers[fingerIndex].Pin.dir[0] = dir0; _fingers[fingerIndex].Pin.dir[1] = dir1; _fingers[fingerIndex].Pin.sns = sense; // enable the motor and disable finger inversion _fingers[fingerIndex].invert = inv; _fingers[fingerIndex].motorEn = true; // set limits and initial values setPosLimits(MIN_FINGER_POS,MAX_FINGER_POS); setSpeedLimits(MIN_FINGER_SPEED,MAX_FINGER_SPEED); writeSpeed(MAX_FINGER_SPEED); writePos(MIN_FINGER_POS); _fingers[fingerIndex].CurrDir = OPEN; // set dir to OPEN after initial writePos to configure finger dir // if using the Atmega2560, set the PWM freq to > 20kHz to prevent humming setPWMFreq(dir0, 0x01); // set PWM frequency to max freq setPWMFreq(dir1, 0x01); // set PWM frequency to max freq // initialise the timer if(_timerSetupFlag == false) { _passMotorPtr(&fingerPosCtrl); _timerSetup(); _timerSetupFlag = true; } _fingers[fingerIndex].Pin.isActive = true; // this must be set after the check } return fingerIndex; }
int PCA9685::init() { int ret; ret = I2C::init(); if (ret != OK) { return ret; } ret = reset(); if (ret != OK) { return ret; } ret = setPWMFreq(PCA9685_PWMFREQ); return ret; }
void BEEPER_Set_Volume_Frequency(unsigned short frequency, VOLUME_LEVEL Volume) { strt_Beeper_Value.u16_Beeper_Frequency = frequency; switch(Volume) { case VOLUME_LOW: strt_Beeper_Value.u8_Beeper_Volume = 15; break; case VOLUME_MED: strt_Beeper_Value.u8_Beeper_Volume = 30; break; case VOLUME_HIGH: strt_Beeper_Value.u8_Beeper_Volume = 50; break; case VOLUME_MAX: strt_Beeper_Value.u8_Beeper_Volume = 75; break; default: strt_Beeper_Value.u8_Beeper_Volume = 50; break; } setPWMFreq(strt_Beeper_Value.u16_Beeper_Frequency, strt_Beeper_Value.u8_Beeper_Volume); }
/*! \param bus the bus to use in /dev/i2c-%d. \param address the device address on bus */ PCA9685::PCA9685(int address) { //i2c = new I2C(bus,address); addr = address; reset(); setPWMFreq(50); }