0 Members and 1 Guest are viewing this topic.
Yeah, for my above example that will work because min/max are read out of eeprom at poweron, so the reciprocal can be calculated once at that point. ThanksBut i can't see it working in other areas of my code, such as this table X/Y interpolate function.As the variables change in realtimeCode: [Select]// (T,B,L,R = top/bot/left/right)uint8_t quadinterpolate(uint8_t *quadTL, uint8_t *quadTR, uint8_t *quadBL, uint8_t *quadBR, uint8_t *rowlabel1, uint8_t *rowlabel2, uint8_t *collabel1, uint8_t *collabel2, uint8_t *inputrow, uint8_t *inputcol){ uint8_t colstep,rowstep,quadCAB,quadDAB,temp1; div_t divout; colstep = *collabel2-*collabel1; rowstep = *rowlabel2-*rowlabel1; temp1 = *inputcol - *collabel1; divout = div( (*quadTL-*quadTR) , colstep ); quadCAB = *quadTL - (divout.quot * temp1); divout = div( (*quadBL-*quadBR) , colstep ); quadDAB = *quadBL - (divout.quot * temp1); divout = div( (quadCAB-quadDAB) , rowstep ); return (quadCAB - (divout.quot * (*inputrow - *rowlabel1))); }
// (T,B,L,R = top/bot/left/right)uint8_t quadinterpolate(uint8_t *quadTL, uint8_t *quadTR, uint8_t *quadBL, uint8_t *quadBR, uint8_t *rowlabel1, uint8_t *rowlabel2, uint8_t *collabel1, uint8_t *collabel2, uint8_t *inputrow, uint8_t *inputcol){ uint8_t colstep,rowstep,quadCAB,quadDAB,temp1; div_t divout; colstep = *collabel2-*collabel1; rowstep = *rowlabel2-*rowlabel1; temp1 = *inputcol - *collabel1; divout = div( (*quadTL-*quadTR) , colstep ); quadCAB = *quadTL - (divout.quot * temp1); divout = div( (*quadBL-*quadBR) , colstep ); quadDAB = *quadBL - (divout.quot * temp1); divout = div( (quadCAB-quadDAB) , rowstep ); return (quadCAB - (divout.quot * (*inputrow - *rowlabel1))); }