From 619a8e536cd2f8af53701e5b4c5f99943440bc52 Mon Sep 17 00:00:00 2001 From: Ahmed Alkabir Date: Mon, 20 Sep 2021 20:41:19 +0200 Subject: [PATCH] fix the issue of conflicting types that occur with ArduinoCore-samd, and a few improvements --- MPR121/MPR121.cpp | 8 ++++---- MPR121/MPR121.h | 2 +- MPR121/MPR121_Datastream.cpp | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MPR121/MPR121.cpp b/MPR121/MPR121.cpp index d53176d..326bc55 100644 --- a/MPR121/MPR121.cpp +++ b/MPR121/MPR121.cpp @@ -93,7 +93,7 @@ void MPR121_type::setRegister(uint8_t reg, uint8_t value){ } uint8_t MPR121_type::getRegister(uint8_t reg){ - uint8_t scratch; + uint8_t scratch = 0; Wire.beginTransmission(address); Wire.write(reg); // set address to read from our requested register @@ -786,7 +786,7 @@ void MPR121_type::pinMode(uint8_t electrode, mpr121_pinf_type mode){ uint8_t bitmask = 1<<(electrode-4); switch(mode){ - case INPUT_PULLDOWN: + case mpr121_pinf_type::INPUT_PULLDOWN: // MPR121_EN = 1 // MPR121_DIR = 0 // MPR121_CTL0 = 1 @@ -797,7 +797,7 @@ void MPR121_type::pinMode(uint8_t electrode, mpr121_pinf_type mode){ setRegister(MPR121_CTL1, getRegister(MPR121_CTL1) & ~bitmask); break; - case OUTPUT_HIGHSIDE: + case mpr121_pinf_type::OUTPUT_HIGHSIDE: // MPR121_EN = 1 // MPR121_DIR = 1 // MPR121_CTL0 = 1 @@ -808,7 +808,7 @@ void MPR121_type::pinMode(uint8_t electrode, mpr121_pinf_type mode){ setRegister(MPR121_CTL1, getRegister(MPR121_CTL1) | bitmask); break; - case OUTPUT_LOWSIDE: + case mpr121_pinf_type::OUTPUT_LOWSIDE: // MPR121_EN = 1 // MPR121_DIR = 1 // MPR121_CTL0 = 1 diff --git a/MPR121/MPR121.h b/MPR121/MPR121.h index 4ff064c..ab5cbc7 100644 --- a/MPR121/MPR121.h +++ b/MPR121/MPR121.h @@ -146,7 +146,7 @@ struct MPR121_settings_type }; // GPIO pin function constants -enum mpr121_pinf_type +enum class mpr121_pinf_type { // INPUT and OUTPUT (and others) are already defined by Arduino, use its definitions if they exist #ifndef INPUT diff --git a/MPR121/MPR121_Datastream.cpp b/MPR121/MPR121_Datastream.cpp index 5b5a2e3..64366d8 100644 --- a/MPR121/MPR121_Datastream.cpp +++ b/MPR121/MPR121_Datastream.cpp @@ -55,12 +55,13 @@ void reset() { #endif } -char *splitString(char *data, char *separator, int index) { +char *splitString(char *data, const char *separator, int index) { char *act, *sub, *ptr; static char copy[255]; int i; strcpy(copy, data); + sub = copy; // to supress the warning for (i = 0, act = copy; i <= index; i++, act = NULL) { sub = strtok_r(act, separator, &ptr);