Many changes for v2

* Send left and right ctrl, VBand's secret keys for their adapter
* Flash lights twice at bootup
* LED reflects whether keyboard mode is enabled
* MIDI receive: if you release key C0, we stop sending keyboard events
* Get rid of the "keyboard mode" pin
* Add Makefile so I don't have to use Arduino IDE
This commit is contained in:
Neale Pickett 2022-04-19 22:16:12 -06:00
parent fa3596f6a9
commit 0962708f27
5 changed files with 144 additions and 83 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build/

39
Makefile Normal file
View File

@ -0,0 +1,39 @@
FQBN = Seeeduino:samd:seeed_XIAO_m0
UF2_MOUNT = /mnt/chromeos/removable/Arduino
ARDUINO_DIR = /app/Arduino
BUILDER = flatpak run --command ${ARDUINO_DIR}/arduino-builder cc.arduino.arduinoide
default: build/vail-adapter.ino.uf2
install: build/vail-adapter.ino.uf2
./install.sh $< $(UF2_MOUNT)
# uf2conv.py is covered by an MIT license.
build/uf2conv.py: build/uf2families.json
mkdir -p build
curl -L https://raw.githubusercontent.com/microsoft/uf2/master/utils/$(@F) > $@
chmod +x $@
build/uf2families.json:
mkdir -p build
curl -L https://raw.githubusercontent.com/microsoft/uf2/master/utils/$(@F) > $@
%.uf2: %.bin build/uf2conv.py
build/uf2conv.py -b 0x2000 -c -o $@ $<
build/%.bin: % *.cpp *.h
arduino-builder \
-build-cache ~/.cache/arduino \
-build-path build \
-core-api-version 10813 \
-fqbn $(FQBN) \
-hardware ~/.arduino15/packages \
-tools $(ARDUINO_DIR)/tools-builder \
-tools ~/.arduino15/packages \
-hardware $(ARDUINO_DIR)/hardware \
-hardware ~/.arduino15/packages \
-built-in-libraries $(ARDUINO_DIR)/libraries \
-libraries ~/Arduino/libraries \
-compile \
$<
upload: vail-adapter.ino
arduino --upload --board $(FQBN) $<

View File

