From 87f86bc05f47e71082c9051a7c97cce67927c948 Mon Sep 17 00:00:00 2001
From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de>
Date: Wed, 7 Jun 2017 09:46:54 +0200
Subject: [PATCH] Fix redundant value readings when displaying

---
 source/EV3.m               | 7 ++++---
 source/displayProperties.m | 6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/source/EV3.m b/source/EV3.m
index e551b3b..f05ad90 100644
--- a/source/EV3.m
+++ b/source/EV3.m
@@ -471,9 +471,10 @@ classdef EV3 < MaskedHandle
             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));
+                member = ev3.(p);
+                
+                if strcmp(class(member),'Sensor') || strcmp(class(member), 'Motor')
+                    fprintf('\t%15s [Type: %s]\n', p, char(member.type));
                 end
             end
             warning('on', 'all');
diff --git a/source/displayProperties.m b/source/displayProperties.m
index 7b39943..3c7a8ef 100644
--- a/source/displayProperties.m
+++ b/source/displayProperties.m
@@ -46,15 +46,15 @@ for i = 1:length(dependentProps)
     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)
+    elseif isnumeric(value) || 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))
+    elseif ischar(value)
         fprintf('\t%15s:   %s\n', p, value);
-    elseif islogical(device.(p))
+    elseif islogical(value)
 
     end
 end
-- 
GitLab