[tuxdroid-user] Extended remote control standalone functionality
Status: Beta
Brought to you by:
ks156
From: Martin T. <ma...@ma...> - 2007-04-09 02:37:41
|
I was showing off my tuxdroid at the Dallas area unix group and I =20 realised that there was no function to play sounds so I went browsing =20 in the firmware source code. The patches are attached. See =20 http://www.tuxisalive.com/documentation/how-to/remote-control-standaloneby = =20 just pushing buttons (no computer or dongle involved). I decided that the colour keys would be suitable and tried a stored =20 sound to each one and ended up assigning a behaviour (like when you =20 connect the power or turn tux on). In the tuxcore code, the file standalone.c contains a switch statement =20 that describes what should happen when the remote sends a key press. It =20 looks like this: switch (ir_command) { case K_0: COMMAND; break; } with a case for each key code. So I added cases for K_RED, K_GREEN, K_BLUE and K_YELLOW, something =20 like this: case K_RED: launchActions((const uint8_t*)&tux_k_red_e); break; tux_k_red_e describes what should happen when the red button key code =20 is received. There is one for each key. In config.c, I added an entry for tux_k_red_e: uint8_t tux_k_red_e[LONG_EVENT] EEMEM =3D TUX_K_RED_E_SEQ; and in common/config.h, I added a description of the sequence: /* Actions on Red Button */ #define TUX_K_RED_E_SEQ {\ 10, PLAY_SOUND_CMD, 3, 0, 0, /* play a sound */\ 10, MOVE_MOUTH_CMD, 2, 0, 0,\ END_OF_ACTIONS\ } The number after the sound cmd is the index of the stored sound to be =20 played. I don't know what the number at the start of each line is for. A few lines need to be added to the config.h in tuxcore (not the one in =20 common/): /* Demo sequences on remote colour keys */ extern uint8_t tux_k_red_e[]; After I compile everything, upload it to the tux and try it out, I find =20 it mostly works. For some reason, even though all the behaviour =20 sequences look alike except for the sound number, Tux doesn't always =20 want to play when the red button is pressed, but works on the other =20 keys. Also, the eyes don't light when Tux is powered on and he makes =20 no noise. Another oddity is that the mouth movements and wing flappings occur at =20 different times for each colour, but occur consistently at those times. I have attached patches in case they are of interest: demo_h.patch - patches config.h. demo.patch - patches common/config.h demo_c.patch - patches config.c and standalone.c - if this patch is not =20 applied, the patches to the .h files have no effect. Cheerio // Martin |