Move map redefinition to arduino.ino

This commit is contained in:
pascallanger 2016-10-16 23:12:28 +02:00
parent f557609e9e
commit 22a5f411d0
2 changed files with 12 additions and 13 deletions

View File

@ -17,6 +17,18 @@
/************************************/ /************************************/
/** Arduino replacement routines **/ /** Arduino replacement routines **/
/************************************/ /************************************/
// replacement map()
int16_t map( int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max)
{
// return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
long y ;
x -= in_min ;
y = out_max - out_min ;
y *= x ;
x = y / (in_max - in_min) ;
return x + out_min ;
}
// replacement millis() and micros() // replacement millis() and micros()
// These work polled, no interrupts // These work polled, no interrupts
// micros() MUST be called at least once every 32 milliseconds // micros() MUST be called at least once every 32 milliseconds

View File

@ -15,19 +15,6 @@
/************************/ /************************/
/** Convert routines **/ /** Convert routines **/
/************************/ /************************/
#ifndef STM32_BOARD
int16_t map( int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max)
{
// return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
long y ;
x -= in_min ;
y = out_max - out_min ;
y *= x ;
x = y / (in_max - in_min) ;
return x + out_min ;
}
#endif
// Channel value is converted to 8bit values full scale // Channel value is converted to 8bit values full scale
uint8_t convert_channel_8b(uint8_t num) uint8_t convert_channel_8b(uint8_t num)
{ {