Changeset 921 for trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
- Timestamp:
- 08/30/01 16:02:20 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
r920 r921 13 13 #include <sys/resource.h> // PRIO_PROCESS 14 14 15 ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL) 15 ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL), fPosHasChanged(false) 16 16 { 17 17 } … … 112 112 } 113 113 114 void ShaftEncoder::HandlePDOType0(BYTE_t *data )114 void ShaftEncoder::HandlePDOType0(BYTE_t *data, struct timeval *tv) 115 115 { 116 116 // 117 117 // Decode information, we have a 14bit only 118 118 // 119 fPos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 120 } 121 122 void ShaftEncoder::HandlePDOType1(BYTE_t *data) 119 LWORDS_t pos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 120 if (pos==fPos) 121 return; 122 123 fPos = pos; 124 fTime.SetTimer(tv); 125 fPosHasChanged = true; 126 } 127 128 void ShaftEncoder::HandlePDOType1(BYTE_t *data, struct timeval *tv) 123 129 { 124 130 // … … 127 133 LWORDS_t pos = data[0] | (data[1]<<8) | (data[2]<<16); // | (data[3]<<24); 128 134 BYTE_t flag = data[4]; 129 pos=pos; 135 136 if (fPos==pos) 137 return; 138 139 fPos=pos; 140 fTime.SetTimer(tv); 141 fPosHasChanged=true; 142 130 143 flag=flag; 131 144 } … … 141 154 fAcc = data[6] | (data[7]<<8); 142 155 143 fTime.SetTimer(tv);144 145 156 const int uplim = 9*fTicks/10; 146 157 const int dnlim = 1*fTicks/10; 147 158 159 int turn = fTurn; 160 148 161 if (fPos > uplim && pos < dnlim) 149 fTurn++;162 turn++; 150 163 151 164 if (fPos < dnlim && pos > uplim) 152 fTurn--; 153 154 fPos = pos; 165 turn--; 166 167 if (fPos==pos && fTurn==fTurn) 168 return; 169 170 fPos = pos; 171 fTurn = turn; 172 fTime.SetTimer(tv); 173 fPosHasChanged=true; 155 174 } 156 175
Note:
See TracChangeset
for help on using the changeset viewer.