mirror of
https://github.com/google/mozc-devices.git
synced 2025-11-08 16:53:28 +03:00
Add mozc-dial nine dial edition.
Co-authored-by: Takashi Toyoshima <toyoshim@google.com> Co-authored-by: Shun Ikejima <ikejima@google.com>
This commit is contained in:
@@ -49,9 +49,10 @@ bool MotorController::OnAlarm(repeating_timer* t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MotorController::MotorController(Mode mode) {
|
||||
MotorController::MotorController(Mode mode, Direction direction)
|
||||
: direction_(direction) {
|
||||
if (mode == Mode::k9Motor) {
|
||||
// Each decoder is responsible for a specific phase to driver 1 of 8 motor
|
||||
// Each decoder is responsible for a specific phase to drive 1 of 8 motor
|
||||
// drivers. As we have 4 phases, it can drive 4 motors at the same time, and
|
||||
// by time division multiplexing, we make them drive 8 motors.
|
||||
decoder_[0] = std::make_unique<Decoder>(1, 2, 3, 4);
|
||||
@@ -88,7 +89,7 @@ void MotorController::Step() {
|
||||
size_t start_index = (phase_ & 1) ? kNumOfPhases : 0;
|
||||
size_t half_phase = phase_ >> 1;
|
||||
for (size_t i = start_index; i < start_index + kNumOfPhases; ++i) {
|
||||
if (!decoder_[i]) {
|
||||
if (!decoder_[i % kNumOfPhases]) {
|
||||
continue;
|
||||
}
|
||||
if (started_[i]) {
|
||||
@@ -104,5 +105,9 @@ void MotorController::Step() {
|
||||
gpio_put(19, on && half_phase == 2);
|
||||
gpio_put(20, on && half_phase == 3);
|
||||
|
||||
phase_ = (phase_ + 7) % 8;
|
||||
if (direction_ == Direction::kForward) {
|
||||
phase_ = (phase_ + 1) % 8;
|
||||
} else if (direction_ == Direction::kBackward) {
|
||||
phase_ = (phase_ + 7) % 8;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@
|
||||
class MotorController final {
|
||||
public:
|
||||
enum class Mode { k1Motor, k9Motor };
|
||||
explicit MotorController(Mode = Mode::k9Motor);
|
||||
enum class Direction { kForward, kBackward };
|
||||
explicit MotorController(Mode = Mode::k9Motor, Direction = Direction::kForward);
|
||||
MotorController(const MotorController&) = delete;
|
||||
MotorController& operator=(const MotorController&) = delete;
|
||||
~MotorController();
|
||||
@@ -33,6 +34,7 @@ class MotorController final {
|
||||
bool started_[kNumOfMotors] = { false };
|
||||
uint8_t phase_ = 0;
|
||||
repeating_timer timer_;
|
||||
Direction direction_ = Direction::kForward;
|
||||
};
|
||||
|
||||
#endif // COMMON_MOTOR_CONTROLLER_H_
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "hardware/gpio.h"
|
||||
|
||||
//#define NO_SENSOR_PULL
|
||||
|
||||
PhotoSensor::PhotoSensor(int8_t bit0,
|
||||
int8_t bit1,
|
||||
int8_t bit2,
|
||||
@@ -16,7 +18,13 @@ PhotoSensor::PhotoSensor(int8_t bit0,
|
||||
for (int8_t gpio : bits) {
|
||||
gpio_init(gpio);
|
||||
gpio_set_dir(gpio, GPIO_IN);
|
||||
gpio_pull_up(gpio); // Built-in 50-80K pull-up
|
||||
#ifdef NO_SENSOR_PULL
|
||||
gpio_disable_pulls(gpio);
|
||||
#else
|
||||
// Built-in 50-80K pull-up is expected, but the actual value appears to
|
||||
// depend on the RP2040's shipping years?
|
||||
gpio_pull_up(gpio);
|
||||
#endif // NO_SENSOR_PULL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ const std::vector<uint8_t> a = {
|
||||
0x14, // q
|
||||
0x04, // a
|
||||
0x1d, // z
|
||||
0x39, // <CAPS>
|
||||
0x2c, // <SPACE>
|
||||
0x39, // <CAPS>
|
||||
};
|
||||
const std::vector<uint8_t> fn_a = {};
|
||||
const std::vector<uint8_t> modifier_a = {};
|
||||
|
||||
Reference in New Issue
Block a user