gmio/src/c/task_control.c

23 lines
556 B
C
Raw Normal View History

#include "task_control.h"
#include <math.h>
#include <string.h>
2013-03-05 08:04:29 +08:00
foug_bool_t foug_task_control_handle_progress(foug_task_control_t* ctrl, uint8_t progress_pc)
{
2013-03-05 08:04:29 +08:00
if (ctrl != NULL && ctrl->handle_progress_func != NULL)
return ctrl->handle_progress_func(ctrl, progress_pc);
return 1;
}
2013-03-05 08:04:29 +08:00
uint8_t foug_percentage(size_t range_min, size_t range_max, size_t value)
{
2013-03-05 08:04:29 +08:00
if (value >= range_max)
return 100;
else if (value <= range_min)
return 0;
else if (range_min < range_max)
return (value * 100) / (range_max - range_min);
return 0;
}