diff --git a/src/keyer.cpp b/src/keyer.cpp index 1514d2c..e0cda1e 100644 --- a/src/keyer.cpp +++ b/src/keyer.cpp @@ -16,7 +16,7 @@ extern const uint CW_OUT_PIN; const uint SIDETONE_FREQ = 622; -bool Keyer::dit_paddle_pressed() const +bool Keyer::ditPaddlePressed() const { if (!gpio_get(DIT_PADDLE_PIN)) { return true; @@ -24,7 +24,7 @@ bool Keyer::dit_paddle_pressed() const return false; } -bool Keyer::dah_paddle_pressed() const +bool Keyer::dahPaddlePressed() const { if (!gpio_get(DAH_PADDLE_PIN)) { return true; @@ -112,7 +112,7 @@ void Keyer::run() gpio_put(CW_OUT_PIN, 1); m_buzzer.on(SIDETONE_FREQ); } - if (dit_paddle_pressed() || dah_paddle_pressed()) { + if (ditPaddlePressed() || dahPaddlePressed()) { m_messageKeyingState = MessageState::Abort; } if (absolute_time_diff_us(timestamp, m_keying_until) <= 0) { @@ -131,7 +131,7 @@ void Keyer::run() gpio_put(CW_OUT_PIN, 1); m_buzzer.on(SIDETONE_FREQ); } - if (dit_paddle_pressed() || dah_paddle_pressed()) { + if (ditPaddlePressed() || dahPaddlePressed()) { m_messageKeyingState = MessageState::Abort; } if (absolute_time_diff_us(timestamp, m_keying_until) <= 0) { @@ -147,7 +147,7 @@ void Keyer::run() m_pausing_until = make_timeout_time_us(m_elementDuration); m_currentlyPausing = true; } - if (dit_paddle_pressed() || dah_paddle_pressed()) { + if (ditPaddlePressed() || dahPaddlePressed()) { m_messageKeyingState = MessageState::Abort; } if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0) { @@ -160,7 +160,7 @@ void Keyer::run() m_pausing_until = make_timeout_time_us(m_elementDuration * 3); m_currentlyPausing = true; } - if (dit_paddle_pressed() || dah_paddle_pressed()) { + if (ditPaddlePressed() || dahPaddlePressed()) { m_messageKeyingState = MessageState::Abort; } if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0) { @@ -174,7 +174,7 @@ void Keyer::run() (7 - 3)); // 7-3, because we aleady have the InterCharSpace of 3 m_currentlyPausing = true; } - if (dit_paddle_pressed() || dah_paddle_pressed()) { + if (ditPaddlePressed() || dahPaddlePressed()) { m_messageKeyingState = MessageState::Abort; } if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0) { @@ -202,7 +202,7 @@ void Keyer::run() // If we are in Straight key mode … if (m_mode == Mode::Straight) { - if (dit_paddle_pressed()) { + if (ditPaddlePressed()) { gpio_put(LED_PIN, 1); gpio_put(CW_OUT_PIN, 1); m_buzzer.on(SIDETONE_FREQ); @@ -218,10 +218,10 @@ void Keyer::run() // If we are in IambicA or IambicB-Mode … switch (m_paddleKeyingState) { case State::Wait: - if (dit_paddle_pressed()) { + if (ditPaddlePressed()) { m_keyNextIambicB = false; m_paddleKeyingState = State::Dit; - } else if (dah_paddle_pressed()) { + } else if (dahPaddlePressed()) { m_keyNextIambicB = false; m_paddleKeyingState = State::Dah; } else { @@ -245,7 +245,7 @@ void Keyer::run() // m_audioOut.on(SIDETONE_FREQ); } else { // If right paddle üressed -> note for Iambic B - if (dah_paddle_pressed() && !m_keyNextIambicB) { + if (dahPaddlePressed() && !m_keyNextIambicB) { m_keyNextIambicB = true; } @@ -270,7 +270,7 @@ void Keyer::run() // m_audioOut.on(SIDETONE_FREQ); } else { // If left paddle pressed -> Note for Iambic B - if (dit_paddle_pressed() && !m_keyNextIambicB) { + if (ditPaddlePressed() && !m_keyNextIambicB) { m_keyNextIambicB = true; } @@ -293,10 +293,10 @@ void Keyer::run() if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0) { m_currentlyPausing = false; - if (dah_paddle_pressed()) { + if (dahPaddlePressed()) { m_paddleKeyingState = State::Dah; m_keyNextIambicB = false; - } else if (dit_paddle_pressed()) { + } else if (ditPaddlePressed()) { m_paddleKeyingState = State::Dit; m_keyNextIambicB = false; } else { @@ -313,10 +313,10 @@ void Keyer::run() if (absolute_time_diff_us(timestamp, m_pausing_until) <= 0) { m_currentlyPausing = false; - if (dit_paddle_pressed()) { + if (ditPaddlePressed()) { m_paddleKeyingState = State::Dit; m_keyNextIambicB = false; - } else if (dah_paddle_pressed()) { + } else if (dahPaddlePressed()) { m_paddleKeyingState = State::Dah; m_keyNextIambicB = false; } else { diff --git a/src/keyer.h b/src/keyer.h index 381f605..fb02bfa 100644 --- a/src/keyer.h +++ b/src/keyer.h @@ -39,8 +39,8 @@ class Keyer final Abort, }; - bool dit_paddle_pressed() const; - bool dah_paddle_pressed() const; + bool ditPaddlePressed() const; + bool dahPaddlePressed() const; uint8_t m_wpm {18}; Mode m_mode {Mode::IambicB}; diff --git a/src/tm1637.cpp b/src/tm1637.cpp index 55a6205..09c0e4a 100644 --- a/src/tm1637.cpp +++ b/src/tm1637.cpp @@ -15,24 +15,24 @@ void TM1637::init(uint8_t dio, uint8_t clk) { static constexpr size_t PULL_THRESHOLD = 32; - state_machine = static_cast(pio_claim_unused_sm(m_pio, true)); + m_stateMachine = static_cast(pio_claim_unused_sm(m_pio, true)); auto offset = pio_add_program(m_pio, &tm1637_program); - state_machine_config = tm1637_program_get_default_config(offset); + m_stateMachineConfig = tm1637_program_get_default_config(offset); - sm_config_set_sideset_pins(&state_machine_config, clk); + sm_config_set_sideset_pins(&m_stateMachineConfig, clk); uint32_t both_pins = (1 << clk) | (1 << dio); - pio_sm_set_pins_with_mask(m_pio, state_machine, both_pins, both_pins); - pio_sm_set_pindirs_with_mask(m_pio, state_machine, both_pins, both_pins); + pio_sm_set_pins_with_mask(m_pio, m_stateMachine, both_pins, both_pins); + pio_sm_set_pindirs_with_mask(m_pio, m_stateMachine, both_pins, both_pins); - sm_config_set_out_pins(&state_machine_config, dio, 1); - sm_config_set_set_pins(&state_machine_config, dio, 1); + sm_config_set_out_pins(&m_stateMachineConfig, dio, 1); + sm_config_set_set_pins(&m_stateMachineConfig, dio, 1); - sm_config_set_out_shift(&state_machine_config, true, false, PULL_THRESHOLD); + sm_config_set_out_shift(&m_stateMachineConfig, true, false, PULL_THRESHOLD); setClockDivider(); - pio_sm_init(m_pio, state_machine, offset, &state_machine_config); - pio_sm_set_enabled(m_pio, state_machine, true); + pio_sm_init(m_pio, m_stateMachine, offset, &m_stateMachineConfig); + pio_sm_set_enabled(m_pio, m_stateMachine, true); } void TM1637::setClockDivider() @@ -49,7 +49,7 @@ void TM1637::setClockDivider() divider = 1; } - sm_config_set_clkdiv(&state_machine_config, divider); + sm_config_set_clkdiv(&m_stateMachineConfig, divider); } void TM1637::setColon([[maybe_unused]] bool on) @@ -77,10 +77,10 @@ void TM1637::send4Bytes(uint32_t data) data_1 = data & BIT_MASK; data_2 = data >> SHIFT_POSITIONS; - pio_sm_put_blocking(m_pio, state_machine, (data_1 << (2 * BYTE_SIZE)) + (WRITE_ADDRESS << BYTE_SIZE) + WRITE_MODE); - pio_sm_put_blocking(m_pio, state_machine, data_2 << (2 * BYTE_SIZE)); + pio_sm_put_blocking(m_pio, m_stateMachine, (data_1 << (2 * BYTE_SIZE)) + (WRITE_ADDRESS << BYTE_SIZE) + WRITE_MODE); + pio_sm_put_blocking(m_pio, m_stateMachine, data_2 << (2 * BYTE_SIZE)); - pio_sm_put_blocking(m_pio, state_machine, BRIGHTNESS_BASE + m_brightness); + pio_sm_put_blocking(m_pio, m_stateMachine, BRIGHTNESS_BASE + m_brightness); } void TM1637::displayIambicMode(Mode iambic) diff --git a/src/tm1637.h b/src/tm1637.h index d824f68..4f34aa3 100644 --- a/src/tm1637.h +++ b/src/tm1637.h @@ -20,8 +20,8 @@ class TM1637 void send4Bytes(uint32_t data); PIO m_pio {}; - uint8_t state_machine {}; - pio_sm_config state_machine_config {}; + uint8_t m_stateMachine {}; + pio_sm_config m_stateMachineConfig {}; uint8_t m_brightness {0}; uint32_t m_currentSegments {0}; bool m_isColon {false};