diff --git a/mozc-piropiro/README.md b/mozc-piropiro/README.md new file mode 100644 index 0000000..377bed7 --- /dev/null +++ b/mozc-piropiro/README.md @@ -0,0 +1,128 @@ +Copyright 2015 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + + Summary +===================================== + +Mechanical design, circuit diagram and firmware of Google Japanese Input +piropiro version. + + + Files +===================================== + +* stl/* -- 3D shape data of mechanical parts +* README.txt -- this file +* circuit.png -- Circuit diagram +* assembly.png -- Mechanical assembly instruction +* arduino/piropiro/piropiro.ino -- Firmware source code (Arduino sketch) + + + Building your device +===================================== + +## Mechanical parts + +Output all mechanical parts under stl/ directory with a 3D printer. +Additionally, you need these parts. + +* M2x4 scerws x7 +* M2 washer (inside diameter=2.2mm, outside diameter=5.8mm) x1 +* A party horn x1 + +## Electronic parts + +* Arduino Nano + Some other models of Arduino (e.g. Arduino Uno) can be used + if required function is available. +* RN-42-EK or a compatible evaluation kit + RN-42 can be used instead if wired appropriately. +* GP2Y0E02A distance sensor +* 1/8W Resistors + * 1k + * 470 +* Breadboard and jump wires + +## Assembly + +See the circuit diagram and mechanical assembly instruction images. + +## RN42 module configuration + +This step is required for the first time, or when changing the device's name. +Note that you should not connect Arduino Nano when you configure RN-42-EK via +USB, because signal from Arduino Nano overrides the TxD signal on RN-42-EK. +See Microchip's documents for detail. + +1. Connect RN-42-EK to your PC by USB. +2. Run a terminal emulator and open the serial port for RN-42-EK. +3. Type '$$$'. Make sure 'CMD' is returned from RN-42-EK and the green LED on + RN-42-EK blinks fast. +4. Configure the module by these commands: + +* * * * * * + SU,115k + SM,6 + SA,2 + S~,6 + SH,0000 + SN,MY_PIROPIRO_KEYBOARD + R,1 +* * * * * * +MY\_PIROPIRO\_KEYBOARD is a device name that will appear when you scan Bluetooth +devices, and can be replaced by your preferred name. + +The commands will configure the module as follows: + +* 115200bps +* Pairing mode +* SSP "just works" mode +* SPP profile +* HID flag register = 0 (keyboard) + + +## Electronic Circuit Assembly + +See the circuit diagram for detail. +When operating the device, supply power by USB cables to both RN-42-EK and +Arduino Nano. You can alternatively supply 3.3V power to RN-42-EK from Arduino's +3.3V pin, but this requires a modification on RN-42-EK to disconnect the +regulator's output pin on it from the circuit. + + + Using piropiro input +===================================== + +## Sensor adjustment + +1. Attach the device to your party horn. The sensor should be positioned about +40mm apart from the rolled paper tube. +2. Turn on Arduino Nano and adjust the optical axis of the sensor. The LED on +Arduino board is lit while the sensor is collectly sensing the tip of the +paper tube between 50mm -- 350mm. + + +## Bluetooth pairing + +Using your device (e.g. Android phone), scan Bluetooth devices and you will +find MY\_PIROPIRO\_KEYBOARD (or the name you set up) in the available device +list. + +## How to input + +Switch the Japanese IME on the paired device to romaji input mode. +Characters will be input as you blow the horn. +The length of the horn chooses the vowel. +In order to switch to the next column (consonant), quickly shrink the horn and blow it again. diff --git a/mozc-piropiro/arduino/piropiro/piropiro.ino b/mozc-piropiro/arduino/piropiro/piropiro.ino new file mode 100644 index 0000000..6227e92 --- /dev/null +++ b/mozc-piropiro/arduino/piropiro/piropiro.ino @@ -0,0 +1,105 @@ +/* + * Copyright 2015 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Firmware of piropiro (party horn) Bluetooth keyboard. + */ + +#define V_REF 5.0 +#define PIN_LED 13 +#define N_AD_SAMPLES 10 + +#define INTERVAL_MSEC 20 +#define COMMIT_TIME (600 / INTERVAL_MSEC) + +#define ROWS 5 +#define COLS 9 + +const char* characters[ROWS * COLS] = { + "a", "i", "u", "e", "o", + "ka", "ki", "ku", "ke", "ko", + "sa", "si", "su", "se", "so", + "ta", "ti", "tu", "te", "to", + "na", "ni", "nu", "ne", "no", + "ha", "hi", "hu", "he", "ho", + "ma", "mi", "mu", "me", "mo", + "ya", "ya", "yu", "yu", "yo", + "wa", "wo", "nn", ",", "." +}; + +int column = 0; +int vowel = 0; +int release_duration = 0; + +void setup() { + Serial.begin(115200); + pinMode(PIN_LED, OUTPUT); + column = 0; + vowel = 0; +} + +float getVoltage(int ch) { + return analogRead(ch) * V_REF / 1023; +} + +float getAverageVoltage(int ch) { + float sum = 0.0; + for (int i = 0; i < N_AD_SAMPLES; i++) { + sum += getVoltage(ch); + } + return sum / N_AD_SAMPLES; +} + +float voltageToLength(float voltage) { + return 648 - voltage * 268; +} + +void loop() { + float length = voltageToLength(getAverageVoltage(0)); + if (length > 350) { + digitalWrite(PIN_LED, LOW); + } else { + digitalWrite(PIN_LED, HIGH); + if (length < 50) { + if (vowel > 0) { + vowel = 0; + column ++; + if (column >= COLS) { + column = 0; + } + release_duration = 0; + } else if (release_duration > COMMIT_TIME) { + vowel = 0; + column = 0; + } else if (column > 0) { + release_duration ++; + } + } else { + int target_vowel = (length - 80) / 40 + 1; + if (target_vowel > 5) target_vowel = 5; + if (vowel < target_vowel) { + if (column > 0 || vowel > 0) { + Serial.print("\b"); + } + vowel ++; + int current_character = vowel - 1 + column * 5; + Serial.print(characters[current_character]); + } + } + } + delay(INTERVAL_MSEC); +} + diff --git a/mozc-piropiro/assembly.png b/mozc-piropiro/assembly.png new file mode 100644 index 0000000..cce0403 Binary files /dev/null and b/mozc-piropiro/assembly.png differ diff --git a/mozc-piropiro/circuit.png b/mozc-piropiro/circuit.png new file mode 100644 index 0000000..56b1744 Binary files /dev/null and b/mozc-piropiro/circuit.png differ diff --git a/mozc-piropiro/stl/arm.stl b/mozc-piropiro/stl/arm.stl new file mode 100644 index 0000000..15e130a Binary files /dev/null and b/mozc-piropiro/stl/arm.stl differ diff --git a/mozc-piropiro/stl/base.stl b/mozc-piropiro/stl/base.stl new file mode 100644 index 0000000..8d2151e Binary files /dev/null and b/mozc-piropiro/stl/base.stl differ diff --git a/mozc-piropiro/stl/holder1.stl b/mozc-piropiro/stl/holder1.stl new file mode 100644 index 0000000..2adc9e9 Binary files /dev/null and b/mozc-piropiro/stl/holder1.stl differ diff --git a/mozc-piropiro/stl/holder2.stl b/mozc-piropiro/stl/holder2.stl new file mode 100644 index 0000000..2adc9e9 Binary files /dev/null and b/mozc-piropiro/stl/holder2.stl differ diff --git a/mozc-piropiro/stl/sensor_bracket.stl b/mozc-piropiro/stl/sensor_bracket.stl new file mode 100644 index 0000000..39507da Binary files /dev/null and b/mozc-piropiro/stl/sensor_bracket.stl differ