\doxysection{admin\+\_\+pwm.\+ino}
\hypertarget{admin__pwm_8ino_source}{}\label{admin__pwm_8ino_source}\index{examples/admin\_pwm/admin\_pwm.ino@{examples/admin\_pwm/admin\_pwm.ino}}
\doxymbox{\hyperlink{admin__pwm_8ino}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00001}00001\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00002}00002\ //\ ADMIN\ SIMPLE\ -\/\ Solo\ SCAN\ y\ TOGGLE\ RELAY}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00003}00003\ //\ Version\ minimalista\ para\ control\ basico\ I2C}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00004}00004\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00005}00005\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00006}00006\ \#include\ <Wire.h>}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00007}00007\ \#include\ <DevLab\_ICM20948.h>}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00008}00008\ //\ Configuracion\ I2C\ -\/\ Wire1\ con\ GPIO2\ (SDA)\ y\ GPIO3\ (SCL)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00009}00009\ \#define\ WIRE\ Wire}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00010}00010\ \#define\ I2C\_SDA\ 6}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00011}00011\ \#define\ I2C\_SCL\ 7}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00012}00012\ \#define\ I2C\_FREQ\ 100000\ \ //\ 100\ kHz\ -\/\ SEGURO\ para\ inicialización\ (luego\ se\ puede\ subir\ a\ 400kHz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00013}00013\ \#define\ ICM\_ADDR\ 0x69}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00014}00014\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00015}00015\ //\ \ \ \ \ \ \ \ \ \ \ COMANDOS\ CRÍTICOS\ DE\ SEGURIDAD\ (0xA0-\/0xAF)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00016}00016\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00017}00017\ \#define\ CMD\_RELAY\_OFF\ \ \ \ \ \ 0xA0\ \ \ //\ Apagar\ relé\ PA2\ y\ PB5}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00018}00018\ \#define\ CMD\_RELAY\_ON\ \ \ \ \ \ \ 0xA1\ \ \ //\ Encender\ relé\ PA2\ y\ PB5}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00019}00019\ \#define\ CMD\_RELAY\_TOGGLE\ \ \ 0xA6\ \ \ //\ Pulso/Disparo\ relé\ PA2\ y\ PB5}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00020}00020\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00021}00021\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00022}00022\ //\ \ \ \ \ \ \ \ \ \ \ COMANDOS\ NEOPIXEL}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00023}00023\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00024}00024\ \#define\ CMD\_RED\ \ \ \ \ \ \ \ \ \ \ \ 0x02\ \ \ //\ NeoPixels\ rojos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00025}00025\ \#define\ CMD\_GREEN\ \ \ \ \ \ \ \ \ \ 0x03\ \ \ //\ NeoPixels\ verdes}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00026}00026\ \#define\ CMD\_BLUE\ \ \ \ \ \ \ \ \ \ \ 0x04\ \ \ //\ NeoPixels\ azules}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00027}00027\ \#define\ CMD\_OFF\ \ \ \ \ \ \ \ \ \ \ \ 0x05\ \ \ //\ NeoPixels\ apagados\ +\ PWM\ OFF}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00028}00028\ \#define\ CMD\_WHITE\ \ \ \ \ \ \ \ \ \ 0x08\ \ \ //\ NeoPixels\ blancos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00029}00029\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00030}00030\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00031}00031\ //\ \ \ \ \ \ \ \ \ \ \ COMANDOS\ PWM\ /\ BUZZER}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00032}00032\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00033}00033\ \#define\ CMD\_PWM\_OFF\ \ \ \ \ \ \ \ 0x20\ \ \ //\ PWM\ OFF\ -\/\ Silencio}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00034}00034\ \#define\ CMD\_PWM\_25\ \ \ \ \ \ \ \ \ 0x21\ \ \ //\ PWM\ 25\%\ -\/\ Tono\ grave\ 200Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00035}00035\ \#define\ CMD\_PWM\_50\ \ \ \ \ \ \ \ \ 0x22\ \ \ //\ PWM\ 50\%\ -\/\ Tono\ medio\ 500Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00036}00036\ \#define\ CMD\_PWM\_75\ \ \ \ \ \ \ \ \ 0x23\ \ \ //\ PWM\ 75\%\ -\/\ Tono\ agudo\ 1000Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00037}00037\ \#define\ CMD\_PWM\_100\ \ \ \ \ \ \ \ 0x24\ \ \ //\ PWM\ 100\%\ -\/\ Tono\ muy\ agudo\ 2000Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00038}00038\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00039}00039\ //\ Comandos\ deshabilitados\ -\/\ Causan\ problemas\ de\ estabilidad\ I2C}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00040}00040\ /*}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00041}00041\ //\ Notas\ musicales}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00042}00042\ \#define\ CMD\_TONE\_DO\ \ \ \ \ \ \ \ 0x25\ \ \ //\ Tono\ DO\ (261Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00043}00043\ \#define\ CMD\_TONE\_RE\ \ \ \ \ \ \ \ 0x26\ \ \ //\ Tono\ RE\ (294Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00044}00044\ \#define\ CMD\_TONE\_MI\ \ \ \ \ \ \ \ 0x27\ \ \ //\ Tono\ MI\ (330Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00045}00045\ \#define\ CMD\_TONE\_FA\ \ \ \ \ \ \ \ 0x28\ \ \ //\ Tono\ FA\ (349Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00046}00046\ \#define\ CMD\_TONE\_SOL\ \ \ \ \ \ \ 0x29\ \ \ //\ Tono\ SOL\ (392Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00047}00047\ \#define\ CMD\_TONE\_LA\ \ \ \ \ \ \ \ 0x2A\ \ \ //\ Tono\ LA\ (440Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00048}00048\ \#define\ CMD\_TONE\_SI\ \ \ \ \ \ \ \ 0x2B\ \ \ //\ Tono\ SI\ (494Hz)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00049}00049\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00050}00050\ //\ Alertas\ del\ sistema}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00051}00051\ \#define\ CMD\_SUCCESS\ \ \ \ \ \ \ \ 0x2C\ \ \ //\ Success\ -\/\ Tono\ positivo\ 800Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00052}00052\ \#define\ CMD\_OK\ \ \ \ \ \ \ \ \ \ \ \ \ 0x2D\ \ \ //\ OK\ -\/\ Confirmación\ 1000Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00053}00053\ \#define\ CMD\_WARNING\ \ \ \ \ \ \ \ 0x2E\ \ \ //\ Warning\ -\/\ Advertencia\ 1200Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00054}00054\ \#define\ CMD\_ALERT\ \ \ \ \ \ \ \ \ \ 0x2F\ \ \ //\ Alert\ -\/\ Alerta\ crítica\ 1500Hz}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00055}00055\ */}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00056}00056\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00057}00057\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00058}00058\ //\ \ \ \ \ \ \ \ \ \ \ COMANDOS\ LECTURA\ DIGITAL}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00059}00059\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00060}00060\ \#define\ CMD\_PA4\_DIGITAL\ \ \ \ 0x07\ \ \ //\ Leer\ PA0\ como\ entrada\ digital}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00061}00061\ \#define\ RESP\_PA4\_DIGITAL\ \ \ 0x09\ \ \ //\ Respuesta\ PA4\ digital}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00062}00062\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00063}00063\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00064}00064\ //\ \ \ \ \ \ \ \ \ \ \ COMANDOS\ ADC\ 12-\/bit\ (PA1\ interno\ del\ slave)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00065}00065\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00066}00066\ \#define\ CMD\_ADC\_PA1\_HSB\ \ \ \ 0xD8\ \ \ //\ Leer\ ADC\ -\/\ bits\ 11-\/8\ (nibble\ alto)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00067}00067\ \#define\ CMD\_ADC\_PA1\_LSB\ \ \ \ 0xD9\ \ \ //\ Leer\ ADC\ -\/\ bits\ 7-\/0}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00068}00068\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00069}00069\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00070}00070\ //\ \ \ \ \ \ \ \ \ \ \ COMANDOS\ I2C\ ADDRESS\ MANAGEMENT}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00071}00071\ //\ ════════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00072}00072\ \#define\ CMD\_SET\_I2C\_ADDR\ \ \ 0x3D\ \ \ //\ Establecer\ nueva\ dirección\ I2C\ (se\ guarda\ en\ Flash)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00073}00073\ \#define\ CMD\_RESET\_FACTORY\ \ 0x3E\ \ \ //\ Reset\ factory\ (usar\ UID\ por\ defecto)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00074}00074\ \#define\ CMD\_GET\_I2C\_STATUS\ 0x3F\ \ \ //\ Obtener\ estado\ I2C\ (Flash\ vs\ UID)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00075}00075\ \#define\ CMD\_SAVE\_COLOR\ \ \ \ \ 0x46\ \ \ //\ Guardar\ color\ por\ slot\ (1..3\ en\ admin,\ 0..2\ en\ esclavo)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00076}00076\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00077}00077\ \#define\ RESP\_I2C\_ADDR\_SET\ \ 0x0D\ \ \ //\ Nueva\ dirección\ I2C\ establecida}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00078}00078\ \#define\ RESP\_FACTORY\_RESET\ 0x0E\ \ \ //\ Reset\ factory\ ejecutado\ (usar\ UID)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00079}00079\ \#define\ RESP\_I2C\_FROM\_FLASH\ 0x0F\ \ //\ I2C\ usando\ dirección\ desde\ Flash}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00080}00080\ \#define\ RESP\_I2C\_FROM\_UID\ \ 0x0A\ \ \ //\ I2C\ usando\ dirección\ desde\ UID}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00081}00081\ \#define\ RESP\_COLOR\_STAGE\_READY\ 0x15\ //\ Etapa\ de\ save\_color\ lista}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00082}00082\ \#define\ RESP\_COLOR\_SAVED\ \ \ 0x16\ \ \ //\ Color\ guardado\ en\ Flash}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00083}00083\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00084}00084\ //\ Variables\ globales}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00085}00085\ uint8\_t\ found\_devices[128];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00086}00086\ uint8\_t\ device\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00087}00087\ bool\ scan\_loop\_active\ =\ false;\ \ //\ Bandera\ para\ scan\ continuo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00088}00088\ uint32\_t\ last\_scan\_time\ =\ 0;\ \ \ \ //\ Timestamp\ del\ último\ scan}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00089}00089\ uint32\_t\ scan\_interval\ =\ 1000;\ \ //\ Intervalo\ entre\ scans\ (1\ segundo)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00090}00090\ bool\ scan\_in\_progress\ =\ false;\ \ //\ Bandera\ para\ evitar\ scans\ simultáneos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00091}00091\ \#define\ DEVICE\_DELAY\ 30\ \ \ \ \ \ \ \ \ //\ Delay\ óptimo\ entre\ dispositivos\ (ms)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00092}00092\ struct\ DeviceError\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00093}00093\ \ \ uint8\_t\ address;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00094}00094\ \ \ uint32\_t\ error\_count;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00095}00095\ \ \ uint32\_t\ success\_count;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00096}00096\ \ \ uint32\_t\ last\_error\_time;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00097}00097\ \};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00098}00098\ DeviceError\ device\_errors[128];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00099}00099\ int\ device\_error\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00100}00100\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00101}00101\ //\ Test\ mode}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00102}00102\ bool\ test\_mode\_active\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00103}00103\ uint32\_t\ test\_interval\ =\ 100;\ \ //\ Intervalo\ de\ test\ (100ms\ por\ defecto)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00104}00104\ uint32\_t\ test\_start\_time\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00105}00105\ uint32\_t\ test\_duration\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00106}00106\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00107}00107\ //\ PA0\ Digital\ reading\ stats}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00108}00108\ struct\ DigitalReadStats\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00109}00109\ \ \ uint8\_t\ address;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00110}00110\ \ \ uint32\_t\ read\_count;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00111}00111\ \ \ uint32\_t\ fail\_count;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00112}00112\ \ \ uint8\_t\ last\_state;\ \ //\ 0=LOW,\ 1=HIGH}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00113}00113\ \ \ uint32\_t\ last\_read\_time;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00114}00114\ \};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00115}00115\ DigitalReadStats\ digital\_stats[128];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00116}00116\ int\ digital\_stats\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00117}00117\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00118}00118\ //\ Test\ mode\ para\ lecturas\ digitales}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00119}00119\ bool\ read\_test\_active\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00120}00120\ uint32\_t\ read\_test\_interval\ =\ 100;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00121}00121\ uint32\_t\ read\_test\_start\_time\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00122}00122\ uint32\_t\ read\_test\_duration\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00123}00123\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00124}00124\ //\ Flag\ para\ reimprimir\ menú\ cuando\ se\ conecta\ Serial}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00125}00125\ bool\ menu\_shown\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00126}00126\ uint32\_t\ last\_serial\_check\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00127}00127\ bool\ i2c\_safe\_mode\ =\ false;\ \ //\ Modo\ seguro\ si\ I2C\ está\ bloqueado}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00128}00128\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00129}00129\ DevLab\_ICM20948\ imu;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00130}00130\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00131}00131\ void\ setup()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00132}00132\ \ \ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00133}00133\ \ \ //\ PASO\ 1:\ INICIALIZAR\ USB/CDC\ PRIMERO\ (CRÍTICO\ EN\ RP2040/RP2350)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00134}00134\ \ \ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00135}00135\ \ \ Serial.begin(115200);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00136}00136\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00137}00137\ \ \ \#if\ defined(ARDUINO\_ARCH\_RP2040)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00138}00138\ \ \ \ \ //\ RP2040/RP2350:\ Esperar\ a\ que\ USB\ enumere\ ANTES\ de\ tocar\ I2C}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00139}00139\ \ \ \ \ //\ Esto\ evita\ que\ I2C\ bloquee\ IRQs\ y\ mate\ el\ CDC}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00140}00140\ \ \ \ \ uint32\_t\ t0\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00141}00141\ \ \ \ \ while\ (!Serial\ \&\&\ millis()\ -\/\ t0\ <\ 2000)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00142}00142\ \ \ \ \ \ \ delay(10);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00143}00143\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00144}00144\ \ \ \ \ delay(200);\ \ //\ Margen\ extra\ de\ seguridad}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00145}00145\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00146}00146\ \ \ \ \ Serial.println("{}\(\backslash\)n[RP2040/RP2350]\ USB\ CDC\ listo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00147}00147\ \ \ \#else}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00148}00148\ \ \ \ \ delay(500);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00149}00149\ \ \ \#endif}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00150}00150\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00151}00151\ \ \ Serial.println("{}\(\backslash\)n\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00152}00152\ \ \ Serial.println("{}╔═══════════════════════════════════════╗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00153}00153\ \ \ Serial.println("{}║\ \ \ ADMIN\ PWM\ -\/\ I2C\ Control\ \ \ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00154}00154\ \ \ Serial.println("{}║\ \ \ Scan\ +\ Relay\ +\ PWM/Buzzer\ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00155}00155\ \ \ Serial.println("{}╚═══════════════════════════════════════╝"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00156}00156\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00157}00157\ \ \ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00158}00158\ \ \ //\ PASO\ 2:\ AHORA\ SÍ\ INICIALIZAR\ I2C\ (USB\ ya\ está\ vivo)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00159}00159\ \ \ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00160}00160\ \ \ Serial.println("{}\(\backslash\)n[INFO]\ Inicializando\ I2C..."{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00161}00161\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00162}00162\ \ \ //\ Verificar\ que\ SDA/SCL\ no\ estén\ bloqueados\ ANTES\ de\ WIRE.begin()}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00163}00163\ \ \ Serial.println("{}[CHECK]\ Verificando\ bus\ I2C..."{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00164}00164\ \ \ pinMode(I2C\_SDA,\ INPUT\_PULLUP);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00165}00165\ \ \ pinMode(I2C\_SCL,\ INPUT\_PULLUP);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00166}00166\ \ \ delay(10);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00167}00167\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00168}00168\ \ \ bool\ sda\_ok\ =\ digitalRead(I2C\_SDA);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00169}00169\ \ \ bool\ scl\_ok\ =\ digitalRead(I2C\_SCL);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00170}00170\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00171}00171\ \ \ Serial.printf("{}\ \ SDA\ (GPIO\%d):\ \%s\(\backslash\)n"{},\ I2C\_SDA,\ sda\_ok\ ?\ "{}HIGH\ ✓"{}\ :\ "{}LOW\ ✗\ BLOQUEADO"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00172}00172\ \ \ Serial.printf("{}\ \ SCL\ (GPIO\%d):\ \%s\(\backslash\)n"{},\ I2C\_SCL,\ scl\_ok\ ?\ "{}HIGH\ ✓"{}\ :\ "{}LOW\ ✗\ BLOQUEADO"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00173}00173\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00174}00174\ \ \ if\ (!sda\_ok\ ||\ !scl\_ok)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00175}00175\ \ \ \ \ Serial.println("{}\(\backslash\)n[ERROR]\ Bus\ I2C\ bloqueado!"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00176}00176\ \ \ \ \ Serial.println("{}CAUSA:\ Dispositivo\ esclavo\ colgado\ o\ sin\ pull-\/ups"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00177}00177\ \ \ \ \ Serial.println("{}SOLUCION:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00178}00178\ \ \ \ \ Serial.println("{}\ \ 1.\ Desconecta\ todos\ los\ dispositivos\ I2C"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00179}00179\ \ \ \ \ Serial.println("{}\ \ 2.\ Verifica\ resistencias\ pull-\/up\ (4.7k\ ohm)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00180}00180\ \ \ \ \ Serial.println("{}\ \ 3.\ Resetea\ el\ RP2350"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00181}00181\ \ \ \ \ Serial.println("{}\(\backslash\)n[MODO\ SEGURO]\ I2C\ NO\ inicializado"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00182}00182\ \ \ \ \ i2c\_safe\_mode\ =\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00183}00183\ \ \ \ \ //\ NO\ return\ -\/\ continuar\ para\ procesar\ comandos\ seriales}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00184}00184\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00185}00185\ \ \ \ \ Serial.println("{}[OK]\ Bus\ I2C\ libre"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00186}00186\ \ \ \ \ i2c\_safe\_mode\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00187}00187\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00188}00188\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00189}00189\ \ \ //\ Solo\ inicializar\ I2C\ si\ el\ bus\ está\ libre}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00190}00190\ \ \ if\ (!i2c\_safe\_mode)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00191}00191\ \ \ \ \ //\ Inicializar\ I2C\ con\ Wire1}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00192}00192\ \ \ \ \ //\ RP2040\ /\ RP2350:\ configurar\ pines\ ANTES\ de\ begin()}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00193}00193\ \ \ \ \ //\ WIRE.setSDA(I2C\_SDA);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00194}00194\ \ \ \ \ //\ WIRE.setSCL(I2C\_SCL);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00195}00195\ \ \ \ \ WIRE.begin(I2C\_SDA,I2C\_SCL);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00196}00196\ \ \ \ \ WIRE.setClock(I2C\_FREQ);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00197}00197\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00198}00198\ \ \ \ \ if(!imu.beginI2C(ICM\_ADDR,WIRE,I2C\_FREQ))\{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00199}00199\ \ \ \ \ \ \ Serial.println(F("{}ERROR:\ beginI2C()\ failed"{}));}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00200}00200\ \ \ \ \ \ \ while\ (1)\ delay(200);\ \ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00201}00201\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00202}00202\ \ \ \ \ if(!imu.auxMasterEnable(0x07))\{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00203}00203\ \ \ \ \ \ \ Serial.println(F("{}ERROR:\ enableAuxMaster()\ failed"{}));}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00204}00204\ \ \ \ \ \ \ while\ (1)\ delay(200);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00205}00205\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00206}00206\ \ \ \ \ //\ Deshabilitado\ temporalmente:\ bloqueaba\ el\ arranque\ (while(1))\ si\ el}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00207}00207\ \ \ \ \ //\ esclavo\ en\ 0x2B\ no\ respondia\ al\ registro\ 0x31\ (valores\ eran\ para\ el}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00208}00208\ \ \ \ \ //\ magnetometro\ AK09916,\ no\ para\ el\ esclavo\ de\ relay/PWM).}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00209}00209\ \ \ \ \ /*}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00210}00210\ \ \ \ \ if(!imu.auxWriteByte(0x2B,\ 0x31,\ 0x08))\{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00211}00211\ \ \ \ \ \ \ \ Serial.println(F("{}ERROR:\ auxwritebyte())\ failed"{}));}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00212}00212\ \ \ \ \ \ \ while\ (1)\ delay(200);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00213}00213\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00214}00214\ \ \ \ \ */}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00215}00215\ \ \ \ \ Serial.println("{}[OK]\ I2C\ inicializado\ sin\ bloquear\ USB"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00216}00216\ \ \ \ \ Serial.printf("{}\ \ \ \ \ Wire1\ -\/\ SDA:GPIO\%d\ SCL:GPIO\%d\ @\ \%d\ kHz\(\backslash\)n"{},\ I2C\_SDA,\ I2C\_SCL,\ I2C\_FREQ/1000);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00217}00217\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00218}00218\ \ \ \}\ \ //\ Fin\ de\ if\ (!i2c\_safe\_mode)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00219}00219\ \ \ \ \ bool\ mag\_ok\ =\ imu.initMag();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00220}00220\ \ \ Serial.printf("{}[TEST]\ initMag()\ =\ \%s\(\backslash\)n"{},\ mag\_ok\ ?\ "{}OK"{}\ :\ "{}FAIL"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00221}00221\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00222}00222\ \ \ Serial.println("{}\(\backslash\)nComandos\ disponibles:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00223}00223\ \ \ Serial.println("{}\ \ s\ \ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Scan\ dispositivos\ I2C"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00224}00224\ \ \ Serial.println("{}\ \ loop\ \ \ \ \ \ \ \ \ \ \ -\/\ Scan\ continuo\ (cada\ 1\ seg)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00225}00225\ \ \ Serial.println("{}\ \ stop\ \ \ \ \ \ \ \ \ \ \ -\/\ Detener\ scan\ continuo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00226}00226\ \ \ Serial.println("{}\ \ t\ XX\ \ \ \ \ \ \ \ \ \ \ -\/\ Pulso\ relay\ (XX\ =\ addr\ hex)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00227}00227\ \ \ Serial.println("{}\ \ on\ XX\ \ \ \ \ \ \ \ \ \ -\/\ Encender\ relay"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00228}00228\ \ \ Serial.println("{}\ \ off\ XX\ \ \ \ \ \ \ \ \ -\/\ Apagar\ relay"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00229}00229\ \ \ Serial.println("{}\ \ help\ \ \ \ \ \ \ \ \ \ \ -\/\ Mostrar\ ayuda"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00230}00230\ \ \ Serial.println("{}\(\backslash\)nEjemplos:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00231}00231\ \ \ Serial.println("{}\ \ s\ \ \ \ \ \ \ \ \ \ \ \ \ \ (scan\ de\ dispositivos)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00232}00232\ \ \ Serial.println("{}\ \ loop\ \ \ \ \ \ \ \ \ \ \ (scan\ continuo)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00233}00233\ \ \ Serial.println("{}\ \ stop\ \ \ \ \ \ \ \ \ \ \ (detener\ scan)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00234}00234\ \ \ Serial.println("{}\ \ t\ 32\ \ \ \ \ \ \ \ \ \ \ (toggle\ relay\ en\ 0x20)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00235}00235\ \ \ Serial.println("{}\ \ off\ 32\ \ \ \ \ \ \ \ \ (apagar\ relay\ en\ 0x20)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00236}00236\ \ \ Serial.println("{}\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00237}00237\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00238}00238\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00239}00239\ void\ loop()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00240}00240\ \ \ //\ Reimprimir\ menú\ si\ se\ reconecta\ el\ Serial\ Monitor}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00241}00241\ \ \ \#if\ defined(ARDUINO\_ARCH\_RP2040)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00242}00242\ \ \ \ \ if\ (Serial\ \&\&\ !menu\_shown\ \&\&\ millis()\ -\/\ last\_serial\_check\ >\ 1000)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00243}00243\ \ \ \ \ \ \ showMenu();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00244}00244\ \ \ \ \ \ \ menu\_shown\ =\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00245}00245\ \ \ \ \ \ \ last\_serial\_check\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00246}00246\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00247}00247\ \ \ \ \ if\ (!Serial)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00248}00248\ \ \ \ \ \ \ menu\_shown\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00249}00249\ \ \ \ \ \ \ last\_serial\_check\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00250}00250\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00251}00251\ \ \ \#endif\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00252}00252\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00253}00253\ \ \ //\ Procesar\ comandos\ desde\ Serial}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00254}00254\ \ \ if\ (Serial.available())\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00255}00255\ \ \ \ \ String\ cmd\ =\ Serial.readStringUntil('\(\backslash\)n');}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00256}00256\ \ \ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00257}00257\ \ \ \ \ cmd.toLowerCase();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00258}00258\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00259}00259\ \ \ \ \ if\ (cmd.length()\ >\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00260}00260\ \ \ \ \ \ \ processCommand(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00261}00261\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00262}00262\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00263}00263\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00264}00264\ \ \ //\ Ejecutar\ scan\ continuo\ si\ está\ activo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00265}00265\ \ \ if\ (scan\_loop\_active\ \&\&\ !scan\_in\_progress)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00266}00266\ \ \ \ \ if\ (millis()\ -\/\ last\_scan\_time\ >=\ scan\_interval)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00267}00267\ \ \ \ \ \ \ scanDevices();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00268}00268\ \ \ \ \ \ \ last\_scan\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00269}00269\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00270}00270\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00271}00271\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00272}00272\ \ \ //\ Ejecutar\ test\ asíncrono\ si\ está\ activo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00273}00273\ \ \ if\ (test\_mode\_active)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00274}00274\ \ \ \ \ if\ (millis()\ -\/\ last\_scan\_time\ >=\ test\_interval)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00275}00275\ \ \ \ \ \ \ testDevices();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00276}00276\ \ \ \ \ \ \ last\_scan\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00277}00277\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00278}00278\ \ \ \ \ //\ Verificar\ si\ el\ test\ debe\ terminar}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00279}00279\ \ \ \ \ if\ (test\_duration\ >\ 0\ \&\&\ (millis()\ -\/\ test\_start\_time\ >=\ test\_duration))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00280}00280\ \ \ \ \ \ \ stopTest();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00281}00281\ \ \ \ \ \ \ showTestResults();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00282}00282\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00283}00283\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00284}00284\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00285}00285\ \ \ //\ Ejecutar\ test\ de\ lectura\ digital\ si\ está\ activo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00286}00286\ \ \ if\ (read\_test\_active)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00287}00287\ \ \ \ \ if\ (millis()\ -\/\ last\_scan\_time\ >=\ read\_test\_interval)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00288}00288\ \ \ \ \ \ \ testReadDigital();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00289}00289\ \ \ \ \ \ \ last\_scan\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00290}00290\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00291}00291\ \ \ \ \ //\ Verificar\ si\ el\ test\ debe\ terminar}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00292}00292\ \ \ \ \ if\ (read\_test\_duration\ >\ 0\ \&\&\ (millis()\ -\/\ read\_test\_start\_time\ >=\ read\_test\_duration))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00293}00293\ \ \ \ \ \ \ stopReadTest();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00294}00294\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00295}00295\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00296}00296\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00297}00297\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00298}00298\ void\ processCommand(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00299}00299\ \ \ if\ (cmd\ ==\ "{}s"{}\ ||\ cmd\ ==\ "{}scan"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00300}00300\ \ \ \ \ scanDevices();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00301}00301\ \ \ \}\ else\ if\ (cmd\ ==\ "{}loop"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00302}00302\ \ \ \ \ startScanLoop();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00303}00303\ \ \ \}\ else\ if\ (cmd\ ==\ "{}stop"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00304}00304\ \ \ \ \ stopScanLoop();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00305}00305\ \ \ \}\ else\ if\ (cmd\ ==\ "{}menu"{}\ ||\ cmd\ ==\ "{}m"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00306}00306\ \ \ \ \ showMenu();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00307}00307\ \ \ \}\ else\ if\ (cmd.startsWith("{}test\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00308}00308\ \ \ \ \ startTest(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00309}00309\ \ \ \}\ else\ if\ (cmd\ ==\ "{}stoptest"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00310}00310\ \ \ \ \ stopTest();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00311}00311\ \ \ \ \ showTestResults();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00312}00312\ \ \ \}\ else\ if\ (cmd\ ==\ "{}errors"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00313}00313\ \ \ \ \ showTestResults();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00314}00314\ \ \ \}\ else\ if\ (cmd.startsWith("{}adc\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00315}00315\ \ \ \ \ readADC(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00316}00316\ \ \ \}\ else\ if\ (cmd.startsWith("{}read\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00317}00317\ \ \ \ \ readDigital(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00318}00318\ \ \ \}\ else\ if\ (cmd\ ==\ "{}dstats"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00319}00319\ \ \ \ \ showDigitalStats();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00320}00320\ \ \ \}\ else\ if\ (cmd.startsWith("{}readtest\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00321}00321\ \ \ \ \ startReadTest(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00322}00322\ \ \ \}\ else\ if\ (cmd\ ==\ "{}stopread"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00323}00323\ \ \ \ \ stopReadTest();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00324}00324\ \ \ \}\ else\ if\ (cmd.startsWith("{}t\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00325}00325\ \ \ \ \ toggleRelay(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00326}00326\ \ \ \}\ else\ if\ (cmd.startsWith("{}on\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00327}00327\ \ \ \ \ relayOn(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00328}00328\ \ \ \}\ else\ if\ (cmd.startsWith("{}off\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00329}00329\ \ \ \ \ relayOff(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00330}00330\ \ \ \}\ else\ if\ (cmd.startsWith("{}pwm\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00331}00331\ \ \ \ \ pwmCommand(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00332}00332\ \ \ /*}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00333}00333\ \ \ //\ Comandos\ deshabilitados}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00334}00334\ \ \ \}\ else\ if\ (cmd.startsWith("{}note\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00335}00335\ \ \ \ \ playNote(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00336}00336\ \ \ \}\ else\ if\ (cmd.startsWith("{}alert\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00337}00337\ \ \ \ \ playAlert(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00338}00338\ \ \ */}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00339}00339\ \ \ \}\ else\ if\ (cmd\ ==\ "{}silence"{}\ ||\ cmd\ ==\ "{}pwmoff"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00340}00340\ \ \ \ \ pwmOff();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00341}00341\ \ \ \}\ else\ if\ (cmd.startsWith("{}neo\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00342}00342\ \ \ \ \ neoCommand(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00343}00343\ \ \ \}\ else\ if\ (cmd.startsWith("{}red\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00344}00344\ \ \ \ \ neoRed(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00345}00345\ \ \ \}\ else\ if\ (cmd.startsWith("{}green\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00346}00346\ \ \ \ \ neoGreen(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00347}00347\ \ \ \}\ else\ if\ (cmd.startsWith("{}blue\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00348}00348\ \ \ \ \ neoBlue(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00349}00349\ \ \ \}\ else\ if\ (cmd.startsWith("{}white\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00350}00350\ \ \ \ \ neoWhite(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00351}00351\ \ \ \}\ else\ if\ (cmd\ ==\ "{}neooff"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00352}00352\ \ \ \ \ neoOff();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00353}00353\ \ \ \}\ else\ if\ (cmd.startsWith("{}ch\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00354}00354\ \ \ \ \ changeI2CAddress(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00355}00355\ \ \ \}\ else\ if\ (cmd.startsWith("{}save\_color\ "{}))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00356}00356\ \ \ \ \ \ saveColorPreset(cmd);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00357}00357\ \ \ \}else\ if\ (cmd\ ==\ "{}help"{}\ ||\ cmd\ ==\ "{}h"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00358}00358\ \ \ \ \ showHelp();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00359}00359\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00360}00360\ \ \ \ \ Serial.println("{}ERROR:\ Comando\ desconocido.\ Usa\ 'help'\ o\ 'menu'\ para\ ver\ comandos."{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00361}00361\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00362}00362\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00363}00363\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00364}00364\ void\ showMenu()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00365}00365\ \ \ Serial.println("{}\(\backslash\)n\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00366}00366\ \ \ Serial.println("{}╔═══════════════════════════════════════╗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00367}00367\ \ \ Serial.println("{}║\ \ \ ADMIN\ PWM\ -\/\ I2C\ Control\ \ \ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00368}00368\ \ \ Serial.println("{}║\ \ \ Scan\ +\ Relay\ +\ PWM/Buzzer\ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00369}00369\ \ \ Serial.println("{}╚═══════════════════════════════════════╝"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00370}00370\ \ \ Serial.println("{}[OK]\ I2C\ inicializado\ sin\ bloquear\ USB"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00371}00371\ \ \ Serial.printf("{}\ \ \ \ \ SDA:GPIO\%d\ SCL:GPIO\%d\ @\ \%d\ kHz\(\backslash\)n"{},\ I2C\_SDA,\ I2C\_SCL,\ I2C\_FREQ/1000);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00372}00372\ \ \ Serial.println("{}\(\backslash\)nComandos\ disponibles:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00373}00373\ \ \ Serial.println("{}\ \ s\ /\ menu\ \ \ \ \ \ \ -\/\ Scan\ dispositivos\ /\ mostrar\ menu"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00374}00374\ \ \ Serial.println("{}\ \ loop\ \ \ \ \ \ \ \ \ \ \ -\/\ Scan\ continuo\ (cada\ 1\ seg)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00375}00375\ \ \ Serial.println("{}\ \ stop\ \ \ \ \ \ \ \ \ \ \ -\/\ Detener\ scan\ continuo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00376}00376\ \ \ Serial.println("{}\ \ t\ XX\ \ \ \ \ \ \ \ \ \ \ -\/\ Pulso\ relay\ (XX\ =\ addr\ hex)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00377}00377\ \ \ Serial.println("{}\ \ on\ XX\ \ \ \ \ \ \ \ \ \ -\/\ Encender\ relay"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00378}00378\ \ \ Serial.println("{}\ \ off\ XX\ \ \ \ \ \ \ \ \ -\/\ Apagar\ relay"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00379}00379\ \ \ Serial.println("{}\ \ pwm\ XX\ NIVEL\ \ \ -\/\ PWM\ (25,\ 50,\ 75,\ 100,\ off)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00380}00380\ \ \ Serial.println("{}\ \ silence\ \ \ \ \ \ \ \ -\/\ Apagar\ PWM\ en\ todos"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00381}00381\ \ \ Serial.println("{}\ \ neo\ XX\ COLOR\ \ \ -\/\ NeoPixel\ (red/green/blue/white/off\ o\ 1/2/3/4/0)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00382}00382\ \ \ Serial.println("{}\ \ ch\ XX\ YY\ \ \ \ \ \ \ -\/\ Cambiar\ dir\ I2C\ (XX=old,\ YY=new)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00383}00383\ \ \ Serial.println("{}\ \ save\_color\ A\ P\ R\ G\ B\ -\/\ Guardar\ color\ por\ slot\ (1..3)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00384}00384\ \ \ Serial.println("{}\ \ help\ \ \ \ \ \ \ \ \ \ \ -\/\ Mostrar\ ayuda\ completa"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00385}00385\ \ \ Serial.println("{}\(\backslash\)nEjemplos:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00386}00386\ \ \ Serial.println("{}\ \ s\ \ \ \ \ \ \ \ \ \ \ \ \ \ (scan\ de\ dispositivos)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00387}00387\ \ \ Serial.println("{}\ \ menu\ \ \ \ \ \ \ \ \ \ \ (mostrar\ este\ menu)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00388}00388\ \ \ Serial.println("{}\ \ pwm\ 20\ 50\ \ \ \ \ \ (PWM\ 50\%\ en\ 0x20)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00389}00389\ \ \ Serial.println("{}\ \ silence\ \ \ \ \ \ \ \ (apagar\ PWM\ en\ todos)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00390}00390\ \ \ Serial.println("{}\ \ neo\ 20\ 1\ \ \ \ \ \ \ (NeoPixel\ rojo\ en\ 0x20)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00391}00391\ \ \ Serial.println("{}\ \ save\_color\ 20\ 1\ 0x00\ 0xff\ 0x60"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00392}00392\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00393}00393\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00394}00394\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00395}00395\ void\ scanDevices()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00396}00396\ \ \ //\ Verificar\ si\ estamos\ en\ modo\ seguro}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00397}00397\ \ \ if\ (i2c\_safe\_mode)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00398}00398\ \ \ \ \ Serial.println("{}[ERROR]\ I2C\ en\ MODO\ SEGURO\ -\/\ comando\ no\ disponible"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00399}00399\ \ \ \ \ Serial.println("{}Desconecta\ dispositivos\ I2C\ y\ resetea\ el\ dispositivo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00400}00400\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00401}00401\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00402}00402\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00403}00403\ \ \ //\ Evitar\ scans\ simultáneos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00404}00404\ \ \ if\ (scan\_in\_progress)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00405}00405\ \ \ \ \ Serial.println("{}⚠\ Scan\ ya\ en\ progreso,\ esperando..."{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00406}00406\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00407}00407\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00408}00408\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00409}00409\ \ \ scan\_in\_progress\ =\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00410}00410\ \ \ Serial.println("{}\(\backslash\)n━━━\ SCAN\ I2C\ +\ TOGGLE\ ━━━"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00411}00411\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00412}00412\ \ \ device\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00413}00413\ \ \ memset(found\_devices,\ 0,\ sizeof(found\_devices));}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00414}00414\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00415}00415\ \ \ WIRE.setTimeout(50);\ \ //\ Timeout\ corto\ para\ velocidad}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00416}00416\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00417}00417\ \ \ for\ (uint8\_t\ addr\ =\ 0x08;\ addr\ <=\ 0x77;\ addr++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00418}00418\ \ \ \ \ /*}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00419}00419\ \ \ \ \ WIRE.beginTransmission(addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00420}00420\ \ \ \ \ uint8\_t\ error\ =\ WIRE.endTransmission();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00421}00421\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00422}00422\ \ \ \ \ if\ (error\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00423}00423\ \ \ \ \ \ \ found\_devices[device\_count++]\ =\ addr;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00424}00424\ \ \ \ \ \ \ Serial.printf("{}\ \ [\%02d]\ 0x\%02X\ (\%3d)\ →\ "{},\ device\_count,\ addr,\ addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00425}00425\ \ \ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00426}00426\ \ \ \ \ \ \ //\ Enviar\ toggle\ automático\ SIN\ esperar\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00427}00427\ \ \ \ \ \ \ if\ (sendCommandFast(addr,\ CMD\_RELAY\_TOGGLE))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00428}00428\ \ \ \ \ \ \ \ \ Serial.println("{}TOGGLE\ ✓"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00429}00429\ \ \ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00430}00430\ \ \ \ \ \ \ \ \ Serial.println("{}TOGGLE\ ✗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00431}00431\ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00432}00432\ \ \ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00433}00433\ \ \ \ \ \ \ delay(DEVICE\_DELAY);\ //\ Delay\ optimizado:\ 30ms}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00434}00434\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00435}00435\ \ \ \ \ \ \ */}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00436}00436\ \ \ \ \ \ \ \ \ uint8\_t\ dummy;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00437}00437\ \ \ \ \ //\ auxReadByte\ retorna\ true\ si\ el\ dispositivo\ hace\ ACK}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00438}00438\ \ \ \ \ if\ (imu.auxReadByte(addr,\ 0x00,\ dummy))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00439}00439\ \ \ \ \ \ \ found\_devices[device\_count++]\ =\ addr;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00440}00440\ \ \ \ \ \ \ Serial.printf("{}\ \ [\%02d]\ 0x\%02X\ (\%3d)\ →\ "{},\ device\_count,\ addr,\ addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00441}00441\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00442}00442\ \ \ \ \ \ \ if\ (imu.auxWriteCommand(addr,\ CMD\_RELAY\_TOGGLE))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00443}00443\ \ \ \ \ \ \ \ \ Serial.println("{}TOGGLE\ ✓"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00444}00444\ \ \ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00445}00445\ \ \ \ \ \ \ \ \ Serial.println("{}TOGGLE\ ✗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00446}00446\ \ \ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00447}00447\ \ \ \ \ \ \ delay(DEVICE\_DELAY);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00448}00448\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00449}00449\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00450}00450\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00451}00451\ \ \ Serial.println("{}━━━━━━━━━━━━━━━━"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00452}00452\ \ \ Serial.printf("{}Total:\ \%d\ dispositivos\(\backslash\)n\(\backslash\)n"{},\ device\_count);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00453}00453\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00454}00454\ \ \ if\ (device\_count\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00455}00455\ \ \ \ \ Serial.println("{}⚠\ No\ se\ encontraron\ dispositivos\ I2C"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00456}00456\ \ \ \ \ Serial.println("{}\ \ Verifica\ conexiones\ y\ pull-\/ups\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00457}00457\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00458}00458\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00459}00459\ \ \ scan\_in\_progress\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00460}00460\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00461}00461\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00462}00462\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00463}00463\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00464}00464\ void\ toggleRelay(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00465}00465\ \ \ //\ Verificar\ si\ estamos\ en\ modo\ seguro}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00466}00466\ \ \ if\ (i2c\_safe\_mode)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00467}00467\ \ \ \ \ Serial.println("{}[ERROR]\ I2C\ en\ MODO\ SEGURO\ -\/\ comando\ no\ disponible"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00468}00468\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00469}00469\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00470}00470\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00471}00471\ \ \ String\ addr\_str\ =\ cmd.substring(2);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00472}00472\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00473}00473\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00474}00474\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00475}00475\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00476}00476\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00477}00477\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00478}00478\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00479}00479\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00480}00480\ \ \ if\ (sendCommand(address,\ CMD\_RELAY\_TOGGLE))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00481}00481\ \ \ \ \ Serial.printf("{}[OK]\ Pulso\ relay\ en\ 0x\%02X\ (10ms)\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00482}00482\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00483}00483\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ enviar\ pulso\ a\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00484}00484\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00485}00485\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00486}00486\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00487}00487\ void\ relayOn(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00488}00488\ \ \ String\ addr\_str\ =\ cmd.substring(3);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00489}00489\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00490}00490\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00491}00491\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00492}00492\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00493}00493\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00494}00494\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00495}00495\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00496}00496\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00497}00497\ \ \ if\ (sendCommand(address,\ CMD\_RELAY\_ON))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00498}00498\ \ \ \ \ Serial.printf("{}[OK]\ Relay\ ON\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00499}00499\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00500}00500\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ encender\ relay\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00501}00501\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00502}00502\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00503}00503\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00504}00504\ void\ relayOff(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00505}00505\ \ \ String\ addr\_str\ =\ cmd.substring(4);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00506}00506\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00507}00507\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00508}00508\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00509}00509\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00510}00510\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00511}00511\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00512}00512\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00513}00513\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00514}00514\ \ \ if\ (sendCommand(address,\ CMD\_RELAY\_OFF))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00515}00515\ \ \ \ \ Serial.printf("{}[OK]\ Relay\ OFF\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00516}00516\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00517}00517\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ apagar\ relay\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00518}00518\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00519}00519\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00520}00520\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00521}00521\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00522}00522\ //\ \ \ \ \ \ \ \ \ \ \ LECTURA\ DIGITAL\ PA0}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00523}00523\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00524}00524\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00525}00525\ void\ readADC(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00526}00526\ \ \ String\ addr\_str\ =\ cmd.substring(4);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00527}00527\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00528}00528\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00529}00529\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00530}00530\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00531}00531\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00532}00532\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00533}00533\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00534}00534\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00535}00535\ \ \ uint16\_t\ raw\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00536}00536\ \ \ if\ (readADC12(address,\ raw))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00537}00537\ \ \ \ \ float\ voltage\ =\ raw\ *\ (3.3f\ /\ 4095.0f);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00538}00538\ \ \ \ \ Serial.printf("{}[OK]\ 0x\%02X\ -\/\ ADC:\ \%u\ (\%.3f\ V)\(\backslash\)n"{},\ address,\ raw,\ voltage);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00539}00539\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00540}00540\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ leer\ ADC\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00541}00541\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00542}00542\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00543}00543\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00544}00544\ void\ readDigital(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00545}00545\ \ \ String\ addr\_str\ =\ cmd.substring(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00546}00546\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00547}00547\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00548}00548\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00549}00549\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00550}00550\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00551}00551\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00552}00552\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00553}00553\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00554}00554\ \ \ uint8\_t\ state\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00555}00555\ \ \ bool\ success\ =\ readPA0Digital(address,\ \&state);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00556}00556\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00557}00557\ \ \ if\ (success)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00558}00558\ \ \ \ \ Serial.printf("{}[OK]\ 0x\%02X\ -\/\ PA0\ Digital:\ \%s\(\backslash\)n"{},\ address,\ state\ ?\ "{}HIGH"{}\ :\ "{}LOW"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00559}00559\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00560}00560\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ leer\ PA0\ digital\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00561}00561\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00562}00562\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00563}00563\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00564}00564\ bool\ readPA0Digital(uint8\_t\ address,\ uint8\_t*\ state)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00565}00565\ \ \ //\ Enviar\ comando\ de\ lectura\ PA0\ digital}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00566}00566\ \ \ WIRE.beginTransmission(address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00567}00567\ \ \ WIRE.write(CMD\_PA4\_DIGITAL);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00568}00568\ \ \ uint8\_t\ error\ =\ WIRE.endTransmission();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00569}00569\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00570}00570\ \ \ if\ (error\ !=\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00571}00571\ \ \ \ \ updateDigitalStats(address,\ false,\ 0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00572}00572\ \ \ \ \ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00573}00573\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00574}00574\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00575}00575\ \ \ //\ Esperar\ procesamiento}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00576}00576\ \ \ delay(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00577}00577\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00578}00578\ \ \ //\ Leer\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00579}00579\ \ \ WIRE.setTimeout(50);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00580}00580\ \ \ uint8\_t\ bytesRead\ =\ WIRE.requestFrom(address,\ (uint8\_t)1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00581}00581\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00582}00582\ \ \ if\ (bytesRead\ ==\ 1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00583}00583\ \ \ \ \ uint8\_t\ response\ =\ WIRE.read();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00584}00584\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00585}00585\ \ \ \ \ //\ El\ estado\ digital\ está\ en\ el\ nibble\ alto\ (bit\ 7-\/4)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00586}00586\ \ \ \ \ //\ 0xF0\ =\ HIGH,\ 0x00\ =\ LOW}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00587}00587\ \ \ \ \ *state\ =\ (response\ \&\ 0xF0)\ ?\ 1\ :\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00588}00588\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00589}00589\ \ \ \ \ updateDigitalStats(address,\ true,\ *state);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00590}00590\ \ \ \ \ return\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00591}00591\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00592}00592\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00593}00593\ \ \ updateDigitalStats(address,\ false,\ 0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00594}00594\ \ \ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00595}00595\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00596}00596\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00597}00597\ bool\ readADC12(uint8\_t\ address,\ uint16\_t\ \&raw)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00598}00598\ \ \ uint8\_t\ hi\ =\ 0,\ lo\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00599}00599\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00600}00600\ \ \ //\ El\ slave\ necesita\ transacciones\ SEPARADAS:\ write\ (comando)\ →\ STOP,}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00601}00601\ \ \ //\ slave\ procesa\ +\ convierte\ ADC\ (\string~20ms),\ luego\ read\ independiente.}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00602}00602\ \ \ //\ auxReadByte\ hace\ write+RSTART+read\ combinado\ →\ el\ slave\ no\ alcanza}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00603}00603\ \ \ //\ a\ llamar\ HAL\_I2C\_Slave\_Transmit\ →\ NACK.}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00604}00604\ \ \ //\ auxReadResponse\ hace\ solo\ [START,\ addr+R,\ 1byte,\ STOP].}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00605}00605\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00606}00606\ \ \ if\ (!imu.auxWriteCommand(address,\ CMD\_ADC\_PA1\_HSB))\ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00607}00607\ \ \ delay(25);\ \ //\ slave:\ main\ loop\ +\ conversión\ ADC\ (HAL\_ADC\_PollForConversion,\ max\ 20ms)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00608}00608\ \ \ if\ (!imu.auxReadResponse(address,\ hi))\ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00609}00609\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00610}00610\ \ \ //\ LSB:\ el\ slave\ usa\ valor\ cacheado\ (adc\_last\_read\ <\ 50ms\ →\ mismo\ sample\ que\ HSB)}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00611}00611\ \ \ if\ (!imu.auxWriteCommand(address,\ CMD\_ADC\_PA1\_LSB))\ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00612}00612\ \ \ delay(5);\ \ \ //\ sin\ conversión\ nueva,\ solo\ tiempo\ de\ main\ loop}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00613}00613\ \ \ if\ (!imu.auxReadResponse(address,\ lo))\ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00614}00614\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00615}00615\ \ \ raw\ =\ ((uint16\_t)(hi\ \&\ 0x0F)\ <<\ 8)\ |\ lo;\ \ //\ 0–4095}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00616}00616\ \ \ return\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00617}00617\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00618}00618\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00619}00619\ void\ updateDigitalStats(uint8\_t\ address,\ bool\ success,\ uint8\_t\ state)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00620}00620\ \ \ //\ Buscar\ dispositivo\ en\ el\ array}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00621}00621\ \ \ int\ index\ =\ -\/1;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00622}00622\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ digital\_stats\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00623}00623\ \ \ \ \ if\ (digital\_stats[i].address\ ==\ address)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00624}00624\ \ \ \ \ \ \ index\ =\ i;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00625}00625\ \ \ \ \ \ \ break;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00626}00626\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00627}00627\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00628}00628\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00629}00629\ \ \ //\ Si\ no\ existe,\ agregarlo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00630}00630\ \ \ if\ (index\ ==\ -\/1\ \&\&\ digital\_stats\_count\ <\ 128)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00631}00631\ \ \ \ \ index\ =\ digital\_stats\_count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00632}00632\ \ \ \ \ digital\_stats[index].address\ =\ address;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00633}00633\ \ \ \ \ digital\_stats[index].read\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00634}00634\ \ \ \ \ digital\_stats[index].fail\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00635}00635\ \ \ \ \ digital\_stats[index].last\_state\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00636}00636\ \ \ \ \ digital\_stats[index].last\_read\_time\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00637}00637\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00638}00638\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00639}00639\ \ \ if\ (index\ >=\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00640}00640\ \ \ \ \ digital\_stats[index].read\_count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00641}00641\ \ \ \ \ if\ (!success)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00642}00642\ \ \ \ \ \ \ digital\_stats[index].fail\_count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00643}00643\ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00644}00644\ \ \ \ \ \ \ digital\_stats[index].last\_state\ =\ state;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00645}00645\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00646}00646\ \ \ \ \ digital\_stats[index].last\_read\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00647}00647\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00648}00648\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00649}00649\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00650}00650\ void\ showDigitalStats()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00651}00651\ \ \ if\ (digital\_stats\_count\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00652}00652\ \ \ \ \ Serial.println("{}No\ hay\ estadisticas\ de\ lectura\ digital"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00653}00653\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00654}00654\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00655}00655\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00656}00656\ \ \ Serial.println("{}\(\backslash\)n╔════════════════════════════════════════════════════════╗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00657}00657\ \ \ Serial.println("{}║\ \ \ \ \ \ ESTADISTICAS\ DE\ LECTURA\ DIGITAL\ PA0\ \ \ \ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00658}00658\ \ \ Serial.println("{}╠════════════════════════════════════════════════════════╣"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00659}00659\ \ \ Serial.println("{}║\ Addr\ │\ Lecturas\ │\ Fallos\ │\ Tasa\ OK\ │\ Estado\ │\ \ Tiempo\ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00660}00660\ \ \ Serial.println("{}╠════════════════════════════════════════════════════════╣"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00661}00661\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00662}00662\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ digital\_stats\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00663}00663\ \ \ \ \ DigitalReadStats*\ stats\ =\ \&digital\_stats[i];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00664}00664\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00665}00665\ \ \ \ \ float\ success\_rate\ =\ 0.0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00666}00666\ \ \ \ \ if\ (stats-\/>read\_count\ >\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00667}00667\ \ \ \ \ \ \ success\_rate\ =\ ((float)(stats-\/>read\_count\ -\/\ stats-\/>fail\_count)\ /\ stats-\/>read\_count)\ *\ 100.0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00668}00668\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00669}00669\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00670}00670\ \ \ \ \ uint32\_t\ time\_since\ =\ (millis()\ -\/\ stats-\/>last\_read\_time)\ /\ 1000;\ \ //\ segundos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00671}00671\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00672}00672\ \ \ \ \ Serial.printf("{}║\ 0x\%02X\ │\ \%8lu\ │\ \%6lu\ │\ \%6.1f\%\%\ │\ \%4s\ \ \ │\ \%4lus\ \ \ ║\(\backslash\)n"{},}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00673}00673\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ stats-\/>address,}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00674}00674\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ stats-\/>read\_count,}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00675}00675\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ stats-\/>fail\_count,}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00676}00676\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ success\_rate,}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00677}00677\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ stats-\/>last\_state\ ?\ "{}HIGH"{}\ :\ "{}LOW"{},}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00678}00678\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ time\_since);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00679}00679\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00680}00680\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00681}00681\ \ \ Serial.println("{}╚════════════════════════════════════════════════════════╝"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00682}00682\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00683}00683\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00684}00684\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00685}00685\ //\ \ \ \ \ \ \ \ \ \ \ TEST\ DE\ LECTURA\ DIGITAL\ CONTINUA}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00686}00686\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00687}00687\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00688}00688\ void\ startReadTest(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00689}00689\ \ \ //\ Formato:\ "{}readtest\ <intervalo\_ms>\ <duracion\_ms>"{}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00690}00690\ \ \ //\ Ejemplo:\ "{}readtest\ 100\ 10000"{}\ =\ leer\ cada\ 100ms\ durante\ 10\ segundos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00691}00691\ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00692}00692\ \ \ int\ space1\ =\ cmd.indexOf('\ ',\ 9);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00693}00693\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00694}00694\ \ \ if\ (space1\ ==\ -\/1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00695}00695\ \ \ \ \ Serial.println("{}ERROR:\ Formato\ incorrecto"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00696}00696\ \ \ \ \ Serial.println("{}Uso:\ readtest\ <intervalo\_ms>\ <duracion\_ms>"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00697}00697\ \ \ \ \ Serial.println("{}Ejemplo:\ readtest\ 100\ 10000\ \ (leer\ cada\ 100ms\ por\ 10\ seg)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00698}00698\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00699}00699\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00700}00700\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00701}00701\ \ \ String\ interval\_str\ =\ cmd.substring(9,\ space1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00702}00702\ \ \ String\ duration\_str\ =\ cmd.substring(space1\ +\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00703}00703\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00704}00704\ \ \ read\_test\_interval\ =\ interval\_str.toInt();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00705}00705\ \ \ read\_test\_duration\ =\ duration\_str.toInt();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00706}00706\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00707}00707\ \ \ //\ Validar\ rango}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00708}00708\ \ \ if\ (read\_test\_interval\ <\ 30)\ read\_test\_interval\ =\ 30;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00709}00709\ \ \ if\ (read\_test\_interval\ >\ 1000)\ read\_test\_interval\ =\ 1000;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00710}00710\ \ \ if\ (read\_test\_duration\ <\ 1000)\ read\_test\_duration\ =\ 1000;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00711}00711\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00712}00712\ \ \ //\ Reset\ contadores\ de\ lectura\ digital}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00713}00713\ \ \ digital\_stats\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00714}00714\ \ \ memset(digital\_stats,\ 0,\ sizeof(digital\_stats));}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00715}00715\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00716}00716\ \ \ read\_test\_active\ =\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00717}00717\ \ \ read\_test\_start\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00718}00718\ \ \ last\_scan\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00719}00719\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00720}00720\ \ \ Serial.println("{}\(\backslash\)n[READ\ TEST\ MODE\ ACTIVADO]"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00721}00721\ \ \ Serial.printf("{}Intervalo:\ \%lu\ ms\(\backslash\)n"{},\ read\_test\_interval);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00722}00722\ \ \ Serial.printf("{}Duración:\ \%lu\ ms\ (\%.1f\ seg)\(\backslash\)n"{},\ read\_test\_duration,\ read\_test\_duration\ /\ 1000.0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00723}00723\ \ \ Serial.println("{}Dispositivos\ a\ leer:\ "{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00724}00724\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00725}00725\ \ \ \ \ Serial.printf("{}\ \ 0x\%02X\(\backslash\)n"{},\ found\_devices[i]);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00726}00726\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00727}00727\ \ \ Serial.println("{}Usa\ 'stopread'\ para\ detener\ antes\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00728}00728\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00729}00729\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00730}00730\ void\ stopReadTest()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00731}00731\ \ \ read\_test\_active\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00732}00732\ \ \ uint32\_t\ elapsed\ =\ millis()\ -\/\ read\_test\_start\_time;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00733}00733\ \ \ Serial.println("{}\(\backslash\)n[READ\ TEST\ MODE\ DETENIDO]"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00734}00734\ \ \ Serial.printf("{}Tiempo\ transcurrido:\ \%.2f\ segundos\(\backslash\)n"{},\ elapsed\ /\ 1000.0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00735}00735\ \ \ showDigitalStats();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00736}00736\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00737}00737\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00738}00738\ void\ testReadDigital()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00739}00739\ \ \ WIRE.setTimeout(50);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00740}00740\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00741}00741\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00742}00742\ \ \ \ \ uint8\_t\ addr\ =\ found\_devices[i];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00743}00743\ \ \ \ \ uint8\_t\ state\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00744}00744\ \ \ \ \ readPA0Digital(addr,\ \&state);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00745}00745\ \ \ \ \ delay(read\_test\_interval\ /\ device\_count);\ \ //\ Distribuir\ tiempo\ entre\ dispositivos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00746}00746\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00747}00747\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00748}00748\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00749}00749\ bool\ sendCommand(uint8\_t\ address,\ uint8\_t\ command)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00750}00750\ \ \ /*WIRE.beginTransmission(address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00751}00751\ \ \ WIRE.write(command);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00752}00752\ \ \ uint8\_t\ error\ =\ WIRE.endTransmission();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00753}00753\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00754}00754\ \ \ if\ (error\ !=\ 0)\ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00755}00755\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00756}00756\ \ \ //\ Esperar\ respuesta\ con\ timeout\ más\ generoso}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00757}00757\ \ \ delay(20);\ \ //\ Dar\ tiempo\ al\ esclavo\ para\ procesar}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00758}00758\ \ \ WIRE.setTimeout(100);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00759}00759\ \ \ uint8\_t\ bytesRead\ =\ WIRE.requestFrom(address,\ (uint8\_t)1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00760}00760\ \ \ if\ (bytesRead\ ==\ 1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00761}00761\ \ \ \ \ WIRE.read();\ \ //\ Leer\ y\ descartar\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00762}00762\ \ \ \ \ return\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00763}00763\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00764}00764\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00765}00765\ \ \ return\ false;*/}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00766}00766\ \ \ return\ imu.auxWriteCommand(address,\ command);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00767}00767\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00768}00768\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00769}00769\ //\ Función\ para\ leer\ respuesta\ del\ dispositivo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00770}00770\ uint8\_t\ readResponse(uint8\_t\ address)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00771}00771\ \ \ delay(10);\ \ //\ Pequeño\ delay\ para\ que\ el\ dispositivo\ prepare\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00772}00772\ \ \ WIRE.setTimeout(100);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00773}00773\ \ \ uint8\_t\ bytesRead\ =\ WIRE.requestFrom(address,\ (uint8\_t)1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00774}00774\ \ \ if\ (bytesRead\ ==\ 1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00775}00775\ \ \ \ \ return\ WIRE.read();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00776}00776\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00777}00777\ \ \ return\ 0xFF;\ \ //\ Error:\ no\ se\ recibió\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00778}00778\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00779}00779\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00780}00780\ //\ Versión\ rápida:\ enviar\ comando\ SIN\ esperar\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00781}00781\ bool\ sendCommandFast(uint8\_t\ address,\ uint8\_t\ command)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00782}00782\ \ \ WIRE.beginTransmission(address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00783}00783\ \ \ WIRE.write(command);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00784}00784\ \ \ uint8\_t\ error\ =\ WIRE.endTransmission();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00785}00785\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00786}00786\ \ \ //\ Actualizar\ contador\ de\ errores}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00787}00787\ \ \ updateDeviceError(address,\ error\ ==\ 0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00788}00788\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00789}00789\ \ \ return\ (error\ ==\ 0);\ \ //\ Solo\ verificar\ que\ se\ envió}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00790}00790\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00791}00791\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00792}00792\ void\ updateDeviceError(uint8\_t\ address,\ bool\ success)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00793}00793\ \ \ //\ Buscar\ dispositivo\ en\ el\ array}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00794}00794\ \ \ int\ index\ =\ -\/1;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00795}00795\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_error\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00796}00796\ \ \ \ \ if\ (device\_errors[i].address\ ==\ address)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00797}00797\ \ \ \ \ \ \ index\ =\ i;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00798}00798\ \ \ \ \ \ \ break;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00799}00799\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00800}00800\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00801}00801\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00802}00802\ \ \ //\ Si\ no\ existe,\ agregarlo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00803}00803\ \ \ if\ (index\ ==\ -\/1\ \&\&\ device\_error\_count\ <\ 128)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00804}00804\ \ \ \ \ index\ =\ device\_error\_count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00805}00805\ \ \ \ \ device\_errors[index].address\ =\ address;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00806}00806\ \ \ \ \ device\_errors[index].error\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00807}00807\ \ \ \ \ device\_errors[index].success\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00808}00808\ \ \ \ \ device\_errors[index].last\_error\_time\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00809}00809\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00810}00810\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00811}00811\ \ \ //\ Actualizar\ contadores}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00812}00812\ \ \ if\ (index\ !=\ -\/1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00813}00813\ \ \ \ \ if\ (success)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00814}00814\ \ \ \ \ \ \ device\_errors[index].success\_count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00815}00815\ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00816}00816\ \ \ \ \ \ \ device\_errors[index].error\_count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00817}00817\ \ \ \ \ \ \ device\_errors[index].last\_error\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00818}00818\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00819}00819\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00820}00820\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00821}00821\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00822}00822\ void\ startTest(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00823}00823\ \ \ //\ Formato:\ "{}test\ <intervalo\_ms>\ <duracion\_ms>"{}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00824}00824\ \ \ //\ Ejemplo:\ "{}test\ 50\ 5000"{}\ =\ test\ cada\ 50ms\ durante\ 5\ segundos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00825}00825\ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00826}00826\ \ \ int\ space1\ =\ cmd.indexOf('\ ',\ 5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00827}00827\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00828}00828\ \ \ if\ (space1\ ==\ -\/1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00829}00829\ \ \ \ \ Serial.println("{}ERROR:\ Formato\ incorrecto"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00830}00830\ \ \ \ \ Serial.println("{}Uso:\ test\ <intervalo\_ms>\ <duracion\_ms>"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00831}00831\ \ \ \ \ Serial.println("{}Ejemplo:\ test\ 50\ 5000\ \ (test\ cada\ 50ms\ por\ 5\ seg)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00832}00832\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00833}00833\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00834}00834\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00835}00835\ \ \ String\ interval\_str\ =\ cmd.substring(5,\ space1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00836}00836\ \ \ String\ duration\_str\ =\ cmd.substring(space1\ +\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00837}00837\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00838}00838\ \ \ test\_interval\ =\ interval\_str.toInt();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00839}00839\ \ \ test\_duration\ =\ duration\_str.toInt();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00840}00840\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00841}00841\ \ \ //\ Validar\ rango}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00842}00842\ \ \ if\ (test\_interval\ <\ 30)\ test\_interval\ =\ 30;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00843}00843\ \ \ if\ (test\_interval\ >\ 1000)\ test\_interval\ =\ 1000;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00844}00844\ \ \ if\ (test\_duration\ <\ 1000)\ test\_duration\ =\ 1000;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00845}00845\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00846}00846\ \ \ //\ Reset\ contadores}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00847}00847\ \ \ device\_error\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00848}00848\ \ \ memset(device\_errors,\ 0,\ sizeof(device\_errors));}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00849}00849\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00850}00850\ \ \ test\_mode\_active\ =\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00851}00851\ \ \ test\_start\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00852}00852\ \ \ last\_scan\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00853}00853\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00854}00854\ \ \ Serial.println("{}\(\backslash\)n[TEST\ MODE\ ACTIVADO]"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00855}00855\ \ \ Serial.printf("{}Intervalo:\ \%lu\ ms\(\backslash\)n"{},\ test\_interval);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00856}00856\ \ \ Serial.printf("{}Duración:\ \%lu\ ms\ (\%.1f\ seg)\(\backslash\)n"{},\ test\_duration,\ test\_duration\ /\ 1000.0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00857}00857\ \ \ Serial.println("{}Usa\ 'stoptest'\ para\ detener\ antes\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00858}00858\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00859}00859\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00860}00860\ void\ stopTest()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00861}00861\ \ \ test\_mode\_active\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00862}00862\ \ \ uint32\_t\ elapsed\ =\ millis()\ -\/\ test\_start\_time;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00863}00863\ \ \ Serial.println("{}\(\backslash\)n[TEST\ MODE\ DETENIDO]"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00864}00864\ \ \ Serial.printf("{}Tiempo\ transcurrido:\ \%.2f\ segundos\(\backslash\)n\(\backslash\)n"{},\ elapsed\ /\ 1000.0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00865}00865\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00866}00866\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00867}00867\ void\ testDevices()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00868}00868\ \ \ //\ Verificar\ si\ estamos\ en\ modo\ seguro}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00869}00869\ \ \ if\ (i2c\_safe\_mode)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00870}00870\ \ \ \ \ Serial.println("{}[ERROR]\ I2C\ en\ MODO\ SEGURO\ -\/\ comando\ no\ disponible"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00871}00871\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00872}00872\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00873}00873\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00874}00874\ \ \ WIRE.setTimeout(50);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00875}00875\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00876}00876\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00877}00877\ \ \ \ \ uint8\_t\ addr\ =\ found\_devices[i];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00878}00878\ \ \ \ \ sendCommandFast(addr,\ CMD\_RELAY\_TOGGLE);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00879}00879\ \ \ \ \ delay(test\_interval\ /\ device\_count);\ \ //\ Distribuir\ tiempo\ entre\ dispositivos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00880}00880\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00881}00881\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00882}00882\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00883}00883\ void\ showTestResults()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00884}00884\ \ \ Serial.println("{}\(\backslash\)n╔═══════════════════════════════════════════════════╗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00885}00885\ \ \ Serial.println("{}║\ \ \ \ \ \ \ \ \ \ \ RESULTADOS\ DE\ TEST\ I2C\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00886}00886\ \ \ Serial.println("{}╚═══════════════════════════════════════════════════╝\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00887}00887\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00888}00888\ \ \ if\ (device\_error\_count\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00889}00889\ \ \ \ \ Serial.println("{}No\ hay\ datos\ de\ test\ disponibles\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00890}00890\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00891}00891\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00892}00892\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00893}00893\ \ \ uint32\_t\ total\_success\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00894}00894\ \ \ uint32\_t\ total\_errors\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00895}00895\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00896}00896\ \ \ Serial.println("{}Addr\ \ |\ Success\ |\ Errors\ |\ Tasa\ Éxito\ |\ Último\ Error"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00897}00897\ \ \ Serial.println("{}-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00898}00898\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00899}00899\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_error\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00900}00900\ \ \ \ \ uint8\_t\ addr\ =\ device\_errors[i].address;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00901}00901\ \ \ \ \ uint32\_t\ success\ =\ device\_errors[i].success\_count;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00902}00902\ \ \ \ \ uint32\_t\ errors\ =\ device\_errors[i].error\_count;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00903}00903\ \ \ \ \ uint32\_t\ total\ =\ success\ +\ errors;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00904}00904\ \ \ \ \ float\ rate\ =\ total\ >\ 0\ ?\ (success\ *\ 100.0\ /\ total)\ :\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00905}00905\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00906}00906\ \ \ \ \ total\_success\ +=\ success;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00907}00907\ \ \ \ \ total\_errors\ +=\ errors;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00908}00908\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00909}00909\ \ \ \ \ Serial.printf("{}0x\%02X\ \ |\ \%7lu\ |\ \%6lu\ |\ \%6.2f\%\%\ \ \ |\ "{},\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00910}00910\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ addr,\ success,\ errors,\ rate);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00911}00911\ \ \ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00912}00912\ \ \ \ \ if\ (errors\ >\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00913}00913\ \ \ \ \ \ \ uint32\_t\ since\_error\ =\ (millis()\ -\/\ device\_errors[i].last\_error\_time)\ /\ 1000;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00914}00914\ \ \ \ \ \ \ Serial.printf("{}\%lu\ seg\(\backslash\)n"{},\ since\_error);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00915}00915\ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00916}00916\ \ \ \ \ \ \ Serial.println("{}Nunca"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00917}00917\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00918}00918\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00919}00919\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00920}00920\ \ \ Serial.println("{}-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00921}00921\ \ \ uint32\_t\ grand\_total\ =\ total\_success\ +\ total\_errors;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00922}00922\ \ \ float\ overall\_rate\ =\ grand\_total\ >\ 0\ ?\ (total\_success\ *\ 100.0\ /\ grand\_total)\ :\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00923}00923\ \ \ Serial.printf("{}TOTAL\ |\ \%7lu\ |\ \%6lu\ |\ \%6.2f\%\%\ \ \ |\(\backslash\)n\(\backslash\)n"{},\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00924}00924\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ total\_success,\ total\_errors,\ overall\_rate);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00925}00925\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00926}00926\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00927}00927\ uint8\_t\ parseHex(String\ hex\_str)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00928}00928\ \ \ hex\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00929}00929\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00930}00930\ \ \ //\ Convertir\ de\ hexadecimal}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00931}00931\ \ \ char*\ endptr;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00932}00932\ \ \ long\ addr\ =\ strtol(hex\_str.c\_str(),\ \&endptr,\ 16);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00933}00933\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00934}00934\ \ \ if\ (*endptr\ !=\ '\(\backslash\)0'\ ||\ addr\ <\ 0x08\ ||\ addr\ >\ 0x77)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00935}00935\ \ \ \ \ return\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00936}00936\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00937}00937\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00938}00938\ \ \ return\ (uint8\_t)addr;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00939}00939\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00940}00940\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00941}00941\ bool\ parseByteAuto(String\ value\_str,\ uint8\_t*\ out)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00942}00942\ \ \ value\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00943}00943\ \ \ char*\ endptr;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00944}00944\ \ \ long\ value\ =\ strtol(value\_str.c\_str(),\ \&endptr,\ 0);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00945}00945\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00946}00946\ \ \ if\ (*endptr\ !=\ '\(\backslash\)0'\ ||\ value\ <\ 0\ ||\ value\ >\ 0xFF)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00947}00947\ \ \ \ \ return\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00948}00948\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00949}00949\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00950}00950\ \ \ *out\ =\ (uint8\_t)value;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00951}00951\ \ \ return\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00952}00952\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00953}00953\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00954}00954\ void\ startScanLoop()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00955}00955\ \ \ scan\_loop\_active\ =\ true;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00956}00956\ \ \ last\_scan\_time\ =\ millis();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00957}00957\ \ \ Serial.println("{}\(\backslash\)n[OK]\ Scan\ continuo\ ACTIVADO"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00958}00958\ \ \ Serial.printf("{}\ \ \ \ \ Intervalo:\ \%lu\ ms\(\backslash\)n"{},\ scan\_interval);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00959}00959\ \ \ Serial.println("{}\ \ \ \ \ Usa\ 'stop'\ para\ detener\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00960}00960\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00961}00961\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00962}00962\ void\ stopScanLoop()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00963}00963\ \ \ scan\_loop\_active\ =\ false;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00964}00964\ \ \ Serial.println("{}\(\backslash\)n[OK]\ Scan\ continuo\ DETENIDO\(\backslash\)n"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00965}00965\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00966}00966\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00967}00967\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00968}00968\ //\ \ \ \ \ \ \ \ \ \ \ FUNCIONES\ PWM\ /\ BUZZER}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00969}00969\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00970}00970\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00971}00971\ void\ pwmOff()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00972}00972\ \ \ Serial.println("{}\(\backslash\)n━━━\ APAGAR\ PWM\ (TODOS)\ ━━━"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00973}00973\ \ \ int\ count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00974}00974\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00975}00975\ \ \ \ \ uint8\_t\ addr\ =\ found\_devices[i];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00976}00976\ \ \ \ \ if\ (sendCommand(addr,\ CMD\_PWM\_OFF))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00977}00977\ \ \ \ \ \ \ Serial.printf("{}\ \ [OK]\ 0x\%02X\ -\/\ PWM\ apagado\(\backslash\)n"{},\ addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00978}00978\ \ \ \ \ \ \ count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00979}00979\ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00980}00980\ \ \ \ \ \ \ Serial.printf("{}\ \ [FAIL]\ 0x\%02X\(\backslash\)n"{},\ addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00981}00981\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00982}00982\ \ \ \ \ delay(10);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00983}00983\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00984}00984\ \ \ Serial.printf("{}\(\backslash\)nTotal:\ \%d/\%d\ dispositivos\(\backslash\)n"{},\ count,\ device\_count);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00985}00985\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00986}00986\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00987}00987\ void\ pwmCommand(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00988}00988\ \ \ //\ Formato:\ "{}pwm\ XX\ NIVEL"{}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00989}00989\ \ \ //\ XX\ =\ dirección\ hex,\ NIVEL\ =\ 25,\ 50,\ 75,\ 100,\ off}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00990}00990\ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00991}00991\ \ \ int\ space\ =\ cmd.indexOf('\ ',\ 4);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00992}00992\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00993}00993\ \ \ if\ (space\ ==\ -\/1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00994}00994\ \ \ \ \ Serial.println("{}ERROR:\ Formato\ incorrecto"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00995}00995\ \ \ \ \ Serial.println("{}Uso:\ pwm\ XX\ NIVEL"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00996}00996\ \ \ \ \ Serial.println("{}Ejemplo:\ pwm\ 20\ 50\ \ (PWM\ 50\%\ en\ 0x20)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00997}00997\ \ \ \ \ Serial.println("{}Niveles:\ 25,\ 50,\ 75,\ 100,\ off"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00998}00998\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l00999}00999\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01000}01000\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01001}01001\ \ \ String\ addr\_str\ =\ cmd.substring(4,\ space);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01002}01002\ \ \ String\ level\_str\ =\ cmd.substring(space\ +\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01003}01003\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01004}01004\ \ \ level\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01005}01005\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01006}01006\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01007}01007\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01008}01008\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01009}01009\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01010}01010\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01011}01011\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01012}01012\ \ \ uint8\_t\ pwm\_cmd\ =\ CMD\_PWM\_OFF;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01013}01013\ \ \ String\ level\_name\ =\ "{}OFF"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01014}01014\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01015}01015\ \ \ if\ (level\_str\ ==\ "{}off"{}\ ||\ level\_str\ ==\ "{}0"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01016}01016\ \ \ \ \ pwm\_cmd\ =\ CMD\_PWM\_OFF;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01017}01017\ \ \ \ \ level\_name\ =\ "{}OFF"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01018}01018\ \ \ \}\ else\ if\ (level\_str\ ==\ "{}25"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01019}01019\ \ \ \ \ pwm\_cmd\ =\ CMD\_PWM\_25;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01020}01020\ \ \ \ \ level\_name\ =\ "{}25\%\ (200Hz)"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01021}01021\ \ \ \}\ else\ if\ (level\_str\ ==\ "{}50"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01022}01022\ \ \ \ \ pwm\_cmd\ =\ CMD\_PWM\_50;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01023}01023\ \ \ \ \ level\_name\ =\ "{}50\%\ (500Hz)"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01024}01024\ \ \ \}\ else\ if\ (level\_str\ ==\ "{}75"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01025}01025\ \ \ \ \ pwm\_cmd\ =\ CMD\_PWM\_75;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01026}01026\ \ \ \ \ level\_name\ =\ "{}75\%\ (1000Hz)"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01027}01027\ \ \ \}\ else\ if\ (level\_str\ ==\ "{}100"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01028}01028\ \ \ \ \ pwm\_cmd\ =\ CMD\_PWM\_100;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01029}01029\ \ \ \ \ level\_name\ =\ "{}100\%\ (2000Hz)"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01030}01030\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01031}01031\ \ \ \ \ Serial.println("{}ERROR:\ Nivel\ invalido.\ Usa:\ 25,\ 50,\ 75,\ 100,\ off"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01032}01032\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01033}01033\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01034}01034\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01035}01035\ \ \ if\ (sendCommand(address,\ pwm\_cmd))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01036}01036\ \ \ \ \ Serial.printf("{}[OK]\ PWM\ \%s\ en\ 0x\%02X\(\backslash\)n"{},\ level\_name.c\_str(),\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01037}01037\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01038}01038\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ configurar\ PWM\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01039}01039\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01040}01040\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01041}01041\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01042}01042\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01043}01043\ //\ \ \ \ \ \ \ \ \ \ \ FUNCIONES\ NEOPIXEL}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01044}01044\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01045}01045\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01046}01046\ void\ neoCommand(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01047}01047\ \ \ //\ Formato:\ "{}neo\ XX\ COLOR"{}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01048}01048\ \ \ //\ XX\ =\ dirección\ hex,\ COLOR\ =\ red/green/blue/white/off\ o\ 1/2/3/4/0}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01049}01049\ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01050}01050\ \ \ int\ space\ =\ cmd.indexOf('\ ',\ 4);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01051}01051\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01052}01052\ \ \ if\ (space\ ==\ -\/1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01053}01053\ \ \ \ \ Serial.println("{}ERROR:\ Formato\ incorrecto"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01054}01054\ \ \ \ \ Serial.println("{}Uso:\ neo\ XX\ COLOR"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01055}01055\ \ \ \ \ Serial.println("{}Ejemplo:\ neo\ 20\ 1\ \ (NeoPixel\ rojo\ en\ 0x20)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01056}01056\ \ \ \ \ Serial.println("{}Colores:\ red,\ green,\ blue,\ white,\ off"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01057}01057\ \ \ \ \ Serial.println("{}Numeros:\ 1=red,\ 2=green,\ 3=blue,\ 4=white,\ 0=off"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01058}01058\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01059}01059\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01060}01060\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01061}01061\ \ \ String\ addr\_str\ =\ cmd.substring(4,\ space);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01062}01062\ \ \ String\ color\_str\ =\ cmd.substring(space\ +\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01063}01063\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01064}01064\ \ \ color\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01065}01065\ \ \ color\_str.toLowerCase();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01066}01066\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01067}01067\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01068}01068\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01069}01069\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01070}01070\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01071}01071\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01072}01072\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01073}01073\ \ \ uint8\_t\ neo\_cmd\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01074}01074\ \ \ String\ color\_name\ =\ "{}"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01075}01075\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01076}01076\ \ \ if\ (color\_str\ ==\ "{}red"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01077}01077\ \ \ \ \ neo\_cmd\ =\ CMD\_RED;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01078}01078\ \ \ \ \ color\_name\ =\ "{}ROJO"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01079}01079\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}1"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01080}01080\ \ \ \ \ neo\_cmd\ =\ CMD\_RED;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01081}01081\ \ \ \ \ color\_name\ =\ "{}ROJO"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01082}01082\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}green"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01083}01083\ \ \ \ \ neo\_cmd\ =\ CMD\_GREEN;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01084}01084\ \ \ \ \ color\_name\ =\ "{}VERDE"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01085}01085\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}2"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01086}01086\ \ \ \ \ neo\_cmd\ =\ CMD\_GREEN;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01087}01087\ \ \ \ \ color\_name\ =\ "{}VERDE"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01088}01088\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}blue"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01089}01089\ \ \ \ \ neo\_cmd\ =\ CMD\_BLUE;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01090}01090\ \ \ \ \ color\_name\ =\ "{}AZUL"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01091}01091\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}3"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01092}01092\ \ \ \ \ neo\_cmd\ =\ CMD\_BLUE;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01093}01093\ \ \ \ \ color\_name\ =\ "{}AZUL"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01094}01094\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}white"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01095}01095\ \ \ \ \ neo\_cmd\ =\ CMD\_WHITE;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01096}01096\ \ \ \ \ color\_name\ =\ "{}BLANCO"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01097}01097\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}4"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01098}01098\ \ \ \ \ neo\_cmd\ =\ CMD\_WHITE;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01099}01099\ \ \ \ \ color\_name\ =\ "{}BLANCO"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01100}01100\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}off"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01101}01101\ \ \ \ \ neo\_cmd\ =\ CMD\_OFF;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01102}01102\ \ \ \ \ color\_name\ =\ "{}APAGADO"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01103}01103\ \ \ \}\ else\ if\ (color\_str\ ==\ "{}0"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01104}01104\ \ \ \ \ neo\_cmd\ =\ CMD\_OFF;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01105}01105\ \ \ \ \ color\_name\ =\ "{}APAGADO"{};}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01106}01106\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01107}01107\ \ \ \ \ Serial.println("{}ERROR:\ Color\ invalido.\ Usa:\ red,\ green,\ blue,\ white,\ off"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01108}01108\ \ \ \ \ Serial.println("{}\ \ \ \ \ \ \ O\ numeros:\ 1=red,\ 2=green,\ 3=blue,\ 4=white,\ 0=off"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01109}01109\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01110}01110\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01111}01111\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01112}01112\ \ \ if\ (sendCommand(address,\ neo\_cmd))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01113}01113\ \ \ \ \ Serial.printf("{}[OK]\ NeoPixel\ \%s\ en\ 0x\%02X\(\backslash\)n"{},\ color\_name.c\_str(),\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01114}01114\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01115}01115\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ configurar\ NeoPixel\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01116}01116\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01117}01117\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01118}01118\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01119}01119\ void\ neoRed(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01120}01120\ \ \ String\ addr\_str\ =\ cmd.substring(4);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01121}01121\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01122}01122\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01123}01123\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01124}01124\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01125}01125\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01126}01126\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01127}01127\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01128}01128\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01129}01129\ \ \ if\ (sendCommand(address,\ CMD\_RED))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01130}01130\ \ \ \ \ Serial.printf("{}[OK]\ NeoPixel\ ROJO\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01131}01131\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01132}01132\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ configurar\ NeoPixel\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01133}01133\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01134}01134\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01135}01135\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01136}01136\ void\ neoGreen(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01137}01137\ \ \ String\ addr\_str\ =\ cmd.substring(6);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01138}01138\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01139}01139\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01140}01140\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01141}01141\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01142}01142\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01143}01143\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01144}01144\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01145}01145\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01146}01146\ \ \ if\ (sendCommand(address,\ CMD\_GREEN))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01147}01147\ \ \ \ \ Serial.printf("{}[OK]\ NeoPixel\ VERDE\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01148}01148\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01149}01149\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ configurar\ NeoPixel\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01150}01150\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01151}01151\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01152}01152\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01153}01153\ void\ neoBlue(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01154}01154\ \ \ String\ addr\_str\ =\ cmd.substring(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01155}01155\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01156}01156\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01157}01157\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01158}01158\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01159}01159\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01160}01160\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01161}01161\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01162}01162\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01163}01163\ \ \ if\ (sendCommand(address,\ CMD\_BLUE))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01164}01164\ \ \ \ \ Serial.printf("{}[OK]\ NeoPixel\ AZUL\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01165}01165\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01166}01166\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ configurar\ NeoPixel\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01167}01167\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01168}01168\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01169}01169\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01170}01170\ void\ neoWhite(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01171}01171\ \ \ String\ addr\_str\ =\ cmd.substring(6);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01172}01172\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01173}01173\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01174}01174\ \ \ uint8\_t\ address\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01175}01175\ \ \ if\ (address\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01176}01176\ \ \ \ \ Serial.println("{}ERROR:\ Direccion\ invalida"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01177}01177\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01178}01178\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01179}01179\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01180}01180\ \ \ if\ (sendCommand(address,\ CMD\_WHITE))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01181}01181\ \ \ \ \ Serial.printf("{}[OK]\ NeoPixel\ BLANCO\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01182}01182\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01183}01183\ \ \ \ \ Serial.printf("{}[FAIL]\ No\ se\ pudo\ configurar\ NeoPixel\ en\ 0x\%02X\(\backslash\)n"{},\ address);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01184}01184\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01185}01185\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01186}01186\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01187}01187\ void\ neoOff()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01188}01188\ \ \ Serial.println("{}\(\backslash\)n━━━\ APAGAR\ NEOPIXEL\ (TODOS)\ ━━━"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01189}01189\ \ \ int\ count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01190}01190\ \ \ for\ (int\ i\ =\ 0;\ i\ <\ device\_count;\ i++)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01191}01191\ \ \ \ \ uint8\_t\ addr\ =\ found\_devices[i];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01192}01192\ \ \ \ \ if\ (sendCommand(addr,\ CMD\_OFF))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01193}01193\ \ \ \ \ \ \ Serial.printf("{}\ \ [OK]\ 0x\%02X\ -\/\ NeoPixel\ apagado\(\backslash\)n"{},\ addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01194}01194\ \ \ \ \ \ \ count++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01195}01195\ \ \ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01196}01196\ \ \ \ \ \ \ Serial.printf("{}\ \ [FAIL]\ 0x\%02X\(\backslash\)n"{},\ addr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01197}01197\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01198}01198\ \ \ \ \ delay(10);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01199}01199\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01200}01200\ \ \ Serial.printf("{}\(\backslash\)nTotal:\ \%d/\%d\ dispositivos\(\backslash\)n"{},\ count,\ device\_count);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01201}01201\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01202}01202\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01203}01203\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01204}01204\ //\ \ \ \ \ \ \ \ \ \ \ FUNCIÓN:\ CAMBIAR\ DIRECCIÓN\ I2C}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01205}01205\ //\ ═══════════════════════════════════════════════════════════}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01206}01206\ void\ changeI2CAddress(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01207}01207\ \ \ //\ Formato:\ "{}ch\ XX\ YY"{}\ donde\ XX=dirección\ actual,\ YY=nueva\ dirección}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01208}01208\ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01209}01209\ \ \ int\ firstSpace\ =\ cmd.indexOf('\ ');}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01210}01210\ \ \ int\ secondSpace\ =\ cmd.indexOf('\ ',\ firstSpace\ +\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01211}01211\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01212}01212\ \ \ if\ (firstSpace\ ==\ -\/1\ ||\ secondSpace\ ==\ -\/1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01213}01213\ \ \ \ \ Serial.println("{}[ERROR]\ Formato:\ ch\ XX\ YY"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01214}01214\ \ \ \ \ Serial.println("{}\ \ \ \ \ \ \ \ XX\ =\ dirección\ actual\ (hex)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01215}01215\ \ \ \ \ Serial.println("{}\ \ \ \ \ \ \ \ YY\ =\ nueva\ dirección\ (hex)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01216}01216\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01217}01217\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01218}01218\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01219}01219\ \ \ String\ oldAddrStr\ =\ cmd.substring(firstSpace\ +\ 1,\ secondSpace);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01220}01220\ \ \ String\ newAddrStr\ =\ cmd.substring(secondSpace\ +\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01221}01221\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01222}01222\ \ \ oldAddrStr.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01223}01223\ \ \ newAddrStr.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01224}01224\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01225}01225\ \ \ //\ Convertir\ direcciones\ de\ hexadecimal}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01226}01226\ \ \ uint8\_t\ oldAddr\ =\ (uint8\_t)strtol(oldAddrStr.c\_str(),\ NULL,\ 16);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01227}01227\ \ \ uint8\_t\ newAddr\ =\ (uint8\_t)strtol(newAddrStr.c\_str(),\ NULL,\ 16);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01228}01228\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01229}01229\ \ \ //\ Validar\ rangos}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01230}01230\ \ \ if\ (oldAddr\ <\ 0x08\ ||\ oldAddr\ >\ 0x77)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01231}01231\ \ \ \ \ Serial.printf("{}[ERROR]\ Dirección\ actual\ 0x\%02X\ fuera\ de\ rango\ (0x08-\/0x77)\(\backslash\)n"{},\ oldAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01232}01232\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01233}01233\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01234}01234\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01235}01235\ \ \ if\ (newAddr\ <\ 0x08\ ||\ newAddr\ >\ 0x77)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01236}01236\ \ \ \ \ Serial.printf("{}[ERROR]\ Nueva\ dirección\ 0x\%02X\ fuera\ de\ rango\ (0x08-\/0x77)\(\backslash\)n"{},\ newAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01237}01237\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01238}01238\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01239}01239\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01240}01240\ \ \ Serial.println("{}\(\backslash\)n━━━\ CAMBIAR\ DIRECCIÓN\ I2C\ ━━━"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01241}01241\ \ \ Serial.printf("{}Dispositivo:\ 0x\%02X\ →\ 0x\%02X\(\backslash\)n"{},\ oldAddr,\ newAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01242}01242\ \ \ Serial.println("{}⚠️\ \ ADVERTENCIA:\ Esta\ operación\ es\ PERMANENTE\ (guarda\ en\ Flash)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01243}01243\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01244}01244\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01245}01245\ \ \ //\ PROTOCOLO\ CORRECTO\ según\ firmware\ i2c\_slave/main.c:}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01246}01246\ \ \ //\ 1.\ Enviar\ 0x3D\ (CMD\_SET\_I2C\_ADDR)\ -\/\ activa\ modo\ "{}esperar\ nueva\ dirección"{}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01247}01247\ \ \ //\ 2.\ El\ firmware\ responde\ 0x0D\ y\ espera\ el\ siguiente\ byte\ como\ nueva\ dirección}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01248}01248\ \ \ //\ 3.\ Enviar\ la\ nueva\ dirección\ como\ siguiente\ comando}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01249}01249\ \ \ //\ 4.\ Firmware\ guarda\ en\ Flash\ y\ responde\ 0x0D}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01250}01250\ \ \ //\ 5.\ Requiere\ reset\ para\ aplicar}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01251}01251\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01252}01252\ \ \ Serial.print("{}Paso\ 1:\ Activando\ modo\ cambio\ dirección...\ "{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01253}01253\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01254}01254\ \ \ WIRE.beginTransmission(oldAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01255}01255\ \ \ WIRE.write(CMD\_SET\_I2C\_ADDR);\ \ //\ 0x3D}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01256}01256\ \ \ uint8\_t\ error\ =\ WIRE.endTransmission();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01257}01257\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01258}01258\ \ \ if\ (error\ !=\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01259}01259\ \ \ \ \ Serial.printf("{}[FAIL]\ Error\ I2C:\ \%d\(\backslash\)n"{},\ error);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01260}01260\ \ \ \ \ Serial.println("{}\ \ El\ dispositivo\ no\ respondió.\ Verifica:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01261}01261\ \ \ \ \ Serial.println("{}\ \ \ -\/\ Dirección\ correcta\ (usa\ 'scan'\ para\ confirmar)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01262}01262\ \ \ \ \ Serial.println("{}\ \ \ -\/\ Dispositivo\ conectado\ y\ funcionando"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01263}01263\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01264}01264\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01265}01265\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01266}01266\ \ \ delay(50);\ \ //\ Delay\ importante:\ firmware\ necesita\ procesar\ comando}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01267}01267\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01268}01268\ \ \ //\ Leer\ respuesta}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01269}01269\ \ \ uint8\_t\ bytesRead\ =\ WIRE.requestFrom(oldAddr,\ (uint8\_t)1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01270}01270\ \ \ uint8\_t\ response\ =\ 0xFF;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01271}01271\ \ \ if\ (bytesRead\ ==\ 1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01272}01272\ \ \ \ \ response\ =\ WIRE.read();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01273}01273\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01274}01274\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01275}01275\ \ \ if\ (response\ ==\ 0x0D)\ \{\ \ //\ RESP\_I2C\_ADDR\_SET}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01276}01276\ \ \ \ \ Serial.println("{}[OK]\ Modo\ activado"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01277}01277\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01278}01278\ \ \ \ \ Serial.printf("{}[WARN]\ Respuesta:\ 0x\%02X\ (esperaba\ 0x0D)\(\backslash\)n"{},\ response);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01279}01279\ \ \ \ \ //\ Continuamos,\ puede\ funcionar\ igual}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01280}01280\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01281}01281\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01282}01282\ \ \ delay(50);\ \ //\ Delay\ adicional\ antes\ del\ siguiente\ comando}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01283}01283\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01284}01284\ \ \ //\ Paso\ 2:\ Enviar\ nueva\ dirección}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01285}01285\ \ \ Serial.printf("{}Paso\ 2:\ Enviando\ nueva\ dirección\ 0x\%02X...\ "{},\ newAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01286}01286\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01287}01287\ \ \ WIRE.beginTransmission(oldAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01288}01288\ \ \ WIRE.write(newAddr);\ \ //\ Nueva\ dirección\ como\ dato}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01289}01289\ \ \ error\ =\ WIRE.endTransmission();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01290}01290\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01291}01291\ \ \ if\ (error\ !=\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01292}01292\ \ \ \ \ Serial.printf("{}[FAIL]\ Error\ I2C:\ \%d\(\backslash\)n"{},\ error);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01293}01293\ \ \ \ \ Serial.println("{}\ \ No\ se\ pudo\ completar\ el\ cambio"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01294}01294\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01295}01295\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01296}01296\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01297}01297\ \ \ delay(100);\ \ //\ Delay\ largo:\ escritura\ Flash\ puede\ tomar\ tiempo}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01298}01298\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01299}01299\ \ \ //\ Leer\ confirmación}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01300}01300\ \ \ bytesRead\ =\ WIRE.requestFrom(oldAddr,\ (uint8\_t)1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01301}01301\ \ \ response\ =\ 0xFF;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01302}01302\ \ \ if\ (bytesRead\ ==\ 1)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01303}01303\ \ \ \ \ response\ =\ WIRE.read();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01304}01304\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01305}01305\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01306}01306\ \ \ if\ (response\ ==\ 0x0D)\ \{\ \ //\ RESP\_I2C\_ADDR\_SET}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01307}01307\ \ \ \ \ Serial.println("{}[OK]\ \ Guardado\ en\ Flash"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01308}01308\ \ \ \}\ else\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01309}01309\ \ \ \ \ Serial.printf("{}[WARN]\ Respuesta:\ 0x\%02X\(\backslash\)n"{},\ response);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01310}01310\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01311}01311\ \ \ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01312}01312\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01313}01313\ \ \ Serial.println("{}╔════════════════════════════════════════════╗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01314}01314\ \ \ Serial.println("{}║\ \ \ CAMBIO\ DE\ DIRECCIÓN\ COMPLETADO\ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01315}01315\ \ \ Serial.println("{}╚════════════════════════════════════════════╝"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01316}01316\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01317}01317\ \ \ Serial.println("{}\ \ IMPORTANTE\ -\/\ PRÓXIMOS\ PASOS:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01318}01318\ \ \ Serial.println("{}\ \ \ 1.\ La\ nueva\ dirección\ está\ GUARDADA\ EN\ FLASH"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01319}01319\ \ \ Serial.println("{}\ \ \ 2.\ DEBES\ RESETEAR\ el\ dispositivo\ para\ aplicar"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01320}01320\ \ \ Serial.println("{}\ \ \ 3.\ Opciones\ de\ reset:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01321}01321\ \ \ Serial.println("{}\ \ \ \ \ \ •\ Desconecta\ y\ reconecta\ el\ dispositivo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01322}01322\ \ \ Serial.println("{}\ \ \ \ \ \ •\ Usa\ el\ botón\ de\ reset\ físico"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01323}01323\ \ \ Serial.println("{}\ \ \ \ \ \ •\ Cicla\ la\ alimentación"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01324}01324\ \ \ Serial.printf("{}\ \ \ 4.\ Después\ del\ reset:\ dispositivo\ en\ 0x\%02X\(\backslash\)n"{},\ newAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01325}01325\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01326}01326\ \ \ Serial.println("{}Verificación:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01327}01327\ \ \ Serial.println("{}\ \ \ 1.\ Resetea\ el\ dispositivo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01328}01328\ \ \ Serial.println("{}\ \ \ 2.\ Ejecuta:\ scan"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01329}01329\ \ \ Serial.printf("{}\ \ \ 3.\ Busca\ la\ dirección\ 0x\%02X\ en\ la\ lista\(\backslash\)n"{},\ newAddr);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01330}01330\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01331}01331\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01332}01332\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01333}01333\ void\ saveColorPreset(String\ cmd)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01334}01334\ \ \ //\ Formato:\ save\_color\ <addr>\ <pos>\ <r>\ <g>\ <b>}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01335}01335\ \ \ cmd.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01336}01336\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01337}01337\ \ \ String\ tokens[6];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01338}01338\ \ \ int\ token\_count\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01339}01339\ \ \ int\ i\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01340}01340\ \ \ while\ (i\ <\ cmd.length()\ \&\&\ token\_count\ <\ 6)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01341}01341\ \ \ \ \ while\ (i\ <\ cmd.length()\ \&\&\ cmd.charAt(i)\ ==\ '\ ')\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01342}01342\ \ \ \ \ \ \ i++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01343}01343\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01344}01344\ \ \ \ \ if\ (i\ >=\ cmd.length())\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01345}01345\ \ \ \ \ \ \ break;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01346}01346\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01347}01347\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01348}01348\ \ \ \ \ int\ start\ =\ i;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01349}01349\ \ \ \ \ while\ (i\ <\ cmd.length()\ \&\&\ cmd.charAt(i)\ !=\ '\ ')\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01350}01350\ \ \ \ \ \ \ i++;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01351}01351\ \ \ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01352}01352\ \ \ \ \ tokens[token\_count++]\ =\ cmd.substring(start,\ i);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01353}01353\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01354}01354\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01355}01355\ \ \ if\ (token\_count\ <\ 6\ ||\ tokens[0]\ !=\ "{}save\_color"{})\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01356}01356\ \ \ \ \ Serial.println("{}[ERROR]\ Formato:\ save\_color\ <addr>\ <pos>\ <r>\ <g>\ <b>"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01357}01357\ \ \ \ \ Serial.println("{}\ \ \ \ \ \ \ \ pos:\ 1=slot\ rojo,\ 2=slot\ verde,\ 3=slot\ azul"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01358}01358\ \ \ \ \ Serial.println("{}\ \ \ \ \ \ \ \ r/g/b:\ 0..255\ (decimal)\ o\ 0x00..0xFF"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01359}01359\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01360}01360\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01361}01361\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01362}01362\ \ \ String\ addr\_str\ =\ tokens[1];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01363}01363\ \ \ String\ pos\_str\ =\ tokens[2];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01364}01364\ \ \ String\ r\_str\ =\ tokens[3];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01365}01365\ \ \ String\ g\_str\ =\ tokens[4];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01366}01366\ \ \ String\ b\_str\ =\ tokens[5];}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01367}01367\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01368}01368\ \ \ addr\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01369}01369\ \ \ pos\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01370}01370\ \ \ r\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01371}01371\ \ \ g\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01372}01372\ \ \ b\_str.trim();}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01373}01373\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01374}01374\ \ \ uint8\_t\ addr\ =\ parseHex(addr\_str);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01375}01375\ \ \ if\ (addr\ ==\ 0)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01376}01376\ \ \ \ \ Serial.println("{}[ERROR]\ Direccion\ invalida\ (0x08-\/0x77)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01377}01377\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01378}01378\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01379}01379\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01380}01380\ \ \ uint8\_t\ pos\_user\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01381}01381\ \ \ uint8\_t\ pos\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01382}01382\ \ \ uint8\_t\ r\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01383}01383\ \ \ uint8\_t\ g\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01384}01384\ \ \ uint8\_t\ b\ =\ 0;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01385}01385\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01386}01386\ \ \ if\ (!parseByteAuto(pos\_str,\ \&pos\_user)\ ||\ pos\_user\ <\ 1\ ||\ pos\_user\ >\ 3)\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01387}01387\ \ \ \ \ Serial.println("{}[ERROR]\ Posicion\ invalida.\ Usa\ 1,\ 2\ o\ 3"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01388}01388\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01389}01389\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01390}01390\ \ \ pos\ =\ (uint8\_t)(pos\_user\ -\/\ 1);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01391}01391\ \ \ if\ (!parseByteAuto(r\_str,\ \&r)\ ||\ !parseByteAuto(g\_str,\ \&g)\ ||\ !parseByteAuto(b\_str,\ \&b))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01392}01392\ \ \ \ \ Serial.println("{}[ERROR]\ RGB\ invalido.\ Usa\ 0..255\ o\ 0x00..0xFF"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01393}01393\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01394}01394\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01395}01395\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01396}01396\ \ \ Serial.println("{}\(\backslash\)n━━━\ SAVE\ COLOR\ PRESET\ ━━━"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01397}01397\ \ \ Serial.printf("{}Dispositivo\ 0x\%02X,\ slot\ \%u,\ RGB=(\%u,\%u,\%u)\(\backslash\)n"{},\ addr,\ pos\_user,\ r,\ g,\ b);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01398}01398\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01399}01399\ \ \ if\ (!sendCommand(addr,\ CMD\_SAVE\_COLOR))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01400}01400\ \ \ \ \ Serial.println("{}[FAIL]\ No\ se\ pudo\ iniciar\ save\_color"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01401}01401\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01402}01402\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01403}01403\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01404}01404\ \ \ delay(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01405}01405\ \ \ if\ (!sendCommand(addr,\ pos))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01406}01406\ \ \ \ \ Serial.println("{}[FAIL]\ No\ se\ pudo\ enviar\ posicion"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01407}01407\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01408}01408\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01409}01409\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01410}01410\ \ \ delay(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01411}01411\ \ \ if\ (!sendCommand(addr,\ r))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01412}01412\ \ \ \ \ Serial.println("{}[FAIL]\ No\ se\ pudo\ enviar\ canal\ R"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01413}01413\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01414}01414\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01415}01415\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01416}01416\ \ \ delay(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01417}01417\ \ \ if\ (!sendCommand(addr,\ g))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01418}01418\ \ \ \ \ Serial.println("{}[FAIL]\ No\ se\ pudo\ enviar\ canal\ G"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01419}01419\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01420}01420\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01421}01421\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01422}01422\ \ \ delay(5);}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01423}01423\ \ \ if\ (!sendCommand(addr,\ b))\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01424}01424\ \ \ \ \ Serial.println("{}[FAIL]\ No\ se\ pudo\ enviar\ canal\ B"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01425}01425\ \ \ \ \ return;}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01426}01426\ \ \ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01427}01427\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01428}01428\ \ \ Serial.println("{}[OK]\ Color\ guardado\ en\ Flash"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01429}01429\ \ \ Serial.println("{}Usa\ comandos\ red/green/blue\ para\ probar\ los\ 3\ slots."{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01430}01430\ \}}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01431}01431\ }
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01432}01432\ void\ showHelp()\ \{}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01433}01433\ \ \ Serial.println("{}\(\backslash\)n╔═══════════════════════════════════════╗"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01434}01434\ \ \ Serial.println("{}║\ \ \ \ \ \ \ \ COMANDOS\ DISPONIBLES\ \ \ \ \ \ \ \ \ \ ║"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01435}01435\ \ \ Serial.println("{}╚═══════════════════════════════════════╝"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01436}01436\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01437}01437\ \ \ Serial.println("{}SCAN:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01438}01438\ \ \ Serial.println("{}\ \ s\ \ \ \ \ \ \ \ \ \ \ \ \ \ -\/\ Escanear\ dispositivos\ I2C"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01439}01439\ \ \ Serial.println("{}\ \ loop\ \ \ \ \ \ \ \ \ \ \ -\/\ Scan\ continuo\ (1\ seg)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01440}01440\ \ \ Serial.println("{}\ \ stop\ \ \ \ \ \ \ \ \ \ \ -\/\ Detener\ scan\ continuo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01441}01441\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01442}01442\ \ \ Serial.println("{}TEST\ I2C:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01443}01443\ \ \ Serial.println("{}\ \ test\ INT\ DUR\ \ \ -\/\ Test\ asíncrono"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01444}01444\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ INT\ =\ intervalo\ (30-\/1000ms)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01445}01445\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ DUR\ =\ duración\ (ms)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01446}01446\ \ \ Serial.println("{}\ \ stoptest\ \ \ \ \ \ \ -\/\ Detener\ test\ y\ mostrar\ resultados"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01447}01447\ \ \ Serial.println("{}\ \ errors\ \ \ \ \ \ \ \ \ -\/\ Mostrar\ estadísticas\ de\ errores"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01448}01448\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01449}01449\ \ \ Serial.println("{}LECTURA\ DIGITAL\ PA0:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01450}01450\ \ \ Serial.println("{}\ \ read\ XX\ \ \ \ \ \ \ \ -\/\ Leer\ estado\ digital\ PA0"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01451}01451\ \ \ Serial.println("{}\ \ dstats\ \ \ \ \ \ \ \ \ -\/\ Estadísticas\ de\ lecturas\ PA0"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01452}01452\ \ \ Serial.println("{}\ \ readtest\ I\ D\ \ \ -\/\ Test\ continuo\ de\ lectura\ PA0"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01453}01453\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ I\ =\ intervalo\ (30-\/1000ms)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01454}01454\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ D\ =\ duración\ (ms)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01455}01455\ \ \ Serial.println("{}\ \ stopread\ \ \ \ \ \ \ -\/\ Detener\ test\ de\ lectura"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01456}01456\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01457}01457\ \ \ Serial.println("{}RELAY:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01458}01458\ \ \ Serial.println("{}\ \ t\ XX\ \ \ \ \ \ \ \ \ \ \ -\/\ Pulso\ relay\ PB5\ (10ms)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01459}01459\ \ \ Serial.println("{}\ \ on\ XX\ \ \ \ \ \ \ \ \ \ -\/\ Encender\ relay\ PB5"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01460}01460\ \ \ Serial.println("{}\ \ off\ XX\ \ \ \ \ \ \ \ \ -\/\ Apagar\ relay\ PB5"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01461}01461\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01462}01462\ \ \ Serial.println("{}PWM\ /\ BUZZER:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01463}01463\ \ \ Serial.println("{}\ \ pwm\ XX\ NIVEL\ \ \ -\/\ PWM\ en\ PA2\ (25,\ 50,\ 75,\ 100,\ off)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01464}01464\ \ \ Serial.println("{}\ \ silence\ \ \ \ \ \ \ \ -\/\ Apagar\ PWM\ en\ todos\ los\ dispositivos"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01465}01465\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01466}01466\ \ \ Serial.println("{}NEOPIXEL:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01467}01467\ \ \ Serial.println("{}\ \ neo\ XX\ COLOR\ \ \ -\/\ Control\ NeoPixel\ (red/green/blue/white/off\ o\ 1/2/3/4/0)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01468}01468\ \ \ Serial.println("{}\ \ red\ XX\ \ \ \ \ \ \ \ \ -\/\ NeoPixel\ rojo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01469}01469\ \ \ Serial.println("{}\ \ green\ XX\ \ \ \ \ \ \ -\/\ NeoPixel\ verde"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01470}01470\ \ \ Serial.println("{}\ \ blue\ XX\ \ \ \ \ \ \ \ -\/\ NeoPixel\ azul"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01471}01471\ \ \ Serial.println("{}\ \ white\ XX\ \ \ \ \ \ \ -\/\ NeoPixel\ blanco"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01472}01472\ \ \ Serial.println("{}\ \ neooff\ \ \ \ \ \ \ \ \ -\/\ Apagar\ NeoPixel\ en\ todos"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01473}01473\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01474}01474\ \ \ Serial.println("{}I2C\ ADDRESS:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01475}01475\ \ \ Serial.println("{}\ \ ch\ XX\ YY\ \ \ \ \ \ \ -\/\ Cambiar\ dirección\ I2C"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01476}01476\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ XX\ =\ dirección\ actual\ (hex)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01477}01477\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ YY\ =\ nueva\ dirección\ (hex)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01478}01478\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (se\ guarda\ en\ Flash,\ requiere\ reset)"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01479}01479\ \ \ Serial.println("{}\ \ save\_color\ A\ P\ R\ G\ B\ -\/\ Guardar\ color\ por\ slot\ en\ Flash"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01480}01480\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ P:\ 1=red\ slot,\ 2=green\ slot,\ 3=blue\ slot"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01481}01481\ \ \ Serial.println("{}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ R/G/B:\ decimal\ o\ 0x00..0xFF"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01482}01482\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01483}01483\ \ \ Serial.println("{}FORMATO:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01484}01484\ \ \ Serial.println("{}\ \ XX\ =\ Direccion\ I2C\ en\ hexadecimal"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01485}01485\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01486}01486\ \ \ Serial.println("{}EJEMPLOS:"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01487}01487\ \ \ Serial.println("{}\ \ s\ \ \ \ \ \ \ \ \ \ \ \ \ \ →\ Scan\ completo"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01488}01488\ \ \ Serial.println("{}\ \ loop\ \ \ \ \ \ \ \ \ \ \ →\ Scan\ automatico\ cada\ 1s"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01489}01489\ \ \ Serial.println("{}\ \ stop\ \ \ \ \ \ \ \ \ \ \ →\ Detener\ scan\ automatico"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01490}01490\ \ \ Serial.println("{}\ \ test\ 50\ 10000\ \ →\ Test\ cada\ 50ms\ por\ 10\ seg"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01491}01491\ \ \ Serial.println("{}\ \ stoptest\ \ \ \ \ \ \ →\ Detener\ test\ y\ ver\ errores"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01492}01492\ \ \ Serial.println("{}\ \ errors\ \ \ \ \ \ \ \ \ →\ Ver\ estadísticas"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01493}01493\ \ \ Serial.println("{}\ \ read\ 20\ \ \ \ \ \ \ \ →\ Leer\ PA0\ digital\ en\ 0x20"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01494}01494\ \ \ Serial.println("{}\ \ readtest\ 50\ 10000\ →\ Test\ lectura\ cada\ 50ms\ por\ 10s"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01495}01495\ \ \ Serial.println("{}\ \ stopread\ \ \ \ \ \ \ →\ Detener\ test\ de\ lectura"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01496}01496\ \ \ Serial.println("{}\ \ dstats\ \ \ \ \ \ \ \ \ →\ Ver\ estadísticas\ PA0"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01497}01497\ \ \ Serial.println("{}\ \ pwm\ 20\ 50\ \ \ \ \ \ →\ PWM\ 50\%\ (500Hz)\ en\ 0x20"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01498}01498\ \ \ Serial.println("{}\ \ silence\ \ \ \ \ \ \ \ →\ Apagar\ PWM\ en\ todos"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01499}01499\ \ \ Serial.println("{}\ \ neo\ 20\ 1\ \ \ \ \ \ \ →\ NeoPixel\ rojo\ en\ 0x20"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01500}01500\ \ \ Serial.println("{}\ \ red\ 20\ \ \ \ \ \ \ \ \ →\ NeoPixel\ rojo\ en\ 0x20"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01501}01501\ \ \ Serial.println("{}\ \ neooff\ \ \ \ \ \ \ \ \ →\ Apagar\ NeoPixel\ en\ todos"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01502}01502\ \ \ Serial.println("{}\ \ t\ 20\ \ \ \ \ \ \ \ \ \ \ →\ Pulso\ en\ 0x20"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01503}01503\ \ \ Serial.println("{}\ \ on\ 32\ \ \ \ \ \ \ \ \ \ →\ Encender\ en\ 0x32"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01504}01504\ \ \ Serial.println("{}\ \ off\ 20\ \ \ \ \ \ \ \ \ →\ Apagar\ relay\ en\ 0x20"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01505}01505\ \ \ Serial.println("{}\ \ ch\ 19\ 25\ \ \ \ \ \ \ →\ Cambiar\ 0x19\ a\ 0x25"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01506}01506\ \ \ Serial.println("{}\ \ save\_color\ 20\ 1\ 0x00\ 0xff\ 0x60\ →\ Slot\ 1\ personalizado"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01507}01507\ \ \ Serial.println("{}"{});}
\DoxyCodeLine{\Hypertarget{admin__pwm_8ino_source_l01508}01508\ \}}

\end{DoxyCode}
