@johnnycubides/micropython-esp32-plugin-catalejo-editor 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/micropython-esp32/README.md +3 -0
- package/micropython-esp32/commands.d.ts +3 -3
- package/micropython-esp32/esp32-libs/esp32-c3-mini/boot.py +14 -0
- package/micropython-esp32/esp32-libs/esp32-c3-mini/webrepl_cfg.py +1 -0
- package/micropython-esp32/esp32-libs/esp32-c3-mini/wifi.py +135 -0
- package/micropython-esp32/esp32-libs/esp32-c3-mini/wifi_config.py +11 -0
- package/micropython-esp32/esp32-libs/esp32-c3-oled-mini/boot.py +14 -0
- package/micropython-esp32/esp32-libs/esp32-c3-oled-mini/display.py +67 -0
- package/micropython-esp32/esp32-libs/esp32-c3-oled-mini/ssd1306.py +164 -0
- package/micropython-esp32/esp32-libs/esp32-c3-oled-mini/webrepl_cfg.py +1 -0
- package/micropython-esp32/esp32-libs/esp32-c3-oled-mini/wifi.py +135 -0
- package/micropython-esp32/esp32-libs/esp32-c3-oled-mini/wifi_config.py +11 -0
- package/micropython-esp32/esp32-libs/esp32-s3-zero/boot.py +14 -0
- package/micropython-esp32/esp32-libs/esp32-s3-zero/webrepl_cfg.py +1 -0
- package/micropython-esp32/esp32-libs/esp32-s3-zero/wifi.py +135 -0
- package/micropython-esp32/esp32-libs/esp32-s3-zero/wifi_config.py +11 -0
- package/micropython-esp32/esp32-libs/esp32-wroom-devkit/boot.py +14 -0
- package/micropython-esp32/esp32-libs/esp32-wroom-devkit/webrepl_cfg.py +1 -0
- package/micropython-esp32/esp32-libs/esp32-wroom-devkit/wifi.py +135 -0
- package/micropython-esp32/esp32-libs/esp32-wroom-devkit/wifi_config.py +11 -0
- package/micropython-esp32/lang.d.ts +60 -1
- package/micropython-esp32/micropython.es.js +330 -178
- package/micropython-esp32/micropython.umd.js +14 -14
- package/micropython-esp32/plugin.json +1 -1
- package/micropython-esp32/upy-websockect.d.ts +30 -2
- package/package.json +1 -1
- package/micropython-esp32/esp32-libs/boot.py +0 -13
- package/micropython-esp32/esp32-libs/wifi.py +0 -77
- package/micropython-esp32/esp32-libs/wifi_config_esp32c3mini.py +0 -14
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(r=typeof globalThis<"u"?globalThis:r||self,p(r.micropython={}))})(this,function(r){"use strict";var Fe=Object.defineProperty;var Te=(r,p,f)=>p in r?Fe(r,p,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[p]=f;var g=(r,p,f)=>Te(r,typeof p!="symbol"?p+"":p,f);const p="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20fill='%23000000'%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M24,12A12,12,0,0,1,0,12a1,1,0,0,1,2,0A10,10,0,1,0,12,2a1,1,0,0,1,0-2A12.013,12.013,0,0,1,24,12ZM10.277,11H8a1,1,0,0,0,0,2h2.277A1.994,1.994,0,1,0,13,10.277V7a1,1,0,0,0-2,0v3.277A2,2,0,0,0,10.277,11ZM1.827,8.784a1,1,0,1,0-1-1A1,1,0,0,0,1.827,8.784ZM4.221,5.207a1,1,0,1,0-1-1A1,1,0,0,0,4.221,5.207ZM7.779,2.841a1,1,0,1,0-1-1A1,1,0,0,0,7.779,2.841Z'/%3e%3c/svg%3e";function f(e,t){e.Blocks.mpy_sleep_s={init:function(){this.appendValueInput("time").setCheck("Number").appendField(new e.FieldImage(p,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Esperar").appendField(new e.FieldDropdown([["segundos","sec"],["milisegundos","ms"],["microsegundos","us"]]),"scale"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(65),this.setTooltip("Se indica el tiempo que la CPU tendrá que esperar antes de hacer la siguiente instrucción."),this.setHelpUrl("")}},t.mpy_sleep_s=function(i){var n=t.valueToCode(i,"time",t.ORDER_ATOMIC),a=i.getFieldValue("scale");t.definitions_.import_time||(t.definitions_.import_time="import time");var o=`...
|
|
2
2
|
`;return a=="sec"?o="time.sleep("+n+`)
|
|
3
3
|
`:a=="ms"?o="time.sleep_ms("+n+`)
|
|
4
4
|
`:a=="us"&&(o="time.sleep_us("+n+`)
|
|
5
|
-
`),o}}const
|
|
6
|
-
`;return
|
|
7
|
-
`;return o}}const
|
|
8
|
-
`;return o},e.Blocks.adc_minimal_read={init:function(){this.appendDummyInput().appendField(new e.FieldImage(
|
|
9
|
-
`;return o},e.Blocks.pwm_init_deinit={init:function(){this.appendDummyInput().appendField(new e.FieldImage(
|
|
10
|
-
`;return o},e.Blocks.pwm_method_freq_duty={init:function(){this.appendValueInput("argument_funtion").setCheck("Number").appendField(new e.FieldImage(
|
|
11
|
-
`;return
|
|
12
|
-
`;return
|
|
13
|
-
`;return a},e.Blocks.dht_read={init:function(){this.appendDummyInput().appendField(new e.FieldImage(
|
|
14
|
-
`;return[o,t.ORDER_NONE]}}function
|
|
5
|
+
`),o}}const k="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20fill='%23000000'%20height='800px'%20width='800px'%20version='1.1'%20id='Capa_1'%20viewBox='0%200%20287.542%20287.542'%20xml:space='preserve'%20sodipodi:docname='plug-svgrepo-com.svg'%20inkscape:version='1.2.2%20(b0a8486541,%202022-12-01)'%20xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'%20xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:svg='http://www.w3.org/2000/svg'%3e%3cdefs%20id='defs7'%20/%3e%3csodipodi:namedview%20id='namedview5'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20showgrid='false'%20inkscape:zoom='0.295'%20inkscape:cx='400'%20inkscape:cy='401.69492'%20inkscape:window-width='1918'%20inkscape:window-height='1150'%20inkscape:window-x='1440'%20inkscape:window-y='24'%20inkscape:window-maximized='1'%20inkscape:current-layer='Capa_1'%20/%3e%3cpath%20d='M258.47,8v14.399c0,1.989-0.602,3.896-2.008,5.304l-70.586,70.691l3.675,3.633c2.813,2.813,4.414,6.628,4.414,10.606%20s-1.57,7.794-4.383,10.606l-54.715,54.72c-2.929,2.929-6.766,4.394-10.604,4.394c-2.708,0-5.408-0.744-7.797-2.202l-34.963,34.964%20c-2.929,2.929-6.767,4.394-10.606,4.394s-7.678-1.465-10.606-4.394l-1.707-1.708l-5.378,5.378%20c-5.89,5.889-9.133,13.718-9.133,22.046s3.243,16.158,9.133,22.047l0.553,0.553c12.155,12.157,31.935,12.157,44.094,0l71.408-71.41%20c18.007-18.004,47.303-18.004,65.308,0l19.861,19.861c2.929,2.93,2.929,7.678,0,10.607c-2.93,2.928-7.678,2.928-10.607,0%20l-19.861-19.861c-12.156-12.157-31.936-12.157-44.094,0l-71.408,71.41c-9.002,9.001-20.83,13.502-32.654,13.503%20c-11.827,0.001-23.649-4.5-32.653-13.503l-0.553-0.553c-8.722-8.723-13.525-20.319-13.525-32.654s4.804-23.932,13.526-32.653%20l5.378-5.378l-4.574-4.574c-5.858-5.857-5.858-15.356,0-21.214l34.964-34.965c-3.524-5.774-2.804-13.412,2.192-18.407l54.72-54.726%20c2.813-2.813,6.628-4.404,10.606-4.404s7.794,1.558,10.606,4.372l4.309,4.265L231.49,2.369C232.897,0.963,234.805,0,236.794,0%20h14.399c1.997,0,3.9,0.97,5.308,2.386l-0.024,0.327C257.874,4.118,258.47,6.019,258.47,8z'%20id='path2'%20style='fill:%23ffffff;stroke:%23000000'%20/%3e%3c/svg%3e";function X(e,t){e.Blocks.mpy_esp32_pin_mode_explicit={init:function(){this.appendValueInput("pin_number").setCheck("Number").setAlign(e.ALIGN_CENTRE).appendField(new e.FieldImage(k,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Crear GPIO").appendField(new e.FieldVariable("item"),"name").appendField(", Modo:").appendField(new e.FieldDropdown([["Entrada","Pin.IN"],["Salida","Pin.OUT"],["Análogo","Pin.ANALOG"]]),"pin_mode").appendField("Pin:"),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(210),this.setTooltip('Crear un GPIO, remplazar "item" por el nombre que le dese poner, ejemplo LED, botón, etc. Selecciona el modo del pin. Si selecciona Entrada, el pin se comportará como una entra digital, Salida, salida Digital, Analog, como pin Analógico'),this.setHelpUrl("")}},t.mpy_esp32_pin_mode_explicit=function(i){var n=t.nameDB_.getName(i.getFieldValue("name"),e.Variables.CATEGORY_NAME),a=i.getFieldValue("pin_mode"),o=t.valueToCode(i,"pin_number",t.ORDER_ATOMIC);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin");var l=n+" = Pin("+o+", "+a+`)
|
|
6
|
+
`;return l},e.Blocks.mpy_esp32_pin_mode={init:function(){this.appendValueInput("pin_number").setCheck("Number").setAlign(e.ALIGN_CENTRE).appendField(new e.FieldImage(k,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Modo:").appendField(new e.FieldDropdown([["Entrada","Pin.IN"],["Salida","Pin.OUT"],["Análogo","Pin.ANALOG"]]),"pin_mode").appendField("Pin:"),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(210),this.setTooltip("Selecciona el modo del pin. Si selecciona Entrada, el pin se comportará como una entra digital, Salida, salida Digital, Analog, como pin Analógico"),this.setHelpUrl("")}},t.mpy_esp32_pin_mode=function(i){var n=i.getFieldValue("pin_mode"),a=t.valueToCode(i,"pin_number",t.ORDER_ATOMIC);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin");var o="Pin("+a+", "+n+")";return[o,t.ORDER_NONE]},e.Blocks.mpy_esp32_pin_read={init:function(){this.appendDummyInput().setAlign(e.ALIGN_CENTRE).appendField(new e.FieldImage(k,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Leer 0/1").appendField(new e.FieldVariable("item"),"pin_var"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(210),this.setTooltip("Lee el valor del pin digital, lo cual devuelve como resultado un 1 o 0 lógico"),this.setHelpUrl("")}},t.mpy_esp32_pin_read=function(i){var n=t.nameDB_.getName(i.getFieldValue("pin_var"),e.Variables.CATEGORY_NAME);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin");var a=n+".value()";return[a,t.ORDER_NONE]},e.Blocks.mpy_esp32_pin_write={init:function(){this.appendValueInput("pin_value").setCheck("Number").appendField(new e.FieldImage(k,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Escribir").appendField(new e.FieldVariable("item"),"pin_var").appendField("a 0/1"),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(210),this.setTooltip("Escribir el valor de salida de un pin, los valores posibles son 1 o 0 lógico"),this.setHelpUrl("")}},t.mpy_esp32_pin_write=function(i){var n=t.nameDB_.getName(i.getFieldValue("pin_var"),e.Variables.CATEGORY_NAME),a=t.valueToCode(i,"pin_value",t.ORDER_ATOMIC);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin");var o=n+".value("+a+`)
|
|
7
|
+
`;return o}}const y="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Created%20with%20Inkscape%20(http://www.inkscape.org/)%20--%3e%3csvg%20width='80mm'%20height='80mm'%20viewBox='0%200%2080%2080'%20version='1.1'%20id='svg5'%20sodipodi:docname='adc.svg'%20inkscape:version='1.2.2%20(b0a8486541,%202022-12-01)'%20xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'%20xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:svg='http://www.w3.org/2000/svg'%3e%3csodipodi:namedview%20id='namedview7'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20inkscape:document-units='mm'%20showgrid='true'%20inkscape:zoom='2.8284272'%20inkscape:cx='118.97071'%20inkscape:cy='143.01234'%20inkscape:window-width='1918'%20inkscape:window-height='1150'%20inkscape:window-x='1440'%20inkscape:window-y='24'%20inkscape:window-maximized='1'%20inkscape:current-layer='layer1'%3e%3cinkscape:grid%20type='xygrid'%20id='grid483'%20/%3e%3c/sodipodi:namedview%3e%3cdefs%20id='defs2'%20/%3e%3cg%20inkscape:label='Layer%201'%20inkscape:groupmode='layer'%20id='layer1'%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:10;stroke-dasharray:none'%20d='M%207.9185622,40.195018%20C%2017.631127,10.282868%2027.506005,-14.748985%2041.621293,39.908944%2061.152028,102.40339%2066.055646,62.159434%2073.289058,40.202455'%20id='path113'%20sodipodi:nodetypes='ccc'%20/%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:5;stroke-dasharray:20,5;stroke-dashoffset:0'%20d='M%201.2772021,39.941328%2079.018925,39.898992'%20id='path1020'%20/%3e%3cpath%20style='fill:none;stroke:%23000000;stroke-width:5;stroke-dasharray:20,5;stroke-dashoffset:0'%20d='M%203.8172185,1.6052225%203.8928693,78.585751'%20id='path1057'%20/%3e%3c/g%3e%3c/svg%3e";function G(e,t){e.Blocks.adc_minimal_class={init:function(){this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(y,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Crear ADC, Pin:"),this.setOutput(!0,null),this.setColour(120),this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC. Los valores de entrada de voltaje están en el rango de 0 voltios a 3 voltios"),this.setHelpUrl("")}},t.adc_minimal_class=function(i){var n=t.valueToCode(i,"id_pin",t.ORDER_ATOMIC);t.definitions_.machine_import_adc||(t.definitions_.machine_import_adc="from machine import ADC");var a="ADC("+n+", atten = ADC.ATTN_11DB)";return[a,t.ORDER_NONE]},e.Blocks.adc_minimal_class_explicit={init:function(){this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(y,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Crear ADC:").appendField(new e.FieldVariable("item"),"name").appendField(", Pin:"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(120),this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC. Los valores de entrada de voltaje están en el rango de 0 voltios a 3 voltios"),this.setHelpUrl("")}},t.adc_minimal_class_explicit=function(i){var n=t.nameDB_.getName(i.getFieldValue("name"),e.Variables.CATEGORY_NAME),a=t.valueToCode(i,"id_pin",t.ORDER_ATOMIC);t.definitions_.machine_import_adc||(t.definitions_.machine_import_adc="from machine import ADC");var o=n+"= ADC("+a+`, atten = ADC.ATTN_11DB)
|
|
8
|
+
`;return o},e.Blocks.adc_minimal_read={init:function(){this.appendDummyInput().appendField(new e.FieldImage(y,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Leer ADC, en:").appendField(new e.FieldVariable("item"),"adc_obj"),this.setInputsInline(!1),this.setOutput(!0,"Number"),this.setColour(120),this.setTooltip("Convierte un valor de voltaje entre [0, 3] a [0, 4095] unidades enteras (12bits), debe seleccionar la variable que representa el pin del canal ADC."),this.setHelpUrl("")}},t.adc_minimal_read=function(i){var n=t.nameDB_.getName(i.getFieldValue("adc_obj"),e.Variables.CATEGORY_NAME);t.definitions_.machine_import_adc||(t.definitions_.machine_import_adc="from machine import ADC");var a=n+".read()";return[a,t.ORDER_NONE]},e.Blocks.adc_atten_class={init:function(){this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(y,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Crear ADC, atenuación:").appendField(new e.FieldDropdown([["0dB","ADC.ATTN_0DB"],["2.5dB","ADC.ATTN_2_5DB"],["6dB","ADC.ATTN_6DB"],["11dB","ADC.ATTN_11DB"]]),"atten").appendField(", Pin:"),this.setOutput(!0,"Number"),this.setColour(120),this.setTooltip("Crear canal del conversor ADC, se debe seleccionar un id pin con esta caracteristica del driver ADC, se puede seleccionar diferentes atenuaciones; 0dB -> (100mV - 950mV), 2.5dB -> (100mV - 1250 mV), 6dB -> (150mV - 1750 mV), 11dB -> (150mV - 2450mV)."),this.setHelpUrl("")}},t.adc_atten_class=function(i){var n=i.getFieldValue("atten"),a=t.valueToCode(i,"id_pin",t.ORDER_ATOMIC);t.definitions_.machine_import_adc||(t.definitions_.machine_import_adc="from machine import ADC");var o="ADC("+a+", atten = "+n+")";return[o,t.ORDER_NONE]},e.Blocks.adc_resolution_select_read={init:function(){this.appendDummyInput().appendField(new e.FieldImage(y,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Leer ADC en").appendField(new e.FieldVariable("item"),"adc_obj").appendField(", resolución").appendField(new e.FieldDropdown([["12bits","read()"],["16bits","read_u16()"],["microvoltios","read_uv()"]]),"resolution"),this.setInputsInline(!1),this.setOutput(!0,"Number"),this.setColour(120),this.setTooltip("Convierte un valor de voltaje a unidades (ADC). Se debe seleccionar la resolución: 12bits -> (0, 4095), 16 bits -> (0, 65535), microvoltios. debe seleccionar la variable que representa el pin del canal de ADC."),this.setHelpUrl("")}},t.adc_resolution_select_read=function(i){var n=t.nameDB_.getName(i.getFieldValue("adc_obj"),e.Variables.CATEGORY_NAME),a=i.getFieldValue("resolution");t.definitions_.machine_import_adc||(t.definitions_.machine_import_adc="from machine import ADC");var o=n+"."+a;return[o,t.ORDER_NONE]}}const T="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Created%20with%20Inkscape%20(http://www.inkscape.org/)%20--%3e%3csvg%20width='80mm'%20height='80mm'%20viewBox='0%200%2080%2080'%20version='1.1'%20id='svg5'%20inkscape:version='1.2.2%20(b0a8486541,%202022-12-01)'%20sodipodi:docname='pwm.svg'%20xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'%20xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:svg='http://www.w3.org/2000/svg'%3e%3csodipodi:namedview%20id='namedview7'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20inkscape:document-units='mm'%20showgrid='true'%20inkscape:zoom='3.8397656'%20inkscape:cx='148.57678'%20inkscape:cy='153.26456'%20inkscape:window-width='2256'%20inkscape:window-height='1427'%20inkscape:window-x='0'%20inkscape:window-y='0'%20inkscape:window-maximized='1'%20inkscape:current-layer='layer1'%3e%3cinkscape:grid%20type='xygrid'%20id='grid1775'%20/%3e%3c/sodipodi:namedview%3e%3cdefs%20id='defs2'%20/%3e%3cg%20inkscape:label='Layer%201'%20inkscape:groupmode='layer'%20id='layer1'%3e%3cpath%20style='fill:none;stroke:%23ffffff;stroke-width:8;stroke-dasharray:none'%20d='M%201.4053079,71.498438%20H%2010.778154%20V%206.763835%20l%2025.032301,0%200.05922,64.481587%2042.339307,0'%20id='path5532'%20sodipodi:nodetypes='cccccc'%20/%3e%3c/g%3e%3c/svg%3e";function K(e,t){e.Blocks.pwm_minimal_class={init:function(){this.appendValueInput("pin_id").setCheck(null).appendField(new e.FieldImage(T,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Crear PWM:").appendField(new e.FieldVariable("item"),"name").appendField(", Pin:"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(290),this.setTooltip("Crear un modulador de ancho de pulso (PWM), con frequecia=1000Hz, Ciclo útil Duty=512 (50%)."),this.setHelpUrl("")}},t.pwm_minimal_class=function(i){var n=t.nameDB_.getName(i.getFieldValue("name"),e.Variables.CATEGORY_NAME),a=t.valueToCode(i,"pin_id",t.ORDER_ATOMIC),a=t.valueToCode(i,"pin_id",t.ORDER_ATOMIC);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin"),t.definitions_.machine_import_pwm||(t.definitions_.machine_import_pwm="from machine import PWM");var o=n+" = PWM(Pin("+a+`), freq=1000, duty=512)
|
|
9
|
+
`;return o},e.Blocks.pwm_init_deinit={init:function(){this.appendDummyInput().appendField(new e.FieldImage(T,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("PWM").appendField(new e.FieldVariable("item"),"pwm").appendField(new e.FieldDropdown([["start","init()"],["stop","deinit()"]]),"start_stop"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(290),this.setTooltip("Iniciar o detener un PWM"),this.setHelpUrl("")}},t.pwm_init_deinit=function(i){var n=t.nameDB_.getName(i.getFieldValue("pwm"),e.Variables.CATEGORY_NAME),a=i.getFieldValue("start_stop");t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin"),t.definitions_.machine_import_pwm||(t.definitions_.machine_import_pwm="from machine import PWM");var o=n+"."+a+`
|
|
10
|
+
`;return o},e.Blocks.pwm_method_freq_duty={init:function(){this.appendValueInput("argument_funtion").setCheck("Number").appendField(new e.FieldImage(T,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("PWM").appendField(new e.FieldVariable("item"),"pwm").appendField(new e.FieldDropdown([["frecuencia","freq"],["ciclo 10bits","duty"],["ciclo 16bits","duty_u16"],["ciclo ns","duty_ns"]]),"freq_duty"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(290),this.setTooltip("Configurar PWM, frecuencia (1 Hz - 40MHz), ciclo útil 10bits (0 - 1023), ciclo útil de 16 bits (0 - 65535) y ciclo útil ns (nano segundos)."),this.setHelpUrl("")}},t.pwm_method_freq_duty=function(i){var n=t.nameDB_.getName(i.getFieldValue("pwm"),e.Variables.CATEGORY_NAME),a=i.getFieldValue("freq_duty"),o=t.valueToCode(i,"argument_funtion",t.ORDER_ATOMIC);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin"),t.definitions_.machine_import_pwm||(t.definitions_.machine_import_pwm="from machine import PWM");var l=n+"."+a+"("+o+`)
|
|
11
|
+
`;return l}}const C="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20version='1.1'%20id='svg4'%20sodipodi:docname='temperature-low-svgrepo-com-light.svg'%20inkscape:version='1.2.2%20(b0a8486541,%202022-12-01)'%20xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape'%20xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:svg='http://www.w3.org/2000/svg'%3e%3cdefs%20id='defs8'%20/%3e%3csodipodi:namedview%20id='namedview6'%20pagecolor='%23ffffff'%20bordercolor='%23000000'%20borderopacity='0.25'%20inkscape:showpageshadow='2'%20inkscape:pageopacity='0.0'%20inkscape:pagecheckerboard='0'%20inkscape:deskcolor='%23d1d1d1'%20showgrid='false'%20inkscape:zoom='0.295'%20inkscape:cx='150.84746'%20inkscape:cy='405.08475'%20inkscape:window-width='1918'%20inkscape:window-height='1150'%20inkscape:window-x='1440'%20inkscape:window-y='24'%20inkscape:window-maximized='1'%20inkscape:current-layer='svg4'%20/%3e%3cpath%20d='M8%2015.9998C7.44772%2015.9998%207%2016.4475%207%2016.9998C7%2017.5521%207.44772%2017.9998%208%2017.9998C8.55228%2017.9998%209%2017.5521%209%2016.9998C9%2016.4475%208.55228%2015.9998%208%2015.9998ZM8%2015.9998L8.00707%2012M8%2016.9998L8.00707%2017.0069M20%205C20%206.10457%2019.1046%207%2018%207C16.8954%207%2016%206.10457%2016%205C16%203.89543%2016.8954%203%2018%203C19.1046%203%2020%203.89543%2020%205ZM12%2016.9998C12%2019.209%2010.2091%2020.9998%208%2020.9998C5.79086%2020.9998%204%2019.209%204%2016.9998C4%2015.9854%204.37764%2015.0591%205%2014.354L5%206C5%204.34315%206.34315%203%208%203C9.65685%203%2011%204.34315%2011%206V14.354C11.6224%2015.0591%2012%2015.9854%2012%2016.9998Z'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20id='path2'%20style='fill:none;stroke:%23ffffff'%20/%3e%3c/svg%3e";function z(e,t){e.Blocks.dht_init={init:function(){this.appendValueInput("pin").setCheck("Number").appendField(new e.FieldImage(C,15,15,{alt:"*",flipRtl:"FALSE"})).appendField("Crear").appendField(new e.FieldDropdown([["DHT11","DHT11"],["DHT22","DHT22"]]),"dht_option").appendField(new e.FieldVariable("variable"),"sensor").appendField("Pin:"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(195),this.setTooltip("Instanciar un sensor DHT (Sensor de humedad y temperatura digital), puede seleccionar un DHT11 o DHT22, ambos tienen diferentes características de precisión. Escoja el nombre de la variable que representará al sensor, finalmente, indique el Pin por el cual se leerá el sensor."),this.setHelpUrl("")}},t.dht_init=function(i){var n=i.getFieldValue("dht_option"),a=t.nameDB_.getName(i.getFieldValue("sensor"),e.Variables.CATEGORY_NAME),o=t.valueToCode(i,"pin",t.ORDER_ATOMIC);t.definitions_.machine_import_pin||(t.definitions_.machine_import_pin="from machine import Pin"),n=="DHT11"?t.definitions_.machine_import_dht11||(t.definitions_.machine_import_dht11="from dht import DHT11"):t.definitions_.machine_import_dht22||(t.definitions_.machine_import_dht22="from dht import DHT22");var l=a+" = "+n+"(Pin("+o+`))
|
|
12
|
+
`;return l},e.Blocks.dht_measure={init:function(){this.appendDummyInput().appendField(new e.FieldImage(C,15,15,{alt:"*",flipRtl:"FALSE"})).appendField(new e.FieldVariable("variable"),"sensor").appendField("Actualizar lectura"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(195),this.setTooltip("Actualizar la medición del sensor DHT"),this.setHelpUrl("")}},t.dht_measure=function(i){var n=t.nameDB_.getName(i.getFieldValue("sensor"),e.Variables.CATEGORY_NAME),a=n+`.measure()
|
|
13
|
+
`;return a},e.Blocks.dht_read={init:function(){this.appendDummyInput().appendField(new e.FieldImage(C,15,15,{alt:"*",flipRtl:"FALSE"})).appendField(new e.FieldVariable("variable"),"sensor").appendField(new e.FieldDropdown([["leer temperatura","temperature()"],["leer humedad","humidity()"]]),"read"),this.setOutput(!0,"Number"),this.setColour(195),this.setTooltip("Obtener la medición de humedad o temperatura del sensor DHT"),this.setHelpUrl("")}},t.dht_read=function(i){var n=t.nameDB_.getName(i.getFieldValue("sensor"),e.Variables.CATEGORY_NAME),a=i.getFieldValue("read"),o=n+"."+a+`
|
|
14
|
+
`;return[o,t.ORDER_NONE]}}function q(e,t){X(e,t),f(e,t),G(e,t),K(e,t),z(e,t)}const Y=`
|
|
15
15
|
<xml id="toolbox" style="display: none">
|
|
16
16
|
<category name="Lógica" colour="%{BKY_LOGIC_HUE}">
|
|
17
17
|
<block type="controls_if"></block>
|
|
@@ -343,9 +343,9 @@
|
|
|
343
343
|
</category>
|
|
344
344
|
<sep></sep>
|
|
345
345
|
</xml>
|
|
346
|
-
`;function
|
|
346
|
+
`;function Z(e,t){return e.INFINITE_LOOP_TRAP=null,e.workspaceToCode(t)}var s=(e=>(e[e.OK=0]="OK",e[e.FAILED=1]="FAILED",e[e.CHANGE=2]="CHANGE",e[e.WITHOUTCHANGE=3]="WITHOUTCHANGE",e[e.REQUEST=4]="REQUEST",e[e.REQUEST_SELECT_FILE_IN_TABVIEW=5]="REQUEST_SELECT_FILE_IN_TABVIEW",e[e.EXISTS=6]="EXISTS",e[e.NOEXIST=7]="NOEXIST",e[e.FOUND=8]="FOUND",e[e.NOTFOUND=9]="NOTFOUND",e[e.ADDED=10]="ADDED",e[e.SAVED=11]="SAVED",e[e.UNSAVED=12]="UNSAVED",e[e.SET_WS=13]="SET_WS",e[e.ENABLED=14]="ENABLED",e[e.DESABLED=15]="DESABLED",e))(s||{}),A=(e=>(e[e.EN=0]="EN",e[e.ES=1]="ES",e))(A||{}),c=(e=>(e[e.TOAST=0]="TOAST",e[e.TEXT_PRINT=1]="TEXT_PRINT",e[e.TEXT_AREA=2]="TEXT_AREA",e[e.URL_PRINT=3]="URL_PRINT",e[e.TERM=4]="TERM",e))(c||{}),N=(e=>(e[e.WEBSOCKET=0]="WEBSOCKET",e[e.TCP_IP=1]="TCP_IP",e[e.SERIAL=2]="SERIAL",e))(N||{});const Q={name:"Python",extension:"py"},M="py",D="json",R="micropython-esp32",$="main.py",J='{"config":{"platform":"micropython-esp32","send":"wifi","ip_mpy":"192.168.4.1","serialport":""},"blocklycode":"<xml xmlns=\\"https://developers.google.com/blockly/xml\\"></xml>"}',j=`# platform: micropython-esp32
|
|
347
347
|
# send: wifi
|
|
348
348
|
# ip_mpy: 192.168.4.1
|
|
349
349
|
# serialport:
|
|
350
|
-
`;var
|
|
351
|
-
`;return{typeResult:
|
|
350
|
+
`;var w=(e=>(e.WIFI="wifi",e.SERIAL="serial",e))(w||{});async function ee(e,t,i){const n=window.catalejo;if(!n)throw{message:"El editor no ofrece la conexión con el backend (window.catalejo)"};return await n.call(e,t,i)}async function te(){try{const e=await ee("serial.list",{});return{status:s.OK,data:e.ports}}catch(e){return console.error("serial.list",e),{status:s.FAILED,data:(e==null?void 0:e.message)||String(e)}}}const V=64,ie=5e3,L=5e3;function P(e){return new Promise(t=>setTimeout(t,e))}class m extends Error{constructor(t,i=""){super(t+(i?": "+i:"")),this.code=t,this.detail=i}}class v{constructor(t){g(this,"text","");g(this,"binary",[]);g(this,"closed",!1);g(this,"wake",null);this.ws=t,t.onmessage=i=>{typeof i.data=="string"?this.text+=i.data:this.binary.push(new Uint8Array(i.data)),this.notify()},t.onclose=()=>{this.closed=!0,this.notify()},t.onerror=()=>{this.closed=!0,this.notify()}}notify(){const t=this.wake;this.wake=null,t&&t()}static open(t){return new Promise((i,n)=>{let a;try{a=new WebSocket("ws://"+t.ipPy+":"+t.portPy+"/"),a.binaryType="arraybuffer"}catch(d){n(new m("connect",String(d)));return}const o=[];a.onmessage=d=>o.push(d);const l=setTimeout(()=>{a.close(),n(new m("connect",t.ipPy))},ie);a.onopen=()=>{clearTimeout(l);const d=new v(a);o.forEach(h=>{var b;return(b=a.onmessage)==null?void 0:b.call(a,h)}),i(d)},a.onerror=()=>{clearTimeout(l),n(new m("connect",t.ipPy))}})}async waitFor(t,i,n=L){const a=Date.now()+n;for(;;){const o=t();if(o!==void 0)return o;if(this.closed)throw new m("closed",i);const l=a-Date.now();if(l<=0)throw new m("timeout",i);await new Promise(d=>{const h=setTimeout(d,l);this.wake=()=>{clearTimeout(h),d()}})}}waitText(t,i){return this.waitFor(()=>{const n=t.find(a=>this.text.includes(a));return n!==void 0&&(this.text=""),n},i)}waitWB(t,i){return this.waitFor(()=>{const n=this.binary.shift();if(n!==void 0)return n.length>=4&&n[0]===87&&n[1]===66?n[2]|n[3]<<8:-1},t,i)}async login(t){if(await this.waitText(["Password:"],"password prompt"),this.ws.send(t+"\r"),await this.waitText(["WebREPL connected","Access denied"],"login")==="Access denied")throw new m("accessDenied")}async putFile(t,i,n,a){const o=new TextEncoder().encode(t);if(o.length===0||o.length>V)throw new m("filename",t);const l=i.length,d=new Uint8Array(18+V);d[0]=87,d[1]=65,d[2]=1,d[12]=l&255,d[13]=l>>8&255,d[14]=l>>16&255,d[15]=l>>24&255,d[16]=o.length&255,d[17]=o.length>>8&255,d.set(o,18),this.binary=[],this.ws.send(d);let h=await this.waitWB("put header");if(h!==0)throw new m("rejected","header "+h);const b=n>0?n:1024;for(let F=0;F<l;F+=b){if(this.closed)throw new m("closed","sending");this.ws.send(i.slice(F,F+b)),a>0&&await P(a)}if(h=await this.waitWB("put end",L+Math.ceil(l/4096)*1e3),h!==0)throw new m("rejected","end "+h)}async sendRepl(t){this.ws.send(t),await P(100)}close(){this.closed=!0;try{this.ws.close()}catch{}}}function B(e){return e instanceof m?{status:s.FAILED,data:{code:e.code,detail:e.detail}}:{status:s.FAILED,data:{code:"connect",detail:String(e)}}}async function ne(e,t,i,n=!0){const a=typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t);let o;try{return o=await v.open(i),await o.login(i.passwordPy),await o.putFile(e,a,i.chuckSizePy,i.sleepTimePy),n&&await o.sendRepl(""),{status:s.OK,data:"File uploaded"}}catch(l){return B(l)}finally{o==null||o.close()}}async function ae(e,t){let i;try{return i=await v.open(t),await i.login(t.passwordPy),await i.sendRepl(e),{status:s.OK,data:"Command sent"}}catch(n){return B(n)}finally{i==null||i.close()}}const _={micropythonSend:{en:"Send",es:"Enviar"},magic:{en:"Translate",es:"Traducir"},getSerialportList:{en:"Get serial ports",es:"Listar puertos seriales"},docs:{en:"Documentation",es:"Documentación"},reset:{en:"Reset micropython",es:"Reiniciar micropython"},play:{en:"Run main",es:"Correr programa principal"},term:{en:"Run terminal",es:"Conectersa a micropython"}},oe={docs:{title:{en:"Micropython documentation",es:"Documentación para Micropython"}}},E={sendOk:{en:"Code sent to the board",es:"Código enviado a la placa"},sendFailed:{en:"Could not send the code",es:"No se pudo enviar el código"},resetOk:{en:"Reset command sent",es:"Se envió el reinicio"},resetFailed:{en:"Could not reset the board",es:"No se pudo reiniciar la placa"},runOk:{en:"Run command sent",es:"Se envió la orden de ejecutar"},runFailed:{en:"Could not run the program",es:"No se pudo ejecutar el programa"},noIp:{en:"Missing the board address: add '# ip_mpy: 192.168.4.1' (or the board name ending in .local) to the configuration",es:"Falta la dirección de la placa: agrega '# ip_mpy: 192.168.4.1' (o el nombre de la placa terminado en .local) a la configuración"},noContent:{en:"This file can't be sent to the board",es:"Este archivo no se puede enviar a la placa"},connect:{en:"Can't reach the board. Check that you are on the same WiFi network as the board and that ip_mpy is right",es:"No se encontró la placa. Revisa que estés en la misma red WiFi que la placa y que ip_mpy sea correcta"},closed:{en:"The board closed the connection. Is someone else connected to it (terminal or another computer)?",es:"La placa cerró la conexión. ¿Hay alguien más conectado a ella (terminal u otro equipo)?"},timeout:{en:"The board didn't answer in time. If a program is running, press Reset and try again",es:"La placa no respondió a tiempo. Si hay un programa corriendo, presiona Reiniciar e intenta de nuevo"},accessDenied:{en:"Wrong WebREPL password: check password_mpy (default 0000)",es:"Clave de WebREPL incorrecta: revisa password_mpy (por defecto 0000)"},filename:{en:"Invalid file name for the board (empty or longer than 64 bytes)",es:"Nombre de archivo no válido para la placa (vacío o de más de 64 bytes)"},rejected:{en:"The board couldn't save the file (no space or invalid name?)",es:"La placa no pudo guardar el archivo (¿sin espacio o nombre no válido?)"}};function u(e,t){return t==A.EN?e.en:t==A.ES?e.es:"noname"}function S(e){return{ipPy:e.ip_mpy!=null&&e.ip_mpy!=""?e.ip_mpy:"",portPy:e.port_mpy!=null&&e.port_mpy!=""?e.port_mpy:"8266",passwordPy:e.password_mpy!=null&&e.password_mpy!=""?e.password_mpy:"0000",sleepTimePy:e.sleepTime_mpy!=null&&e.sleepTime_mpy!=""?parseInt(e.sleepTime_mpy):50,chuckSizePy:e.chuckSize_mpy!=null&&e.chuckSize_mpy!=""?parseInt(e.chuckSize_mpy):1024}}function se(e,t){return e.extension==M?{status:s.OK,data:e.content}:e.extension==D&&e.config.platform==R?{status:s.OK,data:t()}:{status:s.FAILED}}function le(e){return e.extension==M?e.config.filename!=""&&e.config.filename!=null?{status:s.OK,data:e.config.filename}:{status:s.OK,data:e.filename}:e.extension==D&&e.config.platform==R?e.config.filename!=""&&e.config.filename!=null?{status:s.OK,data:e.config.filename}:{status:s.OK,data:$}:{status:s.FAILED}}async function re(e,t){const i=S(e.config);if(i.ipPy=="")return{status:s.FAILED,data:{code:"noIp"}};let n;if(n=le(e),n.status==s.FAILED)return{status:s.FAILED,data:{code:"noContent"}};const a=n.data;if(n=se(e,t),n.status==s.FAILED)return{status:s.FAILED,data:{code:"noContent"}};const o=n.data;return await ne(a,o,i)}function O(e,t,i,n){var l;if(e.status==s.OK)return{typeResult:c.TOAST,data:{severity:"success",summary:u(E[i],t),detail:"",life:3e3}};const a=(l=e.data)==null?void 0:l.code,o=a!=null&&E[a]!=null?u(E[a],t):"";return{typeResult:c.TOAST,data:{severity:"warn",summary:u(E[n],t),detail:o,life:8e3}}}async function de(e,t,i){if(e.config.send==w.WIFI){const a=await re(e,t);return O(a,i,"sendOk","sendFailed")}return{typeResult:c.TOAST,data:{severity:"warn",summary:"TODO from send on micropython",detail:"",life:3e3}}}async function H(e,t){const i=S(e.config);return i.ipPy==""?{status:s.FAILED,data:{code:"noIp"}}:await ae(t,i)}async function ce(e,t){if(e.config.send==w.WIFI){const n=await H(e,"from machine import reset\rreset()\r");return O(n,t,"resetOk","resetFailed")}return{typeResult:c.TOAST,data:{severity:"warn",summary:"Failed soft reset micropython",detail:"",life:3e3}}}async function pe(e,t){if(e.config.send==w.WIFI){const n=await H(e,"");return O(n,t,"runOk","runFailed")}return{typeResult:c.TOAST,data:{severity:"warn",summary:"Failed run main micropython",detail:"",life:3e3}}}async function me(e){const t=e.config.send,i=e.config;if(t==w.WIFI){const n=i.ip_mpy!=null&&i.ip_mpy!=""?i.ip_mpy:"",a=i.port_mpy!=null&&i.port_mpy!=""?i.port_mpy:"8266",o=i.password_mpy!=null&&i.password_mpy!=""?i.password_mpy:"0000";if(n!="")return{typeResult:c.TERM,data:{typeConnection:N.WEBSOCKET,data:{ip:n,port:a,user:"",password:o,endOfCommand:"\r"}}}}return{typeResult:c.TOAST,data:{severity:"warn",summary:"Failed open terminal micropython",detail:"",life:1e3}}}async function ue(e,t){return e.extension==D?{typeResult:c.TEXT_PRINT,data:{title:"Python",content:t()}}:{typeResult:c.TOAST,data:{severity:"warn",summary:"Opción disponible solo con archivos blockly (json)",detail:"",life:5e3}}}async function he(){const e=await te();if(e.status==s.OK){let t="";for(let i=0;i<e.data.length;i++)t+=e.data[i]+`
|
|
351
|
+
`;return{typeResult:c.TEXT_PRINT,data:{title:"SerialPortList",content:t}}}else return{typeResult:c.TOAST,data:{severity:"warn",summary:"No se pudo obtener información sobre los puertos seriales",detail:"",life:5e3}}}async function _e(e){const a="http://"+location.hostname+":"+8080+"/plugins/nodemcu/docs/index.html";return{typeResult:c.URL_PRINT,data:{title:u(oe.docs.title,e),content:a,description:"Abre el siguiente enlace para obtener infomación sobre la documentación de nodemcu"}}}let x,U,W;const fe=R,ye=Q,we=J,be=j;function ge(e,t,i){W=e,x=t,U=i,q(W,x)}function I(){return Z(x,U)}const ke=Y;function ve(e){return[{label:u(_.magic,e),icon:"pi pi-sparkles",command:"micropython-magic"},{label:u(_.micropythonSend,e),icon:"pi pi-send",command:"micropython-send"},{label:"micropython",icon:"pi pi-microchip",items:[{label:u(_.getSerialportList,e),icon:"pi pi-search",command:"nodemcu-getserialportlist"},{label:u(_.docs,e),icon:"pi pi-book",command:"micropython-docs"},{label:u(_.reset,e),icon:"pi pi-refresh",command:"micropython-reset"},{label:u(_.play,e),icon:"pi pi-play",command:"micropython-play"},{label:u(_.term,e),icon:"pi pi-sync",command:"micropython-term"}]}]}async function Ee(e,t,i){return t=="micropython-send"?await de(e,I,i):t=="micropython-magic"?await ue(e,I):t=="nodemcu-getserialportlist"?await he():t=="micropython-docs"?await _e(i):t=="micropython-reset"?await ce(e,i):t=="micropython-play"?await pe(e,i):t=="micropython-term"?await me(e):{typeResult:c.TOAST,data:{severity:"error",summary:"Función no localizada en el plugin",detail:"",life:3e3}}}r.blockly_template=we,r.commandEmit=Ee,r.generateCode=I,r.getItemsToolBarOfPlugin=ve,r.initBlockly=ge,r.lang_template=be,r.platform=fe,r.platformLang=ye,r.toolbox=ke,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
import { Result, UpyWebsocketOptions } from './types';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Cliente WebREPL de MicroPython.
|
|
4
|
+
*
|
|
5
|
+
* Protocolo (ver `webrepl_cli.py` en github.com/micropython/webrepl):
|
|
6
|
+
*
|
|
7
|
+
* 1. Al conectar, la placa envía el texto "Password: ".
|
|
8
|
+
* 2. El cliente responde con la clave y "\r". La placa contesta
|
|
9
|
+
* "WebREPL connected" o "Access denied" (y cierra).
|
|
10
|
+
* 3. Para escribir un archivo, el cliente envía en binario la cabecera `WA`
|
|
11
|
+
* (82 bytes). La placa responde en binario `WB` + estado (2 bytes, 0 = ok).
|
|
12
|
+
* 4. El cliente envía el contenido en binario. Al recibirlo completo, la placa
|
|
13
|
+
* responde otra vez `WB` + estado.
|
|
14
|
+
*
|
|
15
|
+
* Cada paso espera su propia respuesta: un mensaje que llega fuera de lugar
|
|
16
|
+
* no dispara el envío, y cada espera tiene un tiempo límite.
|
|
17
|
+
*/
|
|
18
|
+
/** Motivos de fallo; los textos para el usuario están en `lang.ts`. */
|
|
19
|
+
export declare enum WEBREPL_ERROR {
|
|
20
|
+
CONNECT = "connect",// No se pudo abrir el WebSocket
|
|
21
|
+
CLOSED = "closed",// La placa cerró la conexión a mitad del proceso
|
|
22
|
+
TIMEOUT = "timeout",// La placa no respondió a tiempo
|
|
23
|
+
ACCESS_DENIED = "accessDenied",// Clave de WebREPL incorrecta
|
|
24
|
+
FILENAME = "filename",// Nombre de archivo vacío o de más de 64 bytes
|
|
25
|
+
REJECTED = "rejected"
|
|
26
|
+
}
|
|
27
|
+
/** Escribir un archivo en la placa. Con `runAfter`, al terminar se envía
|
|
28
|
+
* Ctrl-D para que la placa haga un reinicio suave y ejecute `main.py`
|
|
29
|
+
* (lo mismo que hacía la versión anterior). */
|
|
30
|
+
export declare function sendFile(fileName: string, fileContent: string | Uint8Array, options: UpyWebsocketOptions, runAfter?: boolean): Promise<Result>;
|
|
31
|
+
/** Ejecutar un comando en la REPL de la placa. */
|
|
4
32
|
export declare function run(command: string, options: UpyWebsocketOptions): Promise<Result>;
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# platform: micropython-esp32
|
|
2
|
-
# send: wifi
|
|
3
|
-
# ip_mpy: 192.168.4.1
|
|
4
|
-
# filename: boot.py
|
|
5
|
-
# Configuración de arranque para
|
|
6
|
-
# cualquier esp32
|
|
7
|
-
import webrepl
|
|
8
|
-
from wifi import do_ap, do_sta_connect
|
|
9
|
-
|
|
10
|
-
webrepl.start()
|
|
11
|
-
do_ap()
|
|
12
|
-
do_sta_connect()
|
|
13
|
-
gc.collect()
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# platform: micropython-esp32
|
|
2
|
-
# send: wifi
|
|
3
|
-
# ip_mpy: 192.168.4.1
|
|
4
|
-
# filename: wifi.py
|
|
5
|
-
# Configuración para comunicación wifi
|
|
6
|
-
def do_ap():
|
|
7
|
-
import network
|
|
8
|
-
ap_if = network.WLAN(network.AP_IF)
|
|
9
|
-
mac = ''.join('%02x' % b for b in ap_if.config('mac'))[-5:]
|
|
10
|
-
if not network.WLAN(network.AP_IF).active() and not network.WLAN(network.STA_IF).isconnected():
|
|
11
|
-
print("Config...")
|
|
12
|
-
ap_if.config(essid='catalejo-'+mac, authmode=3, password='87654321')
|
|
13
|
-
ap_if.active(True)
|
|
14
|
-
print('WiFi name: ' + 'catalejo-' + mac)
|
|
15
|
-
print('PASS: ' + '87654321')
|
|
16
|
-
|
|
17
|
-
def led_ctr(led, state):
|
|
18
|
-
if led:
|
|
19
|
-
if state != None:
|
|
20
|
-
led.value(state)
|
|
21
|
-
else:
|
|
22
|
-
led.value(not led.value())
|
|
23
|
-
|
|
24
|
-
def but_ctr(but, logic):
|
|
25
|
-
if but:
|
|
26
|
-
return but.value() == logic
|
|
27
|
-
else:
|
|
28
|
-
return False
|
|
29
|
-
|
|
30
|
-
def do_sta_connect():
|
|
31
|
-
import network
|
|
32
|
-
import wifi_config
|
|
33
|
-
if not wifi_config.SSID or not wifi_config.PASS or not wifi_config.ATTE:
|
|
34
|
-
return
|
|
35
|
-
wlan = network.WLAN(network.STA_IF)
|
|
36
|
-
mac = ''.join('%02x' % b for b in network.WLAN(network.AP_IF).config('mac'))[-5:]
|
|
37
|
-
wlan.active(True)
|
|
38
|
-
from machine import Pin
|
|
39
|
-
import time
|
|
40
|
-
led = None
|
|
41
|
-
but = None
|
|
42
|
-
ret_but = None
|
|
43
|
-
if wifi_config.LED != None and wifi_config.LLED != None:
|
|
44
|
-
led = Pin(wifi_config.LED, Pin.OUT)
|
|
45
|
-
if wifi_config.BUT != None and wifi_config.LBUT != None:
|
|
46
|
-
but = Pin(wifi_config.BUT, Pin.IN)
|
|
47
|
-
led_ctr(led, wifi_config.LLED)
|
|
48
|
-
time.sleep(1.5)
|
|
49
|
-
ret_but = but_ctr(but, wifi_config.LBUT)
|
|
50
|
-
if not wlan.isconnected():
|
|
51
|
-
print('Connecting to network...')
|
|
52
|
-
wlan.connect(wifi_config.SSID, wifi_config.PASS)
|
|
53
|
-
attemps = 0
|
|
54
|
-
while not wlan.isconnected() and attemps < wifi_config.ATTE:
|
|
55
|
-
led_ctr(led, wifi_config.LLED)
|
|
56
|
-
time.sleep(0.1)
|
|
57
|
-
led_ctr(led, not wifi_config.LLED)
|
|
58
|
-
time.sleep(0.9)
|
|
59
|
-
attemps += 1
|
|
60
|
-
if wlan.isconnected():
|
|
61
|
-
led_ctr(led, wifi_config.LLED)
|
|
62
|
-
print("IP STA: ", wlan.ifconfig()[0])
|
|
63
|
-
print("Dev: catalejo-" + mac)
|
|
64
|
-
if ret_but :
|
|
65
|
-
time.sleep(3)
|
|
66
|
-
while not but_ctr(but, wifi_config.LBUT):
|
|
67
|
-
led_ctr(led, None)
|
|
68
|
-
print("IP STA: ", wlan.ifconfig()[0])
|
|
69
|
-
print("Dev: catalejo-" + mac)
|
|
70
|
-
time.sleep(1)
|
|
71
|
-
if not wifi_config.AP:
|
|
72
|
-
network.WLAN(network.AP_IF).active(False)
|
|
73
|
-
print("AP_IF off")
|
|
74
|
-
else:
|
|
75
|
-
wlan.active(False)
|
|
76
|
-
led_ctr(led, not wifi_config.LLED)
|
|
77
|
-
print("Don't connect how a STA")
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# platform: micropython-esp32
|
|
2
|
-
# send: wifi
|
|
3
|
-
# ip_mpy: 192.168.4.1
|
|
4
|
-
# filename: wifi_config.py
|
|
5
|
-
# Configuración para el esp32c3mini
|
|
6
|
-
# Modifique unicamente el SSID y PASS
|
|
7
|
-
SSID = 'nombreDeRed'
|
|
8
|
-
PASS = 'Contrasena'
|
|
9
|
-
ATTE = 5
|
|
10
|
-
AP = False
|
|
11
|
-
LED = 8
|
|
12
|
-
LLED = 0
|
|
13
|
-
BUT = 9
|
|
14
|
-
LBUT = 0
|