-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmore-scripts.diff
296 lines (283 loc) · 9.71 KB
/
more-scripts.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2c4577d..55f39dd 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -13,7 +13,7 @@ jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Run clang-format
run: |
curl -O https://raw.githubusercontent.com/Sarcasm/run-clang-format/master/run-clang-format.py
@@ -21,7 +21,7 @@ jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
submodules: recursive
- name: Install ragel
@@ -33,7 +33,7 @@ jobs:
build-simulator:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
submodules: recursive
- name: Install ragel
@@ -45,7 +45,7 @@ jobs:
build-firmware:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
with:
submodules: recursive
- name: Install ragel
@@ -65,15 +65,15 @@ jobs:
run: |
cd module
make
- - name: Upload teletype.hex to artifacts
- uses: actions/upload-artifact@v2
+ - name: Create firmware artifact
+ uses: actions/upload-artifact@v4
with:
path: module/teletype.hex
- name: teletype.hex
+ name: teletype (firmware only)
build-docs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
@@ -89,8 +89,32 @@ jobs:
run: |
cd docs
make
- - name: Upload docs to artifacts
- uses: actions/upload-artifact@v2
+ - name: Create documentation artifact
+ uses: actions/upload-artifact@v4
with:
- path: docs/teletype.pdf
- name: teletype.pdf
+ name: teletype (docs only)
+ path: |
+ docs/*.pdf
+ docs/*.html
+ create-release-zip:
+ runs-on: ubuntu-latest
+ needs: [build-firmware, build-docs]
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ sparse-checkout: module
+ - name: Add firmware update scripts to release
+ run: |
+ mkdir release
+ cp module/update_firmware.command release
+ cp module/flash.sh release
+ - name: Download artifacts from previous steps
+ uses: actions/download-artifact@v4
+ with:
+ path: release
+ merge-multiple: true
+ - name: Add release zip to artifacts
+ uses: actions/upload-artifact@v4
+ with:
+ path: release
+ name: teletype
diff --git a/.gitignore b/.gitignore
index 22903d0..06f0a44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,8 +50,11 @@ __pycache__/
/simulator/tt
/module/gitversion.c
/tests/tests
-/docs/teletype.pdf
-/docs/teletype.html
+/docs/*.pdf
+/docs/*.html
/docs/cheatsheet/*
!/docs/cheatsheet/cs-common.tex
/docs/testServe/
+compile_commands.json
+patch.diff
+.clangd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f62371b..b4981cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## v5.0.x:
+
+- **FIX**: fix risk of crash/corruption in help mode reverse search
+
## v5.0.0
- **FIX**: fix off-by-one error in `P.ROT` understanding of pattern length
diff --git a/docs/Makefile b/docs/Makefile
index 391c355..22c7735 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -1,6 +1,6 @@
.PHONY: build clean
-build: teletype.pdf teletype.html cheatsheet/cheatsheet.pdf cheatsheet/cheatsheet-i2c.pdf
+build: teletype.pdf teletype.html cheatsheet.pdf cheatsheet-i2c.pdf
clean:
rm -f teletype.pdf && \
@@ -24,5 +24,8 @@ cheatsheet/cheatsheet-%.tex: $(wildcard ops/*.toml) ../utils/cheatsheet.py
cheatsheet/cheatsheet-%.pdf: cheatsheet/cs-common.tex cheatsheet/cheatsheet-%.tex
cd cheatsheet && latexmk -xelatex cs-common.tex -jobname=cheatsheet-$*
-cheatsheet/cheatsheet.pdf: cheatsheet/cheatsheet-core.pdf
- cd cheatsheet && cp cheatsheet-core.pdf cheatsheet.pdf
\ No newline at end of file
+cheatsheet.pdf: cheatsheet/cheatsheet-core.pdf
+ cp cheatsheet/cheatsheet-core.pdf cheatsheet.pdf
+
+cheatsheet-i2c.pdf: cheatsheet/cheatsheet-i2c.pdf
+ cp cheatsheet/cheatsheet-i2c.pdf .
diff --git a/docs/whats_new.md b/docs/whats_new.md
index 46e7a07..4dabecc 100644
--- a/docs/whats_new.md
+++ b/docs/whats_new.md
@@ -1,5 +1,9 @@
# Updates
+## v5.0.x
+
+- **FIX**: fix risk of crash/corruption in help mode reverse search
+
## v5.0.0
- **FIX**: fix off-by-one error in `P.ROT` understanding of pattern length
diff --git a/module/edit_mode.c b/module/edit_mode.c
index 3a3294c..01f52dc 100644
--- a/module/edit_mode.c
+++ b/module/edit_mode.c
@@ -402,8 +402,12 @@ uint8_t screen_refresh_edit() {
if (dirty & D_INPUT) {
bool muted = false;
- char prefix = script + '1';
- if (script == METRO_SCRIPT) {
+ char prefix = '1'; // init to 1 for no reason
+ if (script <= 8) { prefix = script + '1'; }
+ else if (script >= 9 && script < REGULAR_SCRIPT_COUNT) {
+ prefix = (script - 9) + 'A';
+ }
+ else if (script == METRO_SCRIPT) {
prefix = 'M';
muted = !scene_state.variables.m_act;
}
diff --git a/module/flash.h b/module/flash.h
index b81a990..5fefd07 100644
--- a/module/flash.h
+++ b/module/flash.h
@@ -7,7 +7,11 @@
#include "line_editor.h"
#include "teletype.h"
-#define SCENE_SLOTS 32
+// for preset indexing to work, must be power of 2
+#define SCENE_SLOTS 16
+// number of bits needed to index SCENE_SLOTS slots
+#define SCENE_BITS (32 - __builtin_clz(SCENE_SLOTS - 1))
+
#define BUTTON_STATE_SIZE (GRID_BUTTON_COUNT >> 3)
typedef struct {
diff --git a/module/help_mode.c b/module/help_mode.c
index 422c513..0cc535c 100644
--- a/module/help_mode.c
+++ b/module/help_mode.c
@@ -1692,6 +1692,7 @@ bool text_search_forward(search_state_t* state, const char* needle,
bool text_search_reverse(search_state_t* state, const char* needle,
const char** haystack, int haystack_len) {
const int needle_len = strlen(needle);
+ if (state->line >= haystack_len) { state->line = haystack_len - 1; }
for (; state->line >= 0; state->line--) {
const int haystack_line_len = strlen(haystack[state->line]);
for (state->ch = haystack_line_len - needle_len; state->ch >= 0;
diff --git a/module/main.c b/module/main.c
index d8acde9..b8b11f4 100644
--- a/module/main.c
+++ b/module/main.c
@@ -419,7 +419,9 @@ void handler_PollADC(int32_t data) {
ss_set_param(&scene_state, adc[1] << 2);
}
else if (mode == M_PRESET_R && !(grid_connected && grid_control_mode)) {
- uint8_t preset = adc[1] >> 6;
+ /* 12 bit adc, so shift by 12 minus N bits needed
+ to index all presets. - 1 for deadzone */
+ uint8_t preset = adc[1] >> (11 - SCENE_BITS);
uint8_t deadzone = preset & 1;
preset >>= 1;
if (!deadzone || abs(preset - get_preset()) > 1)
@@ -902,6 +904,13 @@ bool process_global_keys(uint8_t k, uint8_t m, bool is_held_key) {
run_script(&scene_state, INIT_SCRIPT);
return true;
}
+ // shift-<F1> through <F6>: run scripts (9-E)
+ else if (mod_only_shift(m) && k >= HID_F1 && k <= HID_F6) {
+ // with the new script number constants, I *think*
+ // + 8 will index correctly
+ run_script(&scene_state, k - HID_F1 + 8);
+ return true;
+ }
// alt-<F1> through alt-<F8>: edit corresponding script
else if (mod_only_alt(m) && k >= HID_F1 && k <= HID_F8) {
set_edit_mode_script(k - HID_F1);
@@ -920,6 +929,12 @@ bool process_global_keys(uint8_t k, uint8_t m, bool is_held_key) {
set_mode(M_EDIT);
return true;
}
+ // alt-shift-<F1> through shift-alt-<F6>: edit scripts (9-E)
+ else if (mod_only_shift_alt(m) && k >= HID_F1 && k <= HID_F6) {
+ set_edit_mode_script(k - HID_F1 + 8);
+ set_mode(M_EDIT);
+ return true;
+ }
// ctrl-<F1> through ctrl-<F8> mute triggers
else if (mod_only_ctrl(m) && k >= HID_F1 && k <= HID_F8) {
bool muted = ss_get_mute(&scene_state, (k - HID_F1));
diff --git a/src/scene_serialization.c b/src/scene_serialization.c
index 265e08a..784d27c 100644
--- a/src/scene_serialization.c
+++ b/src/scene_serialization.c
@@ -51,8 +51,8 @@ void serialize_scene(tt_serializer_t* stream, scene_state_t* scene,
stream->write_char(stream->data, 'M');
else if (s == INIT_SCRIPT)
stream->write_char(stream->data, 'I');
- else
- stream->write_char(stream->data, s + 49);
+ else if (s < 9) { stream->write_char(stream->data, s + '1'); }
+ else { stream->write_char(stream->data, (s - 9) + 'A'); }
for (int l = 0; l < ss_get_script_len(scene, s); l++) {
stream->write_char(stream->data, '\n');
@@ -206,7 +206,8 @@ void deserialize_scene(tt_deserializer_t* stream, scene_state_t* scene,
s2 = STATE_GRID;
}
else {
- script = c - 49;
+ if (c >= '1' && c <= '9') { script = c - '1'; }
+ else { script = (c - 'A') + 9; }
if (script < 0 || script >= EDITABLE_SCRIPT_COUNT) {
script = NO_SCRIPT;
}
diff --git a/src/script.h b/src/script.h
index 69491d9..04ead6c 100644
--- a/src/script.h
+++ b/src/script.h
@@ -1,7 +1,8 @@
#ifndef _SCRIPT_H_
#define _SCRIPT_H_
-#define REGULAR_SCRIPT_COUNT 8
+// standard scripts 1-8, library scripts A-F
+#define REGULAR_SCRIPT_COUNT 14
#define METRO_SCRIPT REGULAR_SCRIPT_COUNT
#define INIT_SCRIPT (METRO_SCRIPT + 1)