I was showing off my tuxdroid at the Dallas area unix group and I realised that there was no function to play sounds so I went browsing in the firmware source code. The patches are attached.

See http://www.tuxisalive.com/documentation/how-to/remote-control-standaloneby just pushing buttons (no computer or dongle involved).

I decided that the colour keys would be suitable and tried a stored sound to each one and ended up assigning a behaviour (like when you connect the power or turn tux on).

In the tuxcore code, the file standalone.c contains a switch statement that describes what should happen when the remote sends a key press. It 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 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 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 = 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 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 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 it mostly works. For some reason, even though all the behaviour sequences look alike except for the sound number, Tux doesn't always want to play when the red button is pressed, but works on the other keys. Also, the eyes don't light when Tux is powered on and he makes no noise.

Another oddity is that the mouth movements and wing flappings occur at 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 applied, the patches to the .h files have no effect.

Cheerio // Martin
Index: config.c
===================================================================
--- config.c	(revision 226)
+++ config.c	(working copy)
@@ -55,6 +55,13 @@
 /* Tux greeting second reply event */
 uint8_t tux_gr_repl2_e[SHORT_EVENT] EEMEM = TUX_GR_REPL2_E_SEQ;
 
+/* Demo sequences on remote colour keys */
+uint8_t tux_k_red_e[SHORT_EVENT] EEMEM = TUX_K_RED_E_SEQ;
+uint8_t tux_k_green_e[SHORT_EVENT] EEMEM = TUX_K_GREEN_E_SEQ;
+uint8_t tux_k_blue_e[SHORT_EVENT] EEMEM = TUX_K_BLUE_E_SEQ;
+uint8_t tux_k_yellow_e[SHORT_EVENT] EEMEM = TUX_K_YELLOW_E_SEQ;
+
+
 /* Configuration registers */
 tuxcore_config_t tux_config;
 
Index: standalone.c
===================================================================
--- standalone.c	(revision 226)
+++ standalone.c	(working copy)
@@ -316,6 +316,20 @@
                 case K_NEXT:
                     if (wingsPwm < 5) wingsPwm++;
                     break;
+                /* Added this so we can play demos from the remote */
+                case K_RED:
+                    launchActions((const uint8_t*)&tux_k_red_e);
+                    break;
+                case K_GREEN:
+                    launchActions((const uint8_t*)&tux_k_green_e);
+                    break;
+                case K_BLUE:
+                    launchActions((const uint8_t*)&tux_k_blue_e);
+                    break;
+                case K_YELLOW:
+                    launchActions((const uint8_t*)&tux_k_yellow_e);
+                    break;
+                
             }
         }
 

Index: config.h
===================================================================
--- config.h	(revision 226)
+++ config.h	(working copy)
@@ -59,6 +59,12 @@
 /* Tux greeting second reply event */
 extern uint8_t tux_gr_repl2_e[];
 
+/* Demo sequences on remote colour keys */
+extern uint8_t tux_k_red_e[];
+extern uint8_t tux_k_green_e[];
+extern uint8_t tux_k_yellow_e[];
+extern uint8_t tux_k_blue_e[];
+
 void config_init(void);
 
 #endif /* CONFIG_H */

Index: config.h
===================================================================
--- config.h	(revision 226)
+++ config.h	(working copy)
@@ -99,6 +99,39 @@
     END_OF_ACTIONS\
 }
 
+/* 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,\
+    0, WAVE_WINGS_CMD, 2, 5, 0,\
+    END_OF_ACTIONS\
+}
+
+/* Actions on GREEN Button */
+#define TUX_K_GREEN_E_SEQ {\
+    10, PLAY_SOUND_CMD, 4, 0, 0, /* play a sound */\
+    10, MOVE_MOUTH_CMD, 2, 0, 0,\
+    0, WAVE_WINGS_CMD, 2, 5, 0,\
+    END_OF_ACTIONS\
+}
+
+/* Actions on BLUE Button */
+#define TUX_K_BLUE_E_SEQ {\
+    10, PLAY_SOUND_CMD, 5, 0, 0, /* play a sound */\
+    10, MOVE_MOUTH_CMD, 2, 0, 0,\
+    0, WAVE_WINGS_CMD, 2, 5, 0,\
+    END_OF_ACTIONS\
+}
+
+/* Actions on YELLOW Button */
+#define TUX_K_YELLOW_E_SEQ {\
+    10, PLAY_SOUND_CMD, 6, 0, 0, /* play a sound */\
+    10, MOVE_MOUTH_CMD, 2, 0, 0,\
+    0, WAVE_WINGS_CMD, 2, 5, 0,\
+    END_OF_ACTIONS\
+}
+
+
 /*
  * Configuration settings
  */

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
tux-droid-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-user

Reply via email to