Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Problems when Using Adafruit_ADS1015 in C // Using C++ enum inside main.c

cctroniccctronic United States

I'm working on application for ESP32, with ADS1015 connected.

I know that the hardwaer and connection are correct as the its working when i prototype using mjs.

I wanted to use it in C , so I faced several problems, I managed to solve by forking the original library and modifying the new version so the includes statement look like this:

#ifdef __cplusplus
#include "Adafruit_ADS1015.h"
#else
typedef struct Adafruit_ADS1015Tag Adafruit_ADS1015;
#endif

I'm now left with one error

/libs/arduino-adafruit-ads1x15/include/mgos_arduino_Adafruit_ADS1015.h:96:50: error: unknown type name 'adsGain_t'
 void mgos_ADS1015_setGain(Adafruit_ADS1015 *ads, adsGain_t gain);

And I don't have experience to know how can I use a typedef enum defined in C== library , within C wrapping.

This is the definition under Adafruit_ADS1015.h

typedef enum
{
  GAIN_TWOTHIRDS    = ADS1015_REG_CONFIG_PGA_6_144V,
  GAIN_ONE          = ADS1015_REG_CONFIG_PGA_4_096V,
  GAIN_TWO          = ADS1015_REG_CONFIG_PGA_2_048V,
  GAIN_FOUR         = ADS1015_REG_CONFIG_PGA_1_024V,
  GAIN_EIGHT        = ADS1015_REG_CONFIG_PGA_0_512V,
  GAIN_SIXTEEN      = ADS1015_REG_CONFIG_PGA_0_256V
} adsGain_t;

Comments

Sign In or Register to comment.