ESPRUINO WEB IDE > ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v03 (c) 2018 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate > >dmf() [ "LOW_MEMORY" ] =undefined >pm() { "free": 799, "usage": 1701, "total": 2500, "history": 728, "gc": 0, "gctime": 4.30297851562, "stackEndAddress": 536928592, "flash_start": 0, "flash_binary_end": 428148, "flash_code_start": 442368, "flash_length": 524288 } =undefined >t1() STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 =undefined >st() =undefined STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 1 LOG_FLAG_COUNTER 1 LOG_FLAG_SHOW_BLANK 0 LOG_FLAG_READ_PULSES 1 LOG_FLAG_ISACTIVE_F 1 LOG_FLAG_ISACTIVE_T 1 LOG_FLAG_CALC_ONLY Toggle bits with the following function shortcuts LOG_FLAG_READ_PULSES lrp() LOG_FLAG_SHOW_BLANK lsb() LOG_FLAG_ISACTIVE_F laf() LOG_FLAG_ISACTIVE_T lat() LOG_FLAG_CALC_ONLY lco() Current value of calcFreq3: 0 L166 counterPulses: 2 $$$$$$$$$ &&&&&&&& L437 Read inside swr() counterPulses: 3 &&&&&&&&&&&&&&&&&&&&&&&&&&& Free mem: 295 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 0 Pulse L151 L553 swp() 3 calcFreq3: 0 7 L488 Pulse inside swp() elapsed 52700.31362915039 L501 diff 52700.31362915039 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 0 0 swp() 3 calcFreq3: 0 L559 ********up***************** L553 swp() 3 calcFreq3: 0 9 L488 Pulse inside swp() elapsed 52700.59841918945 L501 diff 0.28479003906 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 9 calc: 55.55555555555 1 /: 0.018 *1000: 18 calcFreq: 18 swp() timeStampPulseDur: 52700.09152221679 swp() 1 / timeStampPulseDur: 0.00001897529 swp() calcFreq: 18 timeStampPulseDur3 * .2: 0.05025024414 timeStampLast3: 52700.19720458984 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.25125122070 swp() 3 timeStampPulseDur3: 0.25125122070 swp() 3 calcFreq3: 3.98008016518 swp() 3 calcFreq3: 3.98008016518 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 3.98008016518 9 swp() 3 calcFreq3: 3.98008016518 L559 ********up***************** Free mem: 283 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 1 Pulse L151 L553 swp() 3 calcFreq3: 3.98008016518 0 L488 Pulse inside swp() elapsed 52701.31793212890 L501 diff 0.71951293945 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 3.98008016518 9 swp() 3 calcFreq3: 3.98008016518 L559 ********up***************** L553 swp() 3 calcFreq3: 3.98008016518 1 L488 Pulse inside swp() elapsed 52701.60476684570 L501 diff 0.28683471679 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52701.09613037109 swp() 1 / timeStampPulseDur: 0.00001897493 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.06774291992 timeStampLast3: 52700.53591918945 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.33871459960 swp() 3 timeStampPulseDur3: 0.33871459960 swp() 3 calcFreq3: 2.95233804847 swp() 3 calcFreq3: 2.95233804847 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 2.95233804847 1 swp() 3 calcFreq3: 2.95233804847 L559 ********up***************** Free mem: 283 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 2 Pulse L151 L553 swp() 3 calcFreq3: 2.95233804847 0 L488 Pulse inside swp() elapsed 52702.3154296875 L501 diff 0.71066284179 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 2.95233804847 1 swp() 3 calcFreq3: 2.95233804847 L559 ********up***************** L553 swp() 3 calcFreq3: 2.95233804847 1 L488 Pulse inside swp() elapsed 52702.59909057617 L501 diff 0.28366088867 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52702.09167480468 swp() 1 / timeStampPulseDur: 0.00001897457 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.20101928710 timeStampLast3: 52701.541015625 timeStampPulseEnd3: 0 timeStampPulseDur3: 1.00509643554 swp() 3 timeStampPulseDur3: 1.00509643554 swp() 3 calcFreq3: 0.99492940640 swp() 3 calcFreq3: 0.99492940640 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 0.99492940640 1 swp() 3 calcFreq3: 0.99492940640 L559 ********up***************** Free mem: 285 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 3 Pulse L151 L553 swp() 3 calcFreq3: 0.99492940640 0 L488 Pulse inside swp() elapsed 52703.31295776367 L501 diff 0.7138671875 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 0.99492940640 1 swp() 3 calcFreq3: 0.99492940640 L559 ********up***************** L553 swp() 3 calcFreq3: 0.99492940640 1 L488 Pulse inside swp() elapsed 52703.59954833984 L501 diff 0.28659057617 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52703.09149169921 swp() 1 / timeStampPulseDur: 0.00001897421 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.19949340820 timeStampLast3: 52702.53848266601 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.99746704101 swp() 3 timeStampPulseDur3: 0.99746704101 swp() 3 calcFreq3: 1.00253939115 swp() 3 calcFreq3: 1.00253939115 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 1.00253939115 1 swp() 3 calcFreq3: 1.00253939115 L559 ********up***************** Free mem: 285 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 4 Pulse L151 L553 swp() 3 calcFreq3: 1.00253939115 0 L488 Pulse inside swp() elapsed 52704.31048583984 L501 diff 0.7109375 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 1.00253939115 1 swp() 3 calcFreq3: 1.00253939115 L559 ********up***************** L553 swp() 3 calcFreq3: 1.00253939115 1 L488 Pulse inside swp() elapsed 52704.60104370117 L501 diff 0.29055786132 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52704.09152221679 swp() 1 / timeStampPulseDur: 0.00001897385 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.19950561523 timeStampLast3: 52703.53601074218 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.99752807617 swp() 3 timeStampPulseDur3: 0.99752807617 swp() 3 calcFreq3: 1.00247804937 swp() 3 calcFreq3: 1.00247804937 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 1.00247804937 1 swp() 3 calcFreq3: 1.00247804937 L559 ********up***************** Free mem: 285 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 5 Pulse L151 L553 swp() 3 calcFreq3: 1.00247804937 0 L488 Pulse inside swp() elapsed 52705.30798339843 L501 diff 0.70693969726 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 1.00247804937 1 swp() 3 calcFreq3: 1.00247804937 L559 ********up***************** L553 swp() 3 calcFreq3: 1.00247804937 1 L488 Pulse inside swp() elapsed 52705.59991455078 L501 diff 0.29193115234 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52705.09164428710 swp() 1 / timeStampPulseDur: 0.00001897349 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.19947509765 timeStampLast3: 52704.53338623046 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.99737548828 swp() 3 timeStampPulseDur3: 0.99737548828 swp() 3 calcFreq3: 1.00263141790 swp() 3 calcFreq3: 1.00263141790 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 1.00263141790 1 swp() 3 calcFreq3: 1.00263141790 L559 ********up***************** Free mem: 285 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 6 Pulse L151 L553 swp() 3 calcFreq3: 1.00263141790 0 L488 Pulse inside swp() elapsed 52706.31289672851 L501 diff 0.71298217773 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 1.00263141790 1 swp() 3 calcFreq3: 1.00263141790 L559 ********up***************** L553 swp() 3 calcFreq3: 1.00263141790 1 L488 Pulse inside swp() elapsed 52706.59957885742 L501 diff 0.28668212890 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52706.09149169921 swp() 1 / timeStampPulseDur: 0.00001897313 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.19953002929 timeStampLast3: 52705.53103637695 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.99765014648 swp() 3 timeStampPulseDur3: 0.99765014648 swp() 3 calcFreq3: 1.00235538833 swp() 3 calcFreq3: 1.00235538833 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 1.00235538833 1 swp() 3 calcFreq3: 1.00235538833 L559 ********up***************** Free mem: 285 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Expected pulse count: 2 argsStartup: [object Object] 1000 500 4 ARGSDEFAULT 5000 20 223 t1() ARGS1000 1000 500 4 t2() ARGS2000 2000 20 321 t3() ARGS1000F200 1000 20 200 t4() ARGS3000F100 3000 20 123 t5() ARGS4000F234 4000 20 234 7 Pulse L151 L553 swp() 3 calcFreq3: 1.00235538833 0 L488 Pulse inside swp() elapsed 52707.31774902343 L501 diff 0.71817016601 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 1.00235538833 1 swp() 3 calcFreq3: 1.00235538833 L559 ********up***************** L553 swp() 3 calcFreq3: 1.00235538833 1 L488 Pulse inside swp() elapsed 52707.60150146484 L501 diff 0.28375244140 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52707.09152221679 swp() 1 / timeStampPulseDur: 0.00001897277 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.20098266601 timeStampLast3: 52706.53594970703 timeStampPulseEnd3: 0 timeStampPulseDur3: 1.00491333007 swp() 3 timeStampPulseDur3: 1.00491333007 swp() 3 calcFreq3: 0.99511069270 swp() 3 calcFreq3: 0.99511069270 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 0.99511069270 1 swp() 3 calcFreq3: 0.99511069270 L559 ********up***************** Free mem: 285 STARTUP: update: 1000 freq: 4 gate: 500 calc time between rising edges: 0.25 pulseMarkFreq: 4 pulseWidthGate: 500 Uncaught SyntaxError: Got ')' expected EOF at line 1030 col 109 .../ ( 1 / argsStartup.freq + ) ); ^ in function "da" called from line 188 col 4 da(); ^ in function "dp" called from line 967 col 8 dp(); ^ in function called from system L553 swp() 3 calcFreq3: 0.99511069270 0 L488 Pulse inside swp() elapsed 52708.29266357421 L501 diff 0.69116210937 L496 swp() isActive=true L497 *********down***************** L477 after stwv() pulse train on L665 swp() 3 calcFreq3: 0.99511069270 1 swp() 3 calcFreq3: 0.99511069270 L559 ********up***************** =undefined L553 swp() 3 calcFreq3: 0.99511069270 1 L488 Pulse inside swp() elapsed 52708.60131835937 L501 diff 0.30865478515 L496 swp() isActive=false L497 *********down***************** pulseWidthGate: 500 counterPulses: 1 calc: 500 1 /: 0.002 *1000: 2 calcFreq: 2 swp() timeStampPulseDur: 52708.09164428710 swp() 1 / timeStampPulseDur: 0.00001897241 swp() calcFreq: 2 timeStampPulseDur3 * .2: 0.19957275390 timeStampLast3: 52707.53381347656 timeStampPulseEnd3: 0 timeStampPulseDur3: 0.99786376953 swp() 3 timeStampPulseDur3: 0.99786376953 swp() 3 calcFreq3: 1.00214080371 swp() 3 calcFreq3: 1.00214080371 L557 after stwoff() pulse train off L599 ********falling****************** L599 ********falling****************** L665 swp() 3 calcFreq3: 1.00214080371 1 swp() 3 calcFreq3: 1.00214080371 L559 ********up***************** > > > > > >dump() var LOG_FLAG_COUNTER = 1; var LOG_FLAG_SHOW_BLANK = 2; var LOG_FLAG_READ_PULSES = 8; var LOG_FLAG_ISACTIVE_F = 16; var LOG_FLAG_ISACTIVE_T = 32; var LOG_FLAG_CALC_ONLY = 256; var logFlags = 307; function rfg() { logFlags = 0x00; df(); } function sfg() { logFlags = 0x00; //logFlags = LOG_FLAG_COUNTER | LOG_FLAG_SHOW_BLANK; logFlags = logFlags | LOG_FLAG_COUNTER; logFlags = logFlags | LOG_FLAG_SHOW_BLANK; //logFlags = logFlags ^ LOG_FLAG_READ_PULSES; // Enable IsActive flags logFlags = logFlags | LOG_FLAG_ISACTIVE_F; logFlags = logFlags | LOG_FLAG_ISACTIVE_T; logFlags = logFlags | LOG_FLAG_CALC_ONLY; } var logEnable = true; var logVerbose = true; function von() {logVerbose = true;} function vof() {logVerbose = false;} function eon() {logEnable = true;} function eof() {logEnable = false;} function lrp() {logFlags = logFlags ^ LOG_FLAG_READ_PULSES;} function lsb() {logFlags = logFlags ^ LOG_FLAG_SHOW_BLANK;} function lat() {logFlags = logFlags ^ LOG_FLAG_ISACTIVE_T;} function laf() {logFlags = logFlags ^ LOG_FLAG_ISACTIVE_F;} function lco() {logFlags = logFlags ^ LOG_FLAG_CALC_ONLY;} function lf() { console.log( " " ); console.log( " Toggle bits with the following function shortcuts" ); console.log( " LOG_FLAG_READ_PULSES " + " lrp()" ); console.log( " LOG_FLAG_SHOW_BLANK " + " lsb()" ); console.log( " " ); console.log( " LOG_FLAG_ISACTIVE_F " + " laf()" ); console.log( " LOG_FLAG_ISACTIVE_T " + " lat()" ); console.log( " " ); console.log( " LOG_FLAG_CALC_ONLY " + " lco()" ); } function df() { console.log( ( ( logFlags & LOG_FLAG_COUNTER ) ? 1 : 0 ) + " LOG_FLAG_COUNTER" ); console.log( ( ( logFlags & LOG_FLAG_SHOW_BLANK ) ? 1 : 0 ) + " LOG_FLAG_SHOW_BLANK" ); console.log( ( ( logFlags & LOG_FLAG_READ_PULSES ) ? 1 : 0 ) + " LOG_FLAG_READ_PULSES" ); console.log( ( ( logFlags & LOG_FLAG_ISACTIVE_F ) ? 1 : 0 ) + " LOG_FLAG_ISACTIVE_F" ); console.log( ( ( logFlags & LOG_FLAG_ISACTIVE_T ) ? 1 : 0 ) + " LOG_FLAG_ISACTIVE_T" ); console.log( ( ( logFlags & LOG_FLAG_CALC_ONLY ) ? 1 : 0 ) + " LOG_FLAG_CALC_ONLY" ); // Display related bit toggle function names lf(); console.log( " " ); console.log( " " ); console.log( " " ); console.log( " Current value of calcFreq3: " + calcFreq3 ); console.log( " L166 counterPulses: " + counterPulses + " $$$$$$$$$ &&&&&&&&" ); console.log( " " ); console.log( " " ); } var pinPulseTiming = D14; var modePinD14 = "output"; var counter = 8; var counterrunning = 0; var pulseWidthGate = 500; function sg(g) { argsStartup.gate = g; pulseWidthGate = g; } function dp() { digitalPulse( pinPulseTiming, 1, pulseWidthGate ); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_COUNTER ) ) { // Display startup args da(); console.log( counter + " Pulse L151" ); } else { let objnull = ( ( counter % 10 ) === 0 ) ? console.log( "counter running " + counterrunning++ ) : ( counter = counter ); } counter++; // Option Base 0 - range 0 - 9 if( counter >= 10 ) counter = 0; } function dpoff() {digitalPulse( pinPulseTiming, 0, pulseWidthGate );} function dpu() { console.log( " pinPulseTiming: " + pinPulseTiming ); console.log( " pulseWidthGate: " + pulseWidthGate ); } var c = { "press": function () { [native code] }, "get": function () { [native code] } }; function swbe() {setWatch( c.press, D15, { repeat:true, edge:"both", irq:true, debounce: 20 } );} function swbp() { setWatch( function(e) { console.log( "Button pressed - Sending pulse" ); dp(); }, D15, { repeat: true, edge: 'rising', debounce: 20 } ); } function swb() { setWatch( function(e) { console.log( "Button pressed" ); }, D15, { repeat: true, edge: 'rising', debounce: 20 } ); } var pinWaveform = D17; var pulseMarkFreq = 4; function stwv() {analogWrite( pinWaveform, 0.2, { freq : pulseMarkFreq } );} function stwoff() {analogWrite( pinWaveform, 0, { freq : pulseMarkFreq } );} var isActive = false; var pinInputWaveform = D18; var counterPulses = 0; var counterPulsesSave = 1; var timeStampLast3 = 52707.53381347656; var timeStampPulseEnd3 = 0; var timeStampPulseDur3 = 0.99786376953; var calcFreq3 = 1.00214080371; var temp3 = 52706.53594970703; var calcInterm = 1.00214080371; var calcIntermSav = calcInterm; var pw = 0; function swr() { setWatch( function(e) { // console.log( " Read inside swr() isActive: " + isActive ); //Debug // if( false ) if( !isActive ) { counterPulses++; //SAVE console.log( " L437 Read inside swr() counterPulses: " + counterPulses ); if( counterPulses === 5 ) console.log( " L411 Read inside swr() counterPulses: " + counterPulses + " &&&&&&&&&&&&& &&&&&&&&" ); } // Hi CS pulse gate // if( isActive ) { if( isActive ) { if( counterPulses == 0 ) { // timeStampLast3 = 0; } counterPulses++; if( counterPulses === 3 ) console.log( " L437 Read inside swr() counterPulses: " + counterPulses + " &&&&&&&&&&&&&&&&&&&&&&&&&&&" ); temp3 = timeStampLast3; timeStampLast3 = e.lastTime; timeStampPulseDur3 = timeStampLast3 - temp3; calcInterm = 1 / timeStampPulseDur3; calcIntermSav = calcInterm; if( false ) if( counterPulses == 2 ) { console.log( " ==2 ************* L398 calcIntermSav swr() L333 :" + calcIntermSav ); } //if( false ) if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_READ_PULSES ) ) { console.log( " L398 swr() L332 :" + counterPulses + " timeStampLast3: " + timeStampLast3 + " temp3: " + temp3 + " timeStampPulseDur3: " + timeStampPulseDur3 ); console.log( " L398 calcInterm swr() L333 :" + calcInterm ); } } }, pinInputWaveform, { repeat: true, edge: 'rising' } ); } var pinSetWatchTiming = D16; var first = 52708.29266357421; var last = 52708.60131835937; var diff = 0.30865478515; var t = 0; var elaspsed = 0; var str = 52708601.318359375; var timeStampLast = 0; var timeStampPulseEnd = 52708.09164428710; var timeStampPulseDur = 52708.09164428710; var calcFreq = 2; var pinStateSync = 0; function sync() { pinStateSync = digitalRead( pinPulseTiming ); isActive = pinStateSync ? false : true; } function swp() { setWatch( function(e) { // Save the current state of the pin on rising should be 1 isActive = e.state; if( isActive ) { stwv(); // Create a 20% duty cycle pulse train // analogWrite( pinWaveform, 0.2, { freq : pulseMarkFreq } ); } if( !isActive ) { counterPulsesSave = counterPulses; // Shut off the pulse stream stwoff(); } if( logFlags & LOG_FLAG_CALC_ONLY ) { console.log( " L553 swp() 3 calcFreq3: " + calcFreq3 + " " + counterPulses ); } if( logVerbose ) { console.log( " L488 Pulse inside swp()" ); } elapsed = getTime()-t; if( logVerbose ) { console.log("elapsed " + elapsed ); } first = last; last = elapsed; diff = last - first; if( logVerbose ) { console.log( " L501 diff " + diff ); } str = elapsed * 1000; //****down*********** console.log( " L496 swp() isActive=" + e.state ); if( logVerbose ) { console.log( " L497 *********down*****************" ); } if( isActive ) { if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( " L477 after stwv() pulse train on" ); } } if( !isActive ) { calcFreq = ( 1 / ( pulseWidthGate / counterPulses ) ) * 1000; if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( " pulseWidthGate: " + pulseWidthGate + " counterPulses: " + counterPulses + " calc: " + ( pulseWidthGate / counterPulses ) ); console.log( " 1 /: " + ( 1 / ( pulseWidthGate / counterPulses ) ) + " *1000: " + ( 1 / ( pulseWidthGate / counterPulses ) ) * 1000 + " calcFreq: " + calcFreq ); } timeStampPulseEnd = e.lastTime; timeStampPulseDur = timeStampPulseEnd - timeStampLast; counterPulses = 0; //stwoff(); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( "swp() timeStampPulseDur: " + timeStampPulseDur ); console.log( "swp() 1 / timeStampPulseDur: " + ( 1 / timeStampPulseDur ) ); console.log( "swp() calcFreq: " + calcFreq ); } var pw = timeStampPulseDur3 * .2; if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( " "); console.log( " timeStampPulseDur3 * .2: " + pw + " timeStampLast3: " + timeStampLast3 ); console.log( " timeStampPulseEnd3: " + timeStampPulseEnd3 + " timeStampPulseDur3: " + timeStampPulseDur3 ); } calcFreq3 = ( 1 / timeStampPulseDur3 ); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( "swp() 3 timeStampPulseDur3: " + timeStampPulseDur3 ); console.log( "swp() 3 calcFreq3: " + calcFreq3 ); } if( logFlags & LOG_FLAG_CALC_ONLY ) { console.log( "swp() 3 calcFreq3: " + calcFreq3 ); } } // if( !isActive ) if( !isActive ) { // Shut off the pulse stream // stwoff(); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_F ) ) { console.log( " L557 after stwoff() pulse train off" ); } if( logVerbose ) { console.log( " L599 ********falling******************" ); console.log( " L599 ********falling******************" ); } } if( logFlags & LOG_FLAG_CALC_ONLY ) { console.log( " L665 swp() 3 calcFreq3: " + calcFreq3 + " " + counterPulsesSave ); console.log( "swp() 3 calcFreq3: " + calcFreq3 ); } console.log( " L559 ********up*****************" ); //**up************* }, pinSetWatchTiming, { repeat: true, edge: 'both' } ); } function ti() { console.log(global["\xFF"].timers); //nice, less info console.log( " " ); console.log( "Starting trace" ); console.log( " " ); trace(global["\xFF"].timers); } function pm() {console.log( process.memory() );} function pmf() {console.log( process.memory().free );} function gmf() {return ( process.memory().free );} function e() {console.log( process.env );} function d() {dump();} function dmf() {console.log( E.getErrorFlags() );} function gmflm() {return ( E.getErrorFlags().LOW_MEMORY );} function rgc() { process.memory(); dmf(); pm(); } function h() {help();} function help() { console.log( " " ); console.log( " " ); console.log( "Tutorial PPI - Programmable Peripheral Interconnect" ); console.log( " for the MDBT42Q Breakout board" ); console.log( " " ); console.log( " " ); console.log( "Single letter command line helper functions" ); console.log( " " ); console.log( " " ); console.log( " h() help " ); console.log( " " ); // console.log( " i() onInit" ); // console.log( " onInit() initialize" ); console.log( " hr() help run commands" ); console.log( " " ); console.log( " pm() process.memory()" ); console.log( " e() process.env" ); console.log( " d() dump()" ); console.log( " " ); console.log( " ti() display timers running" ); console.log( " " ); console.log( " " ); console.log( " " ); console.log( " " ); console.log( " von() Verbose logging on" ); console.log( " vof() Turn off verbose logging" ); console.log( " df() Display logging flags" ); console.log( " ci() clearInterval() using current ID" ); console.log( " cia() all clearInterval()" ); console.log( " ct() clearTimeout()" ); console.log( " cw() clearWatch()" ); console.log( " " ); console.log( " si() setInterval()" ); console.log( " st() start()" ); console.log( " " ); console.log( " " ); console.log( " dp() Digital Pulse()" ); console.log( " dpoff() Turn Off Digital Pulse()" ); console.log( " sync() Sync flag with pin state" ); // Sync flag with pin state console.log( " " ); console.log( " " ); console.log( " swbe() Set Watch Button External" ); console.log( " swb() Set Watch Button Onboard" ); console.log( " swp() Set Watch Pulses" ); console.log( " swr() Set Watch Read" ); console.log( " " ); // console.log( " " ); console.log( " stwv() Start pulse train waveform" ); console.log( " stwoff() Stop pulse train output" ); console.log( " " ); console.log( " " ); //dup above console.log( " swp() Set Watch using PPI" ); console.log( " dc() Display count" ); console.log( " stc() Stop PPI counter" ); console.log( " " ); console.log( " " ); console.log( " " ); } function hr() {helprun();} function helprun() { console.log( " " ); console.log( " " ); console.log( " Common run start commands used during setup" ); console.log( " " ); console.log( " " ); console.log( " h() help" ); console.log( " " ); console.log( " " ); console.log( " " ); console.log( " " ); console.log( " t4() Test dataset 4" ); console.log( " da() Display Args" ); console.log( " df() Display Flags" ); console.log( " rfg() Reset Flags" ); console.log( " " ); console.log( " " ); console.log( " rsc() Run Start Commands" ); console.log( " sf( f ) f SetFrequency( f ) Hz 1 - 3000" ); console.log( " su( u ) u SetUpdate( u ) msec to CS pulse" ); console.log( " sg( g ) g SetGate( g ) msec pulse width" ); console.log( " " ); console.log( " st() Start" ); console.log( " " ); console.log( " " ); } var intervalID = 2; var timeoutID = 1; function ci() {clearInterval( intervalID );} function cia() {clearInterval();} function ct() {clearTimeout( timeoutID );} function cw() {clearWatch();} function si() {sio( argsStartup );} var update = 1000; function sio(options) { if( typeof options !== "object" ) options = {}; options.update = options.update || ARGSUPDATE; options.freq = options.freq || ARGSFREQ; // Default update interval // var update = options.update; update = options.update; pulseMarkFreq = options.freq; if( typeof argsStartup.update !== "undefined" ) { // update = argsStartup.update; argsStartup.update = options.update; } if( typeof argsStartup.freq !== "undefined" ) { // pulseMarkFreq = argsStartup.freq; argsStartup.freq = options.freq; } // Display Args da(); df(); try { var f = {}; var flm = {}; var fm = {}; intervalID = setInterval( function() { fm = gmf(); console.log( " Free mem: " + fm ); f = E.getErrorFlags(); // console.log( " flags LOW_MEMORY: " + f ); flm = E.getErrorFlags().LOW_MEMORY; // console.log( " LOW_MEMORY: " + flm ); //Uncaught // flags LOW_MEMORY: // LOW_MEMORY: undefined if( flm !== undefined ) throw( "Err L1126 " + f ); // Digital Pulse dp(); }, update ); } catch(e) { console.log("L[1140]interval() catch() ***********" + e.toString() ); throw e.toString(); } } var argsStartup = { "gate": 500, "freq": 4, "update": 1000 }; var ARGSUPDATE = 5000; var ARGSFREQ = 223; var ARGSGATE = 20; var ARGSDEFAULT = { "update": 5000, "gate": 20, "freq": 223 }; var ARGS2000 = { "update": 2000, "gate": 20, "freq": 321 }; var ARGS1000 = { "update": 1000, "gate": 500, "freq": 4 }; var ARGS1000F200 = { "update": 1000, "gate": 20, "freq": 200 }; var ARGS3000F100 = { "update": 3000, "gate": 20, "freq": 123 }; var ARGS4000F234 = { "update": 4000, "gate": 20, "freq": 234 }; function da() { console.log( " STARTUP: update: " + argsStartup.update ); console.log( " freq: " + argsStartup.freq ); console.log( " gate: " + argsStartup.gate ); console.log( " " ); console.log( " calc time between rising edges: " + ( 1 / argsStartup.freq ) ); console.log( " " ); console.log( " " ); console.log( " pulseMarkFreq: " + pulseMarkFreq ); console.log( " " ); console.log( " " ); console.log( " pulseWidthGate: " + pulseWidthGate ); console.log( " " ); console.log( " " ); console.log( " Expected pulse count: " + ( (pulseWidthGate / 1000) / ( 1 / argsStartup.freq + ) ); console.log( " " ); console.log( " " ); console.log( " argsStartup: " + argsStartup + " " + argsStartup.update + " " + argsStartup.gate + " " + argsStartup.freq ); console.log( " " ); console.log( " " ); console.log( " ARGSDEFAULT " + ARGSDEFAULT.update + " " + ARGSDEFAULT.gate + " " + ARGSDEFAULT.freq ); // console.log( " ARGS3000F100 " + ARGS3000F100 ); //object console.log( " " ); console.log( " t1() ARGS1000 " + ARGS1000.update + " " + ARGS1000.gate + " " + ARGS1000.freq ); console.log( " " ); console.log( " t2() ARGS2000 " + ARGS2000.update + " " + ARGS2000.gate + " " + ARGS2000.freq ); console.log( " " ); console.log( " t3() ARGS1000F200 " + ARGS1000F200.update + " " + ARGS1000F200.gate + " " + ARGS1000F200.freq ); console.log( " " ); console.log( " t4() ARGS3000F100 " + ARGS3000F100.update + " " + ARGS3000F100.gate + " " + ARGS3000F100.freq ); console.log( " " ); console.log( " t5() ARGS4000F234 " + ARGS4000F234.update + " " + ARGS4000F234.gate + " " + ARGS4000F234.freq ); console.log( " " ); } function sf(f) { argsStartup.freq = f; pulseMarkFreq = f; } function su(u) { argsStartup.update = u; update = u; } function sgt(a) { sg( a.gate ); sf( a.freq ); su( a.update ); // sg( a ); // sf( a ); // su( a ); da(); } function t1() {sgt( ARGS1000 );} function t2() {sgt( ARGS2000 );} function t3() {sgt( ARGS1000F200 );} function t4() {sgt( ARGS3000F100 );} function t5() {sgt( ARGS4000F234 );} function st() { try { // Reset counter - display only counter = 0; // Set default flags sfg(); // Add setWatch()'s // Clear all previous cw(); // Set Watch Button External swbe(); // Set Watch Button Onboard swb(); // setWatch Pulses swp(); // setWatch Read swr(); // Sync flag with pin state pinStateSync = digitalRead( pinPulseTiming ); isActive = pinStateSync ? false : true; //var pinPulseTiming = D14; var pinSetWatchTiming = D16; // Start the pulse train waveform 2000Hz stwv(); //in swp stwv(); timeoutID = setTimeout( function() { // Turn off verbose logging //von(); // vof(); si(); }, 500 ); } catch(e) { console.log("L[1290]interval() catch() ***********" + e.toString() ); throw e.toString(); } } function rsc() { da(); // Start st(); // Gate sg( 50 ); // Turn Off T lat(); // Turn Off F laf(); vof(); } var AUTO_START_ON = false; function r3() { lco(); t5(); rsc(); } function cc() { counterPulses = 0; counter = 0; dc(); dpu(); } function dc() { console.log( " counter: " + counter ); console.log( " counterPulses: " + counterPulses ); } function r() { cc(); //counterPulses = 0; //counter = 0; // Clear setWatch cw(); // Reset Flags rfg(); //These toggle // Turn Off T // lat(); // Turn off F // laf(); // Verbose off // vof(); // Calc only lco(); //t4(); // Gate //sg( 50 ); // Display Args da(); // Start // st(); // Set Watch for gate // Set Watch Button External swbe(); // Set Watch Button Onboard swb(); // setWatch Pulses swp(); // setWatch Read swr(); // External button press sends one pulse swbp(); // Sync flag with pin state dp(); sync(); } function rm(options) { try { update = 1000; var f; var flm; intervalID = setInterval( function() { f = E.getErrorFlags(); // console.log( " flags LOW_MEMORY: " + f ); flm = E.getErrorFlags().LOW_MEMORY; // console.log( " LOW_MEMORY: " + flm ); if( flm !== undefined ) throw( "Err L1576 " + f ); // Digital Pulse dp(); }, update ); } catch(e) { console.log("L[1530]interval() catch() ***********" + e.toString() ); throw e.toString(); } } var elapsed = last; setWatch(function () { [native code] }, D15, { repeat:true, edge:'both', debounce : 19.99950408935 }); setWatch(function (e) {console.log( "Button pressed" );}, D15, { repeat:true, edge:'rising', debounce : 19.99950408935 }); setWatch(function (e) { isActive = e.state; if( isActive ) { stwv(); // Create a 20% duty cycle pulse train // analogWrite( pinWaveform, 0.2, { freq : pulseMarkFreq } ); } if( !isActive ) { counterPulsesSave = counterPulses; // Shut off the pulse stream stwoff(); } if( logFlags & LOG_FLAG_CALC_ONLY ) { console.log( " L553 swp() 3 calcFreq3: " + calcFreq3 + " " + counterPulses ); } if( logVerbose ) { console.log( " L488 Pulse inside swp()" ); } elapsed = getTime()-t; if( logVerbose ) { console.log("elapsed " + elapsed ); } first = last; last = elapsed; diff = last - first; if( logVerbose ) { console.log( " L501 diff " + diff ); } str = elapsed * 1000; //****down*********** console.log( " L496 swp() isActive=" + e.state ); if( logVerbose ) { console.log( " L497 *********down*****************" ); } if( isActive ) { if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( " L477 after stwv() pulse train on" ); } } if( !isActive ) { calcFreq = ( 1 / ( pulseWidthGate / counterPulses ) ) * 1000; if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( " pulseWidthGate: " + pulseWidthGate + " counterPulses: " + counterPulses + " calc: " + ( pulseWidthGate / counterPulses ) ); console.log( " 1 /: " + ( 1 / ( pulseWidthGate / counterPulses ) ) + " *1000: " + ( 1 / ( pulseWidthGate / counterPulses ) ) * 1000 + " calcFreq: " + calcFreq ); } timeStampPulseEnd = e.lastTime; timeStampPulseDur = timeStampPulseEnd - timeStampLast; counterPulses = 0; //stwoff(); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( "swp() timeStampPulseDur: " + timeStampPulseDur ); console.log( "swp() 1 / timeStampPulseDur: " + ( 1 / timeStampPulseDur ) ); console.log( "swp() calcFreq: " + calcFreq ); } var pw = timeStampPulseDur3 * .2; if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( " "); console.log( " timeStampPulseDur3 * .2: " + pw + " timeStampLast3: " + timeStampLast3 ); console.log( " timeStampPulseEnd3: " + timeStampPulseEnd3 + " timeStampPulseDur3: " + timeStampPulseDur3 ); } calcFreq3 = ( 1 / timeStampPulseDur3 ); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_T ) ) { console.log( "swp() 3 timeStampPulseDur3: " + timeStampPulseDur3 ); console.log( "swp() 3 calcFreq3: " + calcFreq3 ); } if( logFlags & LOG_FLAG_CALC_ONLY ) { console.log( "swp() 3 calcFreq3: " + calcFreq3 ); } } // if( !isActive ) if( !isActive ) { // Shut off the pulse stream // stwoff(); if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_ISACTIVE_F ) ) { console.log( " L557 after stwoff() pulse train off" ); } if( logVerbose ) { console.log( " L599 ********falling******************" ); console.log( " L599 ********falling******************" ); } } if( logFlags & LOG_FLAG_CALC_ONLY ) { console.log( " L665 swp() 3 calcFreq3: " + calcFreq3 + " " + counterPulsesSave ); console.log( "swp() 3 calcFreq3: " + calcFreq3 ); } console.log( " L559 ********up*****************" ); }, D16, { repeat:true, edge:'both' }); setWatch(function (e) { if( !isActive ) { counterPulses++; //SAVE console.log( " L437 Read inside swr() counterPulses: " + counterPulses ); if( counterPulses === 5 ) console.log( " L411 Read inside swr() counterPulses: " + counterPulses + " &&&&&&&&&&&&& &&&&&&&&" ); } // Hi CS pulse gate // if( isActive ) { if( isActive ) { if( counterPulses == 0 ) { // timeStampLast3 = 0; } counterPulses++; if( counterPulses === 3 ) console.log( " L437 Read inside swr() counterPulses: " + counterPulses + " &&&&&&&&&&&&&&&&&&&&&&&&&&&" ); temp3 = timeStampLast3; timeStampLast3 = e.lastTime; timeStampPulseDur3 = timeStampLast3 - temp3; calcInterm = 1 / timeStampPulseDur3; calcIntermSav = calcInterm; if( false ) if( counterPulses == 2 ) { console.log( " ==2 ************* L398 calcIntermSav swr() L333 :" + calcIntermSav ); } //if( false ) if( ( logEnable || logVerbose ) && ( logFlags & LOG_FLAG_READ_PULSES ) ) { console.log( " L398 swr() L332 :" + counterPulses + " timeStampLast3: " + timeStampLast3 + " temp3: " + temp3 + " timeStampPulseDur3: " + timeStampPulseDur3 ); console.log( " L398 calcInterm swr() L333 :" + calcInterm ); } } }, D18, { repeat:true, edge:'rising' }); pinMode(D14, "output"); pinMode(D17, "af_output"); =undefined > []