You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MZTC: correct the driver against the camera protocol manual
Five points where the code disagreed with the BJ core serial protocol manual.
The manual is the one shipped with the camera and it is the source for the
class and subclass addresses the driver already used.
Auto shutter wire values
The camera defines 0x01 for temperature only, 0x02 for time only and 0x03 for
time and temperature. It answers 0x00 with a threshold error. The driver sent
the zero-based setting straight through. Every mode was off by one. The
default sent an out of range value. The setting keeps its zero-based ordering
for the settings.yaml lookup table. The driver adds
MZTC_SHUTTER_WIRE_OFFSET on the way out.
Shutter interval belongs to the camera
0x7C/0x05 is a read and write command taking two bytes of minutes. The camera
runs the schedule from it. The driver ignored the command and ran its own
timer, firing manual shutter commands that competed with the camera. The
interval is now pushed on connect. mztcCheckCalibration only counts elapsed
minutes for the status and OSD surfaces.
mztc_ffc_interval now accepts 1 to 60. Zero no longer means disabled, because
the camera owns the schedule. Selecting TEMP_ONLY is how time-driven
correction is turned off.
Initialization status reply address
The host asks on 0x7C/0x14. The manual specifies the reply as class 0x7D
subclass 0x06. The decoder matched on the request address. The reply was never
decoded.
Vignetting correction is an action
0x7C/0x0C with data 0x02, write only. The manual requires the lens to be
pointed at a uniform surface first. Running it automatically would superimpose
the current scene onto the correction. The boolean setting is
removed. mztc_vignetting and MSP2_SET_MZTC_VIGNETTING at 0x224B replace it.
Bad pixel removal is not a setting
0x78/0x1A drives an on-screen cursor through move, confirm and cancel steps.
A flight controller cannot walk that cursor onto each bad pixel. The boolean
setting is removed with nothing in its place.
Both removed booleans were never transmitted. They did nothing.
Contract changes
The MSP config payload drops from 24 to 22 bytes. msp_messages.json moves to
2.3.0 and gains MSP2_SET_MZTC_VIGNETTING. docs/Settings.md is regenerated.
The camera manual contradicts itself on the zoom labels. Its prose says 1x,
2x, 4x and 8x. Its value table for the same command says 1x, 2x, 3x and 4x.
The wire values 0 to 3 are identical either way. The enum is unchanged and the
ambiguity is documented.
Validated on three builds. SPEEDYBEEF405AIO with MZTC on sits at 77.9% flash.
MATEKF722SE with MZTC off sits at 95.1% flash. SITL builds too. All three
compile with no warnings in any MZTC file. 543 of 543 unit tests pass.
Copy file name to clipboardExpand all lines: docs/MassZero_Thermal_Camera.md
+22-6Lines changed: 22 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,6 +148,8 @@ set mztc_mirror_mode = NONE
148
148
149
149
Zoom accepts `1X`, `2X`, `4X` and `8X`. Mirror accepts `NONE`, `HORIZONTAL`, `VERTICAL` and `CENTRAL`. `mztc_zoom 2` applies a zoom level immediately by index.
150
150
151
+
The camera manual contradicts itself on the zoom labels. Its prose says 1x, 2x, 4x and 8x. Its value table for the same command says 1x, 2x, 3x and 4x. The wire values 0 to 3 are the same either way. The setting works regardless of which set of labels is right.
152
+
151
153
### Shutter and flat field correction
152
154
153
155
A manual shutter cycle on this camera performs a flat field correction. One command covers both:
@@ -163,7 +165,9 @@ set mztc_auto_shutter = TIME_AND_TEMP
163
165
set mztc_ffc_interval = 5
164
166
```
165
167
166
-
`mztc_auto_shutter` accepts `TEMP_ONLY`, `TIME_ONLY` and `TIME_AND_TEMP`. `mztc_ffc_interval` is in minutes. Setting it to 0 disables the time-driven correction. INAV issues its own timed correction unless `mztc_auto_shutter` is `TEMP_ONLY`. In that case the timing is left to the camera.
168
+
`mztc_auto_shutter` accepts `TEMP_ONLY`, `TIME_ONLY` and `TIME_AND_TEMP`. `mztc_ffc_interval` is in minutes and accepts 1 to 60.
169
+
170
+
The camera runs the shutter schedule itself. INAV pushes both values to it on connect and then leaves it alone. Select `TEMP_ONLY` to stop the camera correcting on a timer, since it then reacts to temperature drift only.
167
171
168
172
### Temperature alerts
169
173
@@ -177,11 +181,21 @@ Both thresholds accept -40 to 200 degrees Celsius. The low threshold must not ex
177
181
178
182
Alerts only fire once the camera reports a temperature. The published MassZero protocol document defines no temperature-read command. No build in this tree reports one yet. The alert state stays clear.
179
183
180
-
### Correction and display options
184
+
### Vignetting correction
185
+
186
+
Vignetting correction is a one-shot action. There is no setting for it:
187
+
188
+
```
189
+
mztc_vignetting
190
+
```
191
+
192
+
Point the lens at a uniform surface before running it. The camera superimposes whatever it is looking at onto the correction. A cluttered scene makes the image worse.
193
+
194
+
Bad pixel removal is not exposed. The camera drives it through an on-screen cursor that has to be walked onto each bad pixel. A flight controller cannot do that usefully.
195
+
196
+
### Display options
181
197
182
198
```
183
-
set mztc_bad_pixel_removal = ON
184
-
set mztc_vignetting_correction = ON
185
199
set mztc_crosshair_enabled = OFF
186
200
set mztc_temperature_unit = CELSIUS
187
201
set mztc_update_rate = 9
@@ -202,6 +216,7 @@ set mztc_update_rate = 9
202
216
|`mztc_denoise <spatial> <temporal>`| Set both denoising levels |
203
217
|`mztc_alerts <enabled> <high> <low>`| Configure the temperature alerts |
204
218
|`mztc_calibrate`| Trigger a manual shutter cycle for a flat field correction |
219
+
|`mztc_vignetting`| Run one vignetting correction |
205
220
|`mztc_save`| Save the current image settings to the camera's own flash |
206
221
|`mztc_defaults`| Restore the camera to its factory defaults |
207
222
|`mztc_reconnect`| Close the port and restart the connection sequence |
@@ -214,17 +229,18 @@ The camera is reachable over MSP V2 in INAV's own command range. Full payload la
214
229
215
230
| Command | Code | Direction | Payload |
216
231
| --- | --- | --- | --- |
217
-
|`MSP2_MZTC_CONFIG`| 0x2240 | Out |24 bytes |
232
+
|`MSP2_MZTC_CONFIG`| 0x2240 | Out |22 bytes |
218
233
|`MSP2_MZTC_STATUS`| 0x2241 | Out | 19 bytes |
219
234
|`MSP2_MZTC_FRAME_DATA`| 0x2242 | Out | 24 byte header plus thermal bytes |
220
-
|`MSP2_SET_MZTC_CONFIG`| 0x2243 | In |24 bytes |
235
+
|`MSP2_SET_MZTC_CONFIG`| 0x2243 | In |22 bytes |
221
236
|`MSP2_SET_MZTC_MODE`| 0x2244 | In | 1 byte |
222
237
|`MSP2_SET_MZTC_PALETTE`| 0x2245 | In | 1 byte |
223
238
|`MSP2_SET_MZTC_ZOOM`| 0x2246 | In | 1 byte |
224
239
|`MSP2_SET_MZTC_SHUTTER`| 0x2247 | In | 0 or 1 bytes |
225
240
|`MSP2_SET_MZTC_ALERTS`| 0x2248 | In | 5 bytes |
226
241
|`MSP2_SET_MZTC_IMAGE_PARAMS`| 0x2249 | In | 3 bytes |
227
242
|`MSP2_SET_MZTC_CORRECTION`| 0x224A | In | 2 bytes |
243
+
|`MSP2_SET_MZTC_VIGNETTING`| 0x224B | In | 0 or 1 bytes |
228
244
229
245
Temperatures cross as signed 16 bit deci-degrees Celsius. 25.5 degrees is 255. Every field is read and written individually. The wire layout never depends on compiler padding.
Copy file name to clipboardExpand all lines: docs/development/msp/msp_messages.json
+22-29Lines changed: 22 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"version": {
3
3
"major": 2,
4
-
"minor": 2,
4
+
"minor": 3,
5
5
"patch": 0
6
6
},
7
7
"messages": {
@@ -11799,23 +11799,11 @@
11799
11799
"name": "ffc_interval",
11800
11800
"ctype": "uint8_t",
11801
11801
"units": "minutes",
11802
-
"desc": "Automatic flat field correction interval. 0-60, where 0 disables it."
11803
-
},
11804
-
{
11805
-
"name": "bad_pixel_removal",
11806
-
"ctype": "uint8_t",
11807
-
"units": "",
11808
-
"desc": "Bad pixel removal enabled. 0 or 1."
11809
-
},
11810
-
{
11811
-
"name": "vignetting_correction",
11812
-
"ctype": "uint8_t",
11813
-
"units": "",
11814
-
"desc": "Vignetting correction enabled. 0 or 1."
11802
+
"desc": "Automatic shutter interval in minutes. 1-60. The camera runs the schedule itself."
11815
11803
}
11816
11804
]
11817
11805
},
11818
-
"notes": "Requires `USE_MZTC`. Fixed 24 byte reply. Each field is written with the `sbufWrite*` helpers. The layout never depends on compiler padding.",
11806
+
"notes": "Requires `USE_MZTC`. Fixed 22 byte reply. Each field is written with the `sbufWrite*` helpers. The layout never depends on compiler padding.",
11819
11807
"description": "Reads the MassZero thermal camera configuration."
11820
11808
},
11821
11809
"MSP2_MZTC_STATUS": {
@@ -12101,24 +12089,12 @@
12101
12089
"name": "ffc_interval",
12102
12090
"ctype": "uint8_t",
12103
12091
"units": "minutes",
12104
-
"desc": "Automatic flat field correction interval. 0-60, where 0 disables it."
12105
-
},
12106
-
{
12107
-
"name": "bad_pixel_removal",
12108
-
"ctype": "uint8_t",
12109
-
"units": "",
12110
-
"desc": "Bad pixel removal enabled. 0 or 1."
12111
-
},
12112
-
{
12113
-
"name": "vignetting_correction",
12114
-
"ctype": "uint8_t",
12115
-
"units": "",
12116
-
"desc": "Vignetting correction enabled. 0 or 1."
12092
+
"desc": "Automatic shutter interval in minutes. 1-60. The camera runs the schedule itself."
12117
12093
}
12118
12094
]
12119
12095
},
12120
12096
"reply": null,
12121
-
"notes": "Requires `USE_MZTC`. Expects 24 bytes. The whole request is validated against the `MZTC_*` limits before any field is applied. A rejected request leaves the running configuration untouched.",
12097
+
"notes": "Requires `USE_MZTC`. Expects 22 bytes. The whole request is validated against the `MZTC_*` limits before any field is applied. A rejected request leaves the running configuration untouched.",
12122
12098
"description": "Writes the MassZero thermal camera configuration."
12123
12099
},
12124
12100
"MSP2_SET_MZTC_MODE": {
@@ -12269,6 +12245,23 @@
12269
12245
"reply": null,
12270
12246
"notes": "Requires `USE_MZTC`. Expects 2 bytes. Returns an error if the camera is not connected.",
12271
12247
"description": "Sets the MassZero thermal camera denoising parameters."
12248
+
},
12249
+
"MSP2_SET_MZTC_VIGNETTING": {
12250
+
"code": 8779,
12251
+
"mspv": 2,
12252
+
"request": {
12253
+
"payload": [
12254
+
{
12255
+
"name": "trigger",
12256
+
"ctype": "uint8_t",
12257
+
"units": "",
12258
+
"desc": "Ignored. The command itself is the trigger."
12259
+
}
12260
+
]
12261
+
},
12262
+
"reply": null,
12263
+
"notes": "Requires `USE_MZTC`. Accepts 0 or 1 bytes. The camera manual requires the lens to be pointed at a uniform surface before this runs, so it is an action and never a stored setting.",
12264
+
"description": "Runs one vignetting correction on the camera."
Copy file name to clipboardExpand all lines: src/main/fc/settings.yaml
+2-12Lines changed: 2 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -260,7 +260,7 @@ constants:
260
260
261
261
MZTC_MIN_UPDATE_RATE: 1
262
262
MZTC_MAX_UPDATE_RATE: 30
263
-
MZTC_MIN_FFC_INTERVAL: 0
263
+
MZTC_MIN_FFC_INTERVAL: 1
264
264
MZTC_MAX_FFC_INTERVAL: 60
265
265
MZTC_MIN_PERCENT: 0
266
266
MZTC_MAX_PERCENT: 100
@@ -4867,22 +4867,12 @@ groups:
4867
4867
min: MZTC_MIN_ALERT_TEMP
4868
4868
max: MZTC_MAX_ALERT_TEMP
4869
4869
- name: mztc_ffc_interval
4870
-
description: "Flat Field Calibration interval in minutes (0=disabled)"
4870
+
description: "Automatic shutter interval in minutes. The camera runs the schedule itself. Set mztc_auto_shutter to TEMP_ONLY to stop it correcting on a timer."
0 commit comments