Announcement

Collapse
No announcement yet.

rotating primitive with IO1 pin ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • george1
    replied
    Thank you!
    You have email

    Leave a comment:


  • frsantiago
    replied
    Dear George,

    How did you use the code into your project?

    You can contact me at ferdinand at 4dsystems dot com dot au.

    Best Regards,
    Ferdinand

    Leave a comment:


  • george1
    replied
    Hello again Ferdinand,
    i am only able to rotate between three images 3,4 and 5.

    Is there an email i could contact you direct for faster communication please because in a few days i go back to work and wont have any more free time

    Thank you

    Leave a comment:


  • george1
    replied
    Thank you Ferdinand,

    going now to try! Will let you know!

    Best Regards
    George

    Leave a comment:


  • frsantiago
    replied
    Dear George,

    Please try the attached file as a reference.

    It only has 7 frames on the project but you can change the diff according to your no. of frames.
    Then add the additional frames on the else if statement.

    I hope this helps.

    Best Regards,
    Ferdinand

    Attached Files

    Leave a comment:


  • george1
    replied
    Hello Ferdinand ,
    thank you for replying.Its been two weeks and i had no success

    I am only a hobbyist and have no experience in code making .How the "logic" code you refer , should be so i can paste it ?

    This is my code at the moment:


    "

    func main()
    // Uncomment the following if uSD images, fonts or strings used.

    print("Starting\n") ;
    while(!media_Init())
    putstr("Drive not mounted...");
    pause(200);
    gfx_Cls();
    pause(200);
    wend

    var started := 0, old, new, diff, reading, frame := 0;
    pin_Set(ANALOGUE_8, IO1);


    repeat
    reading := pin_Read(IO1);
    if (!started)
    new := reading;
    started := 1;
    else
    old := new;
    new := reading;
    diff := new - old;
    //txt_MoveCursor(0, 0);
    //print("NEW: ", new," \n");
    //print("OLD: ", old, " \n");
    //print("Diff is ", diff, " \n");
    endif
    if (diff > 0 )
    if (new > 131)
    frame := frame + 10;
    if (frame > 7) frame := 7;
    txt_MoveCursor(5,0);
    //print(frame);


    else if (new < 131)
    frame := frame - 10;
    if (frame < 0) frame := 0;
    endif
    // Userimages1 1.0 generated 16/05/2020 2:49:00 pm
    media_SetAdd(iUserimages1H, iUserimages1L) ; // point to the Userimages1 image
    media_VideoFrame(0, 0, frame) ; // where frame is 0 to 7
    endif
    forever
    endfunc


    "


    I would like to be able to change 10 images between 114-148 IO1 pot reading with center the 131 .

    Maybe you can paste me a sample how this "logic" code should be so i can experiment please?

    Thank you and sorry for my multiple post ..i am trying two weeks now with no success because im not an expert .
    Looking forward for your reply!
    George
    Last edited by george1; 25 May 2020, 05:51 PM.

    Leave a comment:


  • frsantiago
    replied
    Hi George,

    Good Day.

    You can get the difference from the maximum resolution to the minimum resolution and divide it by the number of images that you want to display. Then make a logic on which image to be shown with the range of resolution.

    I hope this helps.

    Best Regards,
    Ferdinand

    Leave a comment:


  • george1
    replied
    Paul , Ferdinand or any other 4D experts reading,

    could you help please ?

    Leave a comment:


  • george1
    replied
    Trying but i havent fix the problem
    Any thoughts ?

    Leave a comment:


  • george1
    replied
    Hello again Ferdinand,
    thank you for all your help and time.

    I have successfully upload the project to the uOLED-96-G2 , but it looks that the change of all images take place between 129 and 131 of pots input (in one or two degrees of pots rotation).
    Very sensitive.

    How i can "expand" please this reading resolution between 107 to 155 so i can change the same or more images in wider range and maybe more smoothly?

    Thank you in advance for your reply!
    Kind Regards
    George
    Last edited by george1; 19 May 2020, 02:42 AM.

    Leave a comment:


  • frsantiago
    replied
    Dear George,

    Good Day.

    Please check the attached project as a reference. You can use Userimages to add multiple images.

    I hope this helps.

    Best Regards,
    Attached Files

    Leave a comment:


  • george1
    replied
    Hello Dear Ferdinand ,
    thank you for your guidance because i am new to programming

    The result readings are:

    -when the pot is center "NEW:131 OLD:131 Diff is 0"
    -when the pot is to one end "NEW:155 OLD:155 Diff is 0"
    -when the pot is to the other end "NEW:107 OLD:107 Diff is 0"

    What the code should be to assign my images to this numbers so i can represent the move in my potentiometer on the screen please?
    And how i do that in Visi environment ? I add extra "Forms" or more "Images" in a "Form"?

    Thank you very much for your time and help.
    Kind Regards
    George
    Last edited by george1; 18 May 2020, 11:44 PM.

    Leave a comment:


  • frsantiago
    replied
    Hi George,

    Good Day.

    Please see attached sample code on how you can get a reading from the potentiometer that is attached to IO1. You can calculate the difference between the new value and the old value which you can use to increment or decrement a frame.

    I hope this helps.

    Best Regards,
    Ferdinand
    Attached Files

    Leave a comment:


  • george1
    replied
    Hello there Ferdinand,

    i know the voltages but i dont know how the code should be
    Can you attach me the sample code please?

    Thank you
    Last edited by george1; 14 May 2020, 06:11 AM.

    Leave a comment:


  • frsantiago
    replied
    Hi,

    Good Day.

    Apologies for the delay.
    .
    You can print the reading from the potentiometer into the screen first to see if what will be the value at the center.
    Then, get the difference between the center value and the value read by potentiometer when you turn the knob to left or right.
    If the value is less than the center value then you can decrement the image frame.
    And if the value is greater than the center value then you can increment the image frame.

    I hope this helps.

    Best Regards,
    Ferdinand

    Leave a comment:

Working...
X