Hi guys !;thanks for read this.
I found this code for cs1302 clock,
https://create.arduino.cc/projecthub/eri...lay-6e1035
in this part he define next variables:
const char * DS1302ErrorMessage = "*RTC ERROR";
const char * AM2320ErrorMessage = "*TEMPERROR";
and a function:
void powerOnTest() {
Time t = rtc.time();
if (dayAsString(t.day) == DS1302ErrorMessage ) {
displayStringCondensed(0, DS1302ErrorMessage);
}
switch(th.Read())
case 1 or 2:
displayStringCondensed(0, AM2320ErrorMessage);
}
everything looks nice, however always appears this message
C:\Users\xinal\Documents\Arduino\maxclock\MAXCLOCK_PRUEBA\MAXCLOCK_PRUEBA.ino: In function 'void powerOnTest()':
C:\Users\xinal\Documents\Arduino\maxclock\MAXCLOCK_PRUEBA\MAXCLOCK_PRUEBA.ino:156:51: warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]
displayStringCondensed(0, DS1302ErrorMessage);
C:\Users\xinal\Documents\Arduino\maxclock\MAXCLOCK_PRUEBA\MAXCLOCK_PRUEBA.ino:280:6: note: initializing argument 2 of 'void displayStringCondensed(int, char*)'
void displayStringCondensed (int startCol, char * displayString) {
C:\Users\xinal\Documents\Arduino\maxclock\MAXCLOCK_PRUEBA\MAXCLOCK_PRUEBA.ino:161:51: warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]
displayStringCondensed(0, AM2320ErrorMessage);
Would you help me to understand why appears this plase?
Neodimio58:
Would you help me to understand why appears this plase?
You didn't include all the code, but I'm gonna guess because the signature for the function 'displayStringCondensed()' defines its second parameter as type 'char *'. Does this function need to change the string that this parameter is pointing to? If not, change its type to 'const char *'.
Hi gfvalvo.
Thanks a lot for your time answering me. Wow !! you´re the law
this is original function.
void displayStringCondensed (int startCol, char * displayString) {
int i;
char c;
destMatrix = 0;
destCol = 7 - startCol;
for (i = 7; i > (7 - startCol); i--) // clear first columns if the startCol > 0
lc.setColumn(destMatrix, i, B00000000);
while (displayString[0] != 0) {
c = displayString[0];
if (destMatrix == 4 || displayString[0] == '~') { // next line when we're out of matrices or a newline character is sent: ~
clearLastColumns();
destMatrix = 0;
destCol = 7 - startCol;
if (displayString[0] == '~') {
displayString++;
c = displayString[0];
}
delay(nextLineDelay);
}
if (displayString[0] == '|') { // display one blank column
lc.setColumn(destMatrix, destCol, B00000000);
increaseColCounter();
}
else if (displayString[0] == '.') { // display a point in a single column
lc.setColumn(destMatrix, destCol, B10000000);
increaseColCounter();
}
else if (displayString[0] == '!') { // display a !
lc.setColumn(destMatrix, destCol, B10111111);
increaseColCounter();
}
else if (displayString[0] == '/') { // display a % sign, % sign won't work because of the snprintf function
lc.setColumn(destMatrix, destCol, B11000011);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B00110011);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B11001100);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B11000011);
increaseColCounter();
}
else if (displayString[0] == '*') { // display a *
lc.setColumn(destMatrix, destCol, B00100010);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B00010100);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B01111111);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B00010100);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B00100010);
increaseColCounter();
lc.setColumn(destMatrix, destCol, B00000000);
increaseColCounter();
}
else {
if (destMatrix == 3 && destCol < 4) { // the character does not fit so enforce a new line
clearLastColumns();
destMatrix = 0;
destCol = 7 - startCol;
displayString--;
delay(nextLineDelay);
}
else {
int pos = lc.getCharArrayPosition(c);
for (i = 0; i < 6; i++) {
lc.setColumn(destMatrix, destCol, alphabetBitmap[pos][i]);
increaseColCounter();
}
}
}
displayString++;
}
clearLastColumns();
}
after changing
void displayStringCondensed (int startCol, const char * displayString)
code runs smoothly! Thanks again; I promise study hard to one day helps in this forum like you! 