Questions tagged [struct]
Refers to a basic data structure (also called record).
46 questions
0
votes
1
answer
125
views
Serialise a struct containing a flexible array
I want to serialise and deserialise a struct containing a flexible array.
I did find a working code but wondering if it is the most elegant and optimum way to do it.
This is my first attempt below ...
-1
votes
1
answer
40
views
manage some output based on some parameter and rtc
i'm trying to create a program that given a configuration (i've used multiple struct nested) i need in loop() to check for each output if they need to be on or off and set the output accordingly
let ...
0
votes
0
answers
55
views
I'm looking for the StreamSend.h library for use in Arduino/ESP8266 serial communications using struct [duplicate]
I've come across an interesting yet old article within StackExchange which has great examples of sending structured variables over serial communications. The library StreamSend.h and it's source code ...
1
vote
1
answer
522
views
Trouble initializing a struct array
The goal for this is to create a struct that includes a name, ID, fileName, and a boolean, then create an array of that structs.
Here's what I came up with:
struct Amiibo
{
char *aName{};
char *ID{...
1
vote
0
answers
1k
views
incompatible types in assignment of 'const String' to 'char [32] using server.arg
I am trying to create a class and getting getting the error
incompatible types in assignment of 'const String' to 'char [32]
when I declare
char inString[32];
and try to set it as
inString = server....
2
votes
2
answers
2k
views
Own type definition using a struct does not name a type
I need to initialize several buttons and LEDs connected to my Arduino. To store data related to an individual button or LED, I decided to define my own data type using two different structs. One for a ...
1
vote
2
answers
458
views
Accessing struct's variable parametrically on ESP8266
I have 2 instances of a struct. One has def values stored and second stores values read from a file on SPIFFS.
I'm trying to use a for loop over all struct's variables - if file was read OK and key ...
3
votes
0
answers
23
views
How to properly pass struct as argument? [duplicate]
This is my first question! i'm sorry if i'm doing something wrong.
I'm trying to write a code that blinks some leds, but i cant quite work out how to use structs as arguments.
This is the code:
void ...
2
votes
2
answers
11k
views
Send structure through Serial
Suppose that one defined a data structure and wanted to send it through serial.
struct Gyro_data_structure {
char command_name[5];
float gyro_X;
float gyro_Y;
float gyro_Z;
};
...
0
votes
1
answer
572
views
Second item in array not gets assigned from struct object, ArduinoJson
I got the below code generated this amazing tool.
const size_t capacity = JSON_ARRAY_SIZE(2) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(4) + 2*JSON_OBJECT_SIZE(7);
DynamicJsonDocument doc(capacity);
...
-1
votes
2
answers
185
views
Memory size issue with the struct
I am working on a project where I have to build an IR program that works with all of the AVR/Arduino boards to control the IR devices such as TV, DVD, etc. I am building a struct that can carry the ...
0
votes
2
answers
97
views
Is code in a class repeated for each instance? [closed]
I haven't needed classes before in programming for Arduino, but I now have a good use case. I'm not sure I grasp how this will affect code space, though.
Currently I have a struct that holds the ...
0
votes
1
answer
93
views
Message Interpreter and Handler - How to store a function name in a struct?
For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this:
struct AvcInMessage {...
0
votes
1
answer
58
views
Constants within array of structs causes strange compiler errors?
In my sketch I have the following:
#define HU_ADDR 0x190;
#define ALL_AUDIO_ADDR 0x1FF;
#define MY_ADDR 0x360;
#define UNKNOWN_ADDR 0xFFF;
typedef ...
1
vote
2
answers
1k
views
Function, struct or class?
I am trying to learn more about arduino programming, and recently i've written functions for randomizing and then modifying a single array. Now i'd like to do the same for four individual arrays. This ...
0
votes
1
answer
3k
views
Transfer serial data to struct variable in Arduino
I have declared a struct with some variables that right now are fixed, but one of the variables on the struct needs to be what the Arduino's serial port reads.
struct testing_var
{
const char *...
0
votes
1
answer
889
views
MIDIUSB - Why is the command put twice?
Consider this function:
void noteOn(uint8_t pitch) {
midiEventPacket_t noteOn = {0x09, 0x90 | 9, pitch, 127};
MidiUSB.sendMIDI(noteOn);
}
midiEventPacket_t is defined as:
typedef struct
{
...
1
vote
1
answer
6k
views
Help with struct variable
I made a struct like this:
typedef struct {
int color[3];
int positions[4];
char init[20];
void (*fn)();
} buttons;
and a variable like this:
button test[1] =
{
{{0,0,0},{0,0,100,100},"...
1
vote
2
answers
5k
views
Use of struct and sizeof in C for Arduino
I am a newbie in C and I can not understand the point of using a structure in C. Could someone explain to me what is the point of defining a structure in C programming?
For example, this code(written ...
2
votes
4
answers
10k
views
Transfer a struct's data to an external struct via serial?
Using two boards of similar architecture I would like to send the contents of a struct from the sending board to the receiving board. I am using UART to transfer.
My plan was to populate an array ...
0
votes
1
answer
2k
views
I2C_Anything String / Char Array issues
I've been working with the lovely I2C_Anything.h (thanks to the great work and support from Nick over at http://www.gammon.com.au/forum/?id=10896&reply=9#reply9).. All working great, I was using ...
5
votes
2
answers
12k
views
Using PROGMEM to store array of structs
I am hitting the limits of my arduino's SRAM and found that SRAM usage can be reduced by storing static stuff in flash memory instead of SRAM.
My project can (optionally) be built with an included ...
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 ...