I get these error,, whats wrong with the code?
Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"
In file included from F:\Documents\Arduino\Phi_morse_translator_v1_6_0\Phi_morse_translator_v1_6_0.ino:51:0:
F:\Documents\Arduino\libraries\phi_morse/phi_morse.h:25:36: error: 'phi_buttons' has not been declared
void init_morse(LiquidCrystal * l, phi_buttons ** btns, phi_button_groups * key, byte b, int p);
^
F:\Documents\Arduino\Phi_morse_translator_v1_6_0\Phi_morse_translator_v1_6_0.ino: In function 'void setup()':
Phi_morse_translator_v1_6_0:86:68: error: cannot convert 'phi_button_groups*' to 'int**' for argument '2' to 'void init_morse(LiquidCrystal*, int**, phi_button_groups*, byte, int)'
init_morse(lcd, (phi_button_groups*)(mbi_ptr[0]), 'B', buzzer, 90);
^
exit status 1
cannot convert 'phi_button_groups*' to 'int**' for argument '2' to 'void init_morse(LiquidCrystal*, int**, phi_button_groups*, byte, int)'This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
phi_morse.h
#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
#include <phi_interfaces.h>
void init_morse(LiquidCrystal * l, phi_buttons ** btns, phi_button_groups * key, byte b, int p);
void morse_period(int p);
void morse_out(char* message);
char morse_in(byte col, byte row);
char morse_find(char *detected);
static void di();
static void dah();
static char di_or_dah(void);
.cpp
#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
#include <phi_interfaces.h>
#include "phi_morse.h"
static LiquidCrystal *output_lcd;
static phi_buttons ** panel_btns;
static phi_interfaces * key;
static byte bzr=16;
static int period=90;
unsigned char space_to_Z[][8]={" ", "!-.-.--", "\".-..-.", "# ", "$ ", "% ", "&.-...", "\'.----.", "(-.--.", ")-.--.-", "* ", "+.-.-.", ",--..--", "m-....-", "p.-.-.-", "/-..-.", "0-----", "1.----", "2..---", "3...--", "4....-", "5.....", "6-....", "7--...", "8---..", "9----.", ":---...", ";-.-.-.", "< ", "=-...-", "> ", "?..--..", "@.--.-.","A.-", "B-...", "C-.-.", "D-..", "E.", "F..-.", "G--.", "H....", "I..", "J.---", "K-.-", "L.-..", "M--", "N-.", "O---", "P.--.", "Q--.-", "R.-.", "S...", "T-", "U..-", "V...-", "W.--", "X-..-", "Y-.--", "Z--.."};
void init_morse(LiquidCrystal *l, phi_buttons ** bs, phi_interfaces * k, byte b, int p)
{
output_lcd=l;
panel_btns=bs;
key=k;
bzr=b;
period=p;
}
void morse_period(int p)
{
period=p;
}
void morse_out(char* message)
{
char pointer=0;
char pointer2=0;
while (pointer2>=0)
{
if ((message[pointer2]>=' ')&&(message[pointer2]<='Z'))
{
unsigned char character=message[pointer2]-' ';
pointer=0;
while (pointer>=0)
{
switch(space_to_Z[character][pointer])
{
case '.':
di();
break;
case '-':
dah();
break;
case ' ':
delay(6*period);
break;
case '\0':
delay(2*period);
pointer=-2;
break;
default :
break;
}
pointer++;
}
}
else if (message[pointer2]=='\0') pointer2=-2;
pointer2++;
}
}
char morse_in(byte col, byte row)
// This function decodes one character, display the Morse code at (col,row), and returns the character decoded or error code.
// It calls morse_find to determine the character.
// Returns -1 if input is invalid - . combination.
// Returns -2 if detected too long. This may be used as erase previous character.
{
char temp1=0, pointer=0;
char code[7];
while (pointer<6) // This main loop detects up to six di or dah
{
temp1=di_or_dah();
if (temp1<=-1) return (temp1); // Read di_or_dah for return values.
else if ((temp1==0)&&(pointer==0)) continue;// No di or dah detected yet, this is the wait period, just keep waiting.
else if (temp1==0) break; // Pause after each character is detected. Time to look at the result.
else code[pointer]=temp1; // Store the last detected signal to code.
output_lcd->setCursor(col+pointer,row);
output_lcd->write(code[pointer++]);
}
code[pointer]=0; // Terminate the string.
temp1=morse_find(code);
return(temp1);
}
char morse_find(char *detected)
// Returns the character detected or -1 if the sequence is invalid.
{
char temp1;
for (byte i=0;i<sizeof(space_to_Z)/sizeof(space_to_Z[0]);i++) // sizeof(space_to_Z) returns 472 instead of 59 (number of characters).
{
if (strcmp((const char*) detected,(const char*)(*(space_to_Z+i)+1))==0)
{
temp1=**(space_to_Z+i);
if (temp1=='p') temp1='.';
else if (temp1=='m') temp1=='-';
return (temp1);
}
}
return (-1);
}
static void di()
{
tone(bzr, 770);
delay(period);
noTone(bzr);
delay(period);
}
static void dah()
{
tone(bzr, 770);
delay(3*period);
noTone(bzr);
delay(period);
}
static char di_or_dah()
// Returns 0 if detected a pause
// Returns -1 if detected up button.
// Returns -2 if detected down button.
// Returns -3 if detected left button. This may be used as erase previous character.
// Returns -4 if detected right button. This may be used as adding space.
// Returns -6 if detected escape button. This may be used to escape.
// Returns -127 if detected invalid signal or too short.
// Returns -128 if detected too long.
// Returns '-' or '.' otherwise
// The function doesn't check if enough pause is used after the - or .
{
int temp1;
long t1,t2;
t2=millis();
while(1)
{
for (byte i=0;i<4;i++) //Sense first 4 buttons.
{
if (panel_btns[i]->sense()==buttons_released) return(-(i+1));
}
if (panel_btns[5]->sense()==buttons_released) return(-6);// Skip the confirm button as it is by default the key.
if (millis()-t2>3*period) return(0);
temp1=key->sense();
if (temp1==buttons_down)
{
t1=millis();
tone(bzr, 770);
break;
}
}
while(1)
{
temp1=key->sense();
if (temp1==buttons_released)
{
t1=millis()-t1;
if (abs(float(t1)/3/period-1)<0.4)
{
noTone(bzr);
return('-');
}
else if (abs(float(t1)/period-1)<0.4)
{
noTone(bzr);
return('.');
}
else if ((float(t1)/3/period-1)>0.4)
{
//Tone is too long. This may be used as erase previous character
noTone(bzr);
return(-128);
}
else
{
//error or too short
noTone(bzr);
return(-127);
}
}
}
}
Phi_morse_translator_v1_6_0.ino (4.65 KB)
phi_morse.cpp (7.34 KB)
phi_morse.h (1.09 KB)
phi_interfaces.cpp (45.2 KB)
phi_interfaces.h (39.5 KB)