|
7 | 7 | #include "Arduino_LSM6DSOX.h"
|
8 | 8 | #include <Arduino_LPS22HB.h>
|
9 | 9 | #include <Arduino_HS300x.h>
|
| 10 | +#include <Arduino_FDC1004.h> |
10 | 11 | //#include <SE05X.h> // need to provide a way to change Wire object
|
11 | 12 |
|
12 | 13 | #ifndef ARDUINO_API_VERSION
|
@@ -506,3 +507,71 @@ class ModulinoDistance : public Module {
|
506 | 507 | float internal = NAN;
|
507 | 508 | _distance_api* api = nullptr;
|
508 | 509 | };
|
| 510 | + |
| 511 | + |
| 512 | +class ModulinoFarad: public Module { |
| 513 | +public: |
| 514 | + bool begin() { |
| 515 | + if (_sensor == nullptr) { |
| 516 | + _sensor = new FDC1004Class(*((TwoWire*)getWire())); |
| 517 | + } |
| 518 | + initialized = _sensor->begin(); |
| 519 | + __increaseI2CPriority(); |
| 520 | + return initialized; |
| 521 | + } |
| 522 | + operator bool() { |
| 523 | + return (initialized != 0); |
| 524 | + } |
| 525 | + |
| 526 | + bool measurementSettings(int measuresEn, int measurementRate, int measurementRepeat) |
| 527 | + { |
| 528 | + if (initialized) |
| 529 | + { |
| 530 | + _sensor->measurementConfiguration(measuresEn,measurementRate,measurementRepeat); |
| 531 | + return 1; |
| 532 | + } |
| 533 | + return 0; |
| 534 | + } |
| 535 | + bool channelSettings(int channel,int chA,int chB, int CAPDAC) |
| 536 | + { |
| 537 | + if (initialized) |
| 538 | + { |
| 539 | + _sensor->channelConfiguration(channel,chA,chB,CAPDAC); |
| 540 | + return 1; |
| 541 | + } |
| 542 | + return 0; |
| 543 | + } |
| 544 | + bool channelOffset(int channel,uint16_t offset) |
| 545 | + { |
| 546 | + if (initialized) |
| 547 | + { |
| 548 | + _sensor->channelOffset(channel,offset); |
| 549 | + return 1; |
| 550 | + } |
| 551 | + return 0; |
| 552 | + } |
| 553 | + bool channelGain(int channel ,uint16_t gain) |
| 554 | + { |
| 555 | + if (initialized) |
| 556 | + { |
| 557 | + _sensor->channelGainConfiguration(channel,gain); |
| 558 | + return 1; |
| 559 | + } |
| 560 | + return 0; |
| 561 | + } |
| 562 | + bool measureAvailable(int channel) |
| 563 | + { |
| 564 | + if (initialized) |
| 565 | + return _sensor->measureAvailable(channel); |
| 566 | + return 0; |
| 567 | + } |
| 568 | + int getMeasure(int channel) { |
| 569 | + if (initialized) |
| 570 | + return _sensor->getChannelMeasurement(channel); |
| 571 | + return 0; |
| 572 | + } |
| 573 | + |
| 574 | +private: |
| 575 | + FDC1004Class* _sensor = nullptr; |
| 576 | + int initialized = 0; |
| 577 | +}; |
0 commit comments