Skip to content

Commit

Permalink
AVR modules: Fix KF606, GD00X and Potensic
Browse files Browse the repository at this point in the history
  • Loading branch information
pascallanger committed Sep 26, 2019
1 parent 7e6ec1d commit 18af4a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions Multiprotocol/Common.ino
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,30 @@ uint8_t convert_channel_8b_limit_deadband(uint8_t num,uint8_t min,uint8_t mid, u
{
uint16_t val=limit_channel_100(num); // 204<->1844
uint16_t db_low=CHANNEL_MID-deadband, db_high=CHANNEL_MID+deadband; // 1024+-deadband
int32_t calc;
uint8_t out;
if(val>=db_low && val<=db_high)
return mid;
else if(val<db_low)
val=min+(val-CHANNEL_MIN_100)*(mid-min)/(db_low-CHANNEL_MIN_100);
{
val-=CHANNEL_MIN_100;
calc=mid-min;
calc*=val;
calc/=(db_low-CHANNEL_MIN_100);
out=calc;
out+=min;
}
else
val=mid+(val-db_high)*(max-mid)/(CHANNEL_MAX_100-1-db_high);
return val;
{
val-=db_high;
calc=max-mid;
calc*=val;
calc/=(CHANNEL_MAX_100-db_high+1);
out=calc;
out+=mid;
if(max>min) out++; else out--;
}
return out;
}

// Reverse a channel and store it
Expand Down
2 changes: 1 addition & 1 deletion Multiprotocol/Multiprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_REVISION 1
#define VERSION_PATCH_LEVEL 82
#define VERSION_PATCH_LEVEL 83

//******************
// Protocols
Expand Down

0 comments on commit 18af4a0

Please sign in to comment.