<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>tiez nevidim vytvaranie tasku ako vhodne riesenie.</p>
    <p>neviete vyuzit General Purpose Timer? <br>
    </p>
    <p><a class="moz-txt-link-freetext" href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/timer.html#">https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/timer.html#</a></p>
    <p>Myre<br>
    </p>
    <div class="moz-cite-prefix">On 3. 8. 2021 7:35, Jan Půhoný wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEwSxSFx1FD08w+UVvAxMwqA5uhb+K-7SGKGRri34rdfYi1xGw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Tak jsem to přepsal na vTaskDelayUntil , ale chová
        se to stejně. Problém je totiž v tom, že když se stiskne
        tlačítko we webovém rozhraní pro ovládání toho ventilu rychleji
        než se provede ten task, pustí se task pro otevírání a zavírání
        přes sebe a pak dochází k tomu, že to zůstane viset někde
        uprostřed. Pro tuto aplikaci asi nebude zásadní rozdíl
        mezi vTaskDelayUntil a vTaskDelay.
        <div><br>
        </div>
        <div>Ošetřil jsem to přidáním proměnné unBlock, která blokuje
          čtení tlačítka po dobu spuštění tasku. Takto to funguje
          spolehlivě. Nicméně předpokládám, že to jde vyřešit nějak
          elegantněji. <b>Jak se to správně dělá?</b></div>
        <div><br>
        </div>
        <div>Díky,</div>
        <div><br>
        </div>
        <div>HP</div>
        <div><br>
        </div>
        <div>Callback tlačítka:</div>
        <div>
          <div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(156,220,254)">button1</span>.<span style="color:rgb(220,220,170)">attachCallback</span>([&](<span style="color:rgb(86,156,214)">bool</span> <span style="color:rgb(156,220,254)">value</span>)</div><div>                         {</div><div><span style="color:rgb(106,153,85)">                           /* Print our new button value received from dashboard */</span></div><div>                           <span style="color:rgb(156,220,254)">Serial</span>.<span style="color:rgb(220,220,170)">println</span>(<span style="color:rgb(206,145,120)">"Button Triggered: "</span> <span style="color:rgb(220,220,170)">+</span> <span style="color:rgb(78,201,176)">String</span>((<span style="color:rgb(156,220,254)">value</span>) ? <span style="color:rgb(206,145,120)">"true"</span> : <span style="color:rgb(206,145,120)">"false"</span>));</div><div><span style="color:rgb(106,153,85)">                           /* Make sure we update our button's value and send update to dashboard */</span></div>
