mirror of
https://github.com/rene-dev/stmbl.git
synced 2026-08-18 01:18:58 +08:00
abspos
This commit is contained in:
+10
-1
@@ -3,6 +3,8 @@ HAL_COMP(enc_fb);
|
||||
HAL_PIN(res) = 2048.0;
|
||||
HAL_PIN(ires) = 1024.0;
|
||||
HAL_PIN(pos) = 0.0;
|
||||
HAL_PIN(abspos) = 0.0;
|
||||
HAL_PIN(isabs) = 0.0;
|
||||
HAL_PIN(index) = 0.0;
|
||||
HAL_PIN(a) = 0.0;
|
||||
HAL_PIN(b) = 0.0;
|
||||
@@ -20,6 +22,7 @@ HAL_PIN(c) = 0.0;
|
||||
|
||||
|
||||
MEM(int e_res) = 0.0;
|
||||
MEM(float absoffset) = 0.0;
|
||||
|
||||
RT_INIT(
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
@@ -79,7 +82,13 @@ RT_DEINIT(
|
||||
);
|
||||
|
||||
FRT(
|
||||
PIN(pos) = mod(TIM_GetCounter(ENC1_TIM) * 2.0f * M_PI / (float)e_res);
|
||||
float p = mod(TIM_GetCounter(ENC1_TIM) * 2.0f * M_PI / (float)e_res);
|
||||
PIN(pos) = p;
|
||||
if(RISING_EDGE(!GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_11)) && PIN(isabs) != 1.0){
|
||||
absoffset = -p;
|
||||
PIN(isabs) = 1.0;
|
||||
}
|
||||
PIN(abspos) = mod(p + absoffset);
|
||||
);
|
||||
|
||||
RT(
|
||||
|
||||
Reference in New Issue
Block a user