Exemple #1
0
int tr_filter_task(int argc, char *argv[])
{
	int c, is_collapse = 0;
	int is_nucl = 0;
	int cut_off = 15;
	FILE *fp;
	int is_mask = 1;
	int is_mask_segments = 1;
	MultiAlign *ma;

	while ((c = getopt(argc, argv, "F:ngMN")) >= 0) {
		switch (c) {
			case 'n': is_nucl = 1; break;
			case 'g': is_collapse = 1; break;
			case 'N': is_mask_segments = 0; break;
			case 'M': is_mask = 0; break;
			case 'F': cut_off = atoi(optarg); break;
		}
	}
	if (optind == argc) return tr_filter_usage();
	fp = tr_get_fp(argv[optind]);
	ma = ma_read_alignment(fp, is_nucl);
	if (is_mask) ma_apply_mask(ma);
	ma_filter(ma, is_collapse, cut_off, is_mask_segments);
	tr_align_output(stdout, ma);
	ma_free(ma);
	if (fp != stdin) fclose(fp);
	return 0;
}
int main() {
	printf("Begin\n");

/* @param	system_init			initialize GPIO and ADC structs for pins and ADC variables using system_init()
*  @param	SysTick_Config		set ticks by dividing systemCoreClock with systick frequency (168MHz/50Hz)
*  @param	read_temperature() 	used to convert digital signal to temperature reading
*  @param	filtered			defined as moving average to reduce noise
*  @param	motor_rotate_to  	for the servo motor measurements (with filtered angle measurements)
*  @param	alarm_temperature 	defined to raise the alarm if the temperature goes above threshold
*/	
	system_init();

	SysTick_Config(SystemCoreClock / SYSTICK_FREQUENCY);
	//running while loop to control the frequency measurement readings of the temperature 
	//waits for interrupt to read the temperature readings
	while (1) {
		while (!system_ticks);
		
		read_temperature();

		float filtered = ma_filter(temperature_reading);
		motor_rotate_to(temperature_to_angle(filtered));
		alarm_temperature(filtered);

		system_ticks = 0;

		
	}
	
	
	return 0;
}