@johnnycubides/micropython-esp32-plugin-catalejo-editor 0.1.0
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 +10 -0
- package/micropython-esp32/README.md +10 -0
- package/micropython-esp32/commands.d.ts +20 -0
- package/micropython-esp32/consts.d.ts +55 -0
- package/micropython-esp32/esp32-libs/boot.py +13 -0
- package/micropython-esp32/esp32-libs/wifi.py +77 -0
- package/micropython-esp32/esp32-libs/wifi_config_esp32c3mini.py +14 -0
- package/micropython-esp32/http-request.d.ts +4 -0
- package/micropython-esp32/lang.d.ts +46 -0
- package/micropython-esp32/main.d.ts +36 -0
- package/micropython-esp32/micropython.es.d.ts +1 -0
- package/micropython-esp32/micropython.es.js +874 -0
- package/micropython-esp32/micropython.umd.js +351 -0
- package/micropython-esp32/types.d.ts +90 -0
- package/micropython-esp32/upy-websockect.d.ts +5 -0
- package/package.json +28 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
const N = "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";
|
|
2
|
+
function I(e, t) {
|
|
3
|
+
e.Blocks.mpy_sleep_s = {
|
|
4
|
+
init: function() {
|
|
5
|
+
this.appendValueInput("time").setCheck("Number").appendField(new e.FieldImage(N, 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("");
|
|
6
|
+
}
|
|
7
|
+
}, t.mpy_sleep_s = function(i) {
|
|
8
|
+
var n = t.valueToCode(i, "time", t.ORDER_ATOMIC), a = i.getFieldValue("scale");
|
|
9
|
+
t.definitions_.import_time || (t.definitions_.import_time = "import time");
|
|
10
|
+
var o = `...
|
|
11
|
+
`;
|
|
12
|
+
return a == "sec" ? o = "time.sleep(" + n + `)
|
|
13
|
+
` : a == "ms" ? o = "time.sleep_ms(" + n + `)
|
|
14
|
+
` : a == "us" && (o = "time.sleep_us(" + n + `)
|
|
15
|
+
`), o;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const y = "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";
|
|
19
|
+
function V(e, t) {
|
|
20
|
+
e.Blocks.mpy_esp32_pin_mode_explicit = {
|
|
21
|
+
init: function() {
|
|
22
|
+
this.appendValueInput("pin_number").setCheck("Number").setAlign(e.ALIGN_CENTRE).appendField(new e.FieldImage(y, 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("");
|
|
23
|
+
}
|
|
24
|
+
}, t.mpy_esp32_pin_mode_explicit = function(i) {
|
|
25
|
+
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);
|
|
26
|
+
t.definitions_.machine_import_pin || (t.definitions_.machine_import_pin = "from machine import Pin");
|
|
27
|
+
var d = n + " = Pin(" + o + ", " + a + `)
|
|
28
|
+
`;
|
|
29
|
+
return d;
|
|
30
|
+
}, e.Blocks.mpy_esp32_pin_mode = {
|
|
31
|
+
init: function() {
|
|
32
|
+
this.appendValueInput("pin_number").setCheck("Number").setAlign(e.ALIGN_CENTRE).appendField(new e.FieldImage(y, 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("");
|
|
33
|
+
}
|
|
34
|
+
}, t.mpy_esp32_pin_mode = function(i) {
|
|
35
|
+
var n = i.getFieldValue("pin_mode"), a = t.valueToCode(i, "pin_number", t.ORDER_ATOMIC);
|
|
36
|
+
t.definitions_.machine_import_pin || (t.definitions_.machine_import_pin = "from machine import Pin");
|
|
37
|
+
var o = "Pin(" + a + ", " + n + ")";
|
|
38
|
+
return [o, t.ORDER_NONE];
|
|
39
|
+
}, e.Blocks.mpy_esp32_pin_read = {
|
|
40
|
+
init: function() {
|
|
41
|
+
this.appendDummyInput().setAlign(e.ALIGN_CENTRE).appendField(new e.FieldImage(y, 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("");
|
|
42
|
+
}
|
|
43
|
+
}, t.mpy_esp32_pin_read = function(i) {
|
|
44
|
+
var n = t.nameDB_.getName(i.getFieldValue("pin_var"), e.Variables.CATEGORY_NAME);
|
|
45
|
+
t.definitions_.machine_import_pin || (t.definitions_.machine_import_pin = "from machine import Pin");
|
|
46
|
+
var a = n + ".value()";
|
|
47
|
+
return [a, t.ORDER_NONE];
|
|
48
|
+
}, e.Blocks.mpy_esp32_pin_write = {
|
|
49
|
+
init: function() {
|
|
50
|
+
this.appendValueInput("pin_value").setCheck("Number").appendField(new e.FieldImage(y, 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("");
|
|
51
|
+
}
|
|
52
|
+
}, t.mpy_esp32_pin_write = function(i) {
|
|
53
|
+
var n = t.nameDB_.getName(i.getFieldValue("pin_var"), e.Variables.CATEGORY_NAME), a = t.valueToCode(i, "pin_value", t.ORDER_ATOMIC);
|
|
54
|
+
t.definitions_.machine_import_pin || (t.definitions_.machine_import_pin = "from machine import Pin");
|
|
55
|
+
var o = n + ".value(" + a + `)
|
|
56
|
+
`;
|
|
57
|
+
return o;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const h = "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";
|
|
61
|
+
function M(e, t) {
|
|
62
|
+
e.Blocks.adc_minimal_class = {
|
|
63
|
+
init: function() {
|
|
64
|
+
this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(h, 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("");
|
|
65
|
+
}
|
|
66
|
+
}, t.adc_minimal_class = function(i) {
|
|
67
|
+
var n = t.valueToCode(i, "id_pin", t.ORDER_ATOMIC);
|
|
68
|
+
t.definitions_.machine_import_adc || (t.definitions_.machine_import_adc = "from machine import ADC");
|
|
69
|
+
var a = "ADC(" + n + ", atten = ADC.ATTN_11DB)";
|
|
70
|
+
return [a, t.ORDER_NONE];
|
|
71
|
+
}, e.Blocks.adc_minimal_class_explicit = {
|
|
72
|
+
init: function() {
|
|
73
|
+
this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(h, 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("");
|
|
74
|
+
}
|
|
75
|
+
}, t.adc_minimal_class_explicit = function(i) {
|
|
76
|
+
var n = t.nameDB_.getName(i.getFieldValue("name"), e.Variables.CATEGORY_NAME), a = t.valueToCode(i, "id_pin", t.ORDER_ATOMIC);
|
|
77
|
+
t.definitions_.machine_import_adc || (t.definitions_.machine_import_adc = "from machine import ADC");
|
|
78
|
+
var o = n + "= ADC(" + a + `, atten = ADC.ATTN_11DB)
|
|
79
|
+
`;
|
|
80
|
+
return o;
|
|
81
|
+
}, e.Blocks.adc_minimal_read = {
|
|
82
|
+
init: function() {
|
|
83
|
+
this.appendDummyInput().appendField(new e.FieldImage(h, 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("");
|
|
84
|
+
}
|
|
85
|
+
}, t.adc_minimal_read = function(i) {
|
|
86
|
+
var n = t.nameDB_.getName(i.getFieldValue("adc_obj"), e.Variables.CATEGORY_NAME);
|
|
87
|
+
t.definitions_.machine_import_adc || (t.definitions_.machine_import_adc = "from machine import ADC");
|
|
88
|
+
var a = n + ".read()";
|
|
89
|
+
return [a, t.ORDER_NONE];
|
|
90
|
+
}, e.Blocks.adc_atten_class = {
|
|
91
|
+
init: function() {
|
|
92
|
+
this.appendValueInput("id_pin").setCheck("Number").appendField(new e.FieldImage(h, 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("");
|
|
93
|
+
}
|
|
94
|
+
}, t.adc_atten_class = function(i) {
|
|
95
|
+
var n = i.getFieldValue("atten"), a = t.valueToCode(i, "id_pin", t.ORDER_ATOMIC);
|
|
96
|
+
t.definitions_.machine_import_adc || (t.definitions_.machine_import_adc = "from machine import ADC");
|
|
97
|
+
var o = "ADC(" + a + ", atten = " + n + ")";
|
|
98
|
+
return [o, t.ORDER_NONE];
|
|
99
|
+
}, e.Blocks.adc_resolution_select_read = {
|
|
100
|
+
init: function() {
|
|
101
|
+
this.appendDummyInput().appendField(new e.FieldImage(h, 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("");
|
|
102
|
+
}
|
|
103
|
+
}, t.adc_resolution_select_read = function(i) {
|
|
104
|
+
var n = t.nameDB_.getName(i.getFieldValue("adc_obj"), e.Variables.CATEGORY_NAME), a = i.getFieldValue("resolution");
|
|
105
|
+
t.definitions_.machine_import_adc || (t.definitions_.machine_import_adc = "from machine import ADC");
|
|
106
|
+
var o = n + "." + a;
|
|
107
|
+
return [o, t.ORDER_NONE];
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const w = "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";
|
|
111
|
+
function P(e, t) {
|
|
112
|
+
e.Blocks.pwm_minimal_class = {
|
|
113
|
+
init: function() {
|
|
114
|
+
this.appendValueInput("pin_id").setCheck(null).appendField(new e.FieldImage(w, 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("");
|
|
115
|
+
}
|
|
116
|
+
}, t.pwm_minimal_class = function(i) {
|
|
117
|
+
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);
|
|
118
|
+
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");
|
|
119
|
+
var o = n + " = PWM(Pin(" + a + `), freq=1000, duty=512)
|
|
120
|
+
`;
|
|
121
|
+
return o;
|
|
122
|
+
}, e.Blocks.pwm_init_deinit = {
|
|
123
|
+
init: function() {
|
|
124
|
+
this.appendDummyInput().appendField(new e.FieldImage(w, 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("");
|
|
125
|
+
}
|
|
126
|
+
}, t.pwm_init_deinit = function(i) {
|
|
127
|
+
var n = t.nameDB_.getName(i.getFieldValue("pwm"), e.Variables.CATEGORY_NAME), a = i.getFieldValue("start_stop");
|
|
128
|
+
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");
|
|
129
|
+
var o = n + "." + a + `
|
|
130
|
+
`;
|
|
131
|
+
return o;
|
|
132
|
+
}, e.Blocks.pwm_method_freq_duty = {
|
|
133
|
+
init: function() {
|
|
134
|
+
this.appendValueInput("argument_funtion").setCheck("Number").appendField(new e.FieldImage(w, 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("");
|
|
135
|
+
}
|
|
136
|
+
}, t.pwm_method_freq_duty = function(i) {
|
|
137
|
+
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);
|
|
138
|
+
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");
|
|
139
|
+
var d = n + "." + a + "(" + o + `)
|
|
140
|
+
`;
|
|
141
|
+
return d;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const b = "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";
|
|
145
|
+
function L(e, t) {
|
|
146
|
+
e.Blocks.dht_init = {
|
|
147
|
+
init: function() {
|
|
148
|
+
this.appendValueInput("pin").setCheck("Number").appendField(new e.FieldImage(b, 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("");
|
|
149
|
+
}
|
|
150
|
+
}, t.dht_init = function(i) {
|
|
151
|
+
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);
|
|
152
|
+
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");
|
|
153
|
+
var d = a + " = " + n + "(Pin(" + o + `))
|
|
154
|
+
`;
|
|
155
|
+
return d;
|
|
156
|
+
}, e.Blocks.dht_measure = {
|
|
157
|
+
init: function() {
|
|
158
|
+
this.appendDummyInput().appendField(new e.FieldImage(b, 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("");
|
|
159
|
+
}
|
|
160
|
+
}, t.dht_measure = function(i) {
|
|
161
|
+
var n = t.nameDB_.getName(i.getFieldValue("sensor"), e.Variables.CATEGORY_NAME), a = n + `.measure()
|
|
162
|
+
`;
|
|
163
|
+
return a;
|
|
164
|
+
}, e.Blocks.dht_read = {
|
|
165
|
+
init: function() {
|
|
166
|
+
this.appendDummyInput().appendField(new e.FieldImage(b, 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("");
|
|
167
|
+
}
|
|
168
|
+
}, t.dht_read = function(i) {
|
|
169
|
+
var n = t.nameDB_.getName(i.getFieldValue("sensor"), e.Variables.CATEGORY_NAME), a = i.getFieldValue("read"), o = n + "." + a + `
|
|
170
|
+
`;
|
|
171
|
+
return [o, t.ORDER_NONE];
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function S(e, t) {
|
|
175
|
+
V(e, t), I(e, t), M(e, t), P(e, t), L(e, t);
|
|
176
|
+
}
|
|
177
|
+
const B = `
|
|
178
|
+
<xml id="toolbox" style="display: none">
|
|
179
|
+
<category name="Lógica" colour="%{BKY_LOGIC_HUE}">
|
|
180
|
+
<block type="controls_if"></block>
|
|
181
|
+
<block type="logic_compare"></block>
|
|
182
|
+
<block type="logic_operation"></block>
|
|
183
|
+
<block type="logic_negate"></block>
|
|
184
|
+
<block type="logic_boolean"></block>
|
|
185
|
+
<block type="logic_null"></block>
|
|
186
|
+
<block type="logic_ternary"></block>
|
|
187
|
+
</category>
|
|
188
|
+
<category name="Secuencias" colour="%{BKY_LOOPS_HUE}">
|
|
189
|
+
<block type="controls_repeat_ext">
|
|
190
|
+
<value name="TIMES">
|
|
191
|
+
<shadow type="math_number">
|
|
192
|
+
<field name="NUM">10</field>
|
|
193
|
+
</shadow>
|
|
194
|
+
</value>
|
|
195
|
+
</block>
|
|
196
|
+
<block type="controls_whileUntil"></block>
|
|
197
|
+
<block type="controls_for">
|
|
198
|
+
<value name="FROM">
|
|
199
|
+
<shadow type="math_number">
|
|
200
|
+
<field name="NUM">1</field>
|
|
201
|
+
</shadow>
|
|
202
|
+
</value>
|
|
203
|
+
<value name="TO">
|
|
204
|
+
<shadow type="math_number">
|
|
205
|
+
<field name="NUM">1</field>
|
|
206
|
+
</shadow>
|
|
207
|
+
</value>
|
|
208
|
+
</block>
|
|
209
|
+
<block type="controls_forEach"></block>
|
|
210
|
+
<block type="controls_flow_statements"></block>
|
|
211
|
+
</category>
|
|
212
|
+
<category name="Matemática" colour="%{BKY_MATH_HUE}">
|
|
213
|
+
<block type="math_number"></block>
|
|
214
|
+
<block type="math_arithmetic">
|
|
215
|
+
<value name="A">
|
|
216
|
+
<shadow type="math_number">
|
|
217
|
+
<field name="NUM">1</field>
|
|
218
|
+
</shadow>
|
|
219
|
+
</value>
|
|
220
|
+
<value name="B">
|
|
221
|
+
<shadow type="math_number">
|
|
222
|
+
<field name="NUM">1</field>
|
|
223
|
+
</shadow>
|
|
224
|
+
</value>
|
|
225
|
+
</block>
|
|
226
|
+
<block type="math_single">
|
|
227
|
+
<value name="NUM">
|
|
228
|
+
<shadow type="math_number">
|
|
229
|
+
<field name="NUM">9</field>
|
|
230
|
+
</shadow>
|
|
231
|
+
</value>
|
|
232
|
+
</block>
|
|
233
|
+
<block type="math_trig">
|
|
234
|
+
<value name="NUM">
|
|
235
|
+
<shadow type="math_number">
|
|
236
|
+
<field name="NUM">45</field>
|
|
237
|
+
</shadow>
|
|
238
|
+
</value>
|
|
239
|
+
</block>
|
|
240
|
+
<block type="math_constant"></block>
|
|
241
|
+
<block type="math_number_property">
|
|
242
|
+
<value name="NUMBER_TO_CHECK">
|
|
243
|
+
<shadow type="math_number">
|
|
244
|
+
<field name="NUM">0</field>
|
|
245
|
+
</shadow>
|
|
246
|
+
</value>
|
|
247
|
+
</block>
|
|
248
|
+
<block type="math_round">
|
|
249
|
+
<value name="NUM">
|
|
250
|
+
<shadow type="math_number">
|
|
251
|
+
<field name="NUM">3.1</field>
|
|
252
|
+
</shadow>
|
|
253
|
+
</value>
|
|
254
|
+
</block>
|
|
255
|
+
<block type="math_on_list"></block>
|
|
256
|
+
<block type="math_modulo">
|
|
257
|
+
<value name="DIVIDEND">
|
|
258
|
+
<shadow type="math_number">
|
|
259
|
+
<field name="NUM">64</field>
|
|
260
|
+
</shadow>
|
|
261
|
+
</value>
|
|
262
|
+
<value name="DIVISOR">
|
|
263
|
+
<shadow type="math_number">
|
|
264
|
+
<field name="NUM">10</field>
|
|
265
|
+
</shadow>
|
|
266
|
+
</value>
|
|
267
|
+
</block>
|
|
268
|
+
<block type="math_constrain">
|
|
269
|
+
<value name="VALUE">
|
|
270
|
+
<shadow type="math_number">
|
|
271
|
+
<field name="NUM">50</field>
|
|
272
|
+
</shadow>
|
|
273
|
+
</value>
|
|
274
|
+
<value name="LOW">
|
|
275
|
+
<shadow type="math_number">
|
|
276
|
+
<field name="NUM">1</field>
|
|
277
|
+
</shadow>
|
|
278
|
+
</value>
|
|
279
|
+
<value name="HIGH">
|
|
280
|
+
<shadow type="math_number">
|
|
281
|
+
<field name="NUM">100</field>
|
|
282
|
+
</shadow>
|
|
283
|
+
</value>
|
|
284
|
+
</block>
|
|
285
|
+
<block type="math_random_int">
|
|
286
|
+
<value name="FROM">
|
|
287
|
+
<shadow type="math_number">
|
|
288
|
+
<field name="NUM">1</field>
|
|
289
|
+
</shadow>
|
|
290
|
+
</value>
|
|
291
|
+
<value name="TO">
|
|
292
|
+
<shadow type="math_number">
|
|
293
|
+
<field name="NUM">100</field>
|
|
294
|
+
</shadow>
|
|
295
|
+
</value>
|
|
296
|
+
</block>
|
|
297
|
+
<block type="math_random_float"></block>
|
|
298
|
+
</category>
|
|
299
|
+
<category name="Texto" colour="%{BKY_TEXTS_HUE}">
|
|
300
|
+
<block type="text"></block>
|
|
301
|
+
<block type="text_join"></block>
|
|
302
|
+
<block type="text_append">
|
|
303
|
+
<value name="TEXT">
|
|
304
|
+
<shadow type="text"></shadow>
|
|
305
|
+
</value>
|
|
306
|
+
</block>
|
|
307
|
+
<block type="text_length">
|
|
308
|
+
<value name="VALUE">
|
|
309
|
+
<shadow type="text">
|
|
310
|
+
<field name="TEXT">abc</field>
|
|
311
|
+
</shadow>
|
|
312
|
+
</value>
|
|
313
|
+
</block>
|
|
314
|
+
<block type="text_isEmpty">
|
|
315
|
+
<value name="VALUE">
|
|
316
|
+
<shadow type="text">
|
|
317
|
+
<field name="TEXT"></field>
|
|
318
|
+
</shadow>
|
|
319
|
+
</value>
|
|
320
|
+
</block>
|
|
321
|
+
<block type="text_indexOf">
|
|
322
|
+
<value name="VALUE">
|
|
323
|
+
<block type="variables_get">
|
|
324
|
+
<field name="VAR">{textVariable}</field>
|
|
325
|
+
</block>
|
|
326
|
+
</value>
|
|
327
|
+
<value name="FIND">
|
|
328
|
+
<shadow type="text">
|
|
329
|
+
<field name="TEXT">abc</field>
|
|
330
|
+
</shadow>
|
|
331
|
+
</value>
|
|
332
|
+
</block>
|
|
333
|
+
<block type="text_charAt">
|
|
334
|
+
<value name="VALUE">
|
|
335
|
+
<block type="variables_get">
|
|
336
|
+
<field name="VAR">{textVariable}</field>
|
|
337
|
+
</block>
|
|
338
|
+
</value>
|
|
339
|
+
</block>
|
|
340
|
+
<block type="text_getSubstring">
|
|
341
|
+
<value name="STRING">
|
|
342
|
+
<block type="variables_get">
|
|
343
|
+
<field name="VAR">{textVariable}</field>
|
|
344
|
+
</block>
|
|
345
|
+
</value>
|
|
346
|
+
</block>
|
|
347
|
+
<block type="text_changeCase">
|
|
348
|
+
<value name="TEXT">
|
|
349
|
+
<shadow type="text">
|
|
350
|
+
<field name="TEXT">abc</field>
|
|
351
|
+
</shadow>
|
|
352
|
+
</value>
|
|
353
|
+
</block>
|
|
354
|
+
<block type="text_trim">
|
|
355
|
+
<value name="TEXT">
|
|
356
|
+
<shadow type="text">
|
|
357
|
+
<field name="TEXT">abc</field>
|
|
358
|
+
</shadow>
|
|
359
|
+
</value>
|
|
360
|
+
</block>
|
|
361
|
+
<block type="text_print">
|
|
362
|
+
<value name="TEXT">
|
|
363
|
+
<shadow type="text">
|
|
364
|
+
<field name="TEXT">abc</field>
|
|
365
|
+
</shadow>
|
|
366
|
+
</value>
|
|
367
|
+
</block>
|
|
368
|
+
<block type="text_prompt_ext">
|
|
369
|
+
<value name="TEXT">
|
|
370
|
+
<shadow type="text">
|
|
371
|
+
<field name="TEXT">abc</field>
|
|
372
|
+
</shadow>
|
|
373
|
+
</value>
|
|
374
|
+
</block>
|
|
375
|
+
</category>
|
|
376
|
+
<category name="Listas" colour="%{BKY_LISTS_HUE}">
|
|
377
|
+
<block type="lists_create_with">
|
|
378
|
+
<mutation items="0"></mutation>
|
|
379
|
+
</block>
|
|
380
|
+
<block type="lists_create_with"></block>
|
|
381
|
+
<block type="lists_repeat">
|
|
382
|
+
<value name="NUM">
|
|
383
|
+
<shadow type="math_number">
|
|
384
|
+
<field name="NUM">5</field>
|
|
385
|
+
</shadow>
|
|
386
|
+
</value>
|
|
387
|
+
</block>
|
|
388
|
+
<block type="lists_length"></block>
|
|
389
|
+
<block type="lists_isEmpty"></block>
|
|
390
|
+
<block type="lists_indexOf">
|
|
391
|
+
<value name="VALUE">
|
|
392
|
+
<block type="variables_get">
|
|
393
|
+
<field name="VAR">{listVariable}</field>
|
|
394
|
+
</block>
|
|
395
|
+
</value>
|
|
396
|
+
</block>
|
|
397
|
+
<block type="lists_getIndex">
|
|
398
|
+
<value name="VALUE">
|
|
399
|
+
<block type="variables_get">
|
|
400
|
+
<field name="VAR">{listVariable}</field>
|
|
401
|
+
</block>
|
|
402
|
+
</value>
|
|
403
|
+
</block>
|
|
404
|
+
<block type="lists_setIndex">
|
|
405
|
+
<value name="LIST">
|
|
406
|
+
<block type="variables_get">
|
|
407
|
+
<field name="VAR">{listVariable}</field>
|
|
408
|
+
</block>
|
|
409
|
+
</value>
|
|
410
|
+
</block>
|
|
411
|
+
<block type="lists_getSublist">
|
|
412
|
+
<value name="LIST">
|
|
413
|
+
<block type="variables_get">
|
|
414
|
+
<field name="VAR">{listVariable}</field>
|
|
415
|
+
</block>
|
|
416
|
+
</value>
|
|
417
|
+
</block>
|
|
418
|
+
<block type="lists_split">
|
|
419
|
+
<value name="DELIM">
|
|
420
|
+
<shadow type="text">
|
|
421
|
+
<field name="TEXT">,</field>
|
|
422
|
+
</shadow>
|
|
423
|
+
</value>
|
|
424
|
+
</block>
|
|
425
|
+
<block type="lists_sort"></block>
|
|
426
|
+
</category>
|
|
427
|
+
<sep></sep>
|
|
428
|
+
<category name="Variables" colour="%{BKY_VARIABLES_HUE}" custom="VARIABLE"></category>
|
|
429
|
+
<category name="Funciones" colour="%{BKY_PROCEDURES_HUE}" custom="PROCEDURE"></category>
|
|
430
|
+
<sep></sep>
|
|
431
|
+
<category name="GPIO" colour="210">
|
|
432
|
+
<block type="mpy_esp32_pin_mode_explicit">
|
|
433
|
+
<value name="pin_number">
|
|
434
|
+
<shadow type="math_number">
|
|
435
|
+
<field name="NUM">0</field>
|
|
436
|
+
</shadow>
|
|
437
|
+
</value>
|
|
438
|
+
</block>
|
|
439
|
+
<block type="mpy_esp32_pin_read"></block>
|
|
440
|
+
<block type="mpy_esp32_pin_write">
|
|
441
|
+
<value name="pin_value">
|
|
442
|
+
<shadow type="math_number">
|
|
443
|
+
<field name="NUM">0</field>
|
|
444
|
+
</shadow>
|
|
445
|
+
</value>
|
|
446
|
+
</block>
|
|
447
|
+
</category>
|
|
448
|
+
<category id="timers" name="Temporizadores" colour="65">
|
|
449
|
+
<block type="mpy_sleep_s">
|
|
450
|
+
<value name="time">
|
|
451
|
+
<shadow type="math_number">
|
|
452
|
+
<field name="NUM">1</field>
|
|
453
|
+
</shadow>
|
|
454
|
+
</value>
|
|
455
|
+
</block>
|
|
456
|
+
</category>
|
|
457
|
+
<category id="adc" name="ADC" colour="120">
|
|
458
|
+
<block type="adc_minimal_class_explicit">
|
|
459
|
+
<value name="id_pin">
|
|
460
|
+
<shadow type="math_number">
|
|
461
|
+
<field name="NUM">0</field>
|
|
462
|
+
</shadow>
|
|
463
|
+
</value>
|
|
464
|
+
</block>
|
|
465
|
+
<block type="adc_minimal_read"></block>
|
|
466
|
+
<block type="adc_atten_class">
|
|
467
|
+
<value name="id_pin">
|
|
468
|
+
<shadow type="math_number">
|
|
469
|
+
<field name="NUM">0</field>
|
|
470
|
+
</shadow>
|
|
471
|
+
</value>
|
|
472
|
+
</block>
|
|
473
|
+
<block type="adc_resolution_select_read"></block>
|
|
474
|
+
</category>
|
|
475
|
+
<category id="pwm" name="PWM" colour="290">
|
|
476
|
+
<block type="pwm_minimal_class">
|
|
477
|
+
<value name="pin_id">
|
|
478
|
+
<shadow type="math_number">
|
|
479
|
+
<field name="NUM">0</field>
|
|
480
|
+
</shadow>
|
|
481
|
+
</value>
|
|
482
|
+
</block>
|
|
483
|
+
<block type="pwm_init_deinit">
|
|
484
|
+
</block>
|
|
485
|
+
<block type="pwm_method_freq_duty">
|
|
486
|
+
<value name="argument_funtion">
|
|
487
|
+
<shadow type="math_number">
|
|
488
|
+
<field name="NUM">0</field>
|
|
489
|
+
</shadow>
|
|
490
|
+
</value>
|
|
491
|
+
</block>
|
|
492
|
+
</category>
|
|
493
|
+
<sep></sep>
|
|
494
|
+
<category id="sensors" name="Sensores" colour="195">
|
|
495
|
+
<category id="dht" name="DHT" colour="195">
|
|
496
|
+
<block type="dht_init">
|
|
497
|
+
<value name="pin">
|
|
498
|
+
<shadow type="math_number">
|
|
499
|
+
<field name="NUM">0</field>
|
|
500
|
+
</shadow>
|
|
501
|
+
</value>
|
|
502
|
+
</block>
|
|
503
|
+
<block type="dht_measure"></block>
|
|
504
|
+
<block type="dht_read"></block>
|
|
505
|
+
</category>
|
|
506
|
+
</category>
|
|
507
|
+
<sep></sep>
|
|
508
|
+
</xml>
|
|
509
|
+
`;
|
|
510
|
+
function H(e, t) {
|
|
511
|
+
return e.INFINITE_LOOP_TRAP = null, e.workspaceToCode(t);
|
|
512
|
+
}
|
|
513
|
+
var s = /* @__PURE__ */ ((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 || {}), k = /* @__PURE__ */ ((e) => (e[e.EN = 0] = "EN", e[e.ES = 1] = "ES", e))(k || {}), r = /* @__PURE__ */ ((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))(r || {}), D = /* @__PURE__ */ ((e) => (e[e.WEBSOCKET = 0] = "WEBSOCKET", e[e.TCP_IP = 1] = "TCP_IP", e[e.SERIAL = 2] = "SERIAL", e))(D || {});
|
|
514
|
+
const U = { name: "Python", extension: "py" }, C = "py", v = "json", E = "micropython-esp32", W = "main.py", K = '{"config":{"platform":"micropython-esp32","send":"wifi","ip_mpy":"192.168.4.1","serialport":""},"blocklycode":"<xml xmlns=\\"https://developers.google.com/blockly/xml\\"></xml>"}', X = `# platform: micropython-esp32
|
|
515
|
+
# send: wifi
|
|
516
|
+
# ip_mpy: 192.168.4.1
|
|
517
|
+
# serialport:
|
|
518
|
+
`;
|
|
519
|
+
var _ = /* @__PURE__ */ ((e) => (e.WIFI = "wifi", e.SERIAL = "serial", e))(_ || {});
|
|
520
|
+
const G = "http://" + location.hostname, z = "8080", q = "cors", Y = "nodemcu/";
|
|
521
|
+
async function Z(e, t) {
|
|
522
|
+
try {
|
|
523
|
+
const n = await (await fetch(e, t)).json();
|
|
524
|
+
return n.status == s.OK, n;
|
|
525
|
+
} catch (i) {
|
|
526
|
+
return console.error(i), { status: s.FAILED };
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
async function Q() {
|
|
530
|
+
const e = Y + "getserialportlist", t = G + ":" + z + "/" + e, n = {
|
|
531
|
+
method: "PUT",
|
|
532
|
+
mode: q,
|
|
533
|
+
headers: {
|
|
534
|
+
"Content-Type": "application/json"
|
|
535
|
+
},
|
|
536
|
+
body: JSON.stringify({})
|
|
537
|
+
};
|
|
538
|
+
return await Z(t, n);
|
|
539
|
+
}
|
|
540
|
+
function m(e) {
|
|
541
|
+
return new Promise((t) => setTimeout(t, e));
|
|
542
|
+
}
|
|
543
|
+
async function J(e, t, i) {
|
|
544
|
+
typeof t == "string" ? t = new TextEncoder().encode(t) : t instanceof Uint8Array || (t = new Uint8Array(t));
|
|
545
|
+
const n = new WebSocket("ws://" + i.ipPy + ":" + i.portPy + "/");
|
|
546
|
+
return n.binaryType = "arraybuffer", new Promise((a) => {
|
|
547
|
+
n.onmessage = (o) => {
|
|
548
|
+
console.log(o.data);
|
|
549
|
+
}, n.onopen = async function() {
|
|
550
|
+
console.log("WebSocket connection opened."), await m(100), console.log("This password: " + i.passwordPy), n.send(i.passwordPy + "\r"), await m(100);
|
|
551
|
+
const o = t.length, d = e;
|
|
552
|
+
let l = new Uint8Array(82);
|
|
553
|
+
l[0] = 87, l[1] = 65, l[2] = 1, l[3] = 0, l[4] = 0, l[5] = 0, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = 0, l[11] = 0, l[12] = o & 255, l[13] = o >> 8 & 255, l[14] = o >> 16 & 255, l[15] = o >> 24 & 255, l[16] = d.length & 255, l[17] = d.length >> 8 & 255;
|
|
554
|
+
for (var u = 0; u < 64; ++u)
|
|
555
|
+
u < d.length ? l[18 + u] = d.charCodeAt(u) : l[18 + u] = 0;
|
|
556
|
+
console.log("Send file to micropython: " + e), n.send(l), n.onmessage = async function() {
|
|
557
|
+
for (let f = 0; f < t.length; f += i.chuckSizePy) {
|
|
558
|
+
const F = t.slice(f, f + i.chuckSizePy);
|
|
559
|
+
console.log(F), n.send(F), await m(i.sleepTimePy);
|
|
560
|
+
}
|
|
561
|
+
n.send(""), m(100), n.close(), a({ status: s.OK, data: "File uploaded" });
|
|
562
|
+
};
|
|
563
|
+
}, n.onerror = function(o) {
|
|
564
|
+
a({ status: s.FAILED, data: "WebSocket error" + o });
|
|
565
|
+
}, n.onclose = function() {
|
|
566
|
+
console.log("WebSocket connection closed.");
|
|
567
|
+
};
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
async function $(e, t) {
|
|
571
|
+
const i = new WebSocket("ws://" + t.ipPy + ":" + t.portPy + "/");
|
|
572
|
+
return new Promise((n) => {
|
|
573
|
+
i.onopen = async function() {
|
|
574
|
+
await m(100), i.send(t.passwordPy + "\r"), await m(100), i.send(e), await m(100), i.close(), n({ status: s.OK, data: "File uploaded" });
|
|
575
|
+
}, i.onerror = function(a) {
|
|
576
|
+
n({ status: s.FAILED, data: "WebSocket error" + a });
|
|
577
|
+
}, i.onclose = function() {
|
|
578
|
+
console.log("WebSocket connection closed.");
|
|
579
|
+
}, i.onmessage = (a) => {
|
|
580
|
+
console.log(a.data);
|
|
581
|
+
};
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
const c = {
|
|
585
|
+
micropythonSend: {
|
|
586
|
+
en: "Send",
|
|
587
|
+
es: "Enviar"
|
|
588
|
+
},
|
|
589
|
+
magic: {
|
|
590
|
+
en: "Translate",
|
|
591
|
+
es: "Traducir"
|
|
592
|
+
},
|
|
593
|
+
getSerialportList: {
|
|
594
|
+
en: "Get serial ports",
|
|
595
|
+
es: "Listar puertos seriales"
|
|
596
|
+
},
|
|
597
|
+
docs: {
|
|
598
|
+
en: "Documentation",
|
|
599
|
+
es: "Documentación"
|
|
600
|
+
},
|
|
601
|
+
reset: {
|
|
602
|
+
en: "Reset micropython",
|
|
603
|
+
es: "Reiniciar micropython"
|
|
604
|
+
},
|
|
605
|
+
play: {
|
|
606
|
+
en: "Run main",
|
|
607
|
+
es: "Correr programa principal"
|
|
608
|
+
},
|
|
609
|
+
term: {
|
|
610
|
+
en: "Run terminal",
|
|
611
|
+
es: "Conectersa a micropython"
|
|
612
|
+
}
|
|
613
|
+
}, j = {
|
|
614
|
+
docs: {
|
|
615
|
+
title: {
|
|
616
|
+
en: "Micropython documentation",
|
|
617
|
+
es: "Documentación para Micropython"
|
|
618
|
+
},
|
|
619
|
+
description: {
|
|
620
|
+
en: "Open the next link to get information about Micropython",
|
|
621
|
+
es: " Abre el siguiente enlace para obtener información sobre Micropython"
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
function p(e, t) {
|
|
626
|
+
return t == k.EN ? e.en : t == k.ES ? e.es : "noname";
|
|
627
|
+
}
|
|
628
|
+
function O(e) {
|
|
629
|
+
return {
|
|
630
|
+
ipPy: e.ip_mpy != null && e.ip_mpy != "" ? e.ip_mpy : "",
|
|
631
|
+
portPy: e.port_mpy != null && e.port_mpy != "" ? e.port_mpy : "8266",
|
|
632
|
+
passwordPy: e.password_mpy != null && e.password_mpy != "" ? e.password_mpy : "0000",
|
|
633
|
+
sleepTimePy: e.sleepTime_mpy != null && e.sleepTime_mpy != "" ? parseInt(e.sleepTime_mpy) : 50,
|
|
634
|
+
chuckSizePy: e.chuckSize_mpy != null && e.chuckSize_mpy != "" ? parseInt(e.chuckSize_mpy) : 1024
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
function ee(e, t) {
|
|
638
|
+
return e.extension == C ? { status: s.OK, data: e.content } : e.extension == v && e.config.platform == E ? { status: s.OK, data: t() } : { status: s.FAILED };
|
|
639
|
+
}
|
|
640
|
+
function te(e) {
|
|
641
|
+
return e.extension == C ? e.config.filename != "" && e.config.filename != null ? { status: s.OK, data: e.config.filename } : { status: s.OK, data: e.filename } : e.extension == v && e.config.platform == E ? e.config.filename != "" && e.config.filename != null ? { status: s.OK, data: e.config.filename } : { status: s.OK, data: W } : { status: s.FAILED };
|
|
642
|
+
}
|
|
643
|
+
async function ie(e, t) {
|
|
644
|
+
const i = O(e.config);
|
|
645
|
+
if (i.ipPy == "")
|
|
646
|
+
return { status: s.FAILED };
|
|
647
|
+
let n;
|
|
648
|
+
if (n = te(e), n.status == s.FAILED)
|
|
649
|
+
return n;
|
|
650
|
+
const a = n.data;
|
|
651
|
+
if (n = ee(e, t), n.status == s.FAILED)
|
|
652
|
+
return n;
|
|
653
|
+
const o = n.data;
|
|
654
|
+
return n = await J(a, o, i), n;
|
|
655
|
+
}
|
|
656
|
+
async function ne(e, t) {
|
|
657
|
+
return e.config.send == _.WIFI && (await ie(e, t)).status == s.OK ? {
|
|
658
|
+
typeResult: r.TOAST,
|
|
659
|
+
data: {
|
|
660
|
+
severity: "success",
|
|
661
|
+
summary: "Code save Ok",
|
|
662
|
+
detail: "",
|
|
663
|
+
life: 3e3
|
|
664
|
+
}
|
|
665
|
+
} : {
|
|
666
|
+
typeResult: r.TOAST,
|
|
667
|
+
data: {
|
|
668
|
+
severity: "warn",
|
|
669
|
+
summary: "TODO from send on micropython",
|
|
670
|
+
detail: "",
|
|
671
|
+
life: 3e3
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
async function R(e, t) {
|
|
676
|
+
const i = O(e.config);
|
|
677
|
+
return i.ipPy == "" ? { status: s.FAILED } : await $(t, i);
|
|
678
|
+
}
|
|
679
|
+
async function ae(e) {
|
|
680
|
+
return e.config.send == _.WIFI && (await R(e, "from machine import reset\rreset()\r")).status == s.OK ? {
|
|
681
|
+
typeResult: r.TOAST,
|
|
682
|
+
data: {
|
|
683
|
+
severity: "success",
|
|
684
|
+
summary: "Reset command send",
|
|
685
|
+
detail: "",
|
|
686
|
+
life: 3e3
|
|
687
|
+
}
|
|
688
|
+
} : {
|
|
689
|
+
typeResult: r.TOAST,
|
|
690
|
+
data: {
|
|
691
|
+
severity: "warn",
|
|
692
|
+
summary: "Failed soft reset micropython",
|
|
693
|
+
detail: "",
|
|
694
|
+
life: 1e3
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
async function oe(e) {
|
|
699
|
+
return e.config.send == _.WIFI && (await R(e, "")).status == s.OK ? {
|
|
700
|
+
typeResult: r.TOAST,
|
|
701
|
+
data: {
|
|
702
|
+
severity: "success",
|
|
703
|
+
summary: "Run main command send",
|
|
704
|
+
detail: "",
|
|
705
|
+
life: 3e3
|
|
706
|
+
}
|
|
707
|
+
} : {
|
|
708
|
+
typeResult: r.TOAST,
|
|
709
|
+
data: {
|
|
710
|
+
severity: "warn",
|
|
711
|
+
summary: "Failed run main micropython",
|
|
712
|
+
detail: "",
|
|
713
|
+
life: 1e3
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
async function se(e) {
|
|
718
|
+
const t = e.config.send, i = e.config;
|
|
719
|
+
if (t == _.WIFI) {
|
|
720
|
+
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";
|
|
721
|
+
if (n != "")
|
|
722
|
+
return {
|
|
723
|
+
typeResult: r.TERM,
|
|
724
|
+
data: {
|
|
725
|
+
typeConnection: D.WEBSOCKET,
|
|
726
|
+
data: {
|
|
727
|
+
ip: n,
|
|
728
|
+
port: a,
|
|
729
|
+
user: "",
|
|
730
|
+
password: o,
|
|
731
|
+
endOfCommand: "\r"
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
return {
|
|
737
|
+
typeResult: r.TOAST,
|
|
738
|
+
data: {
|
|
739
|
+
severity: "warn",
|
|
740
|
+
summary: "Failed open terminal micropython",
|
|
741
|
+
detail: "",
|
|
742
|
+
life: 1e3
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
async function le(e, t) {
|
|
747
|
+
return e.extension == v ? {
|
|
748
|
+
typeResult: r.TEXT_PRINT,
|
|
749
|
+
data: {
|
|
750
|
+
title: "Lua",
|
|
751
|
+
content: t()
|
|
752
|
+
}
|
|
753
|
+
} : {
|
|
754
|
+
typeResult: r.TOAST,
|
|
755
|
+
data: {
|
|
756
|
+
severity: "warn",
|
|
757
|
+
summary: "Opción disponible solo con archivos blockly (json)",
|
|
758
|
+
detail: "",
|
|
759
|
+
life: 5e3
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
async function re() {
|
|
764
|
+
const e = await Q();
|
|
765
|
+
if (e.status == s.OK) {
|
|
766
|
+
let t = "";
|
|
767
|
+
for (let i = 0; i < e.data.length; i++)
|
|
768
|
+
t += e.data[i] + `
|
|
769
|
+
`;
|
|
770
|
+
return {
|
|
771
|
+
typeResult: r.TEXT_PRINT,
|
|
772
|
+
data: {
|
|
773
|
+
title: "SerialPortList",
|
|
774
|
+
content: t
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
} else
|
|
778
|
+
return {
|
|
779
|
+
typeResult: r.TOAST,
|
|
780
|
+
data: {
|
|
781
|
+
severity: "warn",
|
|
782
|
+
summary: "No se pudo obtener información sobre los puertos seriales",
|
|
783
|
+
detail: "",
|
|
784
|
+
life: 5e3
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
async function de(e) {
|
|
789
|
+
const a = "http://" + location.hostname + ":" + 8080 + "/plugins/nodemcu/docs/index.html";
|
|
790
|
+
return {
|
|
791
|
+
typeResult: r.URL_PRINT,
|
|
792
|
+
data: {
|
|
793
|
+
title: p(j.docs.title, e),
|
|
794
|
+
content: a,
|
|
795
|
+
description: "Abre el siguiente enlace para obtener infomación sobre la documentación de nodemcu"
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
let g, x, A;
|
|
800
|
+
const pe = E, ce = U, me = K, ue = X;
|
|
801
|
+
function he(e, t, i) {
|
|
802
|
+
A = e, g = t, x = i, S(A, g);
|
|
803
|
+
}
|
|
804
|
+
function T() {
|
|
805
|
+
return H(g, x);
|
|
806
|
+
}
|
|
807
|
+
const _e = B;
|
|
808
|
+
function fe(e) {
|
|
809
|
+
return [
|
|
810
|
+
{
|
|
811
|
+
label: p(c.magic, e),
|
|
812
|
+
icon: "pi pi-sparkles",
|
|
813
|
+
command: "micropython-magic"
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
label: p(c.micropythonSend, e),
|
|
817
|
+
icon: "pi pi-send",
|
|
818
|
+
command: "micropython-send"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
label: "micropython",
|
|
822
|
+
icon: "pi pi-microchip",
|
|
823
|
+
items: [
|
|
824
|
+
{
|
|
825
|
+
label: p(c.getSerialportList, e),
|
|
826
|
+
icon: "pi pi-search",
|
|
827
|
+
command: "nodemcu-getserialportlist"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
label: p(c.docs, e),
|
|
831
|
+
icon: "pi pi-book",
|
|
832
|
+
command: "micropython-docs"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
label: p(c.reset, e),
|
|
836
|
+
icon: "pi pi-refresh",
|
|
837
|
+
command: "micropython-reset"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
label: p(c.play, e),
|
|
841
|
+
icon: "pi pi-play",
|
|
842
|
+
command: "micropython-play"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
label: p(c.term, e),
|
|
846
|
+
icon: "pi pi-sync",
|
|
847
|
+
command: "micropython-term"
|
|
848
|
+
}
|
|
849
|
+
]
|
|
850
|
+
}
|
|
851
|
+
];
|
|
852
|
+
}
|
|
853
|
+
async function ye(e, t, i) {
|
|
854
|
+
return t == "micropython-send" ? await ne(e, T) : t == "micropython-magic" ? await le(e, T) : t == "nodemcu-getserialportlist" ? await re() : t == "micropython-docs" ? await de(i) : t == "micropython-reset" ? await ae(e) : t == "micropython-play" ? await oe(e) : t == "micropython-term" ? await se(e) : {
|
|
855
|
+
typeResult: r.TOAST,
|
|
856
|
+
data: {
|
|
857
|
+
severity: "error",
|
|
858
|
+
summary: "Función no localizada en el plugin",
|
|
859
|
+
detail: "",
|
|
860
|
+
life: 3e3
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
export {
|
|
865
|
+
me as blockly_template,
|
|
866
|
+
ye as commandEmit,
|
|
867
|
+
T as generateCode,
|
|
868
|
+
fe as getItemsToolBarOfPlugin,
|
|
869
|
+
he as initBlockly,
|
|
870
|
+
ue as lang_template,
|
|
871
|
+
pe as platform,
|
|
872
|
+
ce as platformLang,
|
|
873
|
+
_e as toolbox
|
|
874
|
+
};
|