Announcement

Collapse
No announcement yet.

Gif animation videoObject

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gif animation videoObject

    Hi Guys,

    Maybe is a stupid question, but anyway......here I am,

    I have a circular progress waiting object(Gif), made of 19 frames on the welcome page(form0),
    is working perfectly, the question is:
    I have a waiting time of 6 seconds before I change the form to the main page(\Form1), that gives the machine the time to startup and run the firmware.
    I would need to run the Gif continuously for the 6 seconds till it changes the page.
    This is the code I use now, but it works only for 1 cycle of the Gif, then I can see the Gif still freezed for the rest of the time (as it does just one cycle)

    if (CurrentForm == 0)

    for (i:=0; i <= 18; i++)
    WriteObject(tVideo, 0, i); // animates the Gif Video
    pause(20);
    next
    pause(6000);
    ActivateForm(1);

    endif

    PS. The Working environment is VISI GENIE

    Can someone please correct the code by adding the missing part to make the video run continuously for the full 6 seconds till it changes Form?
    Maybe By getting the " i " to zero again and repeat the cycle when it reaches the frame 18?
    I cannot find the right syntax.

    I attached the Gif just in case.....




    Thank you very much for any help
    Best regards
    Emanuel
    Attached Files
    Last edited by Emanuel; 13 November 2017, 01:55 AM.

  • #2
    Hi Emanuel,

    The simplest way to do this without involving timers etc is to have another for next loop.

    if (CurrentForm == 0)

    for (n:=0; n < 7; n++)
    for (i:=0; i <= 18; i++)
    WriteObject(tVideo, 0, i); // animates the Gif Video
    pause(20);
    next
    next
    //pause(6000);
    ActivateForm(1);

    endif

    which takes roughly 6 seconds.

    The other way with a timer sys_T();

    if (CurrentForm == 0)

    tnow := sys_T() + 6000;
    while(sys_T() < tnow)
    for (i:=0; i <= 18; i++)
    WriteObject(tVideo, 0, i); // animates the Gif Video
    pause(20);
    next
    wend

    ActivateForm(1);

    endif


    I hope this helps

    Best regards

    Paul


    Comment


    • #3
      Hi Paul,
      Thank you very much for the code, I tried, but the result is the same, it just slows down the gif animation till it reaches the time, so the frame rate is really bad to watch.
      There's any chance I could make the gif routine counter " for (i:=0; i <= 18; i++)" being repeated for the amount of time ( pause(6000) like an independent routine?
      For example, if i change the 6 second for 10 seconds that would go on for that amount of time regardless.
      Thank you for the help,

      If is not possible i can live without the Gif, will just remove from the page and that's that, was just to make the page better.

      Bets regards
      Emanuel

      Comment


      • #4
        Hi Emanuel

        I did try both of them and they worked as expected, I put the var's in a magic-code in globals/data

        var tnow;

        and my code was in the mainloop.



        Paul

        Comment


        • #5
          Hi Paul,

          My Apologies!!!!

          Your code is working good (As usual), I just realize about the main loop
          I used the timer routine, is better.

          Really sorry,

          Thank you very much!!!!!!

          All the Best,
          Emanuel

          Comment


          • #6
            Hi Emanuel,

            Thanks for letting me know, No apologies necessary I did forget to mention the code placement. I am glad it's working ok

            Paul

            Comment


            • #7
              Hi Paul,
              It's me again,

              In 2 words, how can I make a gif video(attached) Click image for larger version  Name:	Fan-49x49-1.gif Views:	1 Size:	74.9 KB ID:	60604 run continuously when I push a non-temporary button, and stop it play when is released?
              The Gif is 50 frames
              I already coded another Gif loader in the welcome Form and works great,(stay on for 5 seconds and then change the form) but this one is running when the Fan is on.
              I can't figure out how.........
              Any suggestion is welcome, thank you
              Attached is the code that is related to the button, at the moment is managing a 2 pictures Userimage and working perfectly, I would like to change the pictures for the Gif-Video (Play or Stopped).
              Is it that possible without freezing the form while is running?

              func MagicEvent47(var fanvar)

              fanvar := 0;
              fanvar:=img_GetWord(hndl, iUserbutton1, IMAGE_INDEX);
              if (fanvar == 0)
              img_SetWord(hndl,iUserimages4,IMAGE_INDEX, 0);
              to(COM0);
              putstr("M106 S255");
              serout('\n');
              else if (fanvar == 2)
              img_SetWord(hndl,iUserimages4,IMAGE_INDEX, 1);
              to(COM0);
              putstr("M106 S0");
              serout('\n');
              endif
              img_Show(hndl, iUserimages4);

              endfunc

              Best regards
              Emanuel
              Last edited by Emanuel; 17 November 2017, 11:10 AM.

              Comment


              • #8
                Hi Emanuel,

                You can do this in a similar manner as you did with the arrows. You could define 2 global var's in global/data

                var fanOn;
                var fanImage;

                and then in the mainloop code,

                if (fanOn == 1)

                img_SetWord(hndl,iUserimages4,IMAGE_INDEX, fanImage)
                img_Show(hndl, iUserimages4);

                fanImage ++;
                if (fanImage > 50)
                fanImage := 0;
                endif

                endif

                In the code you sent, you could set the fanOn variable instead of the img_SetWord(hndl,iUserimages4,IMAGE_INDEX, 0)

                Or you could change the gif to a video like the other gif you did and use video commands.

                I hope this helps

                Best regards

                Paul

                Comment


                • #9
                  Thank you very much Paul, I’ll give it a try and let you know, last night I figured out how to make the Gif working by pressing the button, but I got caught in a loop, basically it was starting the video, but freeze the screen and just play the video endlessly, not a good result...
                  let’s see what I can do now.

                  As usual, all the best and thank you very much
                  Emanuel
                  Last edited by Emanuel; 17 November 2017, 08:56 PM.

                  Comment


                  • #10
                    Hi Paul,

                    Fantastic!!!!!

                    All work with a beautiful effect, and thru all the forms,
                    Very very good, thanks a lot for your great help!!!
                    All the best
                    Emanuel

                    Comment


                    • #11
                      Hello,

                      I walked similar way and coded a loader that can be enabled/disabled by serial commands from the master. I use for this task a MagicObject that sets the value of a global variable
                      Code:
                      loader_en
                      depending on a given value in write command.

                      Code:
                      if(CurrentForm == 0)
                        if(loader_en == 1)
                          for(i:=0; i<8; i++)
                            if(loader_en == 1)
                              WriteObject(tVideo, 1, i);
                              pause(50);
                            else
                              break;
                            endif
                          next
                        else
                          WriteObject(tVideo, 1, 0);
                        endif
                      endif
                      When I set loader_en = 1 the video starts to play immediately. The problem is that when I set loader_en = 0, there is a significant delay of a few seconds before the video stops. Other buttons on the form are also non-responsive. Adding the second if-else (inside the loop, as you can see above) does not work (the result is still the same).

                      I'm not using Timer0-driven animation - I tried but with similar results.
                      Is that normal behavior or I'm doing something wrong with this animation?

                      Best regards,
                      Przemyslaw

                      Comment


                      • #12
                        Hi,

                        It looks like Genie becomes out of sync after you have called the MagicObject.

                        You could try adding this as the last command in the MAgicObject code

                        serout(0x06);

                        or

                        serout1(0x06);

                        if you are using COM1 on the display.

                        Best regards

                        Paul

                        Comment


                        • #13
                          Hi,
                          thank you for reply. Unfortunately this solution doesn't work for me.
                          I think I should provide more detailed description of my problem, so:

                          Code:
                          // MagicCode0.inc (@MainLoop)
                          
                          if(CurrentForm == 16)
                          if(loader_en == 1)
                          for(i:=0; i<8; i++)
                          if(loader_en == 1)
                          WriteObject(tVideo, 1, i);
                          pause(50);
                          else
                          break;
                          endif
                          next
                          else
                          WriteObject(tVideo, 1, 0);
                          endif
                          endif
                          
                          
                          // MagicCode1.inc (@Constant/Global/Data)
                          
                          var loader_en;
                          
                          // MagicObject0.inc
                          
                          func rMagicObject0(var action, var object, var newVal, var *ptr)
                          if(action == WRITE_OBJ)
                          if(object == 0)
                          if(newVal == 1)
                          loader_en := 1;
                          else
                          loader_en := 0;
                          endif
                          endif
                          endif
                          
                          serout(0x06);
                          
                          endfunc
                          My goal is to show a loader for a couple of seconds and - after doing some stuff by master MCU - replace the loader animation with a button. So when I call enable/disable command for the button, I also call a write command to the magic object. Showing and hiding the button comes nearly at the same time as stopping and starting the animation (respectively), but the difference is that when an animation is running, the gen4-uLCD seems to be unresponsive (for about 2.5s from sending the commands from the master).

                          Maybe there is a simplier way to do such stuff - I need similar operations in more than one place in my GUI, so I'll be grateful for any advice.

                          Best regards,
                          P.

                          Comment


                          • #14
                            Hi

                            Thanks for the information. I might have misunderstood the problem and it looked like it was a comms issue. On testing the MagicObject, an ACK (0x06) is sent automtically so no need for the command I asked you to add and it can be removed.

                            As it is playing the whole video and pausing in between frames there won't be any touch detection during this process.

                            It may be better to have a global variable for the frame and increment this in the mainloop and just play one frame per loop cycle

                            put this in MagicCode that is in GlobalsData

                            Code:
                            var videoFrame;
                            And this in the mainloop

                            Code:
                            if(CurrentForm == 16)
                               if(loader_en == 1)
                                WriteObject(tVideo, 1, videoFrame);
                                videoFrame ++;
                                if(videoFrame > 8) videoFrame := 0
                               endif
                            endif

                            Comment


                            • #15
                              You could also reset your animation to frame 0 by using this


                              Code:
                              if(CurrentForm == 16)
                                if(loader_en == 1)
                                  WriteObject(tVideo, 1, videoFrame);
                                  videoFrame ++;
                                  if(videoFrame > 8) videoFrame := 0
                                endif
                                if(loader_en == 0)
                                  WriteObject(tVideo, 1, 0);
                                  loader_en := -1;
                                endif
                              endif

                              Comment

                              Working...
                              X