SMFSW / Queue

Queue handling library (designed on Arduino)
BSD 3-Clause "New" or "Revised" License
97 stars 20 forks source link

Request: add keyword and function POP #1

Closed Booli closed 7 years ago

Booli commented 7 years ago

Hey,

really like your library. Most implementations do not use the word pull , but use the keyword pop.

Could you maybe implement that? I was trying to add an extra function in the header just to call the pull function, but my C++ is not up to par.

Thanks

SMFSW commented 7 years ago

Hello,

thank you! It's true, usually keyword pop is used.

I'll update the lib this way, and maybe implement peek method too...

In the meantime, you can use a define to alias the name of the function. If you don't use another lib with the keyword pop, it shouldn't cause you any trouble. Add this line at the end of Queue.h: #define pop pull

SMFSW commented 7 years ago

Changes done!

Booli commented 7 years ago

Hey,

I would keep pull in as a keyword, because maybe people are already using the library with pull and when they update it breaks.

Secondly, I get an error "Queue is not type name" when I want to import it from my libraries folder. If I copy it in my sketch folder and use "Queue.h" instead of it does work.

Thanks for your effort.

SMFSW commented 7 years ago

Alright, pull will be re-enabled as an inline to pop.

About your include issue, can you tell me more about it? Board, system, where your libs are stored? I'll try to reproduce it.

Booli commented 7 years ago

Building with PlatformIO through Deviot for ESP8266.

This is the build error:

/Users/booli/queue_test.ino:52:1: error: 'Queue' does not name a type
Queue sendLogDataQueue(sizeof(Logdata), 24, LIFO, true);
^

Relevant code:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <SoftwareSerial.h>
#include <TickerScheduler.h>
#include <time.h>
#include <FS.h>
#include <Queue.h>
#include "SimpleTime.h"
#include "config.h"
#include "credentials.h"

// Solar data variables
float solar_yield = 0;
float consumption_yield = 0;
uint32_t aggregate_tick = 0;

typedef struct { 
    uint32_t    solar;
    uint32_t    consumption;
    char        date_hour[10];
} Logdata;

Queue sendLogDataQueue(sizeof(Logdata), 24, LIFO, true);

void setup() { 
   // stuff
}

void loop () { 
  // stuff 
}

It does work when I put the library directly into my project folder an use "Queue.h"

SMFSW commented 7 years ago

I get the same error when on ESP8266. I opened another issue for this to fix. Issue #2

1 fixed in latest commit