Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed QEI BNO055 MPU6050_DMP_Nucleo-I2Cdev virgo3_imuHandler_Orion_PCB MAX17048 Servo
Fork of Orion_newPCB_test by
generalFunctions.cpp
00001 #include "generalFunctions.h" 00002 00003 float generalFunctions::sign_f(float in) 00004 { 00005 if(in >= 0) return 1; 00006 else return -1; 00007 } 00008 00009 float generalFunctions::abs_f(float in) 00010 { 00011 if(in >= 0) return in; 00012 else return (-1.0*in); 00013 } 00014 00015 float generalFunctions::map_f(float in, float in_min, float in_max, float out_min, float out_max) 00016 { 00017 return (in - in_min)*(out_max - out_min)/(in_max - in_min) + out_min; 00018 } 00019 00020 float generalFunctions::constrain_f(float in, float out_min, float out_max) 00021 { 00022 if(in <= out_min) 00023 return (out_min); 00024 else if(in >= out_max) 00025 return (out_max); 00026 else 00027 return (in); 00028 } 00029 00030 float generalFunctions::moving_window(float array[], unsigned int window_size) 00031 { 00032 float movAvg_out=0; 00033 00034 for(volatile unsigned int i=0; i<window_size; i++) { 00035 movAvg_out += array[i]; 00036 } 00037 00038 movAvg_out = movAvg_out/((float)window_size); 00039 00040 return (movAvg_out); 00041 }
Generated on Tue Jul 12 2022 20:53:07 by
1.7.2
