Hey everyone, I'm having trouble with figuring out the source of this error
'class Watchy' has no member named 'getHeightData'
Here is the code for .ino:
#include <Watchy.h> //include the Watchy library
#include <Fonts/FreeMonoOblique24pt7b.h> //include any fonts you want to use
class MyFirstWatchFace : public Watchy{ //inherit and extend Watchy class
public:
Watchy face;
void drawWatchFace(){ //override this method to customize how the watch face looks
display.setFont(&FreeMonoOblique24pt7b);
display.setCursor(25, 110);
display.setFullWindow();
display.setTextColor(GxEPD_BLACK);
display.fillScreen(GxEPD_WHITE);
display.print(face.getHeightData());
display.display(true);
}
};
MyFirstWatchFace m; //instantiate your watchface
void setup() {
m.init(); //call init in setup
}
void loop() {
// this should never run, Watchy deep sleeps after init();
}
A snippet from the header file:
#ifndef WATCHY_H
#define WATCHY_H
#include <Arduino.h>
#include <WiFiManager.h>
#include <HTTPClient.h>
#include <Arduino_JSON.h>
#include <DS3232RTC.h>
#include <GxEPD2_BW.h>
#include <Wire.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "DSEG7_Classic_Bold_53.h"
#include "BLE.h"
#include "bma.h"
#include "config.h"
typedef struct weatherData{
int8_t temperature;
int16_t weatherConditionCode;
}weatherData;
class Watchy {
public:
static DS3232RTC RTC;
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
tmElements_t currentTime;
public:
Watchy();
void init(String datetime = "");
void deepSleep();
float getBatteryVoltage();
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
int getHeightData();
void handleButtonPress();
void showMenu(byte menuIndex, bool partialRefresh);
void showFastMenu(byte menuIndex);
void showBattery();
void showBuzz();
void showAccelerometer();
void showUpdateFW();
void setTime();
void setupWifi();
bool connectWiFi();
weatherData getWeatherData();
void updateFWBegin();
void showWatchFace(bool partialRefresh);
virtual void drawWatchFace(); //override this method for different watch faces
private:
void _rtcConfig(String datetime);
void _bmaConfig();
static void _configModeCallback(WiFiManager *myWiFiManager);
static uint16_t _readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
};
And a snippet from the cpp file
int Watchy::getHeightData()
{
int height = 0;
if(connectWiFi())
{
HTTPClient http;
http.setConnectTimeout(3000);//3 second max timeout
String queryURL = String("http://api.blockcypher.com/v1/btc/main");
http.begin(queryURL.c_str());
int httpResponseCode = http.GET();
if(httpResponseCode == 200)
{
String payload = http.getString();
JSONVar responseObject = JSON.parse(payload);
height = int(responseObject["height"]);
}
else
{
height=0;
}
http.end();
}
else
{
return height;
}
return height;
}
I'm unsure as to why it does not recognize this member. Have I initialized it properly?