Arduino header debugging... Help!

Hey everyone I am looking for some input in my header file for my arduino touchscreen. I currently I have the code in my sketch and I am trying to improve efficiency by placing the homescreen initialization in a header file.

Here is my header

#ifdef Homescreen_h
#define Homescreen_h

#include "Arduino.h"

class Homescreen
{
public
homescreen(void);
buttons(void);
boxes(void);
text(void);
};

#endif

and here is my cpp.

#include <LGDP4535.h>
#include<Arduino.h>
#include<Homescreen.h>
#include<Adafruit_GFX.h>

//Define colors pallate available
//16bit
#define Black 0x0000
#define Navy 0x000F
#define DarkGreen 0x03E0
#define LightGrey 0xC618
#define White 0xFFFF

LGDP4535 tft;

Homescreen::Homescreen()
{
//HomeScreen

void Homescreen::boxes()
{
//Initialize screen boxes
tft.fillRoundRect(0, 0, 210, 25, 5, Blue);
tft.fillRoundRect(0, 30, 220, 40, 5, LightGrey);
tft.fillRoundRect(0, 75, 160, 25, 5, Blue);
tft.fillRoundRect(0, 105, 220, 40, 5, LightGrey);
tft.fillRoundRect(0, 150, 240, 42, 5, LightGrey);
}
void Homescreen::text()
{
//Screen Text
tft.setCursor(10,5);
tft.setTextSize (3);
tft.setTextColor (White);
tft.print("Temperature");
tft.setCursor(10,80);
tft.setTextSize (3);
tft.setTextColor (White);
tft.print("Humidity");
}
void Homescreen::buttons()
{
//Initialize buttons
tft.fillCircle(295, 25, 30, Navy);
tft.drawChar(283, 5, 49, White, Navy, 5);

tft.fillCircle(295, 83, 30, Navy);
tft.drawChar(283, 65, 50, White, Navy, 5);

tft.fillCircle(295, 138, 30, Navy);
tft.drawChar(283, 121, 51, White, Navy, 5);

// tft.fillCircle(295, 193, 30, Navy);
// tft.drawChar(283, 178, 52 ,White, Navy, 5);

//Page select
tft.drawChar(292, 200, 175 ,White, Navy, 5);
tft.drawChar(0, 200, 174 ,White, Navy, 5);
}

Its not quite working out for me. lol and input would be awesome!!

Is it possibly because I haven't declared any of the unsigned int's used for my locations?

First, open this link and scroll down to #7 (put your code inside code brackets).

Second,

Jimmyb907:
Its not quite working out for me. lol and input would be awesome!!

What errors are you getting? Post the message(s) here.

class Homescreen
{
  public
    homescreen(void);
    buttons(void);
    boxes(void);
    text(void);
};

I can't believe that compiles - no return types and a missing colon.

thats what I was wondering.... haha needs some debugging. Its something I threw together, but I am really curious if I can use the syntax like I did in this instance. --> Calling other library's functions while creating a new library. If so .. how can I initialize these functions I have created, i'm guessing just make a instance of the class and use that to reference either the button function or the boxes function.

The constructor name MUST be EXACTLY the same as the class name. Homescreen and homescreen are NOT.

Well right of the bat its telling me that homescreen does not name a type in my .cpp file

Here is my header

#ifdef Homescreen_h
#define Homescreen_h

The first line of your header should be "#ifndef Homescreen_h"
"If I haven't already included the definitions, then define a bunch of stuff, including a variable that means I've already included them."

/home/james/Arduino/libraries/Homescreen/Homescreen.h:9:20: error: return type specification for constructor invalid
void Homescreen();

would this be because I am declaring it void??

here is a update of my code

.cpp :

#include <LGDP4535.h>
#include<Arduino.h>
#include<Homescreen.h>
#include<Adafruit_GFX.h>

//Define colors pallate available
//16bit
#define Black 0x0000
#define Navy 0x000F
#define DarkGreen 0x03E0
#define DarkCyan 0x03EF
#define Maroon 0x7800
#define Purple 0x780F
#define Olive 0x7BE0
#define LightGrey 0xC618
#define DarkGrey 0x7BEF
#define Blue 0x001F
#define Green 0x07E0
#define Cyan 0x07FF
#define Red 0xF800
#define Magenta 0xF81F
#define Yellow 0xFFE0
#define White 0xFFFF
#define Orange 0xFD20
#define GreenYellow 0xAFE5

LGDP4535 tft;

Homescreen::Homescreen()
{
//HomeScreen
}

void Homescreen::boxes()
{
//Initialize screen boxes
tft.fillRoundRect(0, 0, 210, 25, 5, Blue);
tft.fillRoundRect(0, 30, 220, 40, 5, LightGrey);
tft.fillRoundRect(0, 75, 160, 25, 5, Blue);
tft.fillRoundRect(0, 105, 220, 40, 5, LightGrey);
tft.fillRoundRect(0, 150, 240, 42, 5, LightGrey);
}
void Homescreen::text()
{
//Screen Text
tft.setCursor(10,5);
tft.setTextSize (3);
tft.setTextColor (White);
tft.print("Temperature");
tft.setCursor(10,80);
tft.setTextSize (3);
tft.setTextColor (White);
tft.print("Humidity");
}
void Homescreen::buttons()
{
//Initialize buttons
tft.fillCircle(295, 25, 30, Navy);
tft.drawChar(283, 5, 49, White, Navy, 5);

tft.fillCircle(295, 83, 30, Navy);
tft.drawChar(283, 65, 50, White, Navy, 5);

tft.fillCircle(295, 138, 30, Navy);
tft.drawChar(283, 121, 51, White, Navy, 5);

// tft.fillCircle(295, 193, 30, Navy);
// tft.drawChar(283, 178, 52 ,White, Navy, 5);

//Page select
tft.drawChar(292, 200, 175 ,White, Navy, 5);
tft.drawChar(0, 200, 174 ,White, Navy, 5);
}

.h :

#ifndef Homescreen_h
#define Homescreen_h

#include "Arduino.h"

class Homescreen
{
public:
void Homescreen();
void buttons();
void boxes();
void text();

};

#endif

Awesome it works :slight_smile: :slight_smile: :slight_smile: .

Thanks