| 1 | function display( obj ) |
|---|
| 2 | % DISPLAY Display method for NXTmotor objects. |
|---|
| 3 | % |
|---|
| 4 | % DISPLAY(OBJ) displays information pertaining to the NXTmotor |
|---|
| 5 | % object OBJ. |
|---|
| 6 | % |
|---|
| 7 | % See also NXTmotor, NXTmotor/get. |
|---|
| 8 | % |
|---|
| 9 | |
|---|
| 10 | % Signature |
|---|
| 11 | % Author: Aulis Telle (see AUTHORS) |
|---|
| 12 | % Date: 2008/08/15 |
|---|
| 13 | % Copyright: 2007-2008, RWTH Aachen University |
|---|
| 14 | % |
|---|
| 15 | % |
|---|
| 16 | % *********************************************************************************************** |
|---|
| 17 | % * This file is part of the RWTH - Mindstorms NXT Toolbox. * |
|---|
| 18 | % * * |
|---|
| 19 | % * The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify * |
|---|
| 20 | % * it under the terms of the GNU General Public License as published by the Free Software * |
|---|
| 21 | % * Foundation, either version 3 of the License, or (at your option) any later version. * |
|---|
| 22 | % * * |
|---|
| 23 | % * The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful, * |
|---|
| 24 | % * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * |
|---|
| 25 | % * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
|---|
| 26 | % * * |
|---|
| 27 | % * You should have received a copy of the GNU General Public License along with the * |
|---|
| 28 | % * RWTH - Mindstorms NXT Toolbox. If not, see <http: |
|---|
| 29 | % *********************************************************************************************** |
|---|
| 30 | |
|---|
| 31 | if ~isa(obj,'NXTmotor') |
|---|
| 32 | error('MATLAB:RWTHMindstormsNXT:InvalidObject',... |
|---|
| 33 | 'No NXTmotor object.'); |
|---|
| 34 | end |
|---|
| 35 | |
|---|
| 36 | if isscalar(obj) |
|---|
| 37 | fprintf([... |
|---|
| 38 | '\n'... |
|---|
| 39 | 'NXTmotor object properties:\n\n' ... |
|---|
| 40 | ' Port(s): ' infoStrPort( obj.Port) '\n' ... |
|---|
| 41 | ' Power: ' infoStrNumber(obj.Power) '\n' ... |
|---|
| 42 | ' SpeedRegulation: ' infoStrOnOff( obj.SpeedRegulation) '\n' ... |
|---|
| 43 | ' TachoLimit: ' infoStrNumber(obj.TachoLimit) '\n' ... |
|---|
| 44 | ' BrakeAtTachoLimit: ' infoStrYesNo( obj.BrakeAtTachoLimit) '\n' ... |
|---|
| 45 | ' TurnRatio: ' infoStrNumber(obj.TurnRatio) '\n' ... |
|---|
| 46 | '\n']); |
|---|
| 47 | else |
|---|
| 48 | disp(obj); |
|---|
| 49 | end |
|---|
| 50 | |
|---|
| 51 | end |
|---|
| 52 | |
|---|
| 53 | function s = infoStrPort(p) |
|---|
| 54 | if numel(p) == 1 |
|---|
| 55 | s = num2str(p); |
|---|
| 56 | else |
|---|
| 57 | s = mat2str(p); |
|---|
| 58 | end |
|---|
| 59 | |
|---|
| 60 | s = [s, ' (' portString(p) ')']; |
|---|
| 61 | end %% END FUNCTION INFOSTRPORT |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | function s = portString(p) |
|---|
| 65 | s = ''''; |
|---|
| 66 | for k = 1:length(p) |
|---|
| 67 | if k > 1 |
|---|
| 68 | s = [s ''',''']; |
|---|
| 69 | end |
|---|
| 70 | switch(p(k)) |
|---|
| 71 | case 0 |
|---|
| 72 | s = [s, 'A']; |
|---|
| 73 | case 1 |
|---|
| 74 | s = [s, 'B']; |
|---|
| 75 | case 2 |
|---|
| 76 | s = [s, 'C']; |
|---|
| 77 | otherwise |
|---|
| 78 | s = 'undefined'; |
|---|
| 79 | end |
|---|
| 80 | end |
|---|
| 81 | s = [s , '''']; |
|---|
| 82 | end %% END FUNCTION PORTSTRING |
|---|
| 83 | |
|---|
| 84 | function s = infoStrNumber(n) |
|---|
| 85 | s = num2str(n); |
|---|
| 86 | end %% END FUNTION INFOSTRNUMBER |
|---|
| 87 | |
|---|
| 88 | function s = infoStrOnOff(b) |
|---|
| 89 | s = num2str(b); |
|---|
| 90 | if b |
|---|
| 91 | s = [s, ' (''on'')']; |
|---|
| 92 | else |
|---|
| 93 | s = [s, ' (''off'')']; |
|---|
| 94 | end |
|---|
| 95 | end %% END FUNCTION INFOSTRONOFF |
|---|
| 96 | |
|---|
| 97 | function s = infoStrYesNo(b) |
|---|
| 98 | s = num2str(b); |
|---|
| 99 | if b |
|---|
| 100 | s = [s, ' (''yes'')']; |
|---|
| 101 | else |
|---|
| 102 | s = [s, ' (''no'')']; |
|---|
| 103 | end |
|---|
| 104 | end %% END FUNCTION INFOSTRYESNO |
|---|