Src/reg_interface.c
//this should return the four tallest peaks and their amplitudes in D0 - D3
//format 0xYYYYZZZZ, YYYY distance in mm, ZZZZ amplitude (little endian)

this should return the four tallest peaks and their amplitudes in D0 - D3
format 0xYYYYZZZZ, YYYY distance in mm, ZZZZ amplitude (little endian)
this should return the four tallest peaks and their amplitudes in D0 - D3 format 0xYYYYZZZZ YYYY distance in mm ZZZZ amplitude ( little endian )
void evalEnvelopeData(void){
	const int n = 4;
	uint16_t dist_res = (uint16_t)(envelope_metadata.step_length_m*1.0e6f);
	uint16_t dist_start = (uint16_t)(envelope_metadata.start_m*1000.0f);
	uint16_t min_sep = (uint16_t)((1000*(uint32_t)RegInt_getreg(0xD4))/dist_res);
	DBG_PRINTINT(min_sep);
	uint16_t indexes[n];
	uint16_t amplitudes[n];
	getpeaks(data, bins, indexes, amplitudes, min_sep);
	uint16_t distances[n];
	for(uint8_t i = 0; i < n; i++){
		distances[i] = (uint16_t)(((uint32_t)indexes[i]*(uint32_t)dist_res)/1e3) + dist_start;
	}
	uint32_t distamp_pack[n];
	pack16to32array(distamp_pack, distances, amplitudes);
	RegInt_setregf(0xD0,(uint32_t)distamp_pack[0], 1);
	RegInt_setregf(0xD1,(uint32_t)distamp_pack[1], 1);
	RegInt_setregf(0xD2,(uint32_t)distamp_pack[2], 1);
	RegInt_setregf(0xD3,(uint32_t)distamp_pack[3], 1);
	print_envelope_results();
}
void evalEnvelopeData ( void ) { const int n = 4 ; uint16_t dist_res = ( uint16_t ) ( envelope_metadata . step_length_m * 1.0e6f ) ; uint16_t dist_start = ( uint16_t ) ( envelope_metadata . start_m * 1000.0f ) ; uint16_t min_sep = ( uint16_t ) ( ( 1000 * ( uint32_t ) RegInt_getreg ( 0xD4 ) ) / dist_res ) ; DBG_PRINTINT ( min_sep ) ; uint16_t indexes [ n ] ; uint16_t amplitudes [ n ] ; getpeaks ( data , bins , indexes , amplitudes , min_sep ) ; uint16_t distances [ n ] ; for ( uint8_t i = 0 ; i < n ; i ++ ) { distances [ i ] = ( uint16_t ) ( ( ( uint32_t ) indexes [ i ] * ( uint32_t ) dist_res ) / 1e3 ) + dist_start ; } uint32_t distamp_pack [ n ] ; pack16to32array ( distamp_pack , distances , amplitudes ) ; RegInt_setregf ( 0xD0 , ( uint32_t ) distamp_pack [ 0 ] , 1 ) ; RegInt_setregf ( 0xD1 , ( uint32_t ) distamp_pack [ 1 ] , 1 ) ; RegInt_setregf ( 0xD2 , ( uint32_t ) distamp_pack [ 2 ] , 1 ) ; RegInt_setregf ( 0xD3 , ( uint32_t ) distamp_pack [ 3 ] , 1 ) ; print_envelope_results ( ) ; }
this should return the four tallest peaks and their amplitudes in D0 - D3
format 0xYYYYZZZZ, YYYY distance in mm, ZZZZ amplitude (little endian)
this should return the four tallest peaks and their amplitudes in D0 - D3 format 0xYYYYZZZZ YYYY distance in mm ZZZZ amplitude ( little endian )
//store results