@ -1,32 +1,33 @@
:Author: neale ---
:Email: neale@woozle.org Author: neale
:Date: 2020-May-3 Email: neale@woozle.org
:Revision: 1 License: MIT
:License: MIT ---
= Project: USB Morse Adapter # Project: USB Morse Adapter
image:https://lh3.googleusercontent.com/pw/ACtC-3d9xbLxL23QeLm-3gy3-Yt0VHE3IlQ-qyMDqTfdF6Bo7fHkkokACdIs68pmXevu14VzrrCeKj1JmRUiekUNiZe9J9rYIh_pTagvCbKSzpY8Ynp1m6cF4G_jTvtiU5eRtoNCsmU5OLy2SR9kYcCDYSt-AA=s1471-no["Vail adapter, assembled and connected",width=300,https://lh3.googleusercontent.com/pw/ACtC-3d9xbLxL23QeLm-3gy3-Yt0VHE3IlQ-qyMDqTfdF6Bo7fHkkokACdIs68pmXevu14VzrrCeKj1JmRUiekUNiZe9J9rYIh_pTagvCbKSzpY8Ynp1m6cF4G_jTvtiU5eRtoNCsmU5OLy2SR9kYcCDYSt-AA=s1471-no] ![Vail adapter, assembled and connected](https://lh3.googleusercontent.com/pw/ACtC-3d9xbLxL23QeLm-3gy3-Yt0VHE3IlQ-qyMDqTfdF6Bo7fHkkokACdIs68pmXevu14VzrrCeKj1JmRUiekUNiZe9J9rYIh_pTagvCbKSzpY8Ynp1m6cF4G_jTvtiU5eRtoNCsmU5OLy2SR9kYcCDYSt-AA=s1471-no)
This translates Morse key inputs into USB events, This translates Morse key inputs into USB events,
either MIDI or MIDI+Keyboard, either MIDI or MIDI+Keyboard,
so you can use a computer. so you can use a computer.
It is fully compatible with [VBand](https://hamradio.solutions/vband/)
and anything else that uses the VBand adapter.
I use this with an Internet morse code repeater I wrote, I use this with an Internet morse code repeater I wrote,
available at https://vail.woozle.org/. available at https://vail.woozle.org/.
It will also work with [VBand](https://hamradio.solutions/vband/),
in MIDI+Keyboard mode.
This project requires an Arduino that can send USB. This project requires an Arduino that can send USB.
The following should work: The following should work:
=== Verified Working ### Verified Working
* Seeeduino Xiao * Seeeduino Xiao **(recommended)**
* Arduino Micro * Arduino Micro
* KeeYees Pro Micro * KeeYees Pro Micro
=== Unverified but should work ### Unverified but should work
Any USB-capable Arduino should be fine, including: Any USB-capable Arduino should be fine, including:
@ -39,28 +40,30 @@ Any USB-capable Arduino should be fine, including:
You might even be able to get a Digispark (attiny85) to work, You might even be able to get a Digispark (attiny85) to work,
but this may require a little hacking. Send me a patch, if you do! but this may require a little hacking. Send me a patch, if you do!
== Step 1: Installation ## Step 1: Installation
If Arduino Create still exists when you're reading this, #### The Easy Way
you might be able to load up
https://create.arduino.cc/editor/neale/f94bb765-47bd-4bc4-9cbf-b978f7124bdc[my project]
and program your board without too much fuss.
Otherwise you are going to need to install the MidiUSB and Keyboard libraries. I plan to begin releasing precompiled images for the Seeeduino XIAO.
You should be able to
[enter bootloader mode](https://wiki.seeedstudio.com/Seeeduino-XIAO/#enter-bootloader-mode)
and just drag the `.uf2` file onto the new drive it provides,
then you're done.
#### The Other Way
Install the MidiUSB and Keyboard libraries.
These are highly popular libraries, These are highly popular libraries,
and there is much better documentation elsewhere on the Internet. and there is much better documentation elsewhere on the Internet.
The code should then build in the Arduino IDE.
## Step 2: Assmble the circuit
== Step 2: Assmble the circuit ### For the impatient:
=== For the impatient: [Photos of assembled circuit](https://github.com/nealey/vail-adapter/wiki)
https://github.com/nealey/vail-adapter/wiki[Photos of assembled circuit] ### For the inquisitive:
Remember to jump pin 9 to ground for Firefox,
or VBand.
=== For the inquisitive:
Morse code keyers are very simple devices, Morse code keyers are very simple devices,
they just connect two wires together. they just connect two wires together.
@ -70,22 +73,21 @@ or even touch wires together.
The only real complication here is that some browsers The only real complication here is that some browsers
need to get keyboard events instead of musical instrument events. need to get keyboard events instead of musical instrument events.
The Vail adapter boots into a mode that sends both keyboard events
and MIDI messages.
If it receives a MIDI key release event
on channel 0
for note C0,
it will disable keyboard events.
=== Decide what browser you're going to use Vail sends this "disable keyboard" MIDI event, so as soon as you
load up Vail, the keyboard events are disabled, and your adapter
will no longer interfere with your typing.
If your browser doesn't support MIDI,
the disable command can't be sent,
and it keeps on sending keystrokes.
Firefox needs a jumper between pin 9 and ground. ### Wire up your input device
Just take a wire, and connect pin 9 directly to ground.
This puts the Arduino into "keyboard mode",
where it sends a comma for straight key,
and brackets for iambic.
If you don't connect pin 9 to ground,
the Arudino only sends MIDI (Musical Instrument Digital Interface)
events, so it looks like you hooked a piano up.
This works great in Chrome,
and lets you switch to other windows while still keying into vail.
=== Wire up your input device
Hook a straight key into ground on one side, Hook a straight key into ground on one side,
pin 10 on the other. pin 10 on the other.
@ -109,21 +111,15 @@ Make sure any straight key you plug in has a TS adapter (mono plug):
this will short pin 11 to ground and signal to the Arduino to this will short pin 11 to ground and signal to the Arduino to
go into straight key mode. go into straight key mode.
You need to reset the Arduino if you change from an iambic to straight key. If you change from an iambic key to a straight key,
On the micro, reset is a white button. you'll have to reset the adapter by unplugging it from the computer.
If you plug in your straight key and it looks like DAH is being held down,
it means you need to switch the connections to pins 11 and 12.
If you plug in your straight key and it looks like DIT is being held down,
it means you need to reset the Arduino to make it detect the key type again.
== Step 3: Load the code ## Step 3: Load the code
Upload the code contained in this sketch on to your board. Upload the code contained in this sketch on to your board.
== Step 4: Test it out ## Step 4: Test it out
Make sure it's plugged in to your computer's USB port. Make sure it's plugged in to your computer's USB port.
@ -136,8 +132,16 @@ Now you can open https://vail.woozle.org/,
click the "KEY" button once to let the browser know it's okay to make sound, click the "KEY" button once to let the browser know it's okay to make sound,
and you should be able to wail away on your new USB keyer. and you should be able to wail away on your new USB keyer.
## Step 5: Debugging
=== License If you plug in your straight key and it looks like DAH is being held down,
it means you need to switch the connections to pins 11 and 12.
If you plug in your straight key and it looks like DIT is being held down,
it means you need to reset the Arduino to make it detect the key type again.
# License
This project is released under an MIT License. This project is released under an MIT License.
@ -162,12 +166,12 @@ in an action of contract, tort or otherwise, arising from, out of, or in
connection with the software or the use or other dealings in the software. connection with the software or the use or other dealings in the software.
=== Contributing # Contributing
To contribute to this project please contact neale@woozle.org To contribute to this project please contact neale@woozle.org
https://id.arduino.cc/neale https://id.arduino.cc/neale
=== BOM # BOM
In addition to a key, some hookup wires, and a USB cable, In addition to a key, some hookup wires, and a USB cable,
you only need a USB-capable Arduino: see above. you only need a USB-capable Arduino: see above.
@ -176,15 +180,6 @@ Since I don't know what might try to parse this section,
I'm calling for an Arduino Micro. But, really, many options I'm calling for an Arduino Micro. But, really, many options
will work fine. will work fine.
|=== | ID | Part name | Part number | Quantity |
| ID | Part name | Part number | Quantity | --- | ------- | ------ | ------ |
| A1 | Arduino Micro | ABX00053 | 1 | A1 | Seeeduino XIAO | 102010328 | 1 |
|===
=== Help
This document is written in the _AsciiDoc_ format, a markup language to describe documents.
If you need help you can search the http://www.methods.co.nz/asciidoc[AsciiDoc homepage]
or consult the http://powerman.name/doc/asciidoc[AsciiDoc cheatsheet]

15
install.sh Executable file
View File

@ -0,0 +1,15 @@
#! /bin/sh
src=$1
dst=$2
info=$dst/INFO_UF2.txt
echo -n "Waiting for $info to appear..."
while ! [ -f $info ]; do
echo -n "."
sleep 1
done
echo "👍"
cp $src $dst
echo "Installed!"

View File

@ -17,21 +17,18 @@
# define KEY_PIN 10 # define KEY_PIN 10
#endif #endif
#define KBD_PIN 9
#define STRAIGHT_KEY ',' #define STRAIGHT_KEY ','
#define DIT_KEY '[' #define DIT_KEY KEY_LEFT_CTRL
#define DAH_KEY ']' #define DAH_KEY KEY_RIGHT_CTRL
bool iambic = true; bool iambic = true;
Bounce kbd = Bounce(); bool keyboard = true;
Bounce dit = Bounce(); Bounce dit = Bounce();
Bounce dah = Bounce(); Bounce dah = Bounce();
Bounce key = Bounce(); Bounce key = Bounce();
void setup() { void setup() {
pinMode(LED_BUILTIN, OUTPUT); pinMode(LED_BUILTIN, OUTPUT);
kbd.attach(KBD_PIN, INPUT_PULLUP);
dit.attach(DIT_PIN, INPUT_PULLUP); dit.attach(DIT_PIN, INPUT_PULLUP);
dah.attach(DAH_PIN, INPUT_PULLUP); dah.attach(DAH_PIN, INPUT_PULLUP);
key.attach(KEY_PIN, INPUT_PULLUP); key.attach(KEY_PIN, INPUT_PULLUP);
@ -50,7 +47,12 @@ void setup() {
iambic = true; iambic = true;
} }
digitalWrite(LED_BUILTIN, !iambic); // Blink 4 times
for (int i = 0; i < 8; i += 1) {
digitalWrite(LED_BUILTIN, i % 2);
delay(250);
}
} }
void midiKey(bool down, uint8_t key) { void midiKey(bool down, uint8_t key) {
@ -59,11 +61,20 @@ void midiKey(bool down, uint8_t key) {
MidiUSB.flush(); MidiUSB.flush();
} }
void loop() { void midiProbe() {
bool keyboard; midiEventPacket_t event = MidiUSB.read();
if (event.byte1 == 0x80) {
// Key release, channel 0
if (event.byte2 == 0x00) {
// C0 note
keyboard = false;
}
}
}
kbd.update(); void loop() {
keyboard = !kbd.read(); midiProbe();
digitalWrite(LED_BUILTIN, !keyboard);
// Monitor straight key pin // Monitor straight key pin
if (key.update()) { if (key.update()) {