arduino / arduino/ArduinoCore-API

Templated map() function

未关闭
#46 2 条评论 0 个 reaction 已指派 1 人 已被 @cmaglie 认领 在 GitHub 查看
主要语言
C++
星标
306
派生
150
PR 合并指标
30 天内没有已合并 PR

描述

Hello !

Apologies if this is a duplicate, but I couldn't find any previous discussions on github about it.

Is there a reason why map() isn't templated to provide maximum awesomeness??

Something as simple as this, would get rid of surprises when trying to use map() to scale to [0,1]:

```
template
T map(T x, T in_min, T in_max, T out_min, T out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。