3131namespace ctbot {
3232using namespace avr ;
3333
34- bool Servo::initialized { false };
34+ bool Servo::initialized_ { false };
3535
36- Servo::Servo (ID num, volatile uint8_t * p_ddr, uint8_t pin, volatile uint16_t * p_ocr_reg) : id { num }, p_ocr { p_ocr_reg }, position { POS_OFF } {
36+ Servo::Servo (ID num, volatile uint8_t * p_ddr, uint8_t pin, volatile uint16_t * p_ocr_reg) : id_ { num }, p_ocr_ { p_ocr_reg }, position_ { POS_OFF } {
3737 SBI (p_ddr, pin); // set servo pin as output
3838
39- if (! initialized ) {
40- initialized = true ;
39+ if (! initialized_ ) {
40+ initialized_ = true ;
4141 GPIOR0 = 0 ; // both servos shut off
4242 TCNT3 = 0 ; // TIMER3 init
4343 ICR3 = 40000UL ;
@@ -52,21 +52,21 @@ Servo::Servo(ID num, volatile uint8_t* p_ddr, uint8_t pin, volatile uint16_t* p_
5252void Servo::set (uint8_t pos) {
5353 if (pos == POS_OFF) {
5454 /* set pwm pin low on next overflow */
55- if (id == ID::SERVO_1) {
55+ if (id_ == ID::SERVO_1) {
5656 CBI (&GPIOR0, static_cast <uint8_t >(0U ));
5757 } else {
5858 CBI (&GPIOR0, static_cast <uint8_t >(1U ));
5959 }
6060 } else {
61- *p_ocr = calc_ocr (pos);
62- if (id == ID::SERVO_1) {
61+ *p_ocr_ = calc_ocr (pos);
62+ if (id_ == ID::SERVO_1) {
6363 SBI (&GPIOR0, static_cast <uint8_t >(0U ));
6464 } else {
6565 SBI (&GPIOR0, static_cast <uint8_t >(1U ));
6666 }
67- TIMSK3 |= BV_8 (ICF3) | (id == ID::SERVO_1 ? BV_8 (OCIE3A) : BV_8 (OCIE3B)); // Input Capture Interrupt Enable, Output Compare A Match Interrupt Enable
67+ TIMSK3 |= BV_8 (ICF3) | (id_ == ID::SERVO_1 ? BV_8 (OCIE3A) : BV_8 (OCIE3B)); // Input Capture Interrupt Enable, Output Compare A Match Interrupt Enable
6868 }
69- position = pos;
69+ position_ = pos;
7070}
7171
7272
0 commit comments