Skip to content

Commit

Permalink
Changed argument type
Browse files Browse the repository at this point in the history
@gergelytakacs error() and serialPrint() functions sometimes throw a warning message: "ISO C++ forbids converting a string constant to 'char*'" when used like they were meant to - serialPrint("text"). Sketch is compilable even without this change, this is just to satisfy the compiler by using the "more correct" argument type.
  • Loading branch information
PeterChmurciak committed Jun 26, 2019
1 parent 8e0d12b commit fec9bea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/AutomationShield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ byte AutomationShieldClass::percToPwm(float perc){
return byte(percFloat);
}

void AutomationShieldClass::error(char *str) // Error handler function
void AutomationShieldClass::error(const char *str) // Error handler function
{
#if ECHO_TO_SERIAL // If Serial Echo is turned on in the DEFINE (by advanced user)
Serial.print("\nError: ");
Expand All @@ -44,7 +44,7 @@ byte AutomationShieldClass::percToPwm(float perc){
while (1); // Stop all activity in busy cycle, so user definitely knows what's wrong.
}

void AutomationShieldClass::serialPrint(char *str){ // Function for printing messages to serial monitor if its enabled
void AutomationShieldClass::serialPrint(const char *str){ // Function for printing messages to serial monitor if its enabled
#if ECHO_TO_SERIAL // If Serial Echo is turned on in the DEFINE (by advanced user)
Serial.print(str); // Print message to serial monitor
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/AutomationShield.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
class AutomationShieldClass{
public:
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max);
void error(char *str);
void serialPrint(char *str);
void error(const char *str);
void serialPrint(const char *str);
float constrainFloat(float x, float min_x, float max_x);
byte percToPwm(float perc);
}; // end of the class
Expand Down

1 comment on commit fec9bea

@gergelytakacs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All righty, nice find. Please make a search for error() in the entire library (other shields as well), since this could potentially affect the API for other shields. Although I don't expect much use of error() so far (which is a shame). Maybe you could also put a note in #42 to teach others how to use these functions correctly.

Please sign in to comment.