I'm having problems with the code I put as inline c for this library (attached).
I get this error log:
The code I use:
These methods code in the cpp file is:
(The code without parameters does not create errors
)...
I get this error log:
sketch\b4r_main.cpp: In function 'void Mp3_set_serial(B4R::Object*)':
b4r_main.cpp:46: error: '__softserial' is not a member of 'b4r_main'
mp3_set_serial(b4r_main::__softserial);
^
sketch\b4r_main.cpp: In function 'void Mp3_set_volume(B4R::Object*)':
b4r_main.cpp:49: error: '__volume' is not a member of 'b4r_main'
mp3_set_volume(b4r_main::__volume);
^
exit status 1
'__softserial' is not a member of 'b4r_main'
The code I use:
B4X:
Sub Process_Globals
Public Serial1 As Serial
Private Softserial As SoftwareSerial
...
Private Volume As UInt
...
End sub
Sub AppStart
...
RunNative("Mp3_set_serial", Null)
Delay(150)
Volume = 15
RunNative("Mp3_set_volume", Null)
Delay(150)
...
End sub
#If C
#include <DFPlayer_Mini_Mp3.h>
void Mp3_set_serial(B4R::Object* o) {
mp3_set_serial(b4r_main::__softserial);
}
void Mp3_set_volume(B4R::Object* o) {
mp3_set_volume(b4r_main::__volume);
}
void Mp3_play(B4R::Object* o) {
mp3_play();
}
#End If
These methods code in the cpp file is:
B4X:
void mp3_set_serial (SoftwareSerial &theSerial) {
_software_serial = &theSerial;
send_func = s_send_func;
}
//0x06 set volume 0-30
void mp3_set_volume (uint16_t volume) {
mp3_send_cmd (0x06, volume);
}
(The code without parameters does not create errors