mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
install a new waveform-flavouring Arduino IDE menu and a new PIO #define (#7712)
This commit is contained in:
@ -69,8 +69,13 @@ uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs)
|
||||
uint8_t Servo::attach(int pin, uint16_t minUs, uint16_t maxUs, int value)
|
||||
{
|
||||
if (!_attached) {
|
||||
#ifdef WAVEFORM_LOCKED_PHASE
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, LOW);
|
||||
#else
|
||||
digitalWrite(pin, LOW);
|
||||
pinMode(pin, OUTPUT);
|
||||
#endif
|
||||
_pin = pin;
|
||||
_attached = true;
|
||||
}
|
||||
@ -115,9 +120,14 @@ void Servo::writeMicroseconds(int value)
|
||||
_valueUs = value;
|
||||
if (_attached) {
|
||||
_servoMap &= ~(1 << _pin);
|
||||
#ifdef WAVEFORM_LOCKED_PHASE
|
||||
// Find the first GPIO being generated by checking GCC's find-first-set (returns 1 + the bit of the first 1 in an int32_t)
|
||||
int phaseReference = __builtin_ffs(_servoMap) - 1;
|
||||
if (startWaveform(_pin, _valueUs, REFRESH_INTERVAL - _valueUs, 0, phaseReference)) {
|
||||
if (startWaveform(_pin, _valueUs, REFRESH_INTERVAL - _valueUs, 0, phaseReference))
|
||||
#else
|
||||
if (startWaveform(_pin, _valueUs, REFRESH_INTERVAL - _valueUs, 0))
|
||||
#endif
|
||||
{
|
||||
_servoMap |= (1 << _pin);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user