<div>                           <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(156,220,254)">value</span>);</div>
<div>                           <span style="color:rgb(197,134,192)">if</span> (<span style="color:rgb(156,220,254)">unBlock</span>)</div><div>                           {</div>
<div>                             <span style="color:rgb(197,134,192)">if</span> (<span style="color:rgb(156,220,254)">value</span>)</div><div>                             {</div>
<div>                               <span style="color:rgb(220,220,170)">xTaskCreatePinnedToCore</span>(</div><div>                                   <span style="color:rgb(220,220,170)">vent1On</span>,<span style="color:rgb(106,153,85)">   // Function that should be called</span></div><div>                                   <span style="color:rgb(206,145,120)">"vent1On"</span>,<span style="color:rgb(106,153,85)"> // Name of the task (for debugging)</span></div><div>                                   <span style="color:rgb(181,206,168)">2000</span>,<span style="color:rgb(106,153,85)">      // Stack size (bytes)</span></div><div>                                   <span style="color:rgb(86,156,214)">NULL</span>,<span style="color:rgb(106,153,85)">      // Parameter to pass</span></div><div>                                   <span style="color:rgb(181,206,168)">1</span>,<span style="color:rgb(106,153,85)">         // Task priority</span></div><div>                                   <span style="color:rgb(86,156,214)">NULL</span>,<span style="color:rgb(106,153,85)">      // Task handle</span></div><div>                                   <span style="color:rgb(181,206,168)">0</span><span style="color:rgb(106,153,85)">          // Core 1/0</span></div><div>                               );</div><div>                             }</div><div>                             <span style="color:rgb(197,134,192)">else</span></div><div>                             {</div>
<div>                               <span style="color:rgb(220,220,170)">xTaskCreatePinnedToCore</span>(</div><div>                                   <span style="color:rgb(220,220,170)">vent1Off</span>,<span style="color:rgb(106,153,85)">   // Function that should be called</span></div><div>                                   <span style="color:rgb(206,145,120)">"vent1Off"</span>,<span style="color:rgb(106,153,85)"> // Name of the task (for debugging)</span></div><div>                                   <span style="color:rgb(181,206,168)">2000</span>,<span style="color:rgb(106,153,85)">       // Stack size (bytes)</span></div><div>                                   <span style="color:rgb(86,156,214)">NULL</span>,<span style="color:rgb(106,153,85)">       // Parameter to pass</span></div><div>                                   <span style="color:rgb(181,206,168)">1</span>,<span style="color:rgb(106,153,85)">          // Task priority</span></div><div>                                   <span style="color:rgb(86,156,214)">NULL</span>,<span style="color:rgb(106,153,85)">       // Task handle</span></div><div>                                   <span style="color:rgb(181,206,168)">0</span><span style="color:rgb(106,153,85)">           // Core 1/0</span></div><div>                               );</div><div>                             }</div><div>                           }</div>
<div>                           <span style="color:rgb(156,220,254)">dashboard</span>.<span style="color:rgb(220,220,170)">sendUpdates</span>();</div><div>                         });</div></div>
        </div>
        <div><br>
        </div>
        <div>Ovládání ventilů:</div>
        <div>
          <div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(220,220,170)">vent1On</span>(<span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(86,156,214)">*</span><span style="color:rgb(156,220,254)">parameter</span>)</div><div>{</div><div>  <span style="color:rgb(78,201,176)">TickType_t</span> <span style="color:rgb(156,220,254)">xLastWakeTime</span>;</div><div>  <span style="color:rgb(86,156,214)">const</span> <span style="color:rgb(78,201,176)">TickType_t</span> <span style="color:rgb(156,220,254)">xFrequency</span> = (<span style="color:rgb(181,206,168)">20000</span> / <span style="color:rgb(86,156,214)">portTICK_PERIOD_MS</span>);</div><div><span style="color:rgb(106,153,85)">  // Initialise the xLastWakeTime variable with the current time.</span></div><div>  <span style="color:rgb(156,220,254)">xLastWakeTime</span> = <span style="color:rgb(220,220,170)">xTaskGetTickCount</span>();</div><div>  <span style="color:rgb(197,134,192)">for</span> (;;)</div><div>  {</div>
<div>    <span style="color:rgb(156,220,254)">unBlock</span> = <span style="color:rgb(181,206,168)">0</span>;</div>
<div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventMain1</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventOn1</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div>
<div>    <span style="color:rgb(156,220,254)">button1</span>.<span style="color:rgb(220,220,170)">update</span>(<span style="color:rgb(181,206,168)">1</span>);</div><div>    <span style="color:rgb(156,220,254)">systemCard</span>.<span style="color:rgb(220,220,170)">update</span>((<span style="color:rgb(86,156,214)">float</span>)<span style="color:rgb(156,220,254)">xFrequency</span>);</div>
<div><span style="color:rgb(106,153,85)">    // Pause the task fo 20s</span></div><div>    <span style="color:rgb(220,220,170)">vTaskDelayUntil</span>(&<span style="color:rgb(156,220,254)">xLastWakeTime</span>, <span style="color:rgb(156,220,254)">xFrequency</span>);</div><div><span style="color:rgb(106,153,85)">    //vTaskDelay(20000 / portTICK_PERIOD_MS);</span></div>
<div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventMain1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventOn1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div>
<div>    <span style="color:rgb(156,220,254)">unBlock</span> = <span style="color:rgb(181,206,168)">1</span>;</div>
<div>    <span style="color:rgb(220,220,170)">vTaskDelete</span>(<span style="color:rgb(86,156,214)">NULL</span>);<span style="color:rgb(106,153,85)"> //spustí se jen jednou</span></div><div>  }</div><div>}</div>
<div><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(220,220,170)">vent1Off</span>(<span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(86,156,214)">*</span><span style="color:rgb(156,220,254)">parameter</span>)</div><div>{</div><div>  <span style="color:rgb(78,201,176)">TickType_t</span> <span style="color:rgb(156,220,254)">xLastWakeTime</span>;</div><div>  <span style="color:rgb(86,156,214)">const</span> <span style="color:rgb(78,201,176)">TickType_t</span> <span style="color:rgb(156,220,254)">xFrequency</span> = (<span style="color:rgb(181,206,168)">20000</span> / <span style="color:rgb(86,156,214)">portTICK_PERIOD_MS</span>);</div><div><span style="color:rgb(106,153,85)">  // Initialise the xLastWakeTime variable with the current time.</span></div><div>  <span style="color:rgb(156,220,254)">xLastWakeTime</span> = <span style="color:rgb(220,220,170)">xTaskGetTickCount</span>();</div><div>  <span style="color:rgb(197,134,192)">for</span> (;;)</div><div>  {<span style="color:rgb(106,153,85)"> // infinite loop</span></div>
<div>    <span style="color:rgb(156,220,254)">unBlock</span> = <span style="color:rgb(181,206,168)">0</span>;</div>
<div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventMain1</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventOn1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div>
<div>    <span style="color:rgb(156,220,254)">button1</span>.<span style="color:rgb(220,220,170)">update</span>(<span style="color:rgb(181,206,168)">0</span>);</div><div>    <span style="color:rgb(156,220,254)">systemCard</span>.<span style="color:rgb(220,220,170)">update</span>((<span style="color:rgb(86,156,214)">float</span>)<span style="color:rgb(156,220,254)">xFrequency</span>);</div>
<div><span style="color:rgb(106,153,85)">    // Pause the task fo 20s</span></div><div>    <span style="color:rgb(220,220,170)">vTaskDelayUntil</span>(&<span style="color:rgb(156,220,254)">xLastWakeTime</span>, <span style="color:rgb(156,220,254)">xFrequency</span>);</div><div><span style="color:rgb(106,153,85)">    //vTaskDelay(20000 / portTICK_PERIOD_MS);</span></div>
<div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventMain1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventOn1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div>
<div>    <span style="color:rgb(156,220,254)">unBlock</span> = <span style="color:rgb(181,206,168)">1</span>;</div>
<div>    <span style="color:rgb(220,220,170)">vTaskDelete</span>(<span style="color:rgb(86,156,214)">NULL</span>);<span style="color:rgb(106,153,85)"> //spustí se jen jednou</span></div><div>  }</div><div>}</div></div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">po 2. 8. 2021 v 16:11
          odesílatel Jaroslav Buchta <<a
            href="mailto:jaroslav.buchta@hascomp.cz"
            moz-do-not-send="true">jaroslav.buchta@hascomp.cz</a>>
          napsal:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <div>A zrovna nad tim badam a jedna vec mi nejde do hlavy:</div>
            <div>v modulu port.c je obsluha <br>
            </div>
            <div><br>
            </div>
            <div>BaseType_t xPortSysTickHandler( void )<br>
              {<br>
                  BaseType_t ret;<br>
              <br>
                  portbenchmarkIntLatency();<br>
                  traceISR_ENTER(SYSTICK_INTR_ID);<br>
                  ret = xTaskIncrementTick();<br>
                  if( ret != pdFALSE )<br>
                  {<br>
                      portYIELD_FROM_ISR();<br>
                  } else {<br>
                      traceISR_EXIT();<br>
                  }<br>
                  return ret;<br>
              }<br>
              <br>
            </div>
            <div>Je logicky umistena v IRAM sekci ale proc??? Funkce
              nema specifikovany IRAM_ATTR, ani v hlavicce.</div>
            <div>zrovna tak BaseType_t xTaskIncrementTick( void ) v
              tasks.c</div>
            <div><br>
            </div>
            <div>Tady uz treba attribut je</div>
            <div>void IRAM_ATTR esp_vApplicationTickHook(void)<br>
              {<br>
                  int n;<br>
                  int core = xPortGetCoreID();<br>
                  for (n=0; n<MAX_HOOKS; n++) {<br>
                      if (tick_cb[core][n]!=NULL) {<br>
                          tick_cb[core][n]();<br>
                      }<br>
                  }<br>
              }</div>
            <div><br>
            </div>
            <div>Funkce se vnoruji v tomto poradi.<br>
            </div>
            <p>Zkousel jsem se povesit na hook od toho casovace a
              funguje to, jak z Flash, tak z IRAM (to je asi rozumnejsi,
              kdyz je to v ISR)<br>
            </p>
            <p><br>
            </p>
            <div>Dne 02.08.2021 v 12:32 Jaroslav Buchta napsal(a):<br>
            </div>
            <blockquote type="cite">
              <div>At to ctu stale dokola, nevidim prostor pro zkraceni
                <a
href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#task-api"
                  target="_blank" moz-do-not-send="true">FreeRTOS -
                  ESP32 - — ESP-IDF Programming Guide latest
                  documentation (espressif.com)</a></div>
              <div>Jen je tam upozorneni, ze je nejista prodleva, kdy
                bude zavolana funkce a az od te doby se to pocita. 
                vTaskDelayUntil bude mit asi jediny rozdil v tom, ze je
                tam dany cas ukonceni cekani jako parametr, u vTaskDelay
                se tato hodnot asi ulozi v okamziku volani.</div>
              <div>A i tak by se jednalo spis o milisekundy nez
                sekundy...</div>
              <div><br>
              </div>
              <div>Koukam na to, ze ty funkce pracuji v principu uplne
                stejne, pouziji pro uspani<br>
              </div>
              <div>    prvAddCurrentTaskToDelayedList(...);<br>
                 jenom jinak pocitaji dobu pro uspani...</div>
              <div><br>
              </div>
              <div>Pokud opravdu muze dojit ke zkraceni intervalu, bylo
                by v systemu neco velmi spatne. Neprobehne nahodou spis
                restart?</div>
              <div><br>
              </div>
              <div>//////////////////////////////<br>
              </div>
              <div><br>
              </div>
              <div>    void vTaskDelay( const TickType_t xTicksToDelay )<br>
                    {<br>
                    BaseType_t xAlreadyYielded = pdFALSE;<br>
                <br>
                        /* A delay time of zero just forces a
                reschedule. */<br>
                        if( xTicksToDelay > ( TickType_t ) 0U )<br>
                        {<br>
                            configASSERT(
                uxSchedulerSuspended[xPortGetCoreID()] == 0 );<br>
                            taskENTER_CRITICAL( &xTaskQueueMutex );<br>
                            {<br>
                                traceTASK_DELAY();<br>
                <br>
                                /* A task that is removed from the event
                list while the<br>
                                scheduler is suspended will not get
                placed in the ready<br>
                                list or removed from the blocked list
                until the scheduler<br>
                                is resumed.<br>
                <br>
                                This task cannot be in an event list as
                it is the currently<br>
                                executing task. */<br>
                                prvAddCurrentTaskToDelayedList(
                xPortGetCoreID(), xTicksToDelay );<br>
                            }<br>
                            taskEXIT_CRITICAL( &xTaskQueueMutex );<br>
                        }<br>
                        else<br>
                        {<br>
                            mtCOVERAGE_TEST_MARKER();<br>
                        }<br>
                <br>
                        /* Force a reschedule if xTaskResumeAll has not
                already done so, we may<br>
                        have put ourselves to sleep. */<br>
                        if( xAlreadyYielded == pdFALSE )<br>
                        {<br>
                            portYIELD_WITHIN_API();<br>
                        }<br>
                        else<br>
                        {<br>
                            mtCOVERAGE_TEST_MARKER();<br>
                        }<br>
                    }<br>
                <br>
              </div>
              <div><br>
              </div>
              <div><br>
              </div>
              <div>    void vTaskDelayUntil( TickType_t * const
                pxPreviousWakeTime, const TickType_t xTimeIncrement )<br>
                    {<br>
                    TickType_t xTimeToWake;<br>
                    BaseType_t xAlreadyYielded = pdFALSE, xShouldDelay =
                pdFALSE;<br>
                <br>
                        configASSERT( pxPreviousWakeTime );<br>
                        configASSERT( ( xTimeIncrement > 0U ) );<br>
                        configASSERT(
                uxSchedulerSuspended[xPortGetCoreID()] == 0 );<br>
                <br>
                        taskENTER_CRITICAL( &xTaskQueueMutex );<br>
                        {<br>
                            /* Minor optimisation.  The tick count
                cannot change in this<br>
                            block. */<br>
                            const TickType_t xConstTickCount =
                xTickCount;<br>
                <br>
                            /* Generate the tick time at which the task
                wants to wake. */<br>
                            xTimeToWake = *pxPreviousWakeTime +
                xTimeIncrement;<br>
                <br>
                            if( xConstTickCount < *pxPreviousWakeTime
                )<br>
                            {<br>
                                /* The tick count has overflowed since
                this function was<br>
                                lasted called.  In this case the only
                time we should ever<br>
                                actually delay is if the wake time has
                also    overflowed,<br>
                                and the wake time is greater than the
                tick time.  When this<br>
                                is the case it is as if neither time had
                overflowed. */<br>
                                if( ( xTimeToWake <
                *pxPreviousWakeTime ) && ( xTimeToWake >
                xConstTickCount ) )<br>
                                {<br>
                                    xShouldDelay = pdTRUE;<br>
                                }<br>
                                else<br>
                                {<br>
                                    mtCOVERAGE_TEST_MARKER();<br>
                                }<br>
                            }<br>
                            else<br>
                            {<br>
                                /* The tick time has not overflowed.  In
                this case we will<br>
                                delay if either the wake time has
                overflowed, and/or the<br>
                                tick time is less than the wake time. */<br>
                                if( ( xTimeToWake <
                *pxPreviousWakeTime ) || ( xTimeToWake >
                xConstTickCount ) )<br>
                                {<br>
                                    xShouldDelay = pdTRUE;<br>
                                }<br>
                                else<br>
                                {<br>
                                    mtCOVERAGE_TEST_MARKER();<br>
                                }<br>
                            }<br>
                <br>
                            /* Update the wake time ready for the next
                call. */<br>
                            *pxPreviousWakeTime = xTimeToWake;<br>
                <br>
                            if( xShouldDelay != pdFALSE )<br>
                            {<br>
                                traceTASK_DELAY_UNTIL();<br>
                <br>
                                /* prvAddCurrentTaskToDelayedList()
                needs the block time, not<br>
                                the time to wake, so subtract the
                current tick count. */<br>
                                prvAddCurrentTaskToDelayedList(
                xPortGetCoreID(), xTimeToWake - xConstTickCount );<br>
                            }<br>
                            else<br>
                            {<br>
                                mtCOVERAGE_TEST_MARKER();<br>
                            }<br>
                        }<br>
                        taskEXIT_CRITICAL( &xTaskQueueMutex );<br>
                <br>
                        /* Force a reschedule if xTaskResumeAll has not
                already done so, we may<br>
                        have put ourselves to sleep. */<br>
                        if( xAlreadyYielded == pdFALSE )<br>
                        {<br>
                            portYIELD_WITHIN_API();<br>
                        }<br>
                        else<br>
                        {<br>
                            mtCOVERAGE_TEST_MARKER();<br>
                        }<br>
                    }<br>
                <br>
              </div>
              <div><br>
              </div>
              <div>Dne 02.08.2021 v 12:09 as5s napsal(a):<br>
              </div>
              <blockquote type="cite">
                <p>Netusim ako to presne funguje, ale v dokumentacii na
                  to upozornuju.</p>
                <p>ale je mi cudne ze sa to skrati. O kolko sa to
                  skrati?</p>
                <p>Myre<br>
                </p>
                <p><br>
                </p>
                <div>On 2. 8. 2021 10:35, Jaroslav Buchta wrote:<br>
                </div>
                <blockquote type="cite">
                  <div>To jako opravdu vTaskDelay muze fungovat
                    nespolehlive, teda jeste k tomu se zkratit? <br>
                  </div>
                  <div>To snad primo pocita systemova preruseni od
                    casovace (default tusim 100Hz), ze by se nejaky
                    nestihly bych jeste pochopil...</div>
                  <div><br>
                  </div>
                  <div>Dne 02.08.2021 v 9:49 as5s napsal(a):<br>
                  </div>
                  <blockquote type="cite">
                    <p>Dobry den,</p>
                    <p>skuste pozriet na vTaskDelayUntil()</p>
                    <p><a
href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#_CPPv415vTaskDelayUntilPC10TickType_tK10TickType_t"
                        target="_blank" moz-do-not-send="true">https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#_CPPv415vTaskDelayUntilPC10TickType_tK10TickType_t</a></p>
                    <p>mozno vam to bude stacit.</p>
                    <p>Myre<br>
                    </p>
                    <div>On 2. 8. 2021 9:45, Jan Půhoný wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Dobrý den,
                        <div><br>
                        </div>
                        <div>mám tady další zádrhel - mějme funkci,
                          která ovládá výstupní piny, potřebuji po
                          nastavení udžet cca 20 sekund v HIGH a pak
                          vrátit vše do low. Jedná se o otevítání a
                          zavírání ventilu. Přidal jsem tedy mezi to <span style="font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(220,220,170)">vTaskDelay</span><span style="color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(30,30,30)">(</span><span style="font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(181,206,168)">20000</span><span style="color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(30,30,30)"> / </span><span style="font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(30,30,30);color:rgb(86,156,214)">portTICK_PERIOD_MS</span><span style="color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;background-color:rgb(30,30,30)">);</span> 
                          , problém je v tom, že někdy se to zpoždění
                          značně zkrátí a ventil zůstane napolo
                          otevřený. Jak se toto dá ošetřit aby
                          se vTaskDelay(20000 / portTICK_PERIOD_MS);
                          nikdy nemohlo zkrátit a bylo dodrženo.</div>
                        <div><br>
                        </div>
                        <div>Volám to pak standardně přes
                          xTaskCreatePinnedToCore() ....</div>
                        <div><br>
                        </div>
                        <div>
                          <div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(220,220,170)">vent1On</span>(<span style="color:rgb(86,156,214)">void</span> <span style="color:rgb(86,156,214)">*</span> <span style="color:rgb(156,220,254)">parameter</span>){</div><div>  <span style="color:rgb(197,134,192)">for</span>(;;){<span style="color:rgb(106,153,85)"> // infinite loop    </span></div>

<div>    <span style="color:rgb(156,220,254)">button1</span>.<span style="color:rgb(220,220,170)">update</span>(<span style="color:rgb(181,206,168)">1</span>);</div>
<div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventMain1</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventOn1</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(86,156,214)">HIGH</span>);</div>
<div><span style="color:rgb(106,153,85)">    // Pause the task fo 20s</span></div><div>    <span style="color:rgb(220,220,170)">vTaskDelay</span>(<span style="color:rgb(181,206,168)">20000</span> / <span style="color:rgb(86,156,214)">portTICK_PERIOD_MS</span>);</div><div>    </div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventMain1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ventOn1</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div><div>    <span style="color:rgb(220,220,170)">digitalWrite</span>(<span style="color:rgb(156,220,254)">ledPinRed</span>, <span style="color:rgb(86,156,214)">LOW</span>);</div>

<div>    <span style="color:rgb(220,220,170)">vTaskDelete</span>(<span style="color:rgb(86,156,214)">NULL</span>);<span style="color:rgb(106,153,85)"> //spustí se jen jednou</span></div><div>  }</div><div>}</div></div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div>xTaskCreatePinnedToCore(<br>
                                vent1On,    // Function that should be
                            called<br>
                                "vent1On",   // Name of the task (for
                            debugging)<br>
                                1000,            // Stack size (bytes)<br>
                                NULL,            // Parameter to pass<br>
                                1,               // Task priority<br>
                                NULL,            // Task handle<br>
                                0            // Core 1/0<br>
                              );<br>
                          </div>
                          <div><br clear="all">
                            <div>
                              <div dir="ltr">
                                <div dir="ltr">
                                  <div>
                                    <div dir="ltr">
                                      <div>HP</div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <br>
                          </div>
                        </div>
                      </div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">so 31. 7. 2021
                          v 8:27 odesílatel Jan Půhoný <<a
                            href="mailto:konference@puhy.cz"
                            target="_blank" moz-do-not-send="true">konference@puhy.cz</a>>
                          napsal:<br>
                        </div>
                        <blockquote class="gmail_quote"
                          style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex">
                          <div dir="ltr">Díky, zkusil jsem jak 2000 tak
                            4000 ale stále stejné. Resetuje se to pořád
                            dokola s tímto:
                            <div><br>
                            </div>
                            <div>rst:0x1 (POWERON_RESET),boot:0x12
                              (SPI_FAST_FLASH_BOOT)<br>
                              configsip: 0, SPIWP:0xee<br>
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00<br>
                              mode:DIO, clock div:2<br>
                              load:0x3fff0018,len:4<br>
                              load:0x3fff001c,len:1044<br>
                              load:0x40078000,len:10124<br>
                              load:0x40080400,len:5828<br>
                              entry 0x400806a8</div>
                            <div><br>
                            </div>
                            <div><b>Ale zjistil jsem, že to dělá jen
                                pokud to napájím z USB. Když to dám
                                přímo do svého zapojení, kde je pořádná
                                kapacita na Vin, tak to drží. Takže
                                skutečně jen problém s napájením.</b></div>
                            <div><br>
                            </div>
                            <div>Teď už to budu programovat jen přes
                              OTA, takže vyřešeno.</div>
                            <div><br>
                            </div>
                            <div>
                              <div>HP<br>
                                <br>
                              </div>
                            </div>
                          </div>
                          <br>
                          <div class="gmail_quote">
                            <div dir="ltr" class="gmail_attr">so 31. 7.
                              2021 v 6:44 odesílatel Jaroslav Buchta
                              <<a
                                href="mailto:jaroslav.buchta@hascomp.cz"
                                target="_blank" moz-do-not-send="true">jaroslav.buchta@hascomp.cz</a>>
                              napsal:<br>
                            </div>
                            <blockquote class="gmail_quote"
                              style="margin:0px 0px 0px
                              0.8ex;border-left:1px solid
                              rgb(204,204,204);padding-left:1ex">kod
                              jsem nezkoumal ale na prvni pohled mi
                              prijde maly zasobnik pro <br>
                              vlakno, tady je to tusim v btech. dal bych
                              2 nebo 4K na zkousku<br>
