% % Implementation by Piotr Hołownia % % Copyright (C) 2006-9 by the HeKatE Project % % PlNXT has been develped by the HeKatE Project, % see http://hekate.ia.agh.edu.pl % % This file is part of PlNXT. % % PlNXT is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % PlNXT is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with PlNXT. If not, see . % :- module(nxt_actions_dummy,[ nxt_actions_connection_open/0, nxt_actions_connection_close/0, nxt_actions_motor_forward/2, nxt_actions_motor_backward/2, nxt_actions_motor_get_speed/2, nxt_actions_motor_stop/1, nxt_actions_motor_rotate/3, nxt_actions_touch_sensor/2, nxt_actions_sound_sensor/2, nxt_actions_light_sensor/2, nxt_actions_light_sensor_LED/2, nxt_actions_ultrasonic_sensor/2, nxt_actions_voltage/1, nxt_actions_voltage_millivolt/1, nxt_actions_start_program/1, nxt_actions_stop_program/0, nxt_actions_play_sound_file/2, nxt_actions_stop_sound_playback/0, nxt_actions_play_tone/2, nxt_actions_get_brick_name/1, nxt_actions_set_brick_name/1 ]). /** NXT Mindstroms - Actions Dummy (does nothing, describes actions only). Motors: 'A', 'B', 'C'. Sensors ports: 'S1', 'S2', 'S3', 'S4'. @author Piotr Hołownia @license GNU General Public License */ %% nxt_actions_connection_open % % Opens connection via Bluetooth using iCommand. nxt_actions_connection_open :- writeln('Openning connection...'), writeln('Connected via Bluetooth using iCommand!'). %% nxt_actions_connection_close % % Closes connection via Bluetooth using iCommand. nxt_actions_connection_close :- writeln('Closing connection...'), writeln('Disconnected!'). %% nxt_actions_motor_forward(+Motor,+Speed). % % Rotates motor forward at specified speed. nxt_actions_motor_forward(Motor,Speed) :- write('Rotating motor '), write(Motor), write(' forward at speed: '), write(Speed), write('.'),nl. %% nxt_actions_motor_backward(+Motor,+Speed). % % Rotates motor backward at specified speed. nxt_actions_motor_backward(Motor,Speed) :- write('Rotating motor '), write(Motor), write(' backward at speed: '), write(Speed), write('.'),nl. %% nxt_actions_motor_get_speed(+Motor,+Speed). % % Gets speed of the motor. nxt_actions_motor_get_speed(Motor,Speed) :- Speed is random(900), write('Motor '), write(Motor), write(' is rotating at Speed: '), write(Speed), write('.'),nl. %% nxt_motor_stop(+Motor). % % Stops motor. nxt_actions_motor_stop(Motor) :- write('Motor '), write(Motor), write(' has been stopped.'),nl. %% nxt_actions_motor_rotate(+Motor,+Speed,+Angle). % % Rotates motor at specified speed. % Forward if Angle is positive, backward if Angle is negative. % Motor will stop, when specified revolution (Angle in degrees) is reached. nxt_actions_motor_rotate(Motor,Speed,Angle) :- write('Rotating motor '), write(Motor), write(' at speed: '), write(Speed), write('. '), write('Angle limit: '), write(Angle), write('.'),nl. %% nxt_actions_touch_sensor(+Port,-Value). % % Gets touch sensor reading. % Returns 1 if pressed, 0 otherwise. nxt_actions_touch_sensor(Port,Value) :- Value is random(1), write('Touch sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_sound_sensor(+Port,-Value). % % Gets sound sensor reading. nxt_actions_sound_sensor(Port,Value) :- Value is random(1000), write('Sound sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_light_sensor(+Port,-Value). % % Gets light sensor reading. nxt_actions_light_sensor(Port,Value) :- Value is random(100), write('Light sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_light_sensor_LED(+Port,+Setting). % % Sets the LED on if Setting is activate or off if passivate. nxt_actions_light_sensor_LED(Port,Setting) :- write('Light sensor LED connected to port '), write(Port), write(' has been set to: '), write(Setting), write(' state. '),nl. %% nxt_actions_ultrasonic_sensor(+Port,-Value). % % Gets ultrasonic sensor reading. nxt_actions_ultrasonic_sensor(Port,Value) :- Value is random(255), write('Ultrasonic sensor connected to port '), write(Port), write(' returns: '), write(Value), write('.'),nl. %% nxt_actions_voltage(-Voltage). % % Returns battery voltage in V. nxt_actions_voltage(Voltage) :- Voltage is random(9), write('Battery Voltage: '), write(Voltage), write(' V.'),nl. %% nxt_actions_voltage_millivolt(-Voltage). % % Returns battery voltage in mV. nxt_actions_voltage_millivolt(Voltage) :- Voltage is random(9000), write('Battery Voltage: '), write(Voltage), write(' mV.'),nl. %% nxt_actions_start_program(+File) % % Starts a Lego executable file on the NXT. nxt_actions_start_program(File) :- write('Executing file: '), write(File),nl. %% nxt_actions_stop_program. % % Stops the currently running Lego executable on the NXT. nxt_actions_stop_program :- writeln('Stopping the currently running program.'). %% nxt_actions_play_sound_file(+File,+Repeat). % % Plays a sound file from the NXT. % Files use the .rso extension. % The filename is not case sensitive. % nxt_actions_play_sound_file/2 plays sound once if Repeat is true % or till nxt_actions_stop_sound_playback is used if Repeat is % false. nxt_actions_play_sound_file(File,true) :- write('Playing in loop sound file: '), write(File),nl. nxt_actions_play_sound_file(File,false) :- write('Playing once sound file: '), write(File),nl. %% nxt_actions_stop_sound_playback. % % Stops a sound file that has been playing/repeating. nxt_actions_stop_sound_playback :- writeln('Stopping the currently playing sound.'). %% nxt_actions_play_tone(Frequency,Duration). % % Plays tone at specified frequency. nxt_actions_play_tone(Frequency,Duration) :- write('Playing tone at frequency: '), write(Frequency), write(' and duration: '), write(Duration), write('.'),nl. %% nxt_actions_get_brick_name(-Name). % % Gets the name of the brick. nxt_actions_get_brick_name(Name) :- Name='MyBrick', write('The name of the brick is: '), write(Name), write('.'),nl. %% nxt_actions_set_brick_name(+Name) % % Sets the name of the brick. nxt_actions_set_brick_name(Name) :- write('Setting the name of the brick to: '), write(Name), write('.'),nl.