kbd_exp[0] printed out a value that changed when a button was pressed, and also changed whenever it wanted to randomly
About the functions with an underscore in front, are these the functions that are defined in functions_by_address.csv? When they're listed in there, they don't have the underscore (but some of them do though), does it get added later when compiling? Or are these functions defined elsewhere instead?
functions_by_address.csv does not get used in the build in any way. It's just there for reference.
Normal - it's just telling you that some of the digital inputs it's watching are changing.
static KeyMap keymap[] = { { 0, KEY_ZOOM_IN ,0x00000060 }, // 2 bits used, 4 values (0x00000060) { 0, KEY_ZOOM_IN ,0x00000020 }, // 2 bits used, 4 values (0x00000060) { 0, KEY_ZOOM_IN ,0x00000040 }, // 2 bits used, 4 values (0x00000060) { 0, KEY_ZOOM_OUT ,0x00000180 }, // 2 bits used, 4 values (0x00000180) { 0, KEY_ZOOM_OUT ,0x00000080 }, // 2 bits used, 4 values (0x00000180) { 0, KEY_ZOOM_OUT ,0x00000100 }, // 2 bits used, 4 values (0x00000180) { 0, KEY_UP ,0x00000400 }, // Found @0xff434aec, levent 0x04 { 0, KEY_DOWN ,0x00000800 }, // Found @0xff434af4, levent 0x05 { 0, KEY_LEFT ,0x00001000 }, // Found @0xff434afc, levent 0x06 { 0, KEY_RIGHT ,0x00002000 }, // Found @0xff434b04, levent 0x07 { 0, KEY_SET ,0x00004000 }, // Found @0xff434b0c, levent 0x08 { 0, KEY_VIDEO ,0x00008000 }, { 0, KEY_ZOOM_ASSIST ,0x00010000 }, { 0, KEY_DISPLAY ,0x00020000 }, // Found @0xff434b24, levent 0x0a { 0, KEY_MENU ,0x00040000 }, // Found @0xff434b2c, levent 0x09 { 0, KEY_ERASE ,0x00080000 }, { 0, KEY_FLASH ,0x00400000 }, { 0, KEY_PRINT ,0x00800000 }, { 2, KEY_POWER ,0x00000800 }, // Found @0xff434b8c, levent 0x100 { 2, KEY_PLAYBACK ,0x00001000 }, // Found @0xff434b94, levent 0x101 { 2, KEY_SHOOT_FULL ,0x0000c000 }, // Found @0xff434bac, levent 0x01 { 2, KEY_SHOOT_FULL_ONLY ,0x00008000 }, // Found @0xff434bac, levent 0x01 { 2, KEY_SHOOT_HALF ,0x00004000 }, // Found @0xff434ba4, levent 0x00 { 0, 0, 0 } };
Well it compiled and printed out, well, something...
It was also very buggy (camera would freeze on half-press and crash often, few of the buttons worked properly)
kbd_exp[0] printed out a value that changed when a button was pressed, and also changed whenever it wanted to randomlykbd_exp[1] and [2] were 2 and 64512 respectively.
About the functions with an underscore in front, are these the functions that are defined in functions_by_address.csv?
OK so it monitors other stuff aswell then. So if I extract the following I will be able to monitor an individual key? As in that the following values (and whatever else is monitored) are added together (when the corresponding key is pressed) and outputted at kbd_exp[0]?
However I still have the problem of it crashing and misbehaving, could this be because I am calling GetKbdState too often?
It does read some MMIOs0xC022F4800xC022F4840xC022F4880xC022F48Cbut the values get fiddled a bunch, so it's not immediately obvious how they correspond to physw_status bits.
long kbd_is_key_pressed_update(long key){ my_kbd_read_keys(); //The only change here int i; for (i=0;keymap[i].hackkey;i++) { if (keymap[i].hackkey == key) { if ((kbd_new_state[keymap[i].grp] & keymap[i].canonkey) == 0) return 1; } } return 0;}
draw_ad("ZA", kbd_is_key_pressed_update(KEY_ZOOM_ASSIST), yofst++); //When this is commented out it works normally draw_ad("Disp", kbd_is_key_pressed(KEY_DISPLAY), yofst++); draw_ad("SH", kbd_is_key_pressed(KEY_SHOOT_HALF), yofst++); draw_ad("SF", kbd_is_key_pressed(KEY_SHOOT_FULL), yofst++);
I am guessing that some of the seemingly random bits might be from multiplexing the keyboard?
I wouldn't have though simply calling my_keyboard_read_keys() would cause so much trouble, as it's used anyway by CHDK right?
Quote from: Recyclojunk64 on 09 / March / 2014, 11:56:31I am guessing that some of the seemingly random bits might be from multiplexing the keyboard?If the keypad was multiplexed then the standard CHDK code that uses the keymap would not work. As CHDK does in fact work on the SX40, this is clearly not the case.
Take a look at the first three lines of the function. It's tracking key states and there is code before and after the function call that depends on that mechanism advancing once every time through. When you add an additional call to my_keyboard_read_keys() you mess up the sequence.
if (kbd_is_key_pressed(KEY_SHOOT_FULL)) {// key_pressed = 0; kbd_key_release_all(); return 1; } if (kbd_is_key_pressed(KEY_SHOOT_HALF)) {// key_pressed = 0; kbd_key_release_all(); return 1; } if (kbd_is_key_pressed(KEY_ZOOM_ASSIST)) {// key_pressed = 0; kbd_key_release_all(); return 1; }
Quote What is the better approach to code a byte and send it over USB to CHDK. Should I use same pulse width and set USB to 5V for logic 1 and 0V for logic 0? Or is there any benefit working with the pulse width e.g. 60ms for logic 1 and 30 ms for logic 0?Either can be made to work. On newer cameras where task execution timing is not always consistent & repeatable, I'd suggest the 60 mSec=1, 30 msec=0 approach will be easier to make robust.
Started by Sasha Creative Uses of CHDK
Started by vikinggoat General Help and Assistance on using CHDK stable releases
Started by stagdriver Forum related topics (including issues)
Started by Recyclojunk64 « 1 2 ... 5 6 » General Discussion and Assistance
Started by Recyclojunk64 General Discussion and Assistance