Results 1 to 9 of 9

Thread: Directional Pad

  1. #1
    Join Date
    Sep 2003
    Location
    Minnesota
    Posts
    63

    Default Directional Pad

    I am using an AST remote and its directional pad sends events similar to the degrees around a circle such that pressing straight up sends 0 straight down sends 180... etc along with the direction it sends either 1 or 2 depending on how hard it is pressed for example pressing down would send 180-1 if it is pressed light or 180-2 if it is pressed hard. Is there a way, probably using lua, to take a range of numbers and make them execute a command depending on the range? For example if i recieved a code between 45-1 and 135-1 it would execute a command in girder called RIGHT. I know i could make a command and learn all those directions as events for it but this would be really tedious and a pain in the butt to change later (theres no way I would even attempt this). If anyone has any advice i would greatly appreciate it.

    Thanks,
    Jared

    EDIT: Well, I didnt look too closely at how this directional pad works. It actually only has 16 different directions (22 & 23 degree increments) not 360. I thought I should correct this just in case anybody reads this and thinks that this remote can do more than it really can. BTW this many directions can get really annoying.

  2. #2
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    586

    Default

    Yes, it should be possible. Look for the LUAEvents plugin here.

    This will give you the ability to write a kind of virtual-in-between-plugin in LUA to process all events from one device and generate custom events.
    Bitmonster

  3. #3
    Join Date
    Sep 2003
    Location
    Minnesota
    Posts
    63

    Default

    I'll give it a shot thanks!

    Jared

  4. #4
    Join Date
    Sep 2003
    Location
    Minnesota
    Posts
    63

    Default

    Hey thanks alot bitmonster I'm a lot closer than I was when I asked the first question heres what ive done so far:

    Code:
    AddEventHandlerName(206, "", "ASTEvent") 
    
    function ASTEvent()
      instring = tonumber(strfind(EventString, "%-."))	-- determine if direction was pressed
      if instring then					-- if direction do following
        dir = tonumber(strsub(EventString, 1, instring-1))	-- dir = direction without pressure
        if dir > 45 and dir <= 135 then			-- is right?
          direc = 1						-- direc = right = 1
        elseif dir > 135 and dir <= 225 then		-- is down?
          direc = 2						-- direc = down = 2
        elseif dir > 225 and dir <= 315 then		-- is left?
          direc = 3						-- direc = left = 3
        elseif dir > 315 or dir <= 45 then			-- is up?
          direc = 0						-- direc = up = 0
        else						-- if error
          direc = 900					-- direc = error = 900
        end
      end
    end
    I've got this all working properly, but I'm stuck again... I need to be able to execute a command in girder from this script and I'm assuming I do this by generating an event and then assigning this event to a command in girder.... but i have no idea how to generate the event. Any suggestions?

    thanks ahead of time,
    Jared

  5. #5
    Join Date
    Sep 2002
    Location
    Davis, CA, USA
    Posts
    382

    Default

    Lua command:

    TriggerEvent("YourEventString",18,yourpld)

    Where YourEventString is an Event String for another command learned by selecting Girder Event in the dropdown, using Learn and then typing in the string.

    18 is the Girder DeviceID

    And yourpld is an optional payload arguments.
    Jim Hughes

  6. #6
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    586

    Default

    I haven't tried it with this plugin so far, but the normal way to generate an event with LUA is to use TriggerEvent:

    TriggerEvent(EventString, DeviceID, pld1, pld2, ...)
    Bitmonster

  7. #7
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    586

    Default

    Jim was faster....
    Bitmonster

  8. #8
    Join Date
    Sep 2003
    Location
    Minnesota
    Posts
    63

    Default

    haha you guys are awesome, I didnt expect one reply so fast... let alone two! I actually found the answer to this right before i checked your replies but I didnt have time to find the syntax for TriggerEvent so thanks! I'll give it a shot in a few minutes here.

    Thanks again,
    Jared

  9. #9
    Join Date
    Sep 2003
    Location
    Minnesota
    Posts
    63

    Default

    Works like a charm! I probably should have searched a little more in the forums before asking these questions but thanks for all your help, and thanks Ron for developing Girder.... whenever I think theres something it cant do, I figure out it was just me, Girder can do anything .

    Jared

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •