Mirror with some correction

Dependencies:   mbed FastIO FastPWM USBDevice

Committer:
mjr
Date:
Fri Feb 26 18:42:03 2016 +0000
Revision:
48:058ace2aed1d
Parent:
47:df7a88cd249c
Child:
51:57eb311faafa
New plunger processing 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mjr 35:e959ffba78fd 1 // USB Message Protocol
mjr 35:e959ffba78fd 2 //
mjr 35:e959ffba78fd 3 // This file is purely for documentation, to describe our USB protocol.
mjr 35:e959ffba78fd 4 // We use the standard HID setup with one endpoint in each direction.
mjr 35:e959ffba78fd 5 // See USBJoystick.cpp/.h for our USB descriptor arrangement.
mjr 35:e959ffba78fd 6 //
mjr 35:e959ffba78fd 7
mjr 35:e959ffba78fd 8 // ------ OUTGOING MESSAGES (DEVICE TO HOST) ------
mjr 35:e959ffba78fd 9 //
mjr 47:df7a88cd249c 10 // General note: 16-bit and 32-bit fields in our reports are little-endian
mjr 47:df7a88cd249c 11 // unless otherwise specified.
mjr 47:df7a88cd249c 12 //
mjr 39:b3815a1c3802 13 // 1. Joystick reports
mjr 35:e959ffba78fd 14 // In most cases, our outgoing messages are HID joystick reports, using the
mjr 35:e959ffba78fd 15 // format defined in USBJoystick.cpp. This allows us to be installed on
mjr 35:e959ffba78fd 16 // Windows as a standard USB joystick, which all versions of Windows support
mjr 35:e959ffba78fd 17 // using in-the-box drivers. This allows a completely transparent, driverless,
mjr 39:b3815a1c3802 18 // plug-and-play installation experience on Windows. Our joystick report
mjr 39:b3815a1c3802 19 // looks like this (see USBJoystick.cpp for the formal HID report descriptor):
mjr 35:e959ffba78fd 20 //
mjr 39:b3815a1c3802 21 // ss status bits: 0x01 -> plunger enabled
mjr 40:cc0d9814522b 22 // 00 2nd byte of status (reserved)
mjr 40:cc0d9814522b 23 // 00 3rd byte of status (reserved)
mjr 39:b3815a1c3802 24 // 00 always zero for joystick reports
mjr 40:cc0d9814522b 25 // bb joystick buttons, low byte (buttons 1-8, 1 bit per button)
mjr 40:cc0d9814522b 26 // bb joystick buttons, 2nd byte (buttons 9-16)
mjr 40:cc0d9814522b 27 // bb joystick buttons, 3rd byte (buttons 17-24)
mjr 40:cc0d9814522b 28 // bb joystick buttons, high byte (buttons 25-32)
mjr 39:b3815a1c3802 29 // xx low byte of X position = nudge/accelerometer X axis
mjr 39:b3815a1c3802 30 // xx high byte of X position
mjr 39:b3815a1c3802 31 // yy low byte of Y position = nudge/accelerometer Y axis
mjr 39:b3815a1c3802 32 // yy high byte of Y position
mjr 39:b3815a1c3802 33 // zz low byte of Z position = plunger position
mjr 39:b3815a1c3802 34 // zz high byte of Z position
mjr 39:b3815a1c3802 35 //
mjr 39:b3815a1c3802 36 // The X, Y, and Z values are 16-bit signed integers. The accelerometer
mjr 39:b3815a1c3802 37 // values are on an abstract scale, where 0 represents no acceleration,
mjr 39:b3815a1c3802 38 // negative maximum represents -1g on that axis, and positive maximum
mjr 39:b3815a1c3802 39 // represents +1g on that axis. For the plunger position, 0 is the park
mjr 39:b3815a1c3802 40 // position (the rest position of the plunger) and positive values represent
mjr 39:b3815a1c3802 41 // retracted (pulled back) positions. A negative value means that the plunger
mjr 39:b3815a1c3802 42 // is pushed forward of the park position.
mjr 39:b3815a1c3802 43 //
mjr 39:b3815a1c3802 44 // 2. Special reports
mjr 35:e959ffba78fd 45 // We subvert the joystick report format in certain cases to report other
mjr 35:e959ffba78fd 46 // types of information, when specifically requested by the host. This allows
mjr 35:e959ffba78fd 47 // our custom configuration UI on the Windows side to query additional
mjr 35:e959ffba78fd 48 // information that we don't normally send via the joystick reports. We
mjr 35:e959ffba78fd 49 // define a custom vendor-specific "status" field in the reports that we
mjr 35:e959ffba78fd 50 // use to identify these special reports, as described below.
mjr 35:e959ffba78fd 51 //
mjr 39:b3815a1c3802 52 // Normal joystick reports always have 0 in the high bit of the 2nd byte
mjr 35:e959ffba78fd 53 // of the report. Special non-joystick reports always have 1 in the high bit
mjr 35:e959ffba78fd 54 // of the first byte. (This byte is defined in the HID Report Descriptor
mjr 35:e959ffba78fd 55 // as an opaque vendor-defined value, so the joystick interface on the
mjr 35:e959ffba78fd 56 // Windows side simply ignores it.)
mjr 35:e959ffba78fd 57 //
mjr 39:b3815a1c3802 58 // 2A. Plunger sensor pixel dump
mjr 39:b3815a1c3802 59 // Software on the PC can request a full read of the pixels from the plunger
mjr 39:b3815a1c3802 60 // image sensor (if an imaging sensor type is being used) by sending custom
mjr 39:b3815a1c3802 61 // protocol message 65 3 (see below). Normally, the pixels from the image
mjr 39:b3815a1c3802 62 // sensor are read and processed on the controller device without being sent
mjr 39:b3815a1c3802 63 // to the PC; the PC only receives the plunger position reading obtained from
mjr 39:b3815a1c3802 64 // analyzing the image data. For debugging and setup purposes, software on
mjr 39:b3815a1c3802 65 // the host can use this special report to obtain the full image pixel array.
mjr 39:b3815a1c3802 66 // The image sensors we use have too many pixels to fit into one report, so
mjr 39:b3815a1c3802 67 // we have to send a series of reports to transmit the full image. We send
mjr 39:b3815a1c3802 68 // as many reports as necessary to transmit the full image. Each report
mjr 39:b3815a1c3802 69 // looks like this:
mjr 35:e959ffba78fd 70 //
mjr 35:e959ffba78fd 71 // bytes 0:1 = 11-bit index, with high 5 bits set to 10000. For
mjr 48:058ace2aed1d 72 // example, 0x8004 (encoded little endian as 0x04 0x80)
mjr 48:058ace2aed1d 73 // indicates index 4. This is the starting pixel number
mjr 48:058ace2aed1d 74 // in the report. The first report will be 0x00 0x80 to
mjr 48:058ace2aed1d 75 // indicate pixel #0.
mjr 47:df7a88cd249c 76 // bytes 2 = 8-bit unsigned int brightness level of pixel at index
mjr 47:df7a88cd249c 77 // bytes 3 = brightness of pixel at index+1
mjr 35:e959ffba78fd 78 // etc for the rest of the packet
mjr 35:e959ffba78fd 79 //
mjr 48:058ace2aed1d 80 // The pixel dump also sends a special final report, after all of the
mjr 48:058ace2aed1d 81 // pixel messages, with the "index" field set to 0x7FF (11 bits of 1's).
mjr 48:058ace2aed1d 82 // It packs special fields instead of pixels:
mjr 48:058ace2aed1d 83 //
mjr 48:058ace2aed1d 84 // bytes 0:1 = 0x87FF (pixel report flags + index 0x7FF)
mjr 48:058ace2aed1d 85 // byte 2 = 0x00 -> special report subtype 0 (this is to leave
mjr 48:058ace2aed1d 86 // room for adding more information via additional
mjr 48:058ace2aed1d 87 // subtypes in the future)
mjr 48:058ace2aed1d 88 // bytes 3:4 = pixel position of detected shadow edge in this image,
mjr 48:058ace2aed1d 89 // or 0xFFFF if no edge was found in this image. For
mjr 48:058ace2aed1d 90 // raw pixel reports, no edge will be detected because
mjr 48:058ace2aed1d 91 // we don't look for one.
mjr 48:058ace2aed1d 92 // byte 5 = flags:
mjr 48:058ace2aed1d 93 // 0x01 = normal orientation detected
mjr 48:058ace2aed1d 94 // 0x02 = reversed orientation detected
mjr 48:058ace2aed1d 95 // bytes 6:7:8 = average time for a sensor scan, in 10us units
mjr 48:058ace2aed1d 96 // byte 9:10:11 = time for processing this image, in 10us units
mjr 48:058ace2aed1d 97 //
mjr 39:b3815a1c3802 98 // 2B. Configuration query.
mjr 39:b3815a1c3802 99 // This is requested by sending custom protocol message 65 4 (see below).
mjr 39:b3815a1c3802 100 // In reponse, the device sends one report to the host using this format:
mjr 35:e959ffba78fd 101 //
mjr 35:e959ffba78fd 102 // bytes 0:1 = 0x8800. This has the bit pattern 10001 in the high
mjr 35:e959ffba78fd 103 // 5 bits, which distinguishes it from regular joystick
mjr 40:cc0d9814522b 104 // reports and from other special report types.
mjr 35:e959ffba78fd 105 // bytes 2:3 = total number of outputs, little endian
mjr 40:cc0d9814522b 106 // bytes 6:7 = plunger calibration zero point, little endian
mjr 40:cc0d9814522b 107 // bytes 8:9 = plunger calibration maximum point, little endian
mjr 40:cc0d9814522b 108 // byte 10 = bit flags:
mjr 40:cc0d9814522b 109 // 0x01 -> configuration loaded; 0 in this bit means that
mjr 40:cc0d9814522b 110 // the firmware has been loaded but no configuration
mjr 40:cc0d9814522b 111 // has been sent from the host
mjr 40:cc0d9814522b 112 // The remaining bytes are reserved for future use.
mjr 35:e959ffba78fd 113 //
mjr 40:cc0d9814522b 114 // 2C. Device ID query.
mjr 40:cc0d9814522b 115 // This is requested by sending custom protocol message 65 7 (see below).
mjr 40:cc0d9814522b 116 // In response, the device sends one report to the host using this format:
mjr 40:cc0d9814522b 117 //
mjr 40:cc0d9814522b 118 // bytes 0:1 = 0x9000. This has bit pattern 10010 in the high 5
mjr 40:cc0d9814522b 119 // bits, which distinguishes this special report from other
mjr 40:cc0d9814522b 120 // report types.
mjr 40:cc0d9814522b 121 // bytes 2-11 = Unique CPU ID. This is the ID stored in the CPU at the
mjr 40:cc0d9814522b 122 // factory, guaranteed to be unique across Kinetis devices.
mjr 40:cc0d9814522b 123 // This can be used by the host to distinguish devices when
mjr 40:cc0d9814522b 124 // two or more controllers are attached.
mjr 35:e959ffba78fd 125 //
mjr 35:e959ffba78fd 126 // WHY WE USE THIS HACKY APPROACH TO DIFFERENT REPORT TYPES
mjr 35:e959ffba78fd 127 //
mjr 35:e959ffba78fd 128 // The HID report system was specifically designed to provide a clean,
mjr 35:e959ffba78fd 129 // structured way for devices to describe the data they send to the host.
mjr 35:e959ffba78fd 130 // Our approach isn't clean or structured; it ignores the promises we
mjr 35:e959ffba78fd 131 // make about the contents of our report via the HID Report Descriptor
mjr 35:e959ffba78fd 132 // and stuffs our own different data format into the same structure.
mjr 35:e959ffba78fd 133 //
mjr 35:e959ffba78fd 134 // We use this hacky approach only because we can't use the official
mjr 35:e959ffba78fd 135 // mechanism, due to the constraint that we want to emulate the LedWiz.
mjr 35:e959ffba78fd 136 // The right way to send different report types is to declare different
mjr 35:e959ffba78fd 137 // report types via extra HID Report Descriptors, then send each report
mjr 35:e959ffba78fd 138 // using one of the types we declared. If it weren't for the LedWiz
mjr 35:e959ffba78fd 139 // constraint, we'd simply define the pixel dump and config query reports
mjr 35:e959ffba78fd 140 // as their own separate HID Report types, each consisting of opaque
mjr 35:e959ffba78fd 141 // blocks of bytes. But we can't do this. The snag is that some versions
mjr 35:e959ffba78fd 142 // of the LedWiz Windows host software parse the USB HID descriptors as part
mjr 35:e959ffba78fd 143 // of identifying a device as a valid LedWiz unit, and will only recognize
mjr 35:e959ffba78fd 144 // the device if it matches certain particulars about the descriptor
mjr 35:e959ffba78fd 145 // structure of a real LedWiz. One of the features that's important to
mjr 35:e959ffba78fd 146 // some versions of the software is the descriptor link structure, which
mjr 35:e959ffba78fd 147 // is affected by the layout of HID Report Descriptor entries. In order
mjr 35:e959ffba78fd 148 // to match the expected layout, we can only define a single kind of output
mjr 35:e959ffba78fd 149 // report. Since we have to use Joystick reports for the sake of VP and
mjr 35:e959ffba78fd 150 // other pinball software, and we're only allowed the one report type, we
mjr 35:e959ffba78fd 151 // have to make that one report type the Joystick type. That's why we
mjr 35:e959ffba78fd 152 // overload the joystick reports with other meanings. It's a hack, but
mjr 35:e959ffba78fd 153 // at least it's a fairly reliable and isolated hack, iun that our special
mjr 35:e959ffba78fd 154 // reports are only generated when clients specifically ask for them.
mjr 35:e959ffba78fd 155 // Plus, even if a client who doesn't ask for a special report somehow
mjr 35:e959ffba78fd 156 // gets one, the worst that happens is that they get a momentary spurious
mjr 35:e959ffba78fd 157 // reading from the accelerometer and plunger.
mjr 35:e959ffba78fd 158
mjr 35:e959ffba78fd 159
mjr 35:e959ffba78fd 160
mjr 35:e959ffba78fd 161 // ------- INCOMING MESSAGES (HOST TO DEVICE) -------
mjr 35:e959ffba78fd 162 //
mjr 35:e959ffba78fd 163 // For LedWiz compatibility, our incoming message format conforms to the
mjr 35:e959ffba78fd 164 // basic USB format used by real LedWiz units. This is simply 8 data
mjr 35:e959ffba78fd 165 // bytes, all private vendor-specific values (meaning that the Windows HID
mjr 35:e959ffba78fd 166 // driver treats them as opaque and doesn't attempt to parse them).
mjr 35:e959ffba78fd 167 //
mjr 35:e959ffba78fd 168 // Within this basic 8-byte format, we recognize the full protocol used
mjr 35:e959ffba78fd 169 // by real LedWiz units, plus an extended protocol that we define privately.
mjr 35:e959ffba78fd 170 // The LedWiz protocol leaves a large part of the potential protocol space
mjr 35:e959ffba78fd 171 // undefined, so we take advantage of this undefined region for our
mjr 35:e959ffba78fd 172 // extensions. This ensures that we can properly recognize all messages
mjr 35:e959ffba78fd 173 // intended for a real LedWiz unit, as well as messages from custom host
mjr 35:e959ffba78fd 174 // software that knows it's talking to a Pinscape unit.
mjr 35:e959ffba78fd 175
mjr 35:e959ffba78fd 176 // --- REAL LED WIZ MESSAGES ---
mjr 35:e959ffba78fd 177 //
mjr 35:e959ffba78fd 178 // The real LedWiz protocol has two message types, identified by the first
mjr 35:e959ffba78fd 179 // byte of the 8-byte USB packet:
mjr 35:e959ffba78fd 180 //
mjr 35:e959ffba78fd 181 // 64 -> SBA (64 xx xx xx xx ss uu uu)
mjr 35:e959ffba78fd 182 // xx = on/off bit mask for 8 outputs
mjr 35:e959ffba78fd 183 // ss = global flash speed setting (1-7)
mjr 35:e959ffba78fd 184 // uu = unused
mjr 35:e959ffba78fd 185 //
mjr 35:e959ffba78fd 186 // If the first byte has value 64 (0x40), it's an SBA message. This type of
mjr 35:e959ffba78fd 187 // message sets all 32 outputs individually ON or OFF according to the next
mjr 35:e959ffba78fd 188 // 32 bits (4 bytes) of the message, and sets the flash speed to the value in
mjr 35:e959ffba78fd 189 // the sixth byte. (The flash speed sets the global cycle rate for flashing
mjr 35:e959ffba78fd 190 // outputs - outputs with their values set to the range 128-132 - to a
mjr 35:e959ffba78fd 191 // relative speed, scaled linearly in frequency. 1 is the slowest at about
mjr 35:e959ffba78fd 192 // 2 Hz, 7 is the fastest at about 14 Hz.)
mjr 35:e959ffba78fd 193 //
mjr 35:e959ffba78fd 194 // 0-49 or 128-132 -> PBA (bb bb bb bb bb bb bb bb)
mjr 35:e959ffba78fd 195 // bb = brightness level/flash pattern for one output
mjr 35:e959ffba78fd 196 //
mjr 35:e959ffba78fd 197 // If the first byte is any valid brightness setting, it's a PBA message.
mjr 35:e959ffba78fd 198 // Valid brightness settings are:
mjr 35:e959ffba78fd 199 //
mjr 35:e959ffba78fd 200 // 0-48 = fixed brightness level, linearly from 0% to 100% intensity
mjr 35:e959ffba78fd 201 // 49 = fixed brightness level at 100% intensity (same as 48)
mjr 35:e959ffba78fd 202 // 129 = flashing pattern, fade up / fade down (sawtooth wave)
mjr 35:e959ffba78fd 203 // 130 = flashing pattern, on / off (square wave)
mjr 35:e959ffba78fd 204 // 131 = flashing pattern, on for 50% duty cycle / fade down
mjr 35:e959ffba78fd 205 // 132 = flashing pattern, fade up / on for 50% duty cycle
mjr 35:e959ffba78fd 206 //
mjr 35:e959ffba78fd 207 // A PBA message sets 8 outputs out of 32. Which 8 are to be set is
mjr 35:e959ffba78fd 208 // implicit in the message sequence: the first PBA sets outputs 1-8, the
mjr 35:e959ffba78fd 209 // second sets 9-16, and so on, rolling around after each fourth PBA.
mjr 35:e959ffba78fd 210 // An SBA also resets the implicit "bank" for the next PBA to outputs 1-8.
mjr 35:e959ffba78fd 211 //
mjr 35:e959ffba78fd 212 // Note that there's no special first byte to indicate the PBA message
mjr 35:e959ffba78fd 213 // type, as there is in an SBA. The first byte of a PBA is simply the
mjr 35:e959ffba78fd 214 // first output setting. The way the LedWiz creators conceived this, the
mjr 35:e959ffba78fd 215 // SBA distinguishable from a PBA because 64 isn't a valid output setting,
mjr 35:e959ffba78fd 216 // hence a message that starts with a byte value of 64 isn't a valid PBA
mjr 35:e959ffba78fd 217 // message.
mjr 35:e959ffba78fd 218 //
mjr 35:e959ffba78fd 219 // Our extended protocol uses the same principle, taking advantage of the
mjr 35:e959ffba78fd 220 // other byte value ranges that are invalid in PBA messages. To be a valid
mjr 35:e959ffba78fd 221 // PBA message, the first byte must be in the range 0-49 or 129-132. As
mjr 35:e959ffba78fd 222 // already mentioned, byte value 64 indicates an SBA message. This leaves
mjr 35:e959ffba78fd 223 // these ranges available for other uses: 50-63, 65-128, and 133-255.
mjr 35:e959ffba78fd 224
mjr 35:e959ffba78fd 225
mjr 35:e959ffba78fd 226 // --- PRIVATE EXTENDED MESSAGES ---
mjr 35:e959ffba78fd 227 //
mjr 35:e959ffba78fd 228 // All of our extended protocol messages are identified by the first byte:
mjr 35:e959ffba78fd 229 //
mjr 35:e959ffba78fd 230 // 65 -> Miscellaneous control message. The second byte specifies the specific
mjr 35:e959ffba78fd 231 // operation:
mjr 35:e959ffba78fd 232 //
mjr 39:b3815a1c3802 233 // 0 -> No Op - does nothing. (This can be used to send a test message on the
mjr 39:b3815a1c3802 234 // USB endpoint.)
mjr 39:b3815a1c3802 235 //
mjr 35:e959ffba78fd 236 // 1 -> Set device unit number and plunger status, and save the changes immediately
mjr 35:e959ffba78fd 237 // to flash. The device will automatically reboot after the changes are saved.
mjr 35:e959ffba78fd 238 // The additional bytes of the message give the parameters:
mjr 35:e959ffba78fd 239 //
mjr 35:e959ffba78fd 240 // third byte = new unit number (0-15, corresponding to nominal unit numbers 1-16)
mjr 35:e959ffba78fd 241 // fourth byte = plunger on/off (0=disabled, 1=enabled)
mjr 35:e959ffba78fd 242 //
mjr 35:e959ffba78fd 243 // 2 -> Begin plunger calibration mode. The device stays in this mode for about
mjr 35:e959ffba78fd 244 // 15 seconds, and sets the zero point and maximum retraction points to the
mjr 35:e959ffba78fd 245 // observed endpoints of sensor readings while the mode is running. After
mjr 35:e959ffba78fd 246 // the time limit elapses, the device automatically stores the results in
mjr 35:e959ffba78fd 247 // non-volatile flash memory and exits the mode.
mjr 35:e959ffba78fd 248 //
mjr 35:e959ffba78fd 249 // 3 -> Send pixel dump. The plunger sensor object sends a series of the special
mjr 35:e959ffba78fd 250 // pixel dump reports, defined in USBJoystick.cpp; the device automatically
mjr 35:e959ffba78fd 251 // resumes normal joystick messages after sending all pixels. If the
mjr 35:e959ffba78fd 252 // plunger sensor isn't an image sensor type, no pixel messages are sent.
mjr 48:058ace2aed1d 253 // Additional parameters:
mjr 48:058ace2aed1d 254 //
mjr 48:058ace2aed1d 255 // third byte = bit flags:
mjr 48:058ace2aed1d 256 // 0x01 = low res mode (for faster updates)
mjr 48:058ace2aed1d 257 //
mjr 48:058ace2aed1d 258 // fourth byte = visualization mode:
mjr 48:058ace2aed1d 259 // 0 = raw pixels
mjr 48:058ace2aed1d 260 // 1 = pixels with noise reduction applied
mjr 48:058ace2aed1d 261 // 2 = high contrast
mjr 48:058ace2aed1d 262 // 3 = edge visualization (only detected edges are displayed)
mjr 35:e959ffba78fd 263 //
mjr 35:e959ffba78fd 264 // 4 -> Query configuration. The device sends a special configuration report,
mjr 40:cc0d9814522b 265 // (see above; see also USBJoystick.cpp), then resumes sending normal
mjr 40:cc0d9814522b 266 // joystick reports.
mjr 35:e959ffba78fd 267 //
mjr 35:e959ffba78fd 268 // 5 -> Turn all outputs off and restore LedWiz defaults. Sets output ports
mjr 35:e959ffba78fd 269 // 1-32 to OFF and LedWiz brightness/mode setting 48, sets outputs 33 and
mjr 35:e959ffba78fd 270 // higher to brightness level 0, and sets the LedWiz global flash speed to 2.
mjr 35:e959ffba78fd 271 //
mjr 35:e959ffba78fd 272 // 6 -> Save configuration to flash. This saves all variable updates sent via
mjr 35:e959ffba78fd 273 // type 66 messages since the last reboot, then automatically reboots the
mjr 35:e959ffba78fd 274 // device to put the changes into effect.
mjr 35:e959ffba78fd 275 //
mjr 40:cc0d9814522b 276 // 7 -> Query device ID. The device replies with a special device ID report
mjr 40:cc0d9814522b 277 // (see above; see also USBJoystick.cpp), then resumes sending normal
mjr 40:cc0d9814522b 278 // joystick reports.
mjr 40:cc0d9814522b 279 //
mjr 40:cc0d9814522b 280 // 8 -> Engage/disengage night mode. The third byte of the message is 1 to
mjr 40:cc0d9814522b 281 // engage night mode, 0 to disengage night mode. (This mode isn't stored
mjr 40:cc0d9814522b 282 // persistently; night mode is disengaged after a reset or power cycle.)
mjr 40:cc0d9814522b 283 //
mjr 35:e959ffba78fd 284 // 66 -> Set configuration variable. The second byte of the message is the config
mjr 35:e959ffba78fd 285 // variable number, and the remaining bytes give the new value for the variable.
mjr 35:e959ffba78fd 286 // The value format is specific to each variable; see the list below for details.
mjr 35:e959ffba78fd 287 // This message only sets the value in RAM - it doesn't write the value to flash
mjr 35:e959ffba78fd 288 // and doesn't put the change into effect immediately. To put updates into effect,
mjr 35:e959ffba78fd 289 // the host must send a type 65 subtype 6 message (see above), which saves updates
mjr 35:e959ffba78fd 290 // to flash and reboots the device.
mjr 35:e959ffba78fd 291 //
mjr 35:e959ffba78fd 292 // 200-228 -> Set extended output brightness. This sets outputs N to N+6 to the
mjr 35:e959ffba78fd 293 // respective brightness values in the 2nd through 8th bytes of the message
mjr 35:e959ffba78fd 294 // (output N is set to the 2nd byte value, N+1 is set to the 3rd byte value,
mjr 35:e959ffba78fd 295 // etc). Each brightness level is a linear brightness level from 0-255,
mjr 35:e959ffba78fd 296 // where 0 is 0% brightness and 255 is 100% brightness. N is calculated as
mjr 35:e959ffba78fd 297 // (first byte - 200)*7 + 1:
mjr 35:e959ffba78fd 298 //
mjr 35:e959ffba78fd 299 // 200 = outputs 1-7
mjr 35:e959ffba78fd 300 // 201 = outputs 8-14
mjr 35:e959ffba78fd 301 // 202 = outputs 15-21
mjr 35:e959ffba78fd 302 // ...
mjr 35:e959ffba78fd 303 // 228 = outputs 197-203
mjr 35:e959ffba78fd 304 //
mjr 35:e959ffba78fd 305 // This message is the only way to address ports 33 and higher, since standard
mjr 35:e959ffba78fd 306 // LedWiz messages are inherently limited to ports 1-32.
mjr 35:e959ffba78fd 307 //
mjr 35:e959ffba78fd 308 // Note that these extended output messages differ from regular LedWiz settings
mjr 35:e959ffba78fd 309 // in two ways. First, the brightness is the ONLY attribute when an output is
mjr 35:e959ffba78fd 310 // set using this mode - there's no separate ON/OFF setting per output as there
mjr 35:e959ffba78fd 311 // is with the SBA/PBA messages. To turn an output OFF with this message, set
mjr 35:e959ffba78fd 312 // the intensity to 0. Setting a non-zero intensity turns it on immediately
mjr 35:e959ffba78fd 313 // without regard to the SBA status for the port. Second, the brightness is
mjr 35:e959ffba78fd 314 // on a full 8-bit scale (0-255) rather than the LedWiz's approximately 5-bit
mjr 35:e959ffba78fd 315 // scale, because there are no parts of the range reserved for flashing modes.
mjr 35:e959ffba78fd 316 //
mjr 35:e959ffba78fd 317 // Outputs 1-32 can be controlled by EITHER the regular LedWiz SBA/PBA messages
mjr 35:e959ffba78fd 318 // or by the extended messages. The latest setting for a given port takes
mjr 35:e959ffba78fd 319 // precedence. If an SBA/PBA message was the last thing sent to a port, the
mjr 35:e959ffba78fd 320 // normal LedWiz combination of ON/OFF and brightness/flash mode status is used
mjr 35:e959ffba78fd 321 // to determine the port's physical output setting. If an extended brightness
mjr 35:e959ffba78fd 322 // message was the last thing sent to a port, the LedWiz ON/OFF status and
mjr 35:e959ffba78fd 323 // flash modes are ignored, and the fixed brightness is set. Outputs 33 and
mjr 35:e959ffba78fd 324 // higher inherently can't be addressed or affected by SBA/PBA messages.
mjr 35:e959ffba78fd 325
mjr 35:e959ffba78fd 326
mjr 35:e959ffba78fd 327 // ------- CONFIGURATION VARIABLES -------
mjr 35:e959ffba78fd 328 //
mjr 35:e959ffba78fd 329 // Message type 66 (see above) sets one configuration variable. The second byte
mjr 35:e959ffba78fd 330 // of the message is the variable ID, and the rest of the bytes give the new
mjr 35:e959ffba78fd 331 // value, in a variable-specific format. 16-bit values are little endian.
mjr 35:e959ffba78fd 332 //
mjr 35:e959ffba78fd 333 // 1 -> USB device ID. Bytes 3-4 give the 16-bit USB Vendor ID; bytes
mjr 35:e959ffba78fd 334 // 5-6 give the 16-bit USB Product ID. For LedWiz emulation, use
mjr 35:e959ffba78fd 335 // vendor 0xFAFA and product 0x00EF + unit# (where unit# is the
mjr 35:e959ffba78fd 336 // nominal LedWiz unit number, from 1 to 16). If LedWiz emulation
mjr 35:e959ffba78fd 337 // isn't desired or causes host conflicts, you can use our private
mjr 35:e959ffba78fd 338 // ID assigned by http://pid.codes (a registry for open-source USB
mjr 35:e959ffba78fd 339 // devices) of vendor 0x1209 and product 0xEAEA. (You can also use
mjr 35:e959ffba78fd 340 // any other values that don't cause a conflict on your PC, but we
mjr 35:e959ffba78fd 341 // recommend using one of these pre-assigned values if possible.)
mjr 35:e959ffba78fd 342 //
mjr 35:e959ffba78fd 343 // 2 -> Pinscape Controller unit number for DOF. Byte 3 is the new
mjr 35:e959ffba78fd 344 // unit number, from 1 to 16.
mjr 35:e959ffba78fd 345 //
mjr 35:e959ffba78fd 346 // 3 -> Enable/disable joystick reports. Byte 2 is 1 to enable, 0 to
mjr 35:e959ffba78fd 347 // disable. When disabled, the device registers as a generic HID
mjr 35:e959ffba78fd 348 / device, and only sends the private report types used by the
mjr 35:e959ffba78fd 349 // Windows config tool.
mjr 35:e959ffba78fd 350 //
mjr 35:e959ffba78fd 351 // 4 -> Accelerometer orientation. Byte 3 is the new setting:
mjr 35:e959ffba78fd 352 //
mjr 35:e959ffba78fd 353 // 0 = ports at front (USB ports pointing towards front of cabinet)
mjr 35:e959ffba78fd 354 // 1 = ports at left
mjr 35:e959ffba78fd 355 // 2 = ports at right
mjr 35:e959ffba78fd 356 // 3 = ports at rear
mjr 35:e959ffba78fd 357 //
mjr 35:e959ffba78fd 358 // 5 -> Plunger sensor type. Byte 3 is the type ID:
mjr 35:e959ffba78fd 359 //
mjr 35:e959ffba78fd 360 // 0 = none (disabled)
mjr 35:e959ffba78fd 361 // 1 = TSL1410R linear image sensor, 1280x1 pixels, serial mode
mjr 47:df7a88cd249c 362 // *2 = TSL1410R, parallel mode
mjr 35:e959ffba78fd 363 // 3 = TSL1412R linear image sensor, 1536x1 pixels, serial mode
mjr 47:df7a88cd249c 364 // *4 = TSL1412R, parallel mode
mjr 35:e959ffba78fd 365 // 5 = Potentiometer with linear taper, or any other device that
mjr 35:e959ffba78fd 366 // represents the position reading with a single analog voltage
mjr 47:df7a88cd249c 367 // *6 = AEDR8300 optical quadrature sensor, 75lpi
mjr 47:df7a88cd249c 368 // *7 = AS5304 magnetic quadrature sensor, 160 steps per 2mm
mjr 47:df7a88cd249c 369 //
mjr 47:df7a88cd249c 370 // * The sensor types marked with asterisks (*) are planned but not
mjr 47:df7a88cd249c 371 // currently implemented. Selecting these types will effectively
mjr 47:df7a88cd249c 372 // disable the plunger.
mjr 35:e959ffba78fd 373 //
mjr 35:e959ffba78fd 374 // 6 -> Plunger pin assignments. Bytes 3-6 give the pin assignments for
mjr 35:e959ffba78fd 375 // pins 1, 2, 3, and 4. These use the Pin Number Mappings listed
mjr 35:e959ffba78fd 376 // below. The meaning of each pin depends on the plunger type:
mjr 35:e959ffba78fd 377 //
mjr 35:e959ffba78fd 378 // TSL1410R/1412R, serial: SI (DigitalOut), CLK (DigitalOut), AO (AnalogIn), NC
mjr 35:e959ffba78fd 379 // TSL1410R/1412R, parallel: SI (DigitalOut), CLK (DigitalOut), AO1 (AnalogIn), AO2 (AnalogIn)
mjr 35:e959ffba78fd 380 // Potentiometer: AO (AnalogIn), NC, NC, NC
mjr 35:e959ffba78fd 381 // AEDR8300: A (InterruptIn), B (InterruptIn), NC, NC
mjr 35:e959ffba78fd 382 // AS5304: A (InterruptIn), B (InterruptIn), NC, NC
mjr 35:e959ffba78fd 383 //
mjr 35:e959ffba78fd 384 // 7 -> Plunger calibration button pin assignments. Byte 3 is the DigitalIn
mjr 35:e959ffba78fd 385 // pin for the button switch; byte 4 is the DigitalOut pin for the indicator
mjr 35:e959ffba78fd 386 // lamp. Either can be set to NC to disable the function. (Use the Pin
mjr 35:e959ffba78fd 387 // Number Mappins listed below for both bytes.)
mjr 35:e959ffba78fd 388 //
mjr 35:e959ffba78fd 389 // 8 -> ZB Launch Ball setup. This configures the ZB Launch Ball feature. Byte
mjr 35:e959ffba78fd 390 // 3 is the LedWiz port number (1-255) mapped to the "ZB Launch Ball" output
mjr 35:e959ffba78fd 391 // in DOF. Set the port to 0 to disable the feature. Byte 4 is the button
mjr 35:e959ffba78fd 392 // number (1-32) that we'll "press" when the feature is activated. Bytes 5-6
mjr 35:e959ffba78fd 393 // give the "push distance" for activating the button by pushing forward on
mjr 40:cc0d9814522b 394 // the plunger knob, in 1/1000 inch increments (e.g., 80 represents 0.08",
mjr 40:cc0d9814522b 395 // which is the recommended setting).
mjr 35:e959ffba78fd 396 //
mjr 35:e959ffba78fd 397 // 9 -> TV ON relay setup. This requires external circuitry implemented on the
mjr 35:e959ffba78fd 398 // Expansion Board (or an equivalent circuit as described in the Build Guide).
mjr 35:e959ffba78fd 399 // Byte 3 is the GPIO DigitalIn pin for the "power status" input, using the
mjr 35:e959ffba78fd 400 // Pin Number Mappings below. Byte 4 is the DigitalOut pin for the "latch"
mjr 35:e959ffba78fd 401 // output. Byte 5 is the DigitalOut pin for the relay trigger. Bytes 6-7
mjr 35:e959ffba78fd 402 // give the delay time in 10ms increments as an unsigned 16-bit value (e.g.,
mjr 35:e959ffba78fd 403 // 550 represents 5.5 seconds).
mjr 35:e959ffba78fd 404 //
mjr 35:e959ffba78fd 405 // 10 -> TLC5940NT setup. This chip is an external PWM controller, with 32 outputs
mjr 35:e959ffba78fd 406 // per chip and a serial data interface that allows the chips to be daisy-
mjr 35:e959ffba78fd 407 // chained. We can use these chips to add an arbitrary number of PWM output
mjr 35:e959ffba78fd 408 // ports for the LedWiz emulation. Set the number of chips to 0 to disable
mjr 35:e959ffba78fd 409 // the feature. The bytes of the message are:
mjr 35:e959ffba78fd 410 // byte 3 = number of chips attached (connected in daisy chain)
mjr 35:e959ffba78fd 411 // byte 4 = SIN pin - Serial data (must connect to SPIO MOSI -> PTC6 or PTD2)
mjr 35:e959ffba78fd 412 // byte 5 = SCLK pin - Serial clock (must connect to SPIO SCLK -> PTC5 or PTD1)
mjr 35:e959ffba78fd 413 // byte 6 = XLAT pin - XLAT (latch) signal (any GPIO pin)
mjr 35:e959ffba78fd 414 // byte 7 = BLANK pin - BLANK signal (any GPIO pin)
mjr 35:e959ffba78fd 415 // byte 8 = GSCLK pin - Grayscale clock signal (must be a PWM-out capable pin)
mjr 35:e959ffba78fd 416 //
mjr 35:e959ffba78fd 417 // 11 -> 74HC595 setup. This chip is an external shift register, with 8 outputs per
mjr 35:e959ffba78fd 418 // chip and a serial data interface that allows daisy-chaining. We use this
mjr 35:e959ffba78fd 419 // chips to add extra digital outputs for the LedWiz emulation. In particular,
mjr 35:e959ffba78fd 420 // the Chime Board (part of the Expansion Board suite) uses these to add timer-
mjr 35:e959ffba78fd 421 // protected outputs for coil devices (knockers, chimes, bells, etc). Set the
mjr 35:e959ffba78fd 422 // number of chips to 0 to disable the feature. The message bytes are:
mjr 35:e959ffba78fd 423 // byte 3 = number of chips attached (connected in daisy chain)
mjr 35:e959ffba78fd 424 // byte 4 = SIN pin - Serial data (any GPIO pin)
mjr 35:e959ffba78fd 425 // byte 5 = SCLK pin - Serial clock (any GPIO pin)
mjr 35:e959ffba78fd 426 // byte 6 = LATCH pin - LATCH signal (any GPIO pin)
mjr 35:e959ffba78fd 427 // byte 7 = ENA pin - ENABLE signal (any GPIO pin)
mjr 35:e959ffba78fd 428 //
mjr 35:e959ffba78fd 429 // 12 -> Input button setup. This sets up one button; it can be repeated for each
mjr 35:e959ffba78fd 430 // button to be configured. There are 32 button slots, numbered 1-32. Each
mjr 35:e959ffba78fd 431 // key can be configured as a joystick button, a regular keyboard key, a
mjr 35:e959ffba78fd 432 // keyboard modifier key (such as Shift, Ctrl, or Alt), or a media control
mjr 35:e959ffba78fd 433 // key (such as volume up/down).
mjr 35:e959ffba78fd 434 //
mjr 35:e959ffba78fd 435 // The bytes of the message are:
mjr 35:e959ffba78fd 436 // byte 3 = Button number (1-32)
mjr 35:e959ffba78fd 437 // byte 4 = GPIO pin to read for button input
mjr 35:e959ffba78fd 438 // byte 5 = key type reported to PC when button is pushed:
mjr 35:e959ffba78fd 439 // 1 = joystick button -> byte 6 is the button number, 1-32
mjr 35:e959ffba78fd 440 // 2 = regular keyboard key -> byte 6 is the USB key code (see below)
mjr 35:e959ffba78fd 441 // 3 = keyboard modifier key -> byte 6 is the USB modifier code (see below)
mjr 35:e959ffba78fd 442 // 4 = media control key -> byte 6 is the USB key code (see below)
mjr 38:091e511ce8a0 443 // 5 = special button -> byte 6 is the special button code (see below)
mjr 35:e959ffba78fd 444 // byte 6 = key code, which depends on the key type in byte 5
mjr 38:091e511ce8a0 445 // byte 7 = flags - a combination of these bit values:
mjr 38:091e511ce8a0 446 // 0x01 = pulse mode. This reports a physical on/off switch's state
mjr 38:091e511ce8a0 447 // to the host as a brief key press whenever the switch changes
mjr 38:091e511ce8a0 448 // state. This is useful for the VPinMAME Coin Door button,
mjr 38:091e511ce8a0 449 // which requires the End key to be pressed each time the
mjr 38:091e511ce8a0 450 // door changes state.
mjr 35:e959ffba78fd 451 //
mjr 35:e959ffba78fd 452 // 13 -> LedWiz output port setup. This sets up one output port; it can be repeated
mjr 35:e959ffba78fd 453 // for each port to be configured. There are 203 possible slots for output ports,
mjr 35:e959ffba78fd 454 // numbered 1 to 203. The number of ports visible to the host is determined by
mjr 35:e959ffba78fd 455 // the first DISABLED port (type 0). For example, if ports 1-32 are set as GPIO
mjr 35:e959ffba78fd 456 // outputs and port 33 is disabled, the host will see 32 ports, regardless of
mjr 35:e959ffba78fd 457 // the settings for post 34 and higher.
mjr 35:e959ffba78fd 458 //
mjr 35:e959ffba78fd 459 // The bytes of the message are:
mjr 35:e959ffba78fd 460 // byte 3 = LedWiz port number (1 to maximum number or ports)
mjr 35:e959ffba78fd 461 // byte 4 = physical output type:
mjr 35:e959ffba78fd 462 // 0 = Disabled. This output isn't used, and isn't visible to the
mjr 35:e959ffba78fd 463 // LedWiz/DOF software on the host. The FIRST disabled port
mjr 35:e959ffba78fd 464 // determines the number of ports visible to the host - ALL ports
mjr 35:e959ffba78fd 465 // after the first disabled port are also implicitly disabled.
mjr 35:e959ffba78fd 466 // 1 = GPIO PWM output: connected to GPIO pin specified in byte 5,
mjr 35:e959ffba78fd 467 // operating in PWM mode. Note that only a subset of KL25Z GPIO
mjr 35:e959ffba78fd 468 // ports are PWM-capable.
mjr 35:e959ffba78fd 469 // 2 = GPIO Digital output: connected to GPIO pin specified in byte 5,
mjr 35:e959ffba78fd 470 // operating in digital mode. Digital ports can only be set ON
mjr 35:e959ffba78fd 471 // or OFF, with no brightness/intensity control. All pins can be
mjr 35:e959ffba78fd 472 // used in this mode.
mjr 35:e959ffba78fd 473 // 3 = TLC5940 port: connected to TLC5940 output port number specified
mjr 35:e959ffba78fd 474 // in byte 5. Ports are numbered sequentially starting from port 0
mjr 35:e959ffba78fd 475 // for the first output (OUT0) on the first chip in the daisy chain.
mjr 35:e959ffba78fd 476 // 4 = 74HC595 port: connected to 74HC595 output port specified in byte 5.
mjr 35:e959ffba78fd 477 // As with the TLC5940 outputs, ports are numbered sequentially from 0
mjr 35:e959ffba78fd 478 // for the first output on the first chip in the daisy chain.
mjr 35:e959ffba78fd 479 // 5 = Virtual output: this output port exists for the purposes of the
mjr 35:e959ffba78fd 480 // LedWiz/DOF software on the host, but isn't physically connected
mjr 35:e959ffba78fd 481 // to any output device. This can be used to create a virtual output
mjr 35:e959ffba78fd 482 // for the DOF ZB Launch Ball signal, for example, or simply as a
mjr 35:e959ffba78fd 483 // placeholder in the LedWiz port numbering. The physical output ID
mjr 35:e959ffba78fd 484 // (byte 5) is ignored for this port type.
mjr 35:e959ffba78fd 485 // byte 5 = physical output ID, interpreted according to the value in byte 4
mjr 35:e959ffba78fd 486 // byte 6 = flags: a combination of these bit values:
mjr 38:091e511ce8a0 487 // 0x01 = active-high output (0V on output turns attached device ON)
mjr 38:091e511ce8a0 488 // 0x02 = noisemaker device: disable this output when "night mode" is engaged
mjr 40:cc0d9814522b 489 // 0x04 = apply gamma correction to this output
mjr 38:091e511ce8a0 490 //
mjr 38:091e511ce8a0 491 // Note that the on-board LED segments can be used as LedWiz output ports. This
mjr 38:091e511ce8a0 492 // is useful for testing a new installation with DOF or other PC software without
mjr 38:091e511ce8a0 493 // having to connect any external devices. Assigning the on-board LED segments to
mjr 38:091e511ce8a0 494 // output ports overrides their normal status/diagnostic display use, so the normal
mjr 38:091e511ce8a0 495 // status flash pattern won't appear when they're used this way.
mjr 38:091e511ce8a0 496 //
mjr 38:091e511ce8a0 497 // Special port numbers: if the LedWiz port number is one of these special values,
mjr 38:091e511ce8a0 498 // the physical output is used for a special purpose. These ports aren't visible
mjr 38:091e511ce8a0 499 // to the PC as LedWiz ports; they're for internal use by the controller. The
mjr 38:091e511ce8a0 500 // special port numbers are:
mjr 38:091e511ce8a0 501 //
mjr 38:091e511ce8a0 502 // 254 = Night Mode indicator lamp. This port is turned on when night mode
mjr 38:091e511ce8a0 503 // is engaged, and turned off when night mode is disengaged. This can
mjr 38:091e511ce8a0 504 // be used, for example, to control an indicator LED inside a lighted
mjr 38:091e511ce8a0 505 // momentary pushbutton switch used to activate night mode. The light
mjr 38:091e511ce8a0 506 // provides visual feedback that the mode is turned on.
mjr 38:091e511ce8a0 507 //
mjr 38:091e511ce8a0 508
mjr 35:e959ffba78fd 509
mjr 35:e959ffba78fd 510
mjr 35:e959ffba78fd 511 // --- PIN NUMBER MAPPINGS ---
mjr 35:e959ffba78fd 512 //
mjr 35:e959ffba78fd 513 // In USB messages that specify GPIO pin assignments, pins are identified with
mjr 35:e959ffba78fd 514 // our own private numbering scheme. Our numbering scheme only includes the
mjr 35:e959ffba78fd 515 // ports connected to external header pins on the KL25Z board, so this is only
mjr 35:e959ffba78fd 516 // a sparse subset of the full GPIO port set. These are numbered in order of
mjr 35:e959ffba78fd 517 // pin name. The special value 0 = NC = Not Connected can be used where
mjr 35:e959ffba78fd 518 // appropriate to indicate a disabled or unused pin.
mjr 35:e959ffba78fd 519 //
mjr 35:e959ffba78fd 520 // 0 = NC (not connected)
mjr 35:e959ffba78fd 521 // 1 = PTA1
mjr 35:e959ffba78fd 522 // 2 = PTA2
mjr 35:e959ffba78fd 523 // 3 = PTA4
mjr 35:e959ffba78fd 524 // 4 = PTA5
mjr 35:e959ffba78fd 525 // 5 = PTA12
mjr 35:e959ffba78fd 526 // 6 = PTA13
mjr 35:e959ffba78fd 527 // 7 = PTA16
mjr 35:e959ffba78fd 528 // 8 = PTA17
mjr 35:e959ffba78fd 529 // 9 = PTB0
mjr 35:e959ffba78fd 530 // 10 = PTB1
mjr 35:e959ffba78fd 531 // 11 = PTB2
mjr 35:e959ffba78fd 532 // 12 = PTB3
mjr 35:e959ffba78fd 533 // 13 = PTB8
mjr 35:e959ffba78fd 534 // 14 = PTB9
mjr 35:e959ffba78fd 535 // 15 = PTB10
mjr 35:e959ffba78fd 536 // 16 = PTB11
mjr 38:091e511ce8a0 537 // 17 = PTB18 (on-board LED Red segment - not exposed as a header pin)
mjr 38:091e511ce8a0 538 // 18 = PTB19 (on-board LED Green segment - not exposed as a header pin)
mjr 38:091e511ce8a0 539 // 19 = PTC0
mjr 38:091e511ce8a0 540 // 20 = PTC1
mjr 38:091e511ce8a0 541 // 21 = PTC2
mjr 38:091e511ce8a0 542 // 22 = PTC3
mjr 38:091e511ce8a0 543 // 23 = PTC4
mjr 38:091e511ce8a0 544 // 24 = PTC5
mjr 38:091e511ce8a0 545 // 25 = PTC6
mjr 38:091e511ce8a0 546 // 26 = PTC7
mjr 38:091e511ce8a0 547 // 27 = PTC8
mjr 38:091e511ce8a0 548 // 28 = PTC9
mjr 38:091e511ce8a0 549 // 29 = PTC10
mjr 38:091e511ce8a0 550 // 30 = PTC11
mjr 38:091e511ce8a0 551 // 31 = PTC12
mjr 38:091e511ce8a0 552 // 32 = PTC13
mjr 38:091e511ce8a0 553 // 33 = PTC16
mjr 38:091e511ce8a0 554 // 34 = PTC17
mjr 38:091e511ce8a0 555 // 35 = PTD0
mjr 38:091e511ce8a0 556 // 36 = PTD1 (on-board LED Blue segment)
mjr 38:091e511ce8a0 557 // 37 = PTD2
mjr 38:091e511ce8a0 558 // 38 = PTD3
mjr 38:091e511ce8a0 559 // 39 = PTD4
mjr 38:091e511ce8a0 560 // 40 = PTD5
mjr 38:091e511ce8a0 561 // 41 = PTD6
mjr 38:091e511ce8a0 562 // 42 = PTD7
mjr 38:091e511ce8a0 563 // 43 = PTE0
mjr 38:091e511ce8a0 564 // 44 = PTE1
mjr 38:091e511ce8a0 565 // 45 = PTE2
mjr 38:091e511ce8a0 566 // 46 = PTE3
mjr 38:091e511ce8a0 567 // 47 = PTE4
mjr 38:091e511ce8a0 568 // 48 = PTE5
mjr 38:091e511ce8a0 569 // 49 = PTE20
mjr 38:091e511ce8a0 570 // 50 = PTE21
mjr 38:091e511ce8a0 571 // 51 = PTE22
mjr 38:091e511ce8a0 572 // 52 = PTE23
mjr 38:091e511ce8a0 573 // 53 = PTE29
mjr 38:091e511ce8a0 574 // 54 = PTE30
mjr 38:091e511ce8a0 575 // 55 = PTE31
mjr 35:e959ffba78fd 576
mjr 35:e959ffba78fd 577 // --- USB KEYBOARD SCAN CODES ---
mjr 35:e959ffba78fd 578 //
mjr 35:e959ffba78fd 579 // Use the standard USB HID keyboard codes for regular keys. See the
mjr 35:e959ffba78fd 580 // HID Usage Tables in the official USB specifications for a full list.
mjr 35:e959ffba78fd 581 // Here are the most common codes for quick references:
mjr 35:e959ffba78fd 582 //
mjr 35:e959ffba78fd 583 // A-Z -> 4-29
mjr 35:e959ffba78fd 584 // top row numbers -> 30-39
mjr 35:e959ffba78fd 585 // Return -> 40
mjr 35:e959ffba78fd 586 // Escape -> 41
mjr 35:e959ffba78fd 587 // Backspace -> 42
mjr 35:e959ffba78fd 588 // Tab -> 43
mjr 35:e959ffba78fd 589 // Spacebar -> 44
mjr 35:e959ffba78fd 590 // -_ -> 45
mjr 35:e959ffba78fd 591 // =+ -> 46
mjr 35:e959ffba78fd 592 // [{ -> 47
mjr 35:e959ffba78fd 593 // ]} -> 48
mjr 35:e959ffba78fd 594 // \| -> 49
mjr 35:e959ffba78fd 595 // ;: -> 51
mjr 35:e959ffba78fd 596 // '" -> 52
mjr 35:e959ffba78fd 597 // `~ -> 53
mjr 35:e959ffba78fd 598 // ,< -> 54
mjr 35:e959ffba78fd 599 // .> -> 55
mjr 35:e959ffba78fd 600 // /? -> 56
mjr 35:e959ffba78fd 601 // Caps Lock -> 57
mjr 35:e959ffba78fd 602 // F1-F12 -> 58-69
mjr 35:e959ffba78fd 603 // F13-F24 -> 104-115
mjr 35:e959ffba78fd 604 // Print Screen -> 70
mjr 35:e959ffba78fd 605 // Scroll Lock -> 71
mjr 35:e959ffba78fd 606 // Pause -> 72
mjr 35:e959ffba78fd 607 // Insert -> 73
mjr 35:e959ffba78fd 608 // Home -> 74
mjr 35:e959ffba78fd 609 // Page Up -> 75
mjr 35:e959ffba78fd 610 // Del -> 76
mjr 35:e959ffba78fd 611 // End -> 77
mjr 35:e959ffba78fd 612 // Page Down -> 78
mjr 35:e959ffba78fd 613 // Right Arrow -> 79
mjr 35:e959ffba78fd 614 // Left Arrow -> 80
mjr 35:e959ffba78fd 615 // Down Arrow -> 81
mjr 35:e959ffba78fd 616 // Up Arrow -> 82
mjr 35:e959ffba78fd 617 // Num Lock/Clear -> 83
mjr 35:e959ffba78fd 618 // Keypad / * - + -> 84 85 86 87
mjr 35:e959ffba78fd 619 // Keypad Enter -> 88
mjr 35:e959ffba78fd 620 // Keypad 1-9 -> 89-97
mjr 35:e959ffba78fd 621 // Keypad 0 -> 98
mjr 35:e959ffba78fd 622 // Keypad . -> 99
mjr 35:e959ffba78fd 623 //
mjr 35:e959ffba78fd 624
mjr 35:e959ffba78fd 625
mjr 35:e959ffba78fd 626 // --- USB KEYBOARD MODIFIER KEY CODES ---
mjr 35:e959ffba78fd 627 //
mjr 35:e959ffba78fd 628 // Use these codes for modifier keys in the button mappings
mjr 35:e959ffba78fd 629 //
mjr 35:e959ffba78fd 630 // 0x01 = Left Control
mjr 35:e959ffba78fd 631 // 0x02 = Left Shift
mjr 35:e959ffba78fd 632 // 0x04 = Left Alt
mjr 35:e959ffba78fd 633 // 0x08 = Left GUI ("Windows" key)
mjr 35:e959ffba78fd 634 // 0x10 = Right Control
mjr 35:e959ffba78fd 635 // 0x20 = Right Shift
mjr 35:e959ffba78fd 636 // 0x40 = Right Alt
mjr 35:e959ffba78fd 637 // 0x80 = Right GUI ("Windows" key)
mjr 35:e959ffba78fd 638
mjr 35:e959ffba78fd 639
mjr 35:e959ffba78fd 640 // --- USB KEYBOARD MEDIA KEY CODES ---
mjr 35:e959ffba78fd 641 //
mjr 35:e959ffba78fd 642 // Use these for media control keys in the button mappings
mjr 35:e959ffba78fd 643 //
mjr 35:e959ffba78fd 644 // 0x01 = Volume Up
mjr 35:e959ffba78fd 645 // 0x02 = Volume Down
mjr 35:e959ffba78fd 646 // 0x04 = Mute on/off
mjr 35:e959ffba78fd 647
mjr 38:091e511ce8a0 648
mjr 38:091e511ce8a0 649 // --- SPECIAL BUTTON KEY CODES ---
mjr 38:091e511ce8a0 650 //
mjr 38:091e511ce8a0 651 // Use these for special keys in the button mappings
mjr 38:091e511ce8a0 652 //
mjr 38:091e511ce8a0 653 // 0x01 = Night mode switch, momentary switch mode. Pushing this button
mjr 38:091e511ce8a0 654 // engages night mode, disabling all LedWiz outputs marked with the
mjr 38:091e511ce8a0 655 // "noisemaker" flag. Other outputs are unaffected. Pushing
mjr 38:091e511ce8a0 656 // the button again disengages night mode. Use this option if the
mjr 38:091e511ce8a0 657 // physical button attached to the input is a momentary switch type.
mjr 38:091e511ce8a0 658 //
mjr 38:091e511ce8a0 659 // 0x02 = Night mode switch, toggle switch mode. When this switch is on,
mjr 38:091e511ce8a0 660 // night mode is engaged; when the switch is off, night mode is
mjr 38:091e511ce8a0 661 // disengaged. Use this option if the physical switch attached to
mjr 38:091e511ce8a0 662 // to the input is a toggle switch (not a momentary switch).
mjr 38:091e511ce8a0 663