Page 10 of 10 FirstFirst ... 8910
Results 91 to 99 of 99

Thread: Anybody using Phidgets under Girder 4?

  1. #91
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    the prints do react but did you check the logger?

  2. #92
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Aha! I found it! You said input 1, but this actually goes to input 0! And there it works! I think I was only watching the print the previous time, before you edited it only to react to input 0 (those un-intuitive numberings annoy me, it's just the same with JRMC and it's zone 0 and up). Should I try the previous version and check the logger?
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  3. #93
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    just use the latest version...

    the numbers are off by one. input on the phidgets = 0 in girder <- thats the way the phidgets software does it not us.

  4. #94
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    I know. And I would say that their logic is also off by one... :wink: But what do I do to use the other 15 inputs? One of these for each input, or should I simply comment out one line and one "end" like this:

    Code:
    function PIEvents&#58;OnInputChange&#40;Index, NewState&#41; 
      print &#40;"Interface " .. Index, "State ",NewState&#41; 
    --if Index == 0 then 
      if NewState then 
       PDelayedEvent&#58;Start &#40;&#41; 
      else 
        PDelayedEvent&#58;Cancel &#40;&#41; 
    --  end 
    end 
    
    end
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  5. #95
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    no, its more complicated then that.

    i thought you were just using one? how many do you need?

  6. #96
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    No, I was only testing one for now. I would like to use them all, I have ready applications for ten already, and the final six I'll probably find use for pretty soon. So it's a lot more complicated to make the delayed action than the regular action that you already had working on my system? How about a wrapping on the original script to make the logger entries? Would that be easier?
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  7. #97
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    Code:
    require 'DelayedEventClass' 
    
    PI = luacom.CreateObject &#40;"PHIDGET.PhidgetInterfaceKit"&#41; 
    PI&#58;Open&#40;0&#41; 
    
    print &#40;"Phidget Interface ".. tostring &#40;PI.IsAttached&#41;&#41; 
    print &#40;"Serial ".. PI.SerialNumber&#41; 
    print &#40;"Version ".. PI.DeviceVersion&#41; 
    print &#40;"Inputs "..PI.NumInputs&#41; 
    print &#40;"Outputs "..PI.NumOutputs&#41; 
    print &#40;"Sensors "..PI.NumSensors&#41; 
    
    PIEvents = &#123;&#125; 
    
    PDelayedEvents = &#123;&#125;
    for k = 1, PI.NumInputs do
    	PDelayedEvents &#91;k&#93; = DelayedEventClass&#58;New &#40;500,nil,'PhidgetsInput&#58;'..k,18&#41; 
    end
    
    function PIEvents&#58;OnDetach&#40;&#41; 
      print &#40;"Detached"&#41; 
    end 
    
    function PIEvents&#58;OnError&#40;Description, SCODE&#41; 
      print &#40;"Error",Description,SCODE&#41; 
    end 
    
    function PIEvents&#58;OnInputChange&#40;Index, NewState&#41; 
    	Index = Index + 1
    	print &#40;"Input " .. Index, "State ",NewState&#41; 
    	if NewState then 
    		PDelayedEvents &#91;Index&#93;&#58;Start &#40;&#41; 
    	else 
    		PDelayedEvents &#91;Index&#93;&#58;Cancel &#40;&#41; 
    	end 
    
    end 
    
    function PIEvents&#58;OnOutputChange&#40;Index, NewState&#41; 
      print &#40;"Output " .. Index, "State "..NewState&#41; 
    end 
    
    function PIEvents&#58;OnSensorChange&#40;Index, SensorValue&#41; 
      print &#40;"Sensor " .. Index, "Value "..SensorValue&#41; 
    end 
    
    luacom.Connect &#40;PI,PIEvents&#41;
    covers all inputs

  8. #98
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    note: prints now match the phidgets numbering

  9. #99
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Thanks, Mike! This is a keeper! I have also tried a few calls with the full CID system, and also a short comserver torture test, and it seems this is stable as well. Great work again! 8)

    Edit: I don't know why, but this one reacts just as it should to script resets. I can change the delay value, and it will take without any problems. Very nice! So far it seems that 50 ms is a very nice value for 100 % reliability ( still see false positives in the print, but not in the logger) and at the same time it doesn't require a long button press. A regular short press will do! I'm a happy camper with my new Phigdet script!
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

Page 10 of 10 FirstFirst ... 8910

Posting Permissions

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