Measuring time passed between button press?

Discussion in 'Mapping Questions & Discussion' started by Musaic, Jan 4, 2018.

  1. Musaic

    Musaic L1: Registered

    Messages:
    11
    Positive Ratings:
    0
    Hey guys I can't seem to figure out a good way to measure the seconds between a button pressed once then pressed again. Failing that, using a seperate start and stop button.

    I wish to output the value to another entity. Any help would be appreciated!

    Thanks
     
  2. Da Spud Lord

    aa Da Spud Lord L0: Crappy Member

    Messages:
    836
    Positive Ratings:
    567
    If you're okay with rounding down to the nearest second, you can try using a logic_timer with a length of 1 second that starts when the button is pressed, and when the logic_timer fires, it increments a math_counter by 1. You can possibly use the Toggle output on the logic_timer to start and stop it from the same button, or if that doesn't work, use two overlapping buttons that each disable themselves and enable the other when pressed, to give the illusion of a single button.
     
    • Agree Agree x 1
  3. Musaic

    Musaic L1: Registered

    Messages:
    11
    Positive Ratings:
    0
    Hmm, I was hoping to be able to measure the time in milliseconds. I should have clarified. Thanks for the idea though.
     
    Last edited: Jan 4, 2018
  4. Izotope

    aa Izotope Never releases maps

    Messages:
    625
    Positive Ratings:
    597
    You should be able to set the logic_timer to 0.01
     
  5. Musaic

    Musaic L1: Registered

    Messages:
    11
    Positive Ratings:
    0
    math_counters don't accept float values though correct?
     
  6. Izotope

    aa Izotope Never releases maps

    Messages:
    625
    Positive Ratings:
    597
    No idea, probably not. Though it doesn't hurt to try.
    Even if it doesn't, you could still just add 1 with every millisecond, then OutValue that to a logic_case or multiple since they only have 16 cases each, and have each value represent a millisecond that triggers whatever event you want.
     
  7. Musaic

    Musaic L1: Registered

    Messages:
    11
    Positive Ratings:
    0
    Awesome, I'll give it a shot when I get home.
     
  8. Musaic

    Musaic L1: Registered

    Messages:
    11
    Positive Ratings:
    0
    Working!
    I didn't need any logic cases either as unexpectedly the math_counter seems to accept float values. Thanks for the help!

    I'm going to attempt to upload a test map if anyone else has issues getting it to work. The map uses the captured time to adjust the time between toggling the light in the center of the map on or off.
     

    Attached Files:

  9. henke37

    aa henke37

    Messages:
    1,932
    Positive Ratings:
    456
    Careful about high frequency I/O, the system has safeguards against doing it on accident. For good reason.
     
  10. Musaic

    Musaic L1: Registered

    Messages:
    11
    Positive Ratings:
    0
    I figured as much, I'll only be implementing one in the map I'm making. I'll reduce the accuracy if I run into issues.