{"id":354041,"date":"2024-05-20T22:40:27","date_gmt":"2024-05-20T22:40:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354041"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354041","title":{"rendered":"<span>\u0421\u0432\u044f\u0437\u044c electron \u0438 FT2232 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 MAX30102<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u044f \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430 MAX30102 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f FT2232 \u0438 electron.js.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u043e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0430\u0442\u0447\u0438\u043a MAX30102 \u043a \u043f\u043b\u0430\u0442\u0435 FT2232HL, \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b \u0432\u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0432\u043e\u0434\u044b ADBUS1 \u0438 ADBUS2. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 SDA, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u044b DI (\u0432\u0445\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445) \u0438 DO (\u0432\u044b\u0445\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/71e\/43a\/840\/71e43a8408b8e87bd01c1d7b4fed5b6c.jpg\" alt=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MAX30102 \u043a FT2232\" title=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MAX30102 \u043a FT2232\" width=\"873\" height=\"459\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/71e\/43a\/840\/71e43a8408b8e87bd01c1d7b4fed5b6c.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MAX30102 \u043a FT2232<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 i2c. \u041d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443 \u043d\u0435\u0451 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b<\/p>\n<p>\u041a\u043e\u0434 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">const FTDI = require('ftdi-d2xx')  \/\/ \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b const SDA_LO_SCL_LO = 0x00 const SDA_IN_SCL_IN = 0x00 const SDA_IN_SCL_OUT = 0x01 const SDA_OUT_SCL_IN = 0x02 const SDA_OUT_SCL_OUT = 0x03 const MSB_RISING_EDGE_CLOCK_BYTE_IN = 0x20 const MSB_FALLING_EDGE_CLOCK_BYTE_OUT = 0x11 const MSB_RISING_EDGE_CLOCK_BIT_IN = 0x22 const MSB_FALLING_EDGE_CLOCK_BIT_OUT = 0x13  class I2C {     #device = null     #clock_divider = 0x005F     #addr = 0xFF     #buf = []      \/**      * \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0431\u0430\u0439\u0442 \u043f\u0440\u0438\u0435\u043c\u0430 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f      * @param {int} count \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f      * @returns {buffer} \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0435 \u0431\u0430\u0439\u0442\u044b      *\/     async read(count) {         for (let i = 0; i &lt; 1000000; i++) {             if (this.#device.status.rx_queue_bytes == count) {                 break             }         }         return await this.#device.read(this.#device.status.rx_queue_bytes)     }      \/**      * \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0430\u0440\u0442      *\/     setStart() {         \/\/ SDA 1 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_IN_SCL_IN)         }         \/\/ SDA 0 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_IN)         }         \/\/ SDA 0 SCL 0         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_OUT)         }     }      \/**      * \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u043e\u043f      *\/     setStop() {         \/\/ SDA 0 SCL 0         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_OUT)         }         \/\/ SDA 0 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_IN)         }         \/\/ SDA 1 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_IN_SCL_IN)         }     }      \/**      * \u0441\u043e\u0435\u0434\u0435\u043d\u0435\u043d\u0438\u0435 \u0441 \u0447\u0438\u043f\u043e\u043c \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u0448\u0438\u043d\u0435 i2c      * @param {byte} addr \u0430\u0434\u0440\u0435\u0441 i2c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430      * @returns {boolean} \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u043d\u0435\u0442 true      *\/     async open(addr) {         if (this.#device) {             return false         }         this.#device = await FTDI.openDevice(\"A\")         if (!this.#device) {             return false         }         this.#device.resetDevice()         await this.read(this.#device.status.rx_queue_bytes)         this.#device.setLatencyTimer(16)         this.#device.setUSBParameters(65535, 65535)         this.#device.setTimeouts(1000, 1000)         this.#device.setBitMode(0x00, FTDI.FT_BITMODE_RESET)         \/\/ \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u0440\u0435\u0436\u0438\u043c MPSSE         this.#device.setBitMode(0x00, FTDI.FT_BITMODE_MPSSE)         \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 0xAA         await this.#device.write(Uint8Array.from([0xAA]))         let response = await this.read(2)         if (response[0] != 0xFA || response[1] != 0xAA) {             this.close()             return false         }         \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 0xAB         await this.#device.write(Uint8Array.from([0xAB]))         response = await this.read(2)         if (response[0] != 0xFA || response[1] != 0xAB) {             this.close()             return false         }         \/\/ \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u0430\u0437\u044b \u0438 \u043f\u043e\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 SCL         await this.#device.write(Uint8Array.from([0x8A, 0x97, 0x8C]))         \/\/ \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 SCL         await this.#device.write(Uint8Array.from([0x80, 0x03, 0x13, 0x86, (this.#clock_divider &amp; 0xFF), ((this.#clock_divider >> 8) &amp; 0xFF)]))         await this.#device.write(Uint8Array.from([0x85]))         this.#addr = addr         return true     }      \/**      * \u043e\u0442\u0441\u043e\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0442 \u0447\u0438\u043f\u0430      * @returns {boolean} \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u043d\u0435\u0442 true      *\/     close() {         if (this.#device) {             this.#device.close()             this.#device = null             return true         }         return false     }      \/**      * \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043b\u0438\u043d\u0438\u044e i2c \u0431\u0430\u0439\u0442\u0430      * @param {byte} val \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u0430        *\/     writeByte(val) {         this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_OUT_SCL_OUT)          this.#buf.push(MSB_FALLING_EDGE_CLOCK_BYTE_OUT)         this.#buf.push(0x00)         this.#buf.push(0x00)         this.#buf.push(val)          this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_IN_SCL_OUT)          this.#buf.push(MSB_RISING_EDGE_CLOCK_BIT_IN)         this.#buf.push(0x00)          this.#buf.push(0x87)     }      \/**      * \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043b\u0438\u043d\u0438\u0438 i2c \u0431\u0430\u0439\u0442\u0430      * @param {boolean} ask        *\/     readByte(ask = false) {         this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_IN_SCL_OUT)          this.#buf.push(MSB_RISING_EDGE_CLOCK_BYTE_IN)         this.#buf.push(0x00)         this.#buf.push(0x00)          this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_OUT_SCL_OUT)          this.#buf.push(MSB_FALLING_EDGE_CLOCK_BIT_OUT)         this.#buf.push(0x00)         this.#buf.push(ask ? 0x00 : 0xFF)          this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_IN_SCL_OUT)          this.#buf.push(0x87)     }      \/**      * \u0447\u0442\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430      * @param {byte} addr \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430      * @param {int} count \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f      * @returns {array|null} \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442 \u0438\u043b\u0438 null, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438      *\/     async readRegister(addr, count = 1) {         if (!this.#device) {             return null         }         this.#buf = []         this.setStart()         this.writeByte((this.#addr &lt;&lt; 1) | 0)         this.writeByte(addr)         this.setStart()         this.writeByte((this.#addr &lt;&lt; 1) | 1)         for (let i = 0; i &lt; count; i++){             this.readByte(i != count - 1)         }         this.setStop()         await this.#device.write(Uint8Array.from(this.#buf))         let result = [...await this.read(count + 3)]         \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445         if (!result || (result[0] &amp; 1) != 0 || (result[1] &amp; 1) != 0 || (result[2] &amp; 1) != 0) {             return null         }         \/\/ \u043e\u0442\u0441\u0435\u043a\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 writeByte         result.splice(0, 3)         return result     }      \/**      * \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0430\u0439\u0442\u0430 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440      * @param {byte} addr \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430      * @param {byte} val \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438      * @returns {boolean} \u0432\u0435\u0440\u043d\u0435\u0442 true \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438      *\/     async writeRegister(addr, val) {         if (!this.#device) {             return false         }         this.#buf = []         this.setStart()         this.writeByte((this.#addr &lt;&lt; 1) | 0)         this.writeByte(addr)         this.writeByte(val)         this.setStop()         await this.#device.write(Uint8Array.from(this.#buf))         const result = await this.read(3)         \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445         if ((result[0] &amp; 1) != 0 || (result[1] &amp; 1) != 0 || (result[2] &amp; 1) != 0) {             return false         }         return true     }      }  module.exports = I2C<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c MAX30102. \u041e\u043a\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438: \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u0440\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u0412 \u043a\u0430\u0440\u0442\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430, \u0442\u0430\u043a \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0441\u0435\u0439 \u0441\u0432\u044f\u0437\u043a\u0438 \u044f \u0441\u0447\u0438\u0442\u0430\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0xFF (Part ID) \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 21 (0x15), \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u0442\u0430\u0448\u0438\u0442 \u043d\u0430 MAX30102. \u041a\u0430\u043a \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d \u0431\u0443\u0444\u0435\u0440. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">\u0418\u043c\u044f<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">\u0420\u0435\u0433.<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">\u0414\u0435\u0444.<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x02<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">192<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">Mode Configure<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x09<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0438\u043d\u0444\u0440\u0430\u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\"> SpO2 Configuration  <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x0A<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">39<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 SpO2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\"> LED Pulse  Amplitude <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x0C<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">36<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u0435\u043c \u044f\u0440\u0447\u0435 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\"> LED Pulse  Amplitude <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x0D<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">36<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0430 \u0438\u043d\u0444\u0440\u0430\u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u0435\u043c \u044f\u0440\u0447\u0435 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">Proximity Mode  LED Pulse  Amplitude  <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x10<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">127<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u043f\u0440\u0438 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c MAX3102<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">const $ = require(\"jquery\") const I2C = require(\"ftdi-i2c\")  const i2c = new I2C() let x = 0 let run = false let red_avr = 0 let red_n = 0 let red_sr = 0 let ir_avr = 0 let ir_sr = 0  \/**  * \u041e\u043f\u0440\u043e\u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 MAX3102 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439  *\/ setInterval(async () => {     const canvas = document.getElementById(\"canvas\")     const ctx = document.getElementById(\"canvas\").getContext(\"2d\")     if (i2c &amp;&amp; run) {         \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438         const rd = await i2c.readRegister(0x06)         \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0443\u0444\u0435\u0440         const wr = await i2c.readRegister(0x04)         const count = (wr - rd) &amp; 31         if (count > 0) {             const result = await i2c.readRegister(0x07, 6 * count)             for(let i = 0; i &lt; count; i++) {                 let red = (result[i*6] &lt;&lt; 16) | (result[1 + i*6] &lt;&lt; 8) | (result[2 + i*6] &lt;&lt; 0)                 let ir = (result[3 + i*6] &lt;&lt; 16) |(result[4 + i*6] &lt;&lt; 8) | (result[5 + i*6] &lt;&lt; 0)                 red_avr += red                 ir_avr += ir                 red_n++                 ctx.fillStyle = \"#ff2626\"                 \/\/ \u0432\u044b\u0432\u043e\u0434 \u0437\u0435\u043b\u0435\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u043a\u0430\u043d\u0430\u043b IR                 ctx.beginPath()                 ctx.arc(x, (red - red_sr) \/ 50 + canvas.height \/ 2, 1, 0, Math.PI * 2, true)                 ctx.fill()                 \/\/ \u0432\u044b\u0432\u043e\u0434 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u043a\u0430\u043d\u0430\u043b RED                 ctx.fillStyle = \"#26ff26\"                 ctx.beginPath()                 ctx.arc(x, (ir - ir_sr) \/ 50 + canvas.height \/ 2, 1, 0, Math.PI * 2, true)                 ctx.fill()                 if (x++ > canvas.width) {                     red_sr = red_avr \/ red_n                     ir_sr = ir_avr \/ red_n                     red_avr = 0                     red_n = 0                     ir_avr = 0                     x = 0                     ctx.clearRect(0, 0, canvas.width, canvas.height)                 }             }         }     }   }, 200)  \/**  * \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0431\u0438\u0442\u043e\u0432 \u0432 \u0431\u0430\u0439\u0442  *\/ function setByte(self) {     const parent = $(self).parent(\"td\").parent(\"tr\")     let byte = 0     for (let i = 0; i &lt; 8; i++) {         byte |= ((parent.find(\"td:eq(\" + (i + 1) + \")\").find(\"input\").val() || 0) &lt;&lt; (7 - i))     }     parent.find(\"td:eq(10)\").find(\"input\").val(byte) }  \/**  * \u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0431\u0430\u0439\u0442\u0430 \u0432 \u0431\u0438\u0442\u044b  *\/ function setBit(self) {     const parent = $(self).parent(\"td\").parent(\"tr\")     const val = (parent.find(\"td:eq(10)\").find(\"input\").val() || 0x00)     parent.find(\"td:eq(1)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 7) != 0) ? 1 : 0)     parent.find(\"td:eq(2)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 6) != 0) ? 1 : 0)     parent.find(\"td:eq(3)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 5) != 0) ? 1 : 0)     parent.find(\"td:eq(4)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 4) != 0) ? 1 : 0)     parent.find(\"td:eq(5)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 3) != 0) ? 1 : 0)     parent.find(\"td:eq(6)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 2) != 0) ? 1 : 0)     parent.find(\"td:eq(7)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 1) != 0) ? 1 : 0)     parent.find(\"td:eq(8)\").find(\"input\").val(((val &amp; 1 &lt;&lt; 0) != 0) ? 1 : 0) }  $(document).ready(() => {     $(\"#open\").click(async function() {         const is_open = $(this).html() == \"OPEN\"         if (is_open) {             if (await i2c.open(0x57)) {                 $(this).html(\"CLOSE\")             }         } else {             if (await i2c.close()) {                 $(this).html(\"OPEN\")             }         }              })     \/**      * \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440      *\/     $(\"#def\").click(async () => {         run = false         $(\"#run\").html(\"RUN\")         await i2c.writeRegister(0x02, 0xC0)         await i2c.writeRegister(0x03, 0x00)         await i2c.writeRegister(0x04, 0x00)         await i2c.writeRegister(0x05, 0x00)         await i2c.writeRegister(0x06, 0x00)         await i2c.writeRegister(0x08, 0x1f)         await i2c.writeRegister(0x09, 0x03)         await i2c.writeRegister(0x0A, 0x27)         await i2c.writeRegister(0x0C, 0x24)         await i2c.writeRegister(0x0D, 0x24)         await i2c.writeRegister(0x10, 0x7f)     })     \/**      * \u0437\u0430\u043f\u0443\u0441\u043a \u0447\u0442\u0435\u043d\u0438\u044f \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430      *\/     $(\"#run\").click(function() {         if (run) {             run = false             $(this).html(\"RUN\")         } else {             run = true             $(this).html(\"STOP\")         }     })      \/**      * \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\/\u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440(\u0430)      *\/     $(\"button.rw\").on(\"click\", async function () {         run = false         $(\"#run\").html(\"RUN\")         const parent = $(this).parent(\"td\").parent(\"tr\")         const addr = parent.find(\"td:eq(9)\").html().trim()         const is_r = $(this).html().trim() == 'R'         if (is_r) {             const val = await i2c.readRegister(Number(addr))             parent.find(\"td:eq(10)\").find(\"input\").val(val[0])             setBit(this)         } else {             const val = Number(parent.find(\"td:eq(10)\").find(\"input\").val() || 0x00)             await i2c.writeRegister(Number(addr), val)         }     })     $(\"input.byte\").on(\"change\", function() {         setBit(this)     })     $(\"input.byte\").on(\"keyup\", function(e) {         setBit(this)     })     $(\"input.bit\").on(\"change\", function() {         $(this).val($(this).val() == 1 ? 1 : 0)         setByte(this)     })     $(\"input.bit\").on(\"keyup\", function(e) {         if (e.keyCode != 8) {             $(this).val($(this).val() == 1 ? 1 : 0)             setByte(this)         }     }) })<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/09f\/176\/d8e\/09f176d8e25bfb2de77086a0eb591ca0.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" width=\"1481\" height=\"779\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/09f\/176\/d8e\/09f176d8e25bfb2de77086a0eb591ca0.png\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/kr0n4ik\/ftdi-electron\" rel=\"noopener noreferrer nofollow\">ftdi-electron<\/a><\/p>\n<pre><code>cd ftdi-electron npm i npm start<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/motla\/ftdi-d2xx\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ftdi<\/a>, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u0433\u043e \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 ftdi-i2c. \u041f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043b\u0430\u0439\u043a, \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u043e<\/p>\n<p><a href=\"https:\/\/github.com\/kr0n4ik\/ftdi-electron\" rel=\"noopener noreferrer nofollow\">\u041a\u043e\u0434 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a> <\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/759038\/\"> https:\/\/habr.com\/ru\/articles\/759038\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u044f \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430 MAX30102 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f FT2232 \u0438 electron.js.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u043e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0434\u0430\u0442\u0447\u0438\u043a MAX30102 \u043a \u043f\u043b\u0430\u0442\u0435 FT2232HL, \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b \u0432\u043c\u0435\u0441\u0442\u0435 \u0432\u044b\u0432\u043e\u0434\u044b ADBUS1 \u0438 ADBUS2. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 SDA, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u044b DI (\u0432\u0445\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445) \u0438 DO (\u0432\u044b\u0445\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 MAX30102 \u043a FT2232<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 i2c. \u041d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443 \u043d\u0435\u0451 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b<\/p>\n<p>\u041a\u043e\u0434 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">const FTDI = require('ftdi-d2xx')  \/\/ \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b const SDA_LO_SCL_LO = 0x00 const SDA_IN_SCL_IN = 0x00 const SDA_IN_SCL_OUT = 0x01 const SDA_OUT_SCL_IN = 0x02 const SDA_OUT_SCL_OUT = 0x03 const MSB_RISING_EDGE_CLOCK_BYTE_IN = 0x20 const MSB_FALLING_EDGE_CLOCK_BYTE_OUT = 0x11 const MSB_RISING_EDGE_CLOCK_BIT_IN = 0x22 const MSB_FALLING_EDGE_CLOCK_BIT_OUT = 0x13  class I2C {     #device = null     #clock_divider = 0x005F     #addr = 0xFF     #buf = []      \/**      * \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0431\u0430\u0439\u0442 \u043f\u0440\u0438\u0435\u043c\u0430 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f      * @param {int} count \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f      * @returns {buffer} \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0435 \u0431\u0430\u0439\u0442\u044b      *\/     async read(count) {         for (let i = 0; i &lt; 1000000; i++) {             if (this.#device.status.rx_queue_bytes == count) {                 break             }         }         return await this.#device.read(this.#device.status.rx_queue_bytes)     }      \/**      * \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0430\u0440\u0442      *\/     setStart() {         \/\/ SDA 1 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_IN_SCL_IN)         }         \/\/ SDA 0 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_IN)         }         \/\/ SDA 0 SCL 0         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_OUT)         }     }      \/**      * \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u043e\u043f      *\/     setStop() {         \/\/ SDA 0 SCL 0         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_OUT)         }         \/\/ SDA 0 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_OUT_SCL_IN)         }         \/\/ SDA 1 SCL 1         for (let i = 0; i &lt; 6; i++) {             this.#buf.push(0x80)             this.#buf.push(SDA_LO_SCL_LO)             this.#buf.push(SDA_IN_SCL_IN)         }     }      \/**      * \u0441\u043e\u0435\u0434\u0435\u043d\u0435\u043d\u0438\u0435 \u0441 \u0447\u0438\u043f\u043e\u043c \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u0448\u0438\u043d\u0435 i2c      * @param {byte} addr \u0430\u0434\u0440\u0435\u0441 i2c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430      * @returns {boolean} \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u043d\u0435\u0442 true      *\/     async open(addr) {         if (this.#device) {             return false         }         this.#device = await FTDI.openDevice(\"A\")         if (!this.#device) {             return false         }         this.#device.resetDevice()         await this.read(this.#device.status.rx_queue_bytes)         this.#device.setLatencyTimer(16)         this.#device.setUSBParameters(65535, 65535)         this.#device.setTimeouts(1000, 1000)         this.#device.setBitMode(0x00, FTDI.FT_BITMODE_RESET)         \/\/ \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u0440\u0435\u0436\u0438\u043c MPSSE         this.#device.setBitMode(0x00, FTDI.FT_BITMODE_MPSSE)         \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 0xAA         await this.#device.write(Uint8Array.from([0xAA]))         let response = await this.read(2)         if (response[0] != 0xFA || response[1] != 0xAA) {             this.close()             return false         }         \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430 0xAB         await this.#device.write(Uint8Array.from([0xAB]))         response = await this.read(2)         if (response[0] != 0xFA || response[1] != 0xAB) {             this.close()             return false         }         \/\/ \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u0430\u0437\u044b \u0438 \u043f\u043e\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 SCL         await this.#device.write(Uint8Array.from([0x8A, 0x97, 0x8C]))         \/\/ \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u0445 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043e\u0432 SCL         await this.#device.write(Uint8Array.from([0x80, 0x03, 0x13, 0x86, (this.#clock_divider &amp; 0xFF), ((this.#clock_divider >> 8) &amp; 0xFF)]))         await this.#device.write(Uint8Array.from([0x85]))         this.#addr = addr         return true     }      \/**      * \u043e\u0442\u0441\u043e\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0442 \u0447\u0438\u043f\u0430      * @returns {boolean} \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u0440\u043d\u0435\u0442 true      *\/     close() {         if (this.#device) {             this.#device.close()             this.#device = null             return true         }         return false     }      \/**      * \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043b\u0438\u043d\u0438\u044e i2c \u0431\u0430\u0439\u0442\u0430      * @param {byte} val \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u0430        *\/     writeByte(val) {         this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_OUT_SCL_OUT)          this.#buf.push(MSB_FALLING_EDGE_CLOCK_BYTE_OUT)         this.#buf.push(0x00)         this.#buf.push(0x00)         this.#buf.push(val)          this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_IN_SCL_OUT)          this.#buf.push(MSB_RISING_EDGE_CLOCK_BIT_IN)         this.#buf.push(0x00)          this.#buf.push(0x87)     }      \/**      * \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043b\u0438\u043d\u0438\u0438 i2c \u0431\u0430\u0439\u0442\u0430      * @param {boolean} ask        *\/     readByte(ask = false) {         this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_IN_SCL_OUT)          this.#buf.push(MSB_RISING_EDGE_CLOCK_BYTE_IN)         this.#buf.push(0x00)         this.#buf.push(0x00)          this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_OUT_SCL_OUT)          this.#buf.push(MSB_FALLING_EDGE_CLOCK_BIT_OUT)         this.#buf.push(0x00)         this.#buf.push(ask ? 0x00 : 0xFF)          this.#buf.push(0x80)         this.#buf.push(SDA_LO_SCL_LO)         this.#buf.push(SDA_IN_SCL_OUT)          this.#buf.push(0x87)     }      \/**      * \u0447\u0442\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430      * @param {byte} addr \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430      * @param {int} count \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f      * @returns {array|null} \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442 \u0438\u043b\u0438 null, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u0438      *\/     async readRegister(addr, count = 1) {         if (!this.#device) {             return null         }         this.#buf = []         this.setStart()         this.writeByte((this.#addr &lt;&lt; 1) | 0)         this.writeByte(addr)         this.setStart()         this.writeByte((this.#addr &lt;&lt; 1) | 1)         for (let i = 0; i &lt; count; i++){             this.readByte(i != count - 1)         }         this.setStop()         await this.#device.write(Uint8Array.from(this.#buf))         let result = [...await this.read(count + 3)]         \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445         if (!result || (result[0] &amp; 1) != 0 || (result[1] &amp; 1) != 0 || (result[2] &amp; 1) != 0) {             return null         }         \/\/ \u043e\u0442\u0441\u0435\u043a\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 writeByte         result.splice(0, 3)         return result     }      \/**      * \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0430\u0439\u0442\u0430 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440      * @param {byte} addr \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430      * @param {byte} val \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438      * @returns {boolean} \u0432\u0435\u0440\u043d\u0435\u0442 true \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438      *\/     async writeRegister(addr, val) {         if (!this.#device) {             return false         }         this.#buf = []         this.setStart()         this.writeByte((this.#addr &lt;&lt; 1) | 0)         this.writeByte(addr)         this.writeByte(val)         this.setStop()         await this.#device.write(Uint8Array.from(this.#buf))         const result = await this.read(3)         \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445         if ((result[0] &amp; 1) != 0 || (result[1] &amp; 1) != 0 || (result[2] &amp; 1) != 0) {             return false         }         return true     }      }  module.exports = I2C<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u043f\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c MAX30102. \u041e\u043a\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438: \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u0440\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432, \u0432 \u043b\u0435\u0432\u043e\u0439 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u0412 \u043a\u0430\u0440\u0442\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043a\u0430\u043a \u0446\u0435\u043b\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u0430, \u0442\u0430\u043a \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0441\u0435\u0439 \u0441\u0432\u044f\u0437\u043a\u0438 \u044f \u0441\u0447\u0438\u0442\u0430\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0xFF (Part ID) \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 21 (0x15), \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u0441\u044f \u0441\u0432\u044f\u0437\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u0442\u0430\u0448\u0438\u0442 \u043d\u0430 MAX30102. \u041a\u0430\u043a \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d \u0431\u0443\u0444\u0435\u0440. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">\u0418\u043c\u044f<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">\u0420\u0435\u0433.<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">\u0414\u0435\u0444.<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x02<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">192<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">Mode Configure<\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x09<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0420\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0438\u043d\u0444\u0440\u0430\u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\"> SpO2 Configuration  <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x0A<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">39<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 SpO2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\"> LED Pulse  Amplitude <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x0C<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">36<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u0435\u043c \u044f\u0440\u0447\u0435 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\"> LED Pulse  Amplitude <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x0D<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">36<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0410\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0430 \u0438\u043d\u0444\u0440\u0430\u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u0435\u043c \u044f\u0440\u0447\u0435 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"142\" width=\"142\">\n<p align=\"left\">Proximity Mode  LED Pulse  Amplitude  <\/p>\n<\/td>\n<td data-colwidth=\"55\" width=\"55\">\n<p align=\"left\">0x10<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">127<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u043f\u0440\u0438 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c MAX3102<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">const $ = require(\"jquery\") const I2C = require(\"ftdi-i2c\")  const i2c = new I2C() let x = 0 let run = false let red_avr = 0 let red_n = 0 let red_sr = 0 let ir_avr = 0 let ir_sr = 0  \/**  * \u041e\u043f\u0440\u043e\u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 MAX3102 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439  *\/ setInterval(async () => {     const canvas = document.getElementById(\"canvas\")     const ctx = document.getElementById(\"canvas\").getContext(\"2d\")     if (i2c &amp;&amp; run) {         \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438         const rd = await i2c.readRegister(0x06)         \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u0443\u0444\u0435\u0440         const wr = await i2c.readRegister(0x04)         const count = (wr - rd) &amp; 31         if (count > 0) {             const result = await i2c.readRegister(0x07, 6 * count)             for(let i = 0; i &lt; count; i++) {                 let red = (result[i*6] &lt;&lt; 16) | (result[1 + i*6] &lt;&lt; 8) | (result[2 + i*6] &lt;&lt; 0)                 let ir = (result[3 + i*6] &lt;&lt; 16) |(result[4 + i*6] &lt;&lt; 8) | (result[5 + i*6] &lt;&lt; 0)                 red_avr += red                 ir_avr += ir                 red_n++<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-354041","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=354041"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354041\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}