diff --git a/source/BrakeMode.m b/source/BrakeMode.m old mode 100644 new mode 100755 diff --git a/source/BrickIO.m b/source/BrickIO.m old mode 100644 new mode 100755 diff --git a/source/ByteCodes.m b/source/ByteCodes.m old mode 100644 new mode 100755 diff --git a/source/COMGetSubCodes.m b/source/COMGetSubCodes.m old mode 100644 new mode 100755 diff --git a/source/COMSetSubCodes.m b/source/COMSetSubCodes.m old mode 100644 new mode 100755 diff --git a/source/Color.m b/source/Color.m old mode 100644 new mode 100755 diff --git a/source/Command.m b/source/Command.m old mode 100644 new mode 100755 diff --git a/source/CommunicationInterface.m b/source/CommunicationInterface.m old mode 100644 new mode 100755 diff --git a/source/ConnectionType.m b/source/ConnectionType.m old mode 100644 new mode 100755 diff --git a/source/Device.m b/source/Device.m old mode 100644 new mode 100755 diff --git a/source/DeviceMode.m b/source/DeviceMode.m old mode 100644 new mode 100755 diff --git a/source/DeviceType.m b/source/DeviceType.m old mode 100644 new mode 100755 diff --git a/source/EV3.m b/source/EV3.m old mode 100644 new mode 100755 index ec1a8c08dac5b71e7b49c2429afbd70ee6ca6dc4..abe4c262544b5232cd40f3c330a92f3f112180ef --- a/source/EV3.m +++ b/source/EV3.m @@ -1,34 +1,9 @@ -classdef EV3 < handle +classdef EV3 < MaskedHandle % High-level class to work with physical bricks. % % This is the 'central' class (from user's view) when working with this toolbox. It % delivers a convenient interface for creating a connection to the brick and sending % commands to it. - % - % Properties: - % Standard - % motorA[,B,C,D] - % sensor1[,2,3,4] - % debug - Debug turned on or off - % batteryMode - Mode for reading battery charge - % Dependent - % batteryValue - Current battery charge level - % get-only - % isConnected - Is virtual brick connected to physical one? - % commInterface - Interface to communication layer - % - % Methods: - % General - % EV3 - % connect - Connects EV3-object and its Motors and Sensors to physical brick via bt or usb - % disconnect - Disconnects EV3-object and its Motors and Sensors from physical brick - % setProperties - Set multiple EV3 properties at once using MATLAB's inputParser - % Brick functions - % beep - Plays a 'beep' tone on brick - % playTone - Plays tone on brick - % stopTone - Stops tone currently played - % tonePlayed - Tests if a tone is currently played - % % % Notes % * Creating multiple EV3 objects and connecting them to different physical bricks has not @@ -36,89 +11,60 @@ classdef EV3 < handle % * When referring to an instance of this class the term 'virtual brick' is used from now % on. The LEGO EV3 brick itself is referred to as 'physical brick'. % - % Example - % % This small example connects to the brick, starts motorA with power 50 and time-limit - % % of 5 seconds. As long as it's running, sensor 1 is read and its readings are plotted - % % the end. - % - %%%%%%%%%% - % brickObject = EV3('debug', 'on', 'batteryMode', 'Voltage'); - % brickObject.connect('bt', 'serPort', '/dev/rfcomm0'); - % - % m = brickObject.motorA; - % s = brickObject.sensor1; - % - % m.setProperties('Power', 50, 'BrakeMode', 'Brake', 'TachoLimitMode', 'Time', ... - % 'TachoLimit', 5000); - % - % if s.type ~= DeviceType.Color - % fprintf('Please connect EV3-color-sensor to port 1!\n'); - % else - % s.mode = DeviceMode.Color.Ambient; - % - % readings = []; - % time = []; - % - % tic; - % m.start(); - % pause(0.5); - % while m.isRunning - % readings = [readings, s.value]; - % time = [time toc]; - % end - % - % plot(time, readings); - % end - % - % brickObject.disconnect(); - % brickObject.delete(); - % clear all - %%%%%%%%%% - % % Signature % Author: Tim Stadtmann % Date: 2016/05/19 % Updated: 2016/08/15 properties % Standard properties - %debug - Debug turned on or off + %debug - [Writable] Debug turned on or off (0/1/off/on/'false'/'true'/2) % In debug mode 1 (debug=1/'on'/true), everytime a command is passed to the sublayer % ('communication layer'), there is feedback in the console about what command has been % called. Debug mode 2 (debug=2) enables debug mode in the lower layers. Each packet % sent and received is printed to the console. - % -> Any valid boolean (0/1/'on'/'off'/true/false) or 2 (for enabling debugging in - % lower layers) debug; - %% Modi - - %batteryMode - Mode for reading battery charge - % -> 'Percentage' / 'Voltage' + %batteryMode - [Writable] Mode for reading battery charge ('Percentage'/'Voltage') % See also EV3.BATTERYVALUE batteryMode; end properties (Dependent) % Parameters to be read directly from physical brick - %batteryValue - Current battery charge + %batteryValue - [Read-only] Current battery charge % Depending on batteryMode, the reading is either in percentage or voltage. % See also EV3.BATTERYMODE batteryValue; end properties (SetAccess = 'private') % Read-only properties that are set internally - %isConnected - Virtual brick connected to physical one? + %isConnected - [Read-only] Virtual brick connected to physical one? + % See also EV3.CONNECT, EV3.DISCONNECT isConnected = false; - - %% Motors and Sensors + %motorA - [Read-only] + % See also MOTOR motorA; + %motorB - [Read-only] + % See also MOTOR motorB; + %motorC - [Read-only] + % See also MOTOR motorC; + %motorD - [Read-only] + % See also MOTOR motorD; + %sensor1 - [Read-only] + % See also SENSOR sensor1; + %sensor2 - [Read-only] + % See also SENSOR sensor2; + %sensor3 - [Read-only] + % See also SENSOR sensor3; + %sensor4 - [Read-only] + % See also SENSOR sensor4; end @@ -466,13 +412,51 @@ classdef EV3 < handle bat = ev3.getBattery(); end - %% Display function display(ev3) - % WIP - warning('off','all'); - builtin('disp', ev3); - warning('on','all'); + displayProperties(ev3); + + fprintf('\n\tDevices\n'); + props = properties(ev3); + + warning('off', 'all'); % Turn off warnings while reading values + for i = 1:length(props) + p = props{i}; + + if strcmp(class(ev3.(p)),'Sensor') || strcmp(class(ev3.(p)), 'Motor') + fprintf('\t%15s [Type: %s]\n', p, char(ev3.(p).type)); + end + end + warning('on', 'all'); end +% function display(ev3) +% warning('off','all'); +% %builtin('disp', ev3); +% +% +% props = properties(ev3); % Save list with property names as strings +% fprintf(' <a href="matlab:helpPopup EV3">EV3</a> with properties:\n\n'); +% for i = 1:length(props) +% p = props{i}; +% +% if isa(ev3.(p), 'handle') && ev3.(p).isvalid % Valid handle? +% if isa(ev3.(p), 'Brick') % Communication interface? +% fprintf('\t%15s: Brick-object (Interface for comm-layer)\n'); +% else % Motor or Sensor object? +% fprintf('\t%15s: %s-object for port %s\n', p, class(ev3.(p)), ... +% port2str(class(ev3.(p)), ev3.(p).port)); +% end +% elseif isnumeric(ev3.(p)) +% fprintf('\t%15s: %d\n', p, ev3.(p)); +% elseif ischar(ev3.(p)) +% fprintf('\t%15s: %s\n', p, ev3.(p)); +% else +% warning('EV3::display: Unsuspected parameter type.'); % Not really useful +% end +% end +% +% warning('on','all'); +% +% end end methods (Access = 'private') % Private brick functions that are wrapped by dependent params diff --git a/source/ID.m b/source/ID.m old mode 100644 new mode 100755 diff --git a/source/InputDeviceSubCodes.m b/source/InputDeviceSubCodes.m old mode 100644 new mode 100755 diff --git a/source/LEDPattern.m b/source/LEDPattern.m old mode 100644 new mode 100755 diff --git a/source/MaskedHandle.m b/source/MaskedHandle.m new file mode 100755 index 0000000000000000000000000000000000000000..4fb94bc3e8d5ce519a1648268f186fdf1bae08e9 --- /dev/null +++ b/source/MaskedHandle.m @@ -0,0 +1,44 @@ +classdef MaskedHandle < handle + methods (Hidden) + function addlistener(varargin) + addlistener@addlistener(varargin{:}) + end + + function findobj(varargin) + findobj@findobj(varargin{:}); + end + +% function findprop(varargin) +% findprop@findprop(varargin{:}); +% end + + function notify(varargin) + notify@notify(varargin{:}); + end + + function ge(h1, h2) + ge@ge(h1, h2); + end + + function gt(h1, h2) + gt@gt(h1, h2); + end + + function le(h1, h2) + le@le(h1, h2); + end + + function lt(h1, h2) + lt@lt(h1, h2); + end + + function ne(h1, h2) + ne@ne(h1, h2); + end + + function eq(h1, h2) + eq@eq(h1, h2); + end + end +end + diff --git a/source/Motor.m b/source/Motor.m old mode 100644 new mode 100755 index 8cbb720dd8bf0c0417ab22da97919353c011e58a..592ec28b178671362e47274753a822df5047b67b --- a/source/Motor.m +++ b/source/Motor.m @@ -1,44 +1,10 @@ -classdef Motor < handle & dynamicprops +classdef Motor < MaskedHandle & dynamicprops % Motor High-level class to work with motors. % % This class is supposed to ease the use of the brick's motors. It is possible to set all % kinds of parameters, request the current status of the motor ports and of course send % commands to the brick to be executed on the respective port. % - % Properties: - % Standard - % power - Power level of motor in percent - % speedRegulation - Speed regulation turned on or off - % smoothStart - Degrees/Time for how far/long the motor should smoothly start (depends on limitMode) - % smoothStop - Degrees/Time for how far/long the motor should smoothly stop (depends on limitMode) - % limitValue - Degrees/Time for how far/long the motor should run (depends on limitMode) - % limitMode - Mode for motor limit - % brakeMode - Mode for braking - % debug - Debug mode turned on or off - % Dependent - % isRunning - True if motor is running (currentSpeed > 0) - % tachoCount - Current tacho count - % currentSpeed - Current speed of motor (should equal power if speedRegulation = 1) - % type - Current motor type (large or medium motor) - % Other - % port - Motor port - % - % Methods: - % Standard - % Motor - % connect - Connects Motor-object to physical brick - % disconnect - Disconnects Motor-object from physical brick - % setProperties - Sets multiple Motor properties at once using MATLAB's inputParser - % Brick functions - % start - Starts the motor taking all parameters set by user into account - % stop - Stops the motor :) - % syncedStart - Starts the motor synchronized with another - % syncedStop - Stops the motors previously started together with syncedStart - % waitFor - Stops execution of program as long as motor is running with tacholimit - % reset - Resets internal tacho count - % resetTachoCount - Resets tacho count to 0 (if running without tacholimit) - % - % % Notes: % * You don't need to create instances of this class. The EV3-class automatically creates % instances for each motor port, and you can work with them via the EV3-object. @@ -50,60 +16,65 @@ classdef Motor < handle & dynamicprops % Updated: 2016/08/15 properties % Standard properties to be set by user - %power - Power level of motor in percent - % -> Any numeric in [-100, 100] + %power - [Writable] Power level of motor in percent (numeric in [-100, 100]) power; - %speedRegulation - Speed regulation turned on or off - % -> Any valid boolean (0/1/'on'/'off'/true/false) + %speedRegulation - [Writable] Speed regulation turned on or off (0/1/off/on/'false'/'true') + % When turned on, motor will try to 'hold' its speed at given power level, whatever the + % load. In this mode, the highest possible speed depends on the load and mostly goes up + % to around 70-80 (at this point, the Brick internally input 100% power). + % When turned off, motor will constantly input the same power into the motor. The + % resulting speed will be somewhat lower, depending on the load. speedRegulation; - %smoothStart - Degrees/Time for how far/long the motor should smoothly start (depends on limitMode) - % -> Any numeric in [0, limitValue] + %smoothStart - [Writable] Degrees/Time indicating how far/long the motor should smoothly start (numeric such that smoothStart+smoothStop < limitValue) + % Depending on limitMode, the input is interpreted either in degrees or milliseconds. + % The first [smoothStart]-milliseconds/degrees of limitValue the motor will slowly + % accelerate until reaching it's defined speed. + % See also MOTOR.LIMITMODE smoothStart; - %smoothStop - Degrees/Time for how far/long the motor should smoothly stop (depends on limitMode) - % -> Any numeric in [0, limitValue] + %smoothStop - [Writable] Degrees/Time indicating how far/long the motor should smoothly stop (numeric such that smoothStart+smoothStop < limitValue) + % Depending on limitMode, the input is interpreted either in degrees or milliseconds. + % The last [smoothStop]-milliseconds/degrees of limitValue the motor will slowly + % slow down until it has stopped. + % See also MOTOR.LIMITMODE smoothStop; - %limitValue- Degrees/Time for how far/long the motor should run (depends on limitMode) - % -> Any numeric >= 0 (in ms, if limitMode = 'Time') + %limitValue - [Writable] Degrees/Time indicating how far/long the motor should run (numeric>=0) + % Depending on limitMode, the input is interpreted either in degrees or milliseconds. + % See also MOTOR.LIMITMODE limitValue; - %limitMode - Mode for motor limit - % -> 'Tacho' / 'Time' + %limitMode - [Writable] Mode for motor limit ('Tacho'/'Time') + % See also MOTOR.SMOOTHSTART, MOTOR.SMOOTHSTOP, MOTOR.LIMITMODE limitMode; - %brakeMode - Mode for braking - % -> 'Brake' / 'Coast' + %brakeMode - [Writable] Mode for braking ('Brake'/'Coast') + % If 'Coast', the motor will (at tacholimit, if ~=0) coast to a stop. If + % 'Brake', the motor will stop immediately (at tacholimit, if ~=0) and hold the brake. brakeMode; - %debug - Debug turned on or off + %debug - [Writable] Debug turned on or off (0/1/off/on/'false'/'true') % In debug mode, everytime a command is passed to the sublayer ('communication layer'), - % there is feedback in the console about what command has been called, etc. - % -> Any valid boolean (0/1/'on'/'off'/true/false) + % there is feedback in the console about what command has been called debug; end - properties (SetAccess = 'private') - %port - Motor port - % This is only the string representation of the motor port to work with. - % Internally, either MotorPort-, MotorBitfield- or MotorInput-member will be used. - % -> 'A' / 'B' / 'C' / 'D' - port; - end - properties (Dependent) % Read-only parameters to be read directly from physical brick - %isRunning - True if motor is running (speed > 0) + %isRunning - [Read-only] True if motor is running (i.e. speed > 0) isRunning; - %tachoCount - Current tacho count + %tachoCount - [Read-only] Current tacho count tachoCount; - %currentSpeed - Current speed of motor (equals power if speedRegulation = true) + %currentSpeed - [Read-only] Current speed of motor + % If speedRegulation=on this should equal power, otherwise it will probably be lower + % than that. + % See also MOTOR.SPEEDREGULATION currentSpeed; - %type - Type of connected device if any + %type - [Read-only] Type of connected device if any % See also DEVICETYPE type; end @@ -112,6 +83,10 @@ classdef Motor < handle & dynamicprops commInterface; % Communication interface %% Hidden brick parameters + %port - [Read-only] Motor port + % This is only the string representation of the motor port to work with. + % Internally, either MotorPort-, MotorBitfield- or MotorInput-member will be used. + port; % brakeMode is an actual parameter on the brick. To avoid inconsistencies with other % modi and to prettify the output, a string representing it is saved. In order to avoid @@ -154,7 +129,7 @@ classdef Motor < handle & dynamicprops %% Brick functions function start(motor) - %start Starts the motor taking all parameters set by user into account. + %start Starts the motor % % Notes % * Right now, alternatingly calling this function with and without tacho limit @@ -268,7 +243,7 @@ classdef Motor < handle & dynamicprops end function stop(motor) - %stop Stops the motor. :) + %stop Stops the motor if ~motor.connectedToBrick error(['Motor::stop: Motor-Object not connected to comm handle.',... @@ -291,9 +266,9 @@ classdef Motor < handle & dynamicprops function syncedStart(motor, syncMotor, varargin) %syncedStart Starts this motor synchronized with another % This motor acts as a 'master', meaning that the synchronized control is done via - % it. When syncedStart is called, the master sets the slave's (syncMotor) - % properties to keep it consistent with the last parameters sent to the physical - % brick. So, for example, changing the power on the master motor will take effect + % this one. When syncedStart is called, the master sets some of the slave's + % (syncMotor) properties to keep it consistent with the physical brick. So, for + % example, changing the power on the master motor will take effect % on the slave as soon as this method is called. % The following parameters will be affected on the slave: power, brakeMode, % limitValue, speedRegulation @@ -315,7 +290,7 @@ classdef Motor < handle & dynamicprops % -> Values greater than +100 makes the right motor run the opposite % direction of the left motor (Spin)" % * This is right now a pretty 'heavy' function, as it tests if both motors are - % connected AND aren't running, wasting four commands, so keep that in mind + % connected AND aren't running, wasting four packets, so keep that in mind % % Example % b = EV3(); b.connect('usb'); @@ -448,16 +423,16 @@ classdef Motor < handle & dynamicprops end function waitFor(motor) - %waitFor Stops execution of program as long as motor is running (WITH TACHOLIMIT). + %waitFor Stops execution of program as long as motor is running % % Notes: - % * This one's a bit tricky. The opCode OutputReady makes the brick stop sending + % * (OLD)This one's a bit tricky. The opCode OutputReady makes the brick stop sending % responses until the motor has stopped. For security reasons, in this toolbox % there is an internal timeout for receiving messages from the brick. It raises - % an error if a reply takes too long, which would happen in this case. To + % an error if a reply takes too long, which would happen in this case. As a % workaround, there is an infinite loop that catches errors from outputReady and % continues then, until outputReady will actually finish without an error. - % * OutputReady (like OutputTest in isRunning) sometimes doesn't work. If + % * (OLD)OutputReady (like OutputTest in isRunning) sometimes doesn't work. If % outputReady returns in less than a second, another while-loop iterates until % the motor has stopped, this time using motor.isRunning() (this only works as % long as not both OutputTest and OutputReady are buggy). @@ -533,13 +508,6 @@ classdef Motor < handle & dynamicprops end function resetTachoCount(motor) - %resetTachoCount Resets tacho count to 0 if running without tacholimit - % Compared to motor.reset, this resets the 'sensor mode' tacho count, a second - % tacho counter. This counter is used for reading the tacho count with inputRead - % and outputGetCount (via motor.tachoCount). - % - % See also MOTOR.RESET - % if ~motor.connectedToBrick error(['Motor::resetTachoCount: Motor-Object not connected to comm handle.',... @@ -830,9 +798,7 @@ classdef Motor < handle & dynamicprops %% Display function display(motor) - warning('off','all'); - builtin('disp', motor); - warning('on','all'); + displayProperties(motor); end end diff --git a/source/MotorBitfield.m b/source/MotorBitfield.m old mode 100644 new mode 100755 diff --git a/source/MotorInput.m b/source/MotorInput.m old mode 100644 new mode 100755 diff --git a/source/MotorPort.m b/source/MotorPort.m old mode 100644 new mode 100755 diff --git a/source/OutputStreamSend.class b/source/OutputStreamSend.class old mode 100644 new mode 100755 diff --git a/source/OutputStreamSend.java b/source/OutputStreamSend.java old mode 100644 new mode 100755 diff --git a/source/Primitives.m b/source/Primitives.m old mode 100644 new mode 100755 diff --git a/source/Sensor.m b/source/Sensor.m old mode 100644 new mode 100755 index bf2c60e690c67d752a83b3581b0e69c3535cf40c..78d9ce6080bd2b7ad2bc91620b8e16abafa56dd4 --- a/source/Sensor.m +++ b/source/Sensor.m @@ -1,72 +1,55 @@ -classdef Sensor < handle +classdef Sensor < MaskedHandle % Sensor High-level class to work with sensors. % - % Properties: - % Standard - % debug - Debug mode turned on or off - % mode - Sensor mode in which the values will be read - % Dependent - % value - Value read from sensor - % type - Type of connected sensor if any - % - % Methods: - % Standard - % EV3 - % connect - Connects Sensor-object to physical brick - % disconnect - Disconnects Sensor-object from physical brick - % reset - Resets value on sensor - % setProperties - Sets multiple Sensor properties at once using MATLAB's inputParser - % - % Example - % % This small example should only roughly demonstrate how to work with sensors. - % % Establish connection, set properties on sensor1 and wait, until user has pressed the - % % touch sensor ten times. Then beep and disconnect. - % - % b = EV3(); - % b = EV3('debug', 'on', 'batteryMode', 'Voltage'); - % b.connect('bt', 'serPort', '/dev/rfcomm0'); - % b.sensor1.mode = DeviceMode.Touch.Bumps; - % while value < 10 - % pause(0.1); - % end - % b.beep(); - % b.disconnect(); - % b.delete() - % - % % Signature % Author: Tim Stadtmann % Date: 2016/05/20 % Updated: 2016/08/15 properties % Standard properties to be set by user - %mode - Sensor mode in which the value will be read - % -> DeviceMode.[...] (except for DeviceMode.Motor.[...]) + %mode - [Writable] Sensor mode in which the value will be read (DeviceMode.[...]) + % By default, mode is set to DeviceMode.Default.Undefined. The allowed mode (and the + % default mode) for a Sensor-object depends on its type. + % Touch-Sensor: DeviceMode.Touch.Pushed (Default) + % DeviceMode.Touch.Bumps + % Ultrasonic-Sensor: DeviceMode.UltraSonic.DistCM (Default) + % DeviceMode.UltraSonic.DistIn + % DeviceMode.UltraSonic.Listen + % Color-Sensor: DeviceMode.Color.Reflect (Default) + % DeviceMode.Color.Ambient + % DeviceMode.Color.Col + % Gyro-Sensor: DeviceMode.Gyro.Angular (Default) + % DeviceMode.Gyro.Rate + % + % See also SENSOR.VALUE, SENSOR.TYPE mode; - %debug - Debug turned on or off + %debug - [Writable] Debug turned on or off (0/1/'on'/'off'/'true'/'false') % In debug mode, everytime a command is passed to the sublayer ('communication layer'), % there is feedback in the console about what command has been called, etc. - % -> Any valid boolean (0/1/'on'/'off'/'true'/'false') debug; end - properties (SetAccess = 'private') - %port - Sensor port - % This is only the string representation of the sensor port to work with. - % Internally, SensorPort-enums are used. - % -> '1' / '2' / '3' / '4' - port; - end - properties (Dependent) % Parameters to be read directly from physical brick - value; % Value read from sensor - type; % Physical sensor connected to this port? + %value - [Read-only] Value read from sensor + % What the value represents depends on sensor.mode. + % See also SENSOR.MODE + value; + + %type - [Read-only] Type of physical sensor connected to port + % Entering "DeviceType." + Tab will show you a list of possible types. If virtual brick + % is not connected to physical one, type will be DeviceType.Unknown by default. + type; end properties (Hidden, Access = 'private') % Hidden properties for internal use only commInterface = 0; % Communication interface + %port - [Read-only] Sensor port ('1'/'2'/'3'/'4') + % This is only the string representation of the sensor port to work with. + % Internally, SensorPort-enums are used. + port; + %% Miscallenous flags connectedToBrick = false; % Does (virtual) sensor-object have a valid brick-handle? @@ -235,9 +218,7 @@ classdef Sensor < handle %% Display function display(sensor) - warning('off','all'); - builtin('disp', sensor); - warning('on','all'); + displayProperties(sensor); end end @@ -345,6 +326,7 @@ classdef Sensor < handle 'Port %d.\n'], sensor.port+1); end end + end methods (Access = {?EV3}) diff --git a/source/SensorPort.m b/source/SensorPort.m old mode 100644 new mode 100755 diff --git a/source/SoundSubCodes.m b/source/SoundSubCodes.m old mode 100644 new mode 100755 diff --git a/source/SystemCommands.m b/source/SystemCommands.m old mode 100644 new mode 100755 diff --git a/source/UIDrawSubCodes.m b/source/UIDrawSubCodes.m old mode 100644 new mode 100755 diff --git a/source/UIReadSubCodes.m b/source/UIReadSubCodes.m old mode 100644 new mode 100755 diff --git a/source/UIWriteSubCodes.m b/source/UIWriteSubCodes.m old mode 100644 new mode 100755 diff --git a/source/_SyncMotor.m b/source/_SyncMotor.m old mode 100644 new mode 100755 index 8ef432218c55fee29bc13d5a682fdfea2ad8a146..ebf110ec7c637fd376c60e35696c48763bfa69c8 --- a/source/_SyncMotor.m +++ b/source/_SyncMotor.m @@ -387,6 +387,13 @@ classdef SyncMotor < Motor function portInput_sec = get.portInput_sec(motor) portInput_sec = motor.getPortInput_sec(); end + + %% Display + function display(syncMotor) + warning('off','all'); + builtin('disp', syncMotor); + warning('on','all'); + end end methods (Access = 'protected') % Private brick functions that are wrapped by dependent params diff --git a/source/bitfield2input.m b/source/bitfield2input.m old mode 100644 new mode 100755 diff --git a/source/bitfield2port.m b/source/bitfield2port.m old mode 100644 new mode 100755 diff --git a/source/bool2str.m b/source/bool2str.m old mode 100644 new mode 100755 diff --git a/source/brake2str.m b/source/brake2str.m old mode 100644 new mode 100755 diff --git a/source/btBrickIO.m b/source/btBrickIO.m old mode 100644 new mode 100755 diff --git a/source/displayProperties.m b/source/displayProperties.m new file mode 100755 index 0000000000000000000000000000000000000000..7b39943844cc380e259cf5628f5a6a0c5ee37ba4 --- /dev/null +++ b/source/displayProperties.m @@ -0,0 +1,65 @@ +function displayProperties(device) +cl = class(device); +if ~strcmp(cl, 'Motor') && ~strcmp(cl, 'Sensor') && ~strcmp(cl, 'EV3') + error('displayProperties: Invalid device given (has to Motor, Sensor or EV3'); +end + +warning('off','all'); + +props = properties(device); % Save list with property names as strings +dependentProps = {}; + +fprintf(' <a href="matlab:helpPopup %s">%s</a> with properties:\n\n', cl, cl); +fprintf('\tWritable\n'); +% Print writable properties, leave out all the rest, leave out all the reeeest +for i = 1:length(props) + p = props{i}; + meta = device.findprop(p); + if meta.Dependent == 1 + dependentProps{end+1} = p; + continue; + elseif ~strcmp(meta.SetAccess, 'public') || ~strcmp(meta.GetAccess, 'public') + continue; + end + + if ~isempty(enumeration(device.(p))) % Test if parameter is enumeration + fprintf('\t%15s: %s\n', p, char(device.(p))); + elseif isnumeric(device.(p)) || islogical(device.(p)) + fprintf('\t%15s: %d\n', p, device.(p)); + elseif ischar(device.(p)) + fprintf('\t%15s: %s\n', p, device.(p)); + else + %fprintf('Mep\n'); + %error('testing'); + end +end + +fprintf('\n\tRead-only\n'); +% Print dependent properties +for i = 1:length(dependentProps) + p = dependentProps{i}; + + if isempty(p) + continue; + end + + value = device.(p); + if ~isempty(enumeration(value)) % Test if parameter is enumeration + fprintf('\t%15s: %s\n', p, char(value)); + elseif isnumeric(device.(p)) || islogical(value) + if isfloat(value) + fprintf('\t%15s: %1.1f\n', p, value); + else + fprintf('\t%15s: %d\n', p, value); + end + elseif ischar(device.(p)) + fprintf('\t%15s: %s\n', p, value); + elseif islogical(device.(p)) + + end +end + +warning('on','all'); + +end + diff --git a/source/hidapi.h b/source/hidapi.h old mode 100644 new mode 100755 diff --git a/source/hidapi.m b/source/hidapi.m old mode 100644 new mode 100755 diff --git a/source/hidapi32.dll b/source/hidapi32.dll old mode 100644 new mode 100755 diff --git a/source/hidapi32_proto.m b/source/hidapi32_proto.m old mode 100644 new mode 100755 diff --git a/source/hidapi64.dll b/source/hidapi64.dll old mode 100644 new mode 100755 diff --git a/source/hidapi64.dylib b/source/hidapi64.dylib old mode 100644 new mode 100755 diff --git a/source/hidapi64_proto.m b/source/hidapi64_proto.m old mode 100644 new mode 100755 diff --git a/source/hidapi64_thunk_maci64.dylib b/source/hidapi64_thunk_maci64.dylib old mode 100644 new mode 100755 diff --git a/source/hidapi64_thunk_pcwin64.dll b/source/hidapi64_thunk_pcwin64.dll old mode 100644 new mode 100755 diff --git a/source/hidapi64_thunk_pcwin64.exp b/source/hidapi64_thunk_pcwin64.exp old mode 100644 new mode 100755 diff --git a/source/hidapi64_thunk_pcwin64.lib b/source/hidapi64_thunk_pcwin64.lib old mode 100644 new mode 100755 diff --git a/source/hidapi64_thunk_pcwin64.obj b/source/hidapi64_thunk_pcwin64.obj old mode 100644 new mode 100755 diff --git a/source/hidapi64mac_proto.m b/source/hidapi64mac_proto.m old mode 100644 new mode 100755 diff --git a/source/hidapi_libusb_proto.m b/source/hidapi_libusb_proto.m old mode 100644 new mode 100755 diff --git a/source/hidapi_old.h b/source/hidapi_old.h old mode 100644 new mode 100755 diff --git a/source/input2bitfield.m b/source/input2bitfield.m old mode 100644 new mode 100755 diff --git a/source/input2port.m b/source/input2port.m old mode 100644 new mode 100755 diff --git a/source/instrBrickIO.m b/source/instrBrickIO.m old mode 100644 new mode 100755 diff --git a/source/isBool.m b/source/isBool.m old mode 100644 new mode 100755 diff --git a/source/isCommInterfaceValid.m b/source/isCommInterfaceValid.m old mode 100644 new mode 100755 diff --git a/source/isDeviceValid.m b/source/isDeviceValid.m old mode 100644 new mode 100755 diff --git a/source/isModeValid.m b/source/isModeValid.m old mode 100644 new mode 100755 diff --git a/source/isPortEnumValid.m b/source/isPortEnumValid.m old mode 100644 new mode 100755 diff --git a/source/isPortStrValid.m b/source/isPortStrValid.m old mode 100644 new mode 100755 diff --git a/source/isSyncedBitfield.m b/source/isSyncedBitfield.m old mode 100644 new mode 100755 diff --git a/source/port2bitfield.m b/source/port2bitfield.m old mode 100644 new mode 100755 diff --git a/source/port2input.m b/source/port2input.m old mode 100644 new mode 100755 diff --git a/source/port2str.m b/source/port2str.m old mode 100644 new mode 100755 diff --git a/source/str2PortParam.m b/source/str2PortParam.m old mode 100644 new mode 100755 diff --git a/source/str2bool.m b/source/str2bool.m old mode 100644 new mode 100755 diff --git a/source/str2brake.m b/source/str2brake.m old mode 100644 new mode 100755 diff --git a/source/tb_optparse.m b/source/tb_optparse.m old mode 100644 new mode 100755 diff --git a/source/usbBrickIO.m b/source/usbBrickIO.m old mode 100644 new mode 100755 diff --git a/source/vmCodes.m b/source/vmCodes.m old mode 100644 new mode 100755 diff --git a/source/wfBrickIO.m b/source/wfBrickIO.m old mode 100644 new mode 100755