_______________________________________________<br>
                              HW-list mailing list  -  sponsored by <a
                                href="http://www.HW.cz" rel="noreferrer"
                                target="_blank" moz-do-not-send="true">www.HW.cz</a><br>
                              <a href="mailto:Hw-list@list.hw.cz"
                                target="_blank" moz-do-not-send="true">Hw-list@list.hw.cz</a><br>
                              <a
                                href="http://list.hw.cz/mailman/listinfo/hw-list"
                                rel="noreferrer" target="_blank"
                                moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
                            </blockquote>
                          </div>
                        </blockquote>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a href="http://www.HW.cz" target="_blank" moz-do-not-send="true">www.HW.cz</a>
<a href="mailto:Hw-list@list.hw.cz" target="_blank" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
                    </blockquote>
                    <br>
                    <fieldset></fieldset>
                    <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a href="http://www.HW.cz" target="_blank" moz-do-not-send="true">www.HW.cz</a>
<a href="mailto:Hw-list@list.hw.cz" target="_blank" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
                  </blockquote>
                  <p><br>
                  </p>
                  <br>
                  <fieldset></fieldset>
                  <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a href="http://www.HW.cz" target="_blank" moz-do-not-send="true">www.HW.cz</a>
<a href="mailto:Hw-list@list.hw.cz" target="_blank" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
                </blockquote>
                <br>
                <fieldset></fieldset>
                <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a href="http://www.HW.cz" target="_blank" moz-do-not-send="true">www.HW.cz</a>
<a href="mailto:Hw-list@list.hw.cz" target="_blank" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
              </blockquote>
              <p><br>
              </p>
              <br>
              <fieldset></fieldset>
              <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a href="http://www.HW.cz" target="_blank" moz-do-not-send="true">www.HW.cz</a>
<a href="mailto:Hw-list@list.hw.cz" target="_blank" moz-do-not-send="true">Hw-list@list.hw.cz</a>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
            </blockquote>
            <p><br>
            </p>
          </div>
          _______________________________________________<br>
          HW-list mailing list  -  sponsored by <a
            href="http://www.HW.cz" rel="noreferrer" target="_blank"
            moz-do-not-send="true">www.HW.cz</a><br>
          <a href="mailto:Hw-list@list.hw.cz" target="_blank"
            moz-do-not-send="true">Hw-list@list.hw.cz</a><br>
          <a href="http://list.hw.cz/mailman/listinfo/hw-list"
            rel="noreferrer" target="_blank" moz-do-not-send="true">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
HW-list mailing list  -  sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
    </blockquote>
  </body>
</html>