Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
122 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 ...
Malzon's user avatar
  • 1
-1 votes
2 answers
1k views

How to properly put a u8g2 handle in a class

I'm trying to create a small battery powered alarm clock using an Arduino MKRZero and a generic SH1106-controlled, 128x64 pixel oled. I started out just dumping all code into a single file named Clock....
Simon's user avatar
  • 107
0 votes
1 answer
4k views

Interrupts inside a class attaching to the function of the class

Hello i have a class and i would like to attach an interrupt inside the class and attach it to a function of the class. class counter{ public: counter(int pin){ Ipin=pin; } void ...
Jack's user avatar
  • 223
0 votes
1 answer
143 views

Segmentation fault and huge SRAM need for Serial.println

I have written my own 'assert' since I want to use it for both Windows and Arduino. The class is called from many files (about 10). AssertUtils.h: #pragma once #define assert(expr) AssertUtils::...
Michel Keijzers's user avatar
1 vote
1 answer
977 views

Initializing an array within a class

I'm making a game of snake on the adafruit Neopixel shield and have run in to a problem. How do you fill out an array (in this case a 5*8 array) with values once the class has been called. This is my ...
Matt's user avatar
  • 158
1 vote
2 answers
76 views

Call class B from Class A

I have two classes in my sketch that are independent of each other (a serial output and an LCD display) A simplified structure of my code is as follows: class A { public: int x; void afoo() ...
ATE-ENGE's user avatar
  • 941
1 vote
1 answer
56 views

How come `MyClass.MyStaticMethod()` doesn't work, but `Serial.begin()` does?

MyProject.ino: #include "MyClass.h" void setup() { Serial.begin(9600); // MyClass.MyStaticMethod(); MyClass::MyStaticMethod(); } Both uncommented lines work, but the commented (when ...
Fine Man's user avatar
  • 189
1 vote
1 answer
2k views

Inheritance not working as expected

Short version: This is a lighting control project. Some of the clases are Pin and Channel. Channel contains a Pin. Pin is a base class for DigitalOutPin and will be the base class for AnalogOutPin, ...
dj_segfault's user avatar
0 votes
1 answer
336 views

Possible Arduino Uno c++ compiler bug?

I recently gave the students in my Arduino-based programming class a project to write some simple unit tests and fix the bugs that they encountered as they did. The class in question mostly stores a ...
dgatwood's user avatar
  • 109
4 votes
2 answers
24k views

using enums in functions

Given the following enums enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW }; enum class CrossingZoneState: uint8_t { CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized ...
dinotom's user avatar
  • 360
2 votes
1 answer
8k views

pass class internal function as callback

I am trying to pass a class internal function as a callback function within the class. The error behavior is similar to this problem. Whatsoever, I was unable to construct working code based on that ...
Faultier's user avatar
  • 143
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 ...
heltonbiker's user avatar
1 vote
1 answer
9k views

Call a class method from inside the same class

If i have file cSpeedOfSound.h: #ifndef cSpeedOfSound_h #define cSpeedOfSound_h #include "Arduino.h" #include "math.h" class cSpeedOfSound{ public: cSpeedOfSound(float *i,float *C); ...
yourstruly's user avatar
1 vote
1 answer
18k views

Use object of other class within class

I am writing a class for a project which will take care of handling any LCD updates for my project. The way I want to handle this is to initialize the LCD object in my main file, and then pass the LCD ...
Alex's user avatar
  • 181
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 ...
Cybergibbons's user avatar
  • 5,420