Changeset 921 for trunk/MagicSoft/Cosy/devdrv
- Timestamp:
- 08/30/01 16:02:20 (23 years ago)
- Location:
- trunk/MagicSoft/Cosy/devdrv
- Files:
-
- 2 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 -
trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
r920 r921 22 22 WORDS_t fUpdAcc; // ticks per 25ms^2 23 23 24 bool fPosHasChanged; 25 24 26 Timer fTime; 25 27 26 void HandlePDOType0(BYTE_t *data );27 void HandlePDOType1(BYTE_t *data );28 void HandlePDOType0(BYTE_t *data, struct timeval *tv); 29 void HandlePDOType1(BYTE_t *data, struct timeval *tv); 28 30 void HandlePDOType2(BYTE_t *data, struct timeval *tv); 29 31 … … 56 58 57 59 void DisplayVal(); 60 61 bool IsPosHasChanged() const { return fPosHasChanged; } 62 void ResetPosHasChanged() { fPosHasChanged = false; } 58 63 }; 59 64
Note:
See TracChangeset
for help on using the changeset viewer.