ADCTouch library cannot be compiled

Hello everyone, I have a code from my senior. He's been doing "Singing Plant" using Arduino Uno and I like to replicate the project but using GR-Sakura but it seems that library that I download has errors. Can someone test it out on Renesas sketch IDE and help me?

 

//Simple Demo that demonstrates 'print' and 'println' new functionality.

#include <ADCTouch.h>
#include <SOMO_II.h>

//define DisplaySerial Serial
#include <SoftwareSerial.h>
SoftwareSerial DisplaySerial(2,3) ; // pin 2 = TX of display, pin3 = RX
SoftwareSerial mySerial = SoftwareSerial(8, 9);
SOMO_II mp3 = SOMO_II(mySerial);

//-------Picaso DISPLAYS-------

#include <Diablo_Const4D.h>
#include <Diablo_Serial_4DLib.h>


Diablo_Serial_4DLib Display(&DisplaySerial);

//---------END-----------------
int ref0, ref1, value0; //reference values to remove offset
boolean playsong = false;
boolean yawn = false;
boolean snore = false;
boolean play = false;
boolean gifplay = false;
int randNumber, i, j, k, l, m, n, nextsong,longtouch;
word img;

void setup() {
//For handling errors
Display.Callback4D = mycallback ;

//5 second timeout on all commands
Display.TimeLimit4D = 5000 ;
mySerial.begin(SOMO_BAUD);
delay(100);
DisplaySerial.begin(9600);
delay(100);
Serial.begin(9600);
delay(100);
i=0;
j=0;
k=0;
l=0;
m=0;
n=0;
longtouch=0;
nextsong=1;
ref0 = ADCTouch.read(A0, 500); //create reference values to
delay(100);
value0 = ADCTouch.read(A0);
delay(100);
//--------------------------------Optional reset routine-----------------------------------
//Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2)
//If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below.
//If using jumper wires, reverse the logic states below.
//Refer to the accompanying application note for important information.
pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
digitalWrite(4, 0); // Reset the Display via D4
delay(100);
digitalWrite(4, 1); // unReset the Display via D4
//-----------------------------------------END---------------------------------------------

delay (5000); //let the display start up

Display.gfx_ScreenMode(PORTRAIT);
Display.gfx_BGcolour(WHITE) ; //change background color to white
Display.gfx_Cls(); //clear the screen
delay (100);
Display.file_Mount();

//img = Display.file_LoadImageControl("test.dat","test.gci",1);
img = Display.file_LoadImageControl("test.dat","test.gci",1);

mp3.begin();
delay (100);
mp3.feedback(false);

}

void loop()
{
value0 = ADCTouch.read(A0); //no second parameter
value0 -= ref0; //remove offset
//--------------------------detect capacitance to confirm 1----------
//Display.print(value0);
if (value0 > 39 && value0 < 151)
{
longtouch=0;
j=0;
m=0;
if(nextsong==11)
{
nextsong=1;
}
if (playsong == false)
{
//randNumber = random(1,11);
//Display.print(nextsong);
mp3.playFile(3, nextsong);
play = true;
nextsong++;
}
if (play == true)
{
playsong = true;
}

for(k=0; k<10; k=k+1)
{
Display.img_SetWord(img,15,IMAGE_INDEX,k );
Display.img_Show(img,15);
}

value0 = ADCTouch.read(A0);
value0 -= ref0;

//Display.print(i);
}

if (value0 > 150) // detect soft touch
{
j=0;
playsong = false;
if(longtouch<8)
{
for(m=0; m<8; m=m+1)
{
Display.img_SetWord(img,19,IMAGE_INDEX,m );
Display.img_Show(img,19);

//-----------------shock sound----

if (m == 0)
{
randNumber = random(19,21);
mp3.playFile(3, randNumber);
}

//-------------------------------
}
longtouch++;
}
if (longtouch>7)
{
for(n=0; n<15; n=n+1)
{
Display.img_SetWord(img,20,IMAGE_INDEX,n );
Display.img_Show(img,20);

//-----------------angry sound----

if (n == 0)
{
randNumber = random(21,23);
mp3.playFile(3, randNumber);
}
}
}
value0 = ADCTouch.read(A0);
value0 -= ref0;
longtouch++;
}
/*
if (value0 >= 20) // detect hard touch
{
j=0;
m=0;
for(n=0; n<15; n=n+1)
{
Display.img_SetWord(img,20,IMAGE_INDEX,n );
Display.img_Show(img,20);

//-----------------angry sound----

if (n == 0)
{
randNumber = random(21,23);
mp3.playFile(3, randNumber);
}

//-------------------------------
}
value0 = ADCTouch.read(A0);
value0 -= ref0;
}
*/
//--------------------------detect capacitance to confirm 0----------
if (value0 < 40)

{
playsong = false;
i=0;
l=0;
longtouch=0;
if (j < 5)
{
Display.img_Show(img,1);
//-----------------rolling sound----

if (j == 0)
{
mp3.playFile(3, 14);
}
if (j == 2)
{
mp3.playFile(3, 15);
}
if (j == 3)
{
mp3.playFile(3, 13);
}

//-------------------------------
for(m=0; m<15; m=m+1)
{
Display.img_SetWord(img,16,IMAGE_INDEX,m );
Display.img_Show(img,16);

n=0;
}
++j;
}
if (j >= 5 && j < 15)
{
//-----------------eating sound----

if (j == 5 )
{
mp3.playFile(3, 16);
}
if (j == 8 || j == 13 )
{
mp3.playFile(3, 18);
}
if (j == 10)
{
mp3.playFile(3, 17);
}

//-------------------------------
Display.img_Show(img,1);
for(n=0; n<15; n=n+1)
{
Display.img_SetWord(img,17,IMAGE_INDEX,n );
Display.img_Show(img,17);
m=0;
}
++j;
}
if (j >= 15 && j < 35)
{
Display.img_Show(img,1);

//-----------------yawn sound----

if (j == 15 || j == 30)
{
mp3.playFile(3, 11);
}

//-------------------------------

for(m=0; m<19; m=m+1)
{
Display.img_SetWord(img,18,IMAGE_INDEX,m );
Display.img_Show(img,18);
n=0;
}
++j;
}
if (j >= 35 && j < 45)
{
Display.img_Show(img,4);
Display.img_Show(img,1);
++j;
}
if (j >= 45 && j < 55)
{
Display.img_Show(img,5);
Display.img_Show(img,1);
++j;
}
if (j >= 55)
{
//-----------------------snore sound---------------
if (j == 55 || j == 200 || j == 400 || j == 600 || j == 800)
{
mp3.playFile(3, 12);
}
//-------------------------------------------------
for(k=0; k<12; k=k+1)
{
Display.img_SetWord(img,14,IMAGE_INDEX,k );
Display.img_Show(img,14);
}
++j;
if (j == 999)
{
j = 0;
Display.gfx_Cls();
}
}
i=0;
value0 = ADCTouch.read(A0); //no second parameter
value0 -= ref0; //remove offset
delay(100);
}
}

void mycallback(int ErrCode, unsigned char Errorbyte)
{
// Pin 13 has an LED connected on most Arduino boards. Just give it a name
int led = 13;
pinMode(led, OUTPUT);
while(1)
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for 200 ms
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for 200 ms
}
}

  • Hi Thwbh,

    Were you able to compile this already? What kind of error do you get? Did your senior created this ADCTouch library?

    JB
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    https://en-us.knowledgebase.renesas.com/

  • In reply to Thwbh:

    In member function 'void Diablo_Serial_4DLib::getString(char*, int)':
    C:\Users\slgo\Desktop\ide4gr-1.11-windows\ide4gr-1.11\libraries\Diablo16-Serial-Arduino-Library-master\src\Diablo_Serial_4DLib.cpp:142:17: warning: unused variable 'readx' [-Wunused-variable]
    unsigned char readx[2] ;
    ^
    C:\Users\slgo\Desktop\ide4gr-1.11-windows\ide4gr-1.11\libraries\Diablo16-Serial-Arduino-Library-master\src\Diablo_Serial_4DLib.cpp: In member function 'void Diablo_Serial_4DLib::SetThisBaudrate(int)':
    C:\Users\slgo\Desktop\ide4gr-1.11-windows\ide4gr-1.11\libraries\Diablo16-Serial-Arduino-Library-master\src\Diablo_Serial_4DLib.cpp:222:7: warning: variable 'br' set but not used [-Wunused-but-set-variable]
    int br ;
    ^
    C:\Users\slgo\Desktop\ide4gr-1.11-windows\ide4gr-1.11\libraries\Diablo16-Serial-Arduino-Library-master\src\Diablo_Serial_4DLib.cpp: In member function 'void Diablo_Serial_4DLib::printFloat(double, uint8_t)':
    C:\Users\slgo\Desktop\ide4gr-1.11-windows\ide4gr-1.11\libraries\Diablo16-Serial-Arduino-Library-master\src\Diablo_Serial_4DLib.cpp:1639:10: warning: unused variable 'n' [-Wunused-variable]
    size_t n = 0;
    ^

    i dont know how to fix there libraries
  • In reply to Thwbh:

    I think it's necessary to modify for GR-SAKURA. I've not confirm all of things, because I don't have shields you used, so I can't solve it.

    First, ADCToutch.cpp has the native code for Atmega MCU like below. I think it can be modified for GR-SAKURA.
    ADMUX |= 0b11111;
    ADCSRA |= (1 << ADSC);
    while((ADCSRA & (1 << ADSC)));

    There seems to be other issues on SOMO_II.cpp, but I think it's better to use HardwareSerial. SoftwareSerial is sometimes unstable even Arduino.
  • In reply to Okamiya Yuuki:

    This is about to compile, so I don't think the shield needed but I will try what you said thank you.
  • In reply to Okamiya Yuuki:

    Do you know how to modified for GR-Sakura, I am still figure out cause I am new to this field
  • In reply to Thwbh:

    I recommend to use e2studio in case modifying unknown libraries, because it has the function to analyze code include predefined macro etc.
    The project for GR-SAKURA is on the below web site. Though you need to install that, you will get effective.
    www.renesas.com/.../gr-sakura.html

    The compilation without errors itself is easy, but I think you don’t expect libraries that does not work.
  • In reply to Okamiya Yuuki:

    I will try install e2studio, but I still dont know what, how and where to fix it.

    Thank you