Skip to content

Commit

Permalink
Merge pull request #73 from samdoshi/2.0
Browse files Browse the repository at this point in the history
Teletype 2.0 work so far
  • Loading branch information
tehn authored May 17, 2017
2 parents 54e2850 + db2cc2e commit 2fda641
Show file tree
Hide file tree
Showing 84 changed files with 6,824 additions and 4,159 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ indent_style = tab
indent_size = 8
trim_trailing_whitespace = true

# C & Cpp
[*.{h,hpp,c,cpp}]
# C & Cpp & Ragel
[*.{h,hpp,c,cpp,rl}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
*.dSYM/

# Build outputs
/src/match_token.c
/src/scanner.c
/simulator/tt
/module/gitversion.c
/tests/tests
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# Changelog

## vNext
- **BREAKING**: remove `II` op. Ops that required it will now work with out it. (e.g. `II MP.PRESET 1` will become just `MP.PRESET 1`)
- **BREAKING**: merge the `MUTE` and `UNMUTE` ops. Now `MUTE x` will return the mute status for trigger `x` (`0` is unmuted, `1` is muted), and `MUTE x y` will set the mute for trigger `x` (`y = 0` to unmute, `y = 1` to mute)
- **NEW**: sub commands, use a `;` separator to run multiple commands on a single line, e.g. `X 1; Y 2`
- **NEW**: key bindings rewritten, see [docs](./docs/modes.md)
- **NEW**: multiple commands on each line separated by ':'
- **NEW**: aliases: `+` for `ADD`, `-` for `SUB`, `*` for `MUL`, `/` for `DIV`, `%` for `MOD`, `<<` for `LSH`, `>>` for `RSH`, `==` for `EQ`, `!=` for `NE`, `<` for `LT`, `>` for `GT`, `<=` for `LTE`, `>=` for `GTE`, `!` for `EZ`, `&&` for `AND`, `||` for `OR`, `PRM` for `PARAM`, `TR.P` for `TR.PULSE`
- **NEW**: new ops: `LTE` (less than or equal), and `GTE` (greater than or equal)
- **NEW**: new pattern ops: `PN.L`, `PN.WRAP`, `PN.START`, `PN.END`, `PN.I`, `PN.HERE`, `PN.NEXT`, `PN.PREV`, `PN.INS`, `PN.RM`, `PN.PUSH` and `PN.POP`
- **NEW**: USB disk loading and saving works at any time
- **IMP**: new Ragel parser backend
- **IMP**: script recursion enhanced, maximum recursion depth is 8, and self recursion is allowed
- **IMP**: removed the need to prefix `:` and `;` with a space, e.g. `IF X : TR.PULSE 1` becomes `IF X: TR.PULSE`
- **FIX**: divide by zero errors now explicitly return a 0 (e.g. `DIV 5 0` now returns 0 instead of -1), previously the behaviour was undefined and would crash the simulator
- **FIX**: numerous crashing bugs with text entry
- **FIX**: `i2c` bus crashes under high `M` times with external triggers
- **NEW**: TELEX Aliases: `TO.TR.P` for `TO.TR.PULSE` (plus all sub-commands) and `TI.PRM` for `TI.PARAM` (plus all sub-commands)
- **NEW**: TELEX initialization commands: `TO.TR.INIT n`, `TO.CV.INIT n`, `TO.INIT x`, `TI.PARAM.INIT n`, `TI.IN.INIT n`, and `TI.INIT x`

## v1.41
- **NEW**: added Ansible remote commands `LV.CV` and `CY.CV`
Expand All @@ -13,7 +30,7 @@
- **NEW**: [Full List of Methods Found and Maintained Here](https://github.com/bpcmusic/telex/blob/master/commands.md)

## v1.21
- **NEW**: Just Friends ops: `JF.GOD`, `JF.MODE`, `JF.NOTE`, `JF.RMODE`, `JF.RUN`, `JF.SHIFT`, `JF.TICK`, `JF.TR`, `JF.VOX`, `JF.VTR`
- **NEW**: Just Friends ops: `JF.GOD`, `JF.MODE`, `JF.NOTE`, `JF.RMODE`, `JF.RUN`, `JF.SHIFT`, `JF.TICK`, `JF.TR`, `JF.TUNE`, `JF.VOX`, `JF.VTR`

## v1.2
- **NEW**: Ansible support added to ops: `CV`, `CV.OFF`, `CV.SET`, `CV.SLEW`, `STATE`, `TR`, `TR.POL`, `TR.PULSE`, `TR.TIME`, `TR.TOG`
Expand Down
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ http://monome.org/docs/modular/teletype

## Building

See the [libavr32 repo](https://github.com/monome/libavr32) for more detailed instructions.
See the [libavr32 repo][libavr32] for more detailed instructions. You will also need `ragel` installed and on the path, see below.

**Make sure that the `libavr32` submodule is correctly checked out**

Expand All @@ -26,6 +26,43 @@ make
./flash.sh
```

## Tests

To run the tests:

```bash
cd tests
make clean # only needed if you've built the module code
make test
```

## Ragel

The [Ragel state machine compiler][ragel] is required to build the firmware. It needs to be installed and on the path:

```bash
brew install ragel # Homebrew (OSX)
apt install ragel # Debian / Ubuntu / WSL (Windows 10)
pacman -Sy ragel # Arch Linux / MSYS2 (Windows)
```

Version 6.9 is known to work.

See section 6.3 in the Ragel manual for information on the `=>` scanner constructor used.

## Adding a new `OP` or `MOD` (a.k.a. `PRE`)

If you want to add a new `OP` or `MOD`, please create the relevant `tele_op_t` or `tele_mod_t` in the `src/ops` directory. You will then need to reference it in the following places:

- `src/ops/op.c`: add a reference to your struct to the relevant table, `tele_ops` or `tele_mods`. Ideally grouped with other ops from the same file.
- `src/ops/op_enum.h`: please run `utils/op_enums.py` to generate this file using Python3.
- `src/match_token.rl`: add an entry to the Ragel list to match the token to the struct. Again, please try to keep the order in the list sensible.

There is a test that checks to see if the above have all been entered correctly. (See above to run tests.)

## Code Formatting

To format the code using `clang-format`, run `make format` in the project's root directory. This *shouldn't* format any code in the `libavr32` submodule.

[libavr32]: https://github.com/monome/libavr32
[ragel]: http://www.colm.net/open-source/ragel/
124 changes: 124 additions & 0 deletions docs/modes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@

## Global key bindings

These bindings work everywhere.

| Key | Action |
|------------------------------|------------------------------------------------|
| `<tab>` | change modes, live to edit to pattern and back |
| `<esc>` | preset read mode, or return to last mode |
| `alt-<esc>` | preset write mode |
| `win-<esc>` | clear delays, stack and slews |
| `<print screen>` | help text, or return to last mode |
| `<F1>` to `<F8>` | run corresponding script |
| `<F9>` | run metro script |
| `<F10>` | run init script |
| `alt-<F1>` to `alt-<F8>` | edit corresponding script |
| `alt-<F9>` | edit metro script |
| `alt-<F10>` | edit init script |
| `<numpad-1>` to `<numpad-8>` | run corresponding script |

## Text editing

These bindings work when entering text or code.

In most cases, the clipboard is shared between _live_, _edit_ and the 2 _preset_ modes.

| Key | Action |
|--------------------------------|-----------------------------------------|
| `<left>` / `ctrl-b` | move cursor left |
| `<right>` / `ctrl-f` | move cursor right |
| `<home>` / `ctrl-a` | move to beginning of line |
| `<end>` / `ctrl-e` | move to end of line |
| `<backspace>` / `ctrl-h` | backwards delete one character |
| `<delete>` / `ctrl-d` | forwards delete one character |
| `shift-<backspace>` / `ctrl-u` | delete from cursor to beginning |
| `shift-<delete>` / `ctrl-e` | delete from cursor to end |
| `alt-<backspace>` / `ctrl-w` | delete from cursor to beginning of word |
| `ctrl-x` / `alt-x` | cut to clipboard |
| `ctrl-c` / `alt-c` | copy to clipboard |
| `ctrl-v` / `alt-v` | paste to clipboard |

## Live mode

| Key | Action |
|------------------|---------------------|
| `<down>` / `C-n` | history next |
| `<up>` / `C-p` | history previous |
| `<enter>` | execute command |
| `[` / `]` | switch to edit mode |

## Edit mode

| Key | Action |
|--------------------|---------------------------|
| `<down>` / `C-n` | line down |
| `<up>` / `C-p` | line up |
| `[` | previous script |
| `]` | next script |
| `<enter>` | enter command |
| `shift-<enter>` | insert command |

## Pattern mode

The pattern mode clipboard is independent of text and code clipboard.

| Key | Action |
|---------------------|---------------------------------------------------------------------------------------|
| `<down>` | move down |
| `alt-<down>` | move a page down |
| `<up>` | move up |
| `alt-<up>` | move a page up |
| `<left>` | move left |
| `alt-<left>` | move to the very left |
| `<right>` | move right |
| `alt-<right>` | move to the very right |
| `[` | decrement by 1 |
| `]` | increment by 1 |
| `<backspace>` | delete a digit |
| `shift-<backspace>` | delete an entry, shift numbers up |
| `<enter>` | move down (increase length only if on the entry immediately after the current length) |
| `shift-<enter>` | duplicate entry and shift downwards (increase length as `<enter>`) |
| `alt-x` | cut value (n.b. `ctrl-x` not supported) |
| `alt-c` | copy value (n.b. `ctrl-c` not supported) |
| `alt-v` | paste value (n.b. `ctrl-v` not supported) |
| `shift-alt-v` | insert value |
| `shift-l` | set length to current position |
| `alt-l` | go to current length entry |
| `shift-s` | set start to current position |
| `alt-s` | go to start entry |
| `shift-e` | set end to current position |
| `alt-e` | go to end entry |
| `-` | negate value |
| `<space>` | toggle non-zero to zero, and zero to 1 |
| `0` to `9` | numeric entry |

## Preset read mode

| Key | Action |
|------------------|-------------|
| `<down>` / `C-n` | line down |
| `<up>` / `C-p` | line up |
| `<left>` / `[` | preset down |
| `<right>` / `]` | preset up |
| `<enter>` | load preset |

## Preset write mode

| Key | Action |
|------------------|-------------|
| `<down>` / `C-n` | line down |
| `<up>` / `C-p` | line up |
| `[` | preset down |
| `]` | preset up |
| `<enter>` | enter text |
| `alt-<enter>` | save preset |

## Help mode

| Key | Action |
|------------------|---------------|
| `<down>` / `C-n` | line down |
| `<up>` / `C-p` | line up |
| `<left>` / `[` | previous page |
| `<right>` / `]` | next page |
2 changes: 1 addition & 1 deletion libavr32
22 changes: 22 additions & 0 deletions module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,29 @@
# \asf_license_stop
#

# Makefile.avr32.in defines an unused variable build, which is used in the clean
# target, it's probably there to list other build targets
build += ../src/scanner.c ../src/match_token.c ../module/gitversion.c

# Include the common Makefile, which will also include the project specific
# config.mk file.
MAKEFILE_PATH = ../libavr32/asf/avr32/utils/make/Makefile.avr32.in
include $(MAKEFILE_PATH)

# Add a rule to build match_token.c from match_token.rl
../src/match_token.c: ../src/match_token.rl
ragel -C -G2 ../src/match_token.rl -o ../src/match_token.c

# Add a rule to build scanner.c from scanner.rl
../src/scanner.c: ../src/scanner.rl
ragel -C -G2 ../src/scanner.rl -o ../src/scanner.c

# Add the git commit id to a file for use when printing out the version
../module/gitversion.c: ../.git/HEAD ../.git/index
echo "const char *git_version = \"$(shell git describe --always --dirty | tr '[a-z]' '[A-Z]')\";" > $@

# Make a zip release
.PHONY: release
release: teletype.hex
rm -f teletype.zip && \
zip teletype.zip teletype.hex flash.sh update_firmware.command
29 changes: 24 additions & 5 deletions module/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,45 @@ TARGET = $(THIS).elf

# List of C source files.
CSRCS = \
../module/main.c \
../module/main.c \
../module/edit_mode.c \
../module/flash.c \
../module/gitversion.c \
../module/help_mode.c \
../module/line_editor.c \
../module/live_mode.c \
../module/pattern_mode.c \
../module/preset_r_mode.c \
../module/preset_w_mode.c \
../module/usb_disk_mode.c \
../src/command.c \
../src/helpers.c \
../src/match_token.c \
../src/scanner.c \
../src/state.c \
../src/table.c \
../src/teletype.c \
../src/ops/op.c \
../src/ops/constants.c \
../src/ops/ansible.c \
../src/ops/controlflow.c \
../src/ops/delay.c \
../src/ops/earthsea.c \
../src/ops/hardware.c \
../src/ops/justfriends.c \
../src/ops/maths.c \
../src/ops/meadowphysics.c \
../src/ops/metronome.c \
../src/ops/orca.c \
../src/ops/patterns.c \
../src/ops/queue.c \
../src/ops/stack.c \
../src/ops/telex.c \
../src/ops/variables.c \
../src/ops/whitewhale.c \
../libavr32/src/adc.c \
../libavr32/src/events.c \
../libavr32/src/euclidean/euclidean.c \
../libavr32/src/euclidean/data.c \
../libavr32/src/euclidean/euclidean.c \
../libavr32/src/euclidean/data.c \
../libavr32/src/fix.c \
../libavr32/src/font.c \
../libavr32/src/i2c.c \
Expand All @@ -100,6 +117,7 @@ CSRCS = \
../libavr32/src/usb/hid/uhi_hid.c \
../libavr32/src/usb/midi/uhi_midi.c \
../libavr32/src/usb/midi/midi.c \
../libavr32/src/usb/msc/msc.c \
avr32/drivers/adc/adc.c \
avr32/drivers/flashc/flashc.c \
avr32/drivers/gpio/gpio.c \
Expand Down Expand Up @@ -137,6 +155,7 @@ INC_PATH = \
../src/usb/ftdi \
../src/usb/hid \
../src/usb/midi \
../src/usb/msc \
../conf \
../conf/teletype \
avr32/boards \
Expand Down Expand Up @@ -193,7 +212,7 @@ ARFLAGS =
ASFLAGS =

# Extra flags to use when compiling.
CFLAGS = -fshort-enums
CFLAGS = -fshort-enums -fno-common

# Extra flags to use when preprocessing.
#
Expand Down
Loading

0 comments on commit 2fda641

Please sign in to comment.