Open z4nD4R opened 6 years ago
I copied your program into Arduino and clicked Verify.
sketch_jun13b: In function 'void loop()':
sketch_jun13b:10: error: 'device' was not declared in this scope
Serial.println(device->get_id());
^
'device' was not declared in this scope
Hello,
thnak you. As I stated in my post "Sorry I didn't put exact code here as it is pretty complex and so I believe to keep it in this form would much usefull."
If you require the whole code I need to prepare a code sample for you.
Y
I have a similar problem.
I store pointer to OneWire object in my Sensors class. It works when I call it directly from this class, but when sensors.class is passed to another class, search doesn't work in that class (zero results). Pointers to sensors are the same everywhere, so it doesnt copy the object.
Everything works fine when OneWire object is defined globally.
ps. i'm creating an object with "new" :
static DataStorage dataStorage;
static _Time time (&dataStorage);
static PWM pwm (&time);
static Sensors sensors;
static Nextion nextion (&time, &pwm, &sensors, &dataStorage);
class Sensors
{
public:
Sensors ();
private:
OneWire* __oneWire;
DS18B20* __sensorsWire;
};
Sensors::Sensors ()
{
__oneWire = new OneWire (ONEWIRE_PIN);
__sensorsWire = new DS18B20 (__oneWire);
}
class Nextion
{
public:
Nextion (_Time *_time, PWM *_pwm, Sensors *_sensors, DataStorage *_dataStorage);
private:
_Time *__time;
PWM *__pwm;
Sensors *__sensors;
DataStorage *__dataStorage;
}
Nextion::Nextion (_Time *_time, PWM *_pwm, Sensors *_sensors, DataStorage *_dataStorage)
{
__time = _time;
__pwm = _pwm;
__sensors = _sensors;
__dataStorage = _dataStorage;
}
Search doesnt work from Nextion class.
Description
Hello Everyone, I'm building my own ESP32 based app in which I'm using modular approach and so I'm using my own created libs for particular devices/sensors. So I did for
ds18b20
. Basicaly I've created a mainmyDevice
class and all libs are inheriting the required method etc.Pretty easy yeah? The problem with
OneWire
lib is: when I use it the eample codewrapped
inside of my own libs, theds.search
won't find any device on the bus.I'm pretty sure that my wiring and the code is corret as:
loop
functionSteps To Reproduce Problem
status
message from main lib a.ka.myDevice->status();
Hardware & Software
ESP32 dev board + ds18b20. I believe it is not hw related
Arduino IDE version 1.8.5
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version Xubuntu 18.04
Arduino Sketch