Fixed adc battery value
This commit is contained in:
parent
ac9e564d6a
commit
ca95fe9f36
|
|
@ -43,7 +43,7 @@ int battery_measure_mv(int32_t *mv_out) {
|
|||
if (ret) return ret;
|
||||
|
||||
ret = adc_raw_to_millivolts_dt(&adc_channel, &sample_buffer);
|
||||
*mv_out = (int)((float)sample_buffer*((270.0f+110.0f)/270.0f));
|
||||
*mv_out = (int)((float)sample_buffer*((270.0f+110.0f)/110.0f));
|
||||
|
||||
gpio_pin_set_dt(&btt_meas_en, 0); // disable measurement
|
||||
|
||||
|
|
|
|||
18
src/main.c
18
src/main.c
|
|
@ -27,10 +27,9 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
actuator_init(ACTUATOR_MODE_SERVO);
|
||||
actuator_enable(1);
|
||||
//actuator_init(ACTUATOR_MODE_MOTOR);
|
||||
|
||||
actuator_servo_set_angle(100);
|
||||
//actuator_servo_set_angle(100);
|
||||
//actuator_motor_set_speed(-50); // -100..100 %
|
||||
/* Init modules */
|
||||
led_init();
|
||||
|
|
@ -101,6 +100,17 @@ int main(void)
|
|||
out_en = !out_en;
|
||||
led_toggle(1); // toggle LED1 on press
|
||||
old_val = val;
|
||||
|
||||
actuator_enable(1);
|
||||
if(out_en){
|
||||
actuator_motor_set_speed(35); // -100..100 %
|
||||
}
|
||||
else{
|
||||
actuator_motor_set_speed(-35); // -100..100 %
|
||||
}
|
||||
k_sleep(K_MSEC(300));
|
||||
actuator_motor_set_speed(0); // -100..100 %
|
||||
actuator_enable(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -112,6 +122,6 @@ int main(void)
|
|||
printk("Button released\n");
|
||||
}
|
||||
|
||||
k_sleep(K_MSEC(50));
|
||||
k_sleep(K_MSEC(100));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue