I have used the PDK to set up my tv remote as a controller for pleo.
To do this i rebuilt the the IR sensor.p and .upf to understand them better ,here they are:
Sensor.p//
//
// ir_remote_test sensors.p rebuilt by justbede
//
//
// Copyright(c) 2008 Ugobe, Inc.
//
// Native functions
//
#include <Log.inc>
#include <Script.inc>
#include <Sensor.inc>
#include <String.inc>
#include <Motion.inc>
#include "motions.inc"
// called once on entry
//
public init()
{
// disable all messages except ours ('script:')
log_disable(MSG_ALL);
log_enable(MSG_SCRIPT);
printf("IR REMOTE TEST\nCompatible with Acroname R278-IR-REMOTE NEC-protocol remote control.\n");
}
// called on each sensor trigger
//
public on_sensor(time, sensor_name:sensor, value)
{
switch (sensor)
{
case SENSOR_IR:
{
new imsg[16];
sensor_read_data(SENSOR_IR, imsg);
printf("=== SENSOR_IR, msg received %s ===\n", imsg);
if (string_compare(imsg, "1600") == 0) // '1' key
{
printf("KEY 1\n");
}
else if (string_compare(imsg, "1500") == 0) // '2' key
{
printf("KEY 2\n");
}
else if (string_compare(imsg, "1400") == 0) // '3' key
{
printf("KEY 3\n");
}
else if (string_compare(imsg, "0E00") == 0) // '4' key
{
printf("KEY 4\n");
}
else if (string_compare(imsg, "0D00") == 0) // '5' key
{
printf("KEY 5\n");
}
else if (string_compare(imsg, "0C00") == 0) // '6' key
{
printf("KEY 6\n");
}
else if (string_compare(imsg, "0A00") == 0) // '7' key
{
printf("KEY 7\n");
}
else if (string_compare(imsg, "0900") == 0) // '8' key
{
printf("KEY 8\n");
}
else if (string_compare(imsg, "0800") == 0) // '9' key
{
printf("KEY 9\n");
}
else if (string_compare(imsg, "4004") == 0) // 'up' key
{
printf("KEY up\n");
motion_play(mot_com_walk_fs)
}
else if (string_compare(imsg, "4404") == 0) // 'mdl' key
{
printf("KEY mdl\n");
}
else if (string_compare(imsg, "0400") == 0) // '12' key
{
printf("KEY 12\n");
}
else if (string_compare(imsg, "0100") == 0) // '13' key
{
printf("KEY 13\n");
}
else if (string_compare(imsg, "0000") == 0) // '14' key
{
// this may not occur since we filter 0 IR values
printf("KEY 14\n");
}
else
{
printf("Unhandled key\n");
}
}
}
// returning true will cause the sensor to be reset. if we do not
// do this, we will continue to be called, unless we do an explicit resetSensor call
return true;
}
// called when we exit, just before unloading
//
public close()
{
printf("close\n");
}
ir_remote_test.upf<ugobe_project name="sensor"> //rebuilt by justbede
<set-default name="INCLUDES" value="" />
<options>
<include value="./include:../../include"/>
<tools>
<pawn value="pawncc %i -S128 -O2 -V2048 -C- %I -o%o TARGET=100"/>
</tools>
<directories>
<build value="build"/>
<include value="include"/>
</directories>
</options>
<set-default name="MEDIA" value="../../media" />
<set name="COMMANDS" value="${MEDIA}/commands"/>
<set name="MOTIONS" value="${MEDIA}/motions"/>
<set name="SOUNDS" value="${MEDIA}/sounds"/>
<resources>
<!-- Scripts -->
<script path="sensors.p"/>
<!-- Motions -->
<motion path="${MOTIONS}/com_walk_fs.csv" />
</resources>
</ugobe_project>
To get this to work with my own tv remote i built the original scripts put it in pleo turned him on and hooked him up to dinomite, i then pointed my tv remote at his nose dinomite then brought up a message saying something like ir signal recieved and listed a 4 digit code for the signal. I wrote the code down turned pleo off edited the sensors.p so that one of the "else...if" functions read as this:
else if (string_compare(imsg, "4004THIS IS MY REMOTE CODE FOR UP") == 0) // 'up' key
{
printf("KEY up\n");
}
Now when pleo was hooked up to dinomite with new script in him when i press up on the remote, the DM monitor reads KEY: up. To then add function to the input i added this to afore edited code:
else if (string_compare(imsg, "4004") == 0) // 'up' key
{
printf("KEY up\n");
motion_play(mot_com_walk_fs)
}
Now with the skit in pleo, he walks forwards on command from the tv remote. Add extra code to make pleo do what you wish via remote
I am now working on getting pleo to control my television so that as part of a drive program he will use the control to up his properties, heres an example. Pleo is feeling a little sad, he turns the tv on and puts a comedy channel on this will up his happiness property.
Video linked below!
http://www.youtube.com/watch?v=nhfhQVJiZ3w