shortening switch debounce

10 views
Skip to first unread message

james cardona

unread,
Dec 25, 2012, 2:48:02 PM12/25/12
to fre...@googlegroups.com
hi all and merry christmas from New Jersey,
I have recently come across a problem with one switch that I think should require some tweak to the switch.c in kernal but I am not sure how to proceed.  The switch is at the base of a saucer and the ball can sometime hit it hard (most of the time) or soft (once in a while).  When the ball hits the switch hard everything works great.  When the ball falls into the saucer softly, the code never detects the switch transition in game and the player is left waiting for ball search to start to get the ball back in play.  I can repeat this in switch test menu and it works fine so it is definately not a hardware problem.  I also tested on another machine and also on the original code and the problem only shows up on freewpc and while ingame.  I am thinking that the switch debounce code is the culprit, so I would like to change the debounce timeout to a shorter time for that one switch.  I know how to make it longer using the debounce(TIME) flag in the md but that only made the problem worse.  I need to shorten debounce, but just for that one switch,  - can anyone help please? 

Brian Dominy

unread,
Dec 25, 2012, 3:11:31 PM12/25/12
to fre...@googlegroups.com
James,

I'm confused - if it's a saucer, then the switch should eventually come to rest in the saucer and the game code would see it as closed all the time.  Shortening the debounce only means that a quick close-and-open would be seen.  Why it doesn't detect the transition baffles me.

It's really not possible to shorten the debounce for one switch.  Without a debounce() option in the md, you get a 4ms debounce time.  This is about as fast as you can do it on the 6809.

That said, I believe you when you say it's not working, but I just think the problem is something else.  Let me ponder this some more.  It may be a problem in the ball device code instead.
 
- Brian

Brian Dominy

unread,
Dec 25, 2012, 11:57:53 PM12/25/12
to fre...@googlegroups.com
Jim,

If you can push your latest code to github, I can take a look at the config and see if anything stands out.  It's the Huxley saucer, right?

I saw in your older code that you were listening for the "sw_eject" event, which is the wrong thing to do.  You have a container definition and should be listening on "dev_eyeball_eject_enter".  The ball device code listens on the raw switches; you should never that from game code.  Not sure if that's how you are still doing it.

Brian

james cardona

unread,
Dec 26, 2012, 9:07:21 AM12/26/12
to fre...@googlegroups.com, br...@oddchange.com
yes - I had not changed that yet.  I wasn't aware that we handle container switches differently. 
I haven't pushed in quiet a while since I bought a new computer and this one is not linked to github yet.  I will upload when I get a chance since there are some OS changes I made that you might be interested in.  For example I split the end_ball code into two functions.  The way it was originally written bonus was never being called on the last ball.  Also adding time to the ball save timer wasn't working if the ball save had already expired so I fixed that.  Can't remember all of them at the moment but I will commit sometime soon.
Reply all
Reply to author
Forward
0 new messages