Skip to content

Commit 2545f82

Browse files
committed
FDC1004 added to modulino.h
1 parent 485e3d2 commit 2545f82

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/Modulino.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "Arduino_LSM6DSOX.h"
88
#include <Arduino_LPS22HB.h>
99
#include <Arduino_HS300x.h>
10+
#include <Arduino_FDC1004.h>
1011
//#include <SE05X.h> // need to provide a way to change Wire object
1112

1213
#ifndef ARDUINO_API_VERSION
@@ -506,3 +507,71 @@ class ModulinoDistance : public Module {
506507
float internal = NAN;
507508
_distance_api* api = nullptr;
508509
};
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

Comments
 (0)