-- Name: racv2.jal -- Author: Mark Craig -- Home: http://homepages.strath.ac.uk/~lau01246/ -- Project: robosapien hacking -- Version: v4.0 -- Purpose: robosapien alarm clock -- Additional: This PIC is connected to robosapien's IR -- and to another PIC (MY two-wire interface) -- which controls the LCD to produce a clock -- Now that my Robosapien has been revived I can return to an alarm clock which -- prompts robosapien to move in someway when the alarm is triggered. include 16F84_4 -- 16F84 at 4Mhz include jlib -- standard library include jdelay -- delay library include sapcommands -- list of const's for robosapien commands -- set up Pic-to-pic comms pin_a3_direction = input -- IN_comm pin_a2_direction = output var volatile bit IN_comm is pin_a3 -- connected to PIC(b), b4 var volatile bit OUT_comm is pin_a2 -- connected to PIC(b), b5 var byte pic_clock = 0h_00 -- as this is not the clock include mark_comms_asm -- my pic-to-pic comms (pretty crappy) (assembly version) var byte data_in -- define pin directions pin_b0_direction = output -- connected to IR-OUT on robosapien's PCB pin_b1_direction = input -- connected to IR-IN -- define robosapien connections var volatile bit ir_in_pin is pin_b1 var volatile bit ir_out_pin is pin_b0 var byte pic_clock_command -- used to receive commands from clock (i.e. alarms) include saplib2 -- robosapien library send_sap( send byte ), read_sap( byte read ) -- saplib2 incorporates checking for data from pic clock var byte lastread var bit finished_yet forever loop read_sap( lastread ) -- wait for remote if ( lastread == sonic_sensor_program ) then -- take another command and send it to second PIC for updating clock / alarm settings finished_yet = off -- used to exit the loop after the sonic button has been pressed again while ( ! finished_yet ) loop read_sap( lastread ) -- Sends the command on to the second PIC without the colour shift -- (i.e. without the remote's function button taking effect) if ( lastread == sonic_sensor_program ) then finished_yet = on elsif ( lastread >= 0h_80 & lastread <= 0h_9F ) then -- no shift send_to_pic( lastread ) elsif ( lastread >= 0h_A0 & lastread <= 0h_BF ) then -- green shifted lastread = lastread - green_shift send_to_pic( lastread ) elsif ( lastread >= 0h_C0 & lastread <= 0h_DF ) then -- orange shifted lastread = lastread - orange_shift send_to_pic( lastread ) end if end loop -- end of while -- insert elsif here for catching other button presses else -- (so it wasn't sonic_sensor_program button) send_sap = lastread end if end loop -- forever loop -- IR codes -- The following commands (const) can be used instead of the hex value -- -- no shift green_shift (+0h20) orange_shift (+0h40) -- 81 (129) -- right_arm_up right_hand_thump right_hand_sweep -- 84 (132) -- right_arm_down _hand_pick_up high_5 -- 85 (133) -- right_arm_in lean_backward _hand_strike_1 -- 82 (130) -- right_arm_out _hand_throw rs_burp -- 83 (131) -- tilt_body_right rs_sleep _hand_strike_2 -- 89 (137) -- left_arm_up left_hand_thump left_hand_sweep -- 8C (140) -- left_arm_down _hand_pick_up talk_back -- 8D (141) -- left_arm_in lean_forward _hand_strike_1 -- 8A (138) -- left_arm_out _hand_throw rs_whistle -- 8B (139) -- tilt_body_left rs_listen _hand_strike_2 -- 80 (128) -- turn_right _step right_hand_strike_3 -- 88 (136) -- turn_left _step left_hand_strike_3 -- 86 (134) -- walk_forward _step bulldozer -- 87 (135) -- walk_backward _step rs_oops -- 8E (142) -- rs_stop rs_reset rs_roar -- 92 (146) -- right_sensor_program _ex rs_demo_1 -- 94 (148) -- sonic_sensor_program _ex rs_dance -- 93 (147) -- left_sensor_program _ex rs_demo_2 -- 90 (144) -- master_command_program _ex rs_all_demo -- 91 (145) -- program_play rs_wake_up rs_power_off -- End of file