[riot-notifications] [RIOT-OS/RIOT] drivers: support for NXP PCA9685 I2C 16-channel, 12-bit PWM controller (#10556)

benpicco notifications at github.com
Fri Sep 6 16:47:44 CEST 2019


benpicco commented on this pull request.



> +    uint16_t on;
+    uint16_t off;
+
+    if (val == 0) {
+        /* full off */
+        on = 0;
+        off = PCA9685_LED_OFF;
+    }
+    else if (val == dev->params.res) {
+        /* full on */
+        on = PCA9685_LED_ON;
+        off = 0;
+    }
+    else {
+        /* duty = scale * val, with scale = 4096 / resolution; */
+        uint16_t duty = round((float)PCA9685_RESOLUTION / dev->params.res * val);

```suggestion
        uint32_t div = dev->params.res * val;
        uint16_t duty = (PCA9685_RESOLUTION + div/2) / div;
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10556#pullrequestreview-284912479
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190906/38df9634/attachment.htm>


More information about the notifications mailing list