diff --git a/source/EV3.m b/source/EV3.m index b2377ac0823a81873b230093aa08ba6fe597c349..65e9952fa99095e3c07d977b6645c9678593bd27 100644 --- a/source/EV3.m +++ b/source/EV3.m @@ -35,20 +35,19 @@ classdef EV3 < MaskedHandle % batteryValue (numeric): Current battery charge. Depending on batteryMode, the reading is either in percentage or voltage. See also :attr:`batteryMode`. *[READ-ONLY]* % isConnected (bool): True if virtual brick-object is connected to physical one. *[READ-ONLY]* % - % :: - % - % Example: - % # This example expects a motor at port A and a (random) sensor at port 1 - % brick = EV3(); - % brick.connect('usb'); - % motorA = brick.motorA; - % motorA.setProperties('power', 50, 'limitValue', 720); - % motorA.start(); - % motorA.waitFor(); - % disp(brick.sensor1.value); - % brick.beep(); - % delete brick; % + % Example: + % % This example expects a motor at port A and a (random) sensor at port 1 |br| + % b = EV3(); % |br| + % b.connect('usb'); % |br| + % ma = b.motorA; % |br| + % ma.setProperties('power', 50, 'limitValue', 720); % |br| + % ma.start(); % |br| + % % fun |br| + % ma.waitFor(); % |br| + % disp(b.sensor1.value); % |br| + % b.beep(); % |br| + % delete b; % |br| properties % batteryMode (string in {'Percentage', 'Voltage'}): Mode for reading battery charge. [WRITABLE] @@ -159,22 +158,21 @@ classdef EV3 < MaskedHandle % (necessary if connectionType is 'bt'). *[OPTIONAL]* % beep (bool): If true, EV3 beeps if connection has been established. *[OPTIONAL]* % - % - % :: - % - % Example: - % % Setup bluetooth connection via com-port 0 - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % % Setup usb connection, beep when connection has been established - % brick = EV3(); - % brick.connect('usb', 'beep', 'on', ); + % Example: + % % Setup bluetooth connection via com-port 0 |br| + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % % Setup usb connection, beep when connection has been established + % b = EV3(); % |br| + % b.connect('usb', 'beep', 'on', ); % |br| % % See also ISCONNECTED / :attr:`isConnected` if ev3.isConnected if isCommInterfaceValid(ev3.commInterface) - warning('EV3::connect: Already connected. Resetting connection now...'); + % Warning lead to confusion of students. Since brick connection is still working + % even if calling connect() multiple times, it is disabled. + % warning('EV3::connect: Already connected. Resetting connection now...'); ev3.disconnect(); else warning(['EV3::connect: EV3.isConnected is set to ''True'', but ',... @@ -230,14 +228,11 @@ classdef EV3 < MaskedHandle % Notes: % * Gets called automatically when EV3-object is destroyed. % - % - % :: - % - % Example: - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % % do stuff - % brick.disconnect(); + % Example: + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % % do stuff |br| + % b.disconnect(); % |br| % Resetting needs a working connection in order to send reset-commands % to the Brick. If the connection has been aborted (e.g. by pulling the @@ -279,13 +274,10 @@ classdef EV3 < MaskedHandle % Notes: % * This equals playTone(10, 1000, 100). % - % - % :: - % - % Example: - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % brick.beep(); + % Example: + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % b.beep(); % |br| % ev3.handleCommand(@soundPlayTone, 10, 1000, 100); end @@ -298,13 +290,11 @@ classdef EV3 < MaskedHandle % frequency (numeric in [250, 10000]): in Hertz % duration (numeric > 0): in milliseconds % - % - % :: - % - % Example: - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % brick.playTone(40, 5000, 1000); % Plays tone with 40% volume and 5000Hz for 1 second. + % Example: + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % b.playTone(40, 5000, 1000); % Plays tone with 40% volume and 5000Hz for 1 + % second. |br| % ev3.handleCommand(@soundPlayTone, volume, frequency, duration); end @@ -312,14 +302,11 @@ classdef EV3 < MaskedHandle function stopTone(ev3) % Stops tone currently played. % - % - % :: - % - % Example: - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % brick.playTone(10,100,100000000); - % brick.stopTone(); % Stops tone immediately. + % Example: + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % b.playTone(10,100,100000000); % Accidentally given wrong tone duration :) |br| + % b.stopTone(); % Stops tone immediately. |br| % ev3.handleCommand(@soundStopTone); end @@ -330,16 +317,12 @@ classdef EV3 < MaskedHandle % Returns: % status (bool): True if a tone is being played % - % - % :: - % - % Example: - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % brick.playTone(10, 100, 1000); - % pause(0.5); - % % Small pause necessary since tone not startong immediately - % brick.tonePlayed(); % -> Outputs 1 to console. + % Example + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % b.playTone(10, 100, 1000); % |br| + % pause(0.5); % Small pause is necessary as tone does not start instantaneously |br| + % b.tonePlayed(); % -> Outputs 1 to console. |br| % status = ev3.handleCommand(@soundTest); end @@ -391,14 +374,11 @@ classdef EV3 < MaskedHandle % debug (numeric in {0,1,2}): see EV3.debug *[OPTIONAL]* % batteryMode (string in {'Voltage'/'Percentage'}): see EV3.batteryMode *[OPTIONAL]* % - % - % :: - % - % Example: - % brick = EV3(); - % brick.connect('bt', 'serPort', '/dev/rfcomm0'); - % brick.setProperties('debug', 'on', 'batteryMode', 'Voltage'); - % % Instead of: b.debug = 'on'; b.batteryMode = 'Voltage'; + % Example: + % b = EV3(); % |br| + % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br| + % b.setProperties('debug', 'on', 'batteryMode', 'Voltage'); % |br| + % % Instead of: b.debug = 'on'; b.batteryMode = 'Voltage'; % |br| % % See also EV3.DEBUG, EV3.BATTERYMODE / :attr:`debug`, :attr:`batteryMode` @@ -530,4 +510,4 @@ classdef EV3 < MaskedHandle end end end -end +end \ No newline at end of file