-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add I2C offset to get the keyboard init state #57
Add I2C offset to get the keyboard init state #57
Conversation
Note that this "kind of" locks the API in regards to this enum, and, may make it difficult to change the behavior later, for backward compatibility. But, if we think these are generic enough init states, I guess it is fine. To think out alternatives, while we can. Should "0" mean "OK"? And 1-127 mean "init in progress", and 128-254 "errorcode"? "255" should probably not be used, as this is the return value for current versions. |
Is there some kind of established "standards" regarding keyboard init states/state numbers? Or, we just invent our own? |
And, this is keyboard only? Mouse is irrelevant here? Mouse have its own similar init state? |
The keyboard init state is not a standard in any way. We could absolutely change KBD_READY to 0 or 1, and reserve the remaining values for other states, as you suggest. An alternative is to do this in the I2C send command:
Then it takes 22 bytes. I realize I couldn't do it better in assembly:
|
Maybe I just overcomplicate stuff. If we think these states cover our needs for now, we can use them as is. We can add new ones later, and even error codes as negative values if we like (2s compliment). If we cannot build upon the current implementation for whatever reason (e.g. we have to insert a new state between current state 2 and 3), we can simply call it "5" and give it a good enum name. Or, we can scrap this i2c offset and take a new one (return 255 means too old, 254 can mean "this is deprecated" or something.) |
… init states are subject to change.
I made the following changes:
If we do it like this, the size of the feature is only 10 bytes. |
The last code produces an unexpected result if no keyboard is attached, when reading the state in AUTOBOOT.X16.
EDIT: Forget that, 0x11 is a valid state, KBD_STATE_RESET_ACK |
This PR makes it possible to get the state of the keyboard, that is if the keyboard has been initialized.
Example: PRINT I2CPEEK($42,$1B) returns 4 if the keyboard is ready.
The changes take 14 bytes.