Questions tagged [class]
A custom structure in C++ (and various other languages) which can contain member data and functions. An instance of a class is called an object.
122 questions
0
votes
0
answers
147
views
Initializing both I2C devices of a RP2040 Rpi Pico with Earle Philhower Core
I'm using the Arduino IDE (v1.8.19) with the Earle Philhower core to program a Raspberry Pi Pico (RP2040) board.
I2C bus 0 of the Pico (pins 4 (SDA) and 5 (SCL) are coupled to a first MCP23017 port ...
-1
votes
1
answer
113
views
Class private variable values not accessible in public function
I'm experimenting with classes in Arduino code. I have the following small code snippet:
#include "Motor.h"
#include "Arduino.h"
Motor::Motor()
{
}
void Motor::Configure(...
3
votes
2
answers
3k
views
Attach the Arduino ISR function to the class member
I intended to use a timer interrupt for limited instances of a class in my ESP32 Arduino project. My first code conception was as follows:
portEXIT_CRITICAL_ISR(&lock0);
}
...
1
vote
1
answer
3k
views
Invalid use of non-static member function
In order to explain my problem I used 3 classes: Actions, Triggers, and Combine.
Actions simulates an action function, that is defined externally.
Triggers has that function that needed to be executed....
1
vote
4
answers
1k
views
Instances of a class inside another class - is there a way to control the amount?
I have a class with 12 instances of a button, to create a keypad( meaning that this is the only case I use 12 instances). But this class can be just a button array of any other number between 1-12. I'...
1
vote
2
answers
2k
views
Call functions of one class from another class - Callback
I am new to C++ & I need to call functions of one class from another class. And so that the classes do not know anything about each other. How to do it in Arduino environment?
class Encoder {
...
1
vote
0
answers
305
views
Using library functions in timer ISR ESP32
I'm trying to use a library function in my ISR function that uses the internal timer to trigger every 1 ms. The chip that I'm using is an ESP32-C3-MINI. Here is my current code:
main.cpp
#include <...
-1
votes
1
answer
364
views
How to pass Strem object to my class
I'm trying to creaper class wraper to use an Streamobject but I've an error when I try to compile.
My .hfile :
#include <Arduino.h>
class TestSerialListener {
public:
TestSerialListener(...
2
votes
1
answer
135
views
How to pass Encoder object to constructor of a different class
I am trying to create a class (Arm) that controls an arm. The arms have 2 motors, each with an encoder, so I pass 4 integers for the pins and I am trying to pass 2 pointers (one for each encoder ...
1
vote
1
answer
152
views
How do I properly use an ISR inside a class definition?
I want to write a class for a model bike.
For controlling the steering I use a DC motor with two encoders.
To get the steering angle stAng of the bike, I attach a interrupt to the pin ST_ENC_A where ...
22
votes
5
answers
79k
views
What overheads and other considerations are there when using a struct vs a class?
C on embedded systems has traditionally use structs to hold structured data.
Arduino brings C++ to the table, so we can use classes instead.
Lets say we have two different data structures which ...
1
vote
1
answer
96
views
Cannot instantiate a parameterized object inside of another class
I'm having troubles understanding the inner workings of classes and such.
I have a class called Attributes that contains parameters. In my .ino, I can simply instantiate an object with Attributes ...
1
vote
1
answer
638
views
Use and definition of a destructor class
I created a class for TFT buttons and messages when using a Wemos 2.4 tft touch display.
In a code I use about 12 buttons (3 different screens with 4 buttons in each screen ), for example in my home ...
21
votes
3
answers
9k
views
Classes and objects: how many and which file types do I actually need to use them?
I have no previous experience with C++ or C, but know how to program C# and am learning Arduino. I just want to organize my sketches and am quite comfortable with the Arduino language even with its ...
0
votes
2
answers
1k
views
Passing a two dimensional array to a function
I'm working on an led matrix project where I'm running a series of patterns made of bitmap frames.
Here's an example: https://vimeo.com/564184465
Right now I'm using a series of method calls named per ...