Description: button i/o driver
Source: button.asm
Wrapper: button.c


The Button module allows the user to detect incoming button presses, and "push" one of the Coke machine's soda stacks. Button pushing and the soda stacks used to be closely linked; now they are completely seperate activities.

When a button is pressed or released, the appropriate message is generated.


MESSAGE_Button_Button0Hit button 0 was pressed
MESSAGE_Button_Button0Released button 0 was released
MESSAGE_Button_Button1Hit button 1 was pressed
MESSAGE_Button_Button1Released button 1 was released
MESSAGE_Button_Button2Hit button 2 was pressed
MESSAGE_Button_Button2Released button 2 was released
MESSAGE_Button_Button3Hit button 3 was pressed
MESSAGE_Button_Button3Released button 3 was released
MESSAGE_Button_Button4Hit button 4 was pressed
MESSAGE_Button_Button4Released button 4 was released


cokerr Button_QueryVersion (char* versionstring)
returns the version string.

cokerr Button_QueryPattern (byte* pattern)
returns in *pattern the current state of the buttons, with each of the five lowest bits corresponding to a button. This command is usually only necessary to detect multiple simultaneous button pushes.

cokerr Button_Push (byte stacknum)
starts "pushing" a soda stack. This only (physically) has an effect after Money_AllowPurchase has been called. Button_ReleaseBeverage () is recommended instead if the resetting problem has been fixed. stacknum is a number between 1 and 6, indicating which soda stack to push. The command will fail if a soda stack is already being pushed.
Errors: ERROR_Button_InvalidStackNumber

cokerr Button_ReleaseBeverage (byte stacknum)
invokes Money_AllowPurchase followed by Button_Push, with the proper delay in between. This command will fail if the Money driver has not been loaded. stacknum is a number between 1 and 6, indicating which soda stack to push. This command is not recommended until the controller resetting problem is fixed, because it is good to know whether AllowPurchase or Push caused it to reset.
Errors: ERROR_Button_InvalidStackNumber