A variable in C/C++ which stores the type and location of data in memory.
0
votes
3answers
33 views
How is a local variable address retrieved/returned inside the CPU of Arduino?
How is the address of a local variable retrieved in Arduino's ATMEGA328 micro-controller?
Lets say somewhere inside the main we have lines as:
int x = 5; //a variable declared and value of 5 stored ...
-1
votes
1answer
44 views
Keep References Between Objects
I'm trying to recreate a small tween engine so I can interpolate values, leds hue, saturation and brightness in a easy way.
I'm having trouble to reference the value to interpolate into my tween ...
0
votes
1answer
51 views
Using pointers with Arduino
I am learning about pointers.
I was wondering how the memory address is defined in programming. I get different outputs depending on the format I choose for memory address. So I was wondering if it ...
1
vote
1answer
27 views
Pass custom element of an array from an inherited class to main sketch
I'm building a base class that creates color patterns using FastLed's CRGB structure. I use the base class as inheritance for another more specific class that modifies a vector of colors (Pixels[]) ...
2
votes
2answers
28 views
Problem with wrapping Adafruit Motor Controller function calls in a class
I'm working on an Arduino robot and I ran into a problem when reorganizing my code. I have an Adafruit Motor Shield v2.3 connected to an Arduino Uno. My robot can be controlled using a bluetooth ...
0
votes
2answers
27 views
Pros and Cons of using a non-pointer class object
In this example I have an one object which uses a pointer and one object which does not.
class MyClass {
public:
void myMethod() {
// do nothing
}
};
MyClass* mc1;
MyClass mc2;
void ...
1
vote
3answers
289 views
Storing an array of function pointers
I have some Arduino code that looks like:
char packet = ser.read();
switch(packet){
case 'a':
someobj.somefunc();
break;
case 'b':
otherobj.otherfunc();
...
0
votes
1answer
263 views
Remove certain characters from char*
I've got an array of char* with serial data that I'm trying to remove ':' from. I have tried to iterate through the char*, find and remove any colons but it just comes out as garbage.
char* espData[...
1
vote
2answers
459 views
User callback functions
I want to write a class that allows the user to attach his own function to a member function that listens for messages coming from a wireless module, so that the user's function can be called ...
1
vote
3answers
96 views
Integer goes garbage after iteration. struct pointer manipulation messed up other variables in memory
I'm writing a library for Charlieplexed LED display (trying to write a common one actually). The library is working quite fine. In my arduino sketch, I'm using an integer to keep track of the LED, ...
1
vote
1answer
145 views
Casting a struct member between uint8_t and char, with regard to serial transfer
Im simply trying to pass my payload to another device that has the same architecture and struct. I'm using UART to transfer, and modeling the protocol from EasyTransfer.
When I call Serial.print((...
5
votes
2answers
519 views
Works with gcc, not with Arduino. error: taking address of temporary array
I need to hard code 8 byte addresses into char arrays of length 8. This must be done many places in my code (in function scope), so I have tried to come up with a one-liner. The following works ...
3
votes
1answer
283 views
Dereferencing char into a struct
I am sending some data over an NRF24 link, using the RF24Network library. So far I have only sent numbers, now I also want to send a string, so I have set up my payload struct as
struct payload_t { ...
0
votes
1answer
82 views
Why doesn't my object's method return back to my caller method?
I am creating a miniature computer using an Arduino, and I am creating a full-scale interpreter for it. Everything works, and the code begins to run after calling the runCode method, but once the run ...
2
votes
1answer
32 views
Mysterious behavior when using objects
I am writing a project that involves using complementary filters to combine gyroscope and accelerator readings in 3 directions. The relevant code is below.
class CompFilter {
public:
long ...
2
votes
2answers
2k views
How can I pass a char array as the parameter to a function?
I am creating a menu for adjusting system variables.
The menu is made up of pointers like so:
char* options4[] = {"hMin1", "hMax1", "refr1", "fSpeed1"};
I want to pass the selected string as the ...
3
votes
1answer
128 views
sending ctrl-z in a struct?
I have a set of buttons wired to an arduino leonardo that are meant to send either single keystrokes to a computer "a, b, c..." etc, or a key sequence like ctrl+z (to perform an undo command.) ...
2
votes
1answer
121 views
C++ Pointer Issues - Mangled Data
I am having trouble getting my head around pointers in C++, specifically how they behave when passed around or used within objects. As far as my understanding goes as long as pointers, or more ...
1
vote
1answer
72 views
String operators
I have a section of code that I am unsure of what it is doing.
static int bufindw = 0;
static char buffer[4][96];
static char *strchr_pointer;
int result;
result = (int)strtod(&buffer[bufindw][...
0
votes
2answers
556 views
Pass a member function pointer to a method of a foreign class (EDB Lib)
I'm currently working on my own arduino library and I'm becoming exasperated with the following problem: I want to store data with the extended database library (https://code.google.com/p/arduino-edb/)...
1
vote
2answers
108 views
cannot convert error with pointers
I write a code to store patterns for LED blinking, but I got this error:
led_basics:39: error: cannot convert 'char (*)[17][2]' to 'char*' in initialization
led_basics:39: error: cannot convert '...
0
votes
2answers
85 views
Use pointer in calculation results in error
I'm building a project to measure/track flyball dog races.
The dogs timings are measured by photoelectric sensors at the start/finish line of the racing lane.
I have most of my code working (available ...
1
vote
3answers
489 views
ISR executes even though an interrupt is not triggered
I am trying to implement a function queue scheduling system. INT1 is connected to a button and int1task causes an LED to flash.
typedef void (*funcptr)(void);
TPrioQueue *queue = NULL;
void int1ISR()...
0
votes
1answer
589 views
Wrong Mouse.move() output in Arduino Leonardo
I'm using my Arduino Leonardo as a Mouse but I'm experimenting a strange behaviour.
I put my mouse at (-1, -1) (absolute) coordinates and then I execute this code:
Move.move(com[curr_cmd_id].x, com[...
1
vote
3answers
470 views
Is it bad coding practice to design a buffer using pointers?
I coded a ring buffer for my Arduino to buffer data from either the SPI or TWI ports. In the .h file I used a pointer for the buffer:
typedef uint8_t *ring_buffer_t;
typedef uint8_t ring_count_t;
...
10
votes
2answers
540 views
Are function pointer assignments atomic in Arduino?
The following snippets are from TimerOne library source code:
// TimerOne.h:
void (*isrCallback)();
// TimerOne.cpp:
ISR(TIMER1_OVF_vect) // interrupt service routine that wraps a user defined ...
1
vote
1answer
2k views
How to use String.substring?
I have the following code in which requestLine is always empty and I can't figure out why. request contains a raw HTTP request, and I want to get the first line of the request which contains the ...
9
votes
2answers
6k views
Why can I not use pointers instead of array with PROGMEM?
I'm currently changing some libraries to use flash instead of RAM for string storage so that I do not run out of SRAM on a project.
Some strings in the library are declared in this manner:
const ...