trouble with applying a library given for a product (Grove EMG/LED Bar)

I am using this setup for EMG control that involves a Grove LED Bar.
https://www.seeedstudio.com/blog/2019/12/27/what-is-emg-sensor-myoware-and-how-to-use-with-arduino/

#include <LED_Bar.h>

LED_Bar bar(9, 8);

int max_analog_dta      = 300;              // max analog data
int min_analog_dta      = 100;              // min analog data
int static_analog_dta   = 0;                // static analog data


// get analog value
int getAnalog(int pin)
{
    long sum = 0;
    
    for(int i=0; i<32; i++)
    {
        sum += analogRead(pin);
    }
    
    int dta = sum>>5;
    
    max_analog_dta = dta>max_analog_dta ? dta : max_analog_dta;         // if max data
    min_analog_dta = min_analog_dta>dta ? dta : min_analog_dta;         // if min data
    
    return sum>>5;
}

void setup()
{
    Serial.begin(115200);
    
    long sum = 0;

    for(int i=0; i<=10; i++)
    {
        for(int j=0; j<100; j++)
        {
            sum += getAnalog(A0);
            delay(1);
        }
        
        bar.setLevel(10-i);
    }
    
    sum /= 1100;
    
    static_analog_dta = sum;

    Serial.print("static_analog_dta = ");
    Serial.println(static_analog_dta);
}

int level       = 5;
int level_buf   = 5;

void loop()
{

    int val = getAnalog(A0);                    // get Analog value
    
    int level2;
    
    if(val>static_analog_dta)                   // larger than static_analog_dta
    {
        level2 = 5 + map(val, static_analog_dta, max_analog_dta, 0, 5);
    }
    else 
    {
        level2 = 5 - map(val, min_analog_dta, static_analog_dta, 0, 5);
    }
    
    // to smooth the change of led bar
    if(level2 > level)
    {
        level++;
    }
    else if(level2 < level)
    {
        level--;
    }

    if(level != level_buf)
    {
        level_buf = level;
        bar.setLevel(level);
    }
    
    delay(10);
}

There was no LED_Bar, so I went to the product Grove EMG Bar, the one mentioned to be purchased and went to their git library where their code is

#ifndef Grove_LED_Bar_H
#define Grove_LED_Bar_H

#include <Arduino.h>

enum LedType {
    LED_TYPE_SHIFT  = 16,
    LED_BAR_10      = 0 << LED_TYPE_SHIFT | 10,
    LED_CIRCULAR_24 = 0 << LED_TYPE_SHIFT | 24,
    LED_MAX_COUNT   = 0 << LED_TYPE_SHIFT | 24,
    //LED_NEW_DEVICE = 1 << LED_TYPE_SHIFT | 10,
    LED_TYPE_MASK   = (1 << LED_TYPE_SHIFT) - 1, //indicated there at most 65535 leds
};

namespace Origin {
    class LedDevice {
      protected:
        uint32_t pinClock;
        uint32_t pinData;
        uint32_t countOfShows;
        LedType  type;
        bool     reverseShow;
        uint8_t  led[LED_MAX_COUNT];
      public:
        LedDevice(uint32_t pinClock, uint32_t pinData, bool reverseShow, LedType type);
        uint32_t countOfLed();
        void send(uint16_t bits);
        void send();
        void reverse();
        void latch();
    };
}

class Grove_LED_Bar : Origin::LedDevice {
  public:
    Grove_LED_Bar(uint32_t pinClock, uint32_t pinData, bool greenToRed, LedType type) :
        Origin::LedDevice(pinClock, pinData, greenToRed, type) {
    }
    void begin() {}
    void setGreenToRed(bool greenToRed);
    void setLevel(float level);
    void setLed(uint32_t ledNo, float brightness);
    void toggleLed(uint32_t ledNo);
    void setBits(uint32_t value);
    void setLedNum(uint32_t count);
    uint32_t getBits();
};

#endif

so I changed the LED_Bar in the first script to

#include <Grove_LED_Bar.h>

Grove_LED_Bar (9, 8);

and it gives me the error

expected unqualified-id before numeric constant

not sure what to do

Hey canadiancookhouse -

It helps a lot if you always post the full error message; Lines that may seem irrelevant could very much be relevant. Past that, it also typically includes line number information.

That being said, this error is that you have not given your variable a name. Note in the first snippet:

LED_Bar bar(9, 8);

You have the variable identifier (bar) here. In the second snippet,

Grove_LED_Bar (9, 8);

you are missing 'bar'.

Grove_LED_Bar (9, 8);

This will likely also give you an error. You can see the constructors signature needs a boolean and LedType.

I would recommend looking in the 'examples' folder of the git repo where you found this code to get a better idea on how to use this library.

I have replaced it with

#include <Grove_LED_Bar.h>

Grove_LED_Bar bar(9, 8);

and it now says

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"

EMG_Sensors:3:23: error: no matching function for call to 'Grove_LED_Bar::Grove_LED_Bar(int, int)'

 Grove_LED_Bar bar(9, 8);

                       ^

In file included from C:\Users\Austen Leversage\Documents\Year 3\Disso\Arduino\EMG_Sensors\EMG_Sensors.ino:1:0:

C:\Users\Austen Leversage\Documents\Arduino\libraries\Grove_LED_Bar/Grove_LED_Bar.h:63:3: note: candidate: Grove_LED_Bar::Grove_LED_Bar(unsigned char, unsigned char, bool)

   Grove_LED_Bar(unsigned char pinClock, unsigned char pinData, bool greenToRed);  // Initialize

   ^~~~~~~~~~~~~

C:\Users\Austen Leversage\Documents\Arduino\libraries\Grove_LED_Bar/Grove_LED_Bar.h:63:3: note:   candidate expects 3 arguments, 2 provided

C:\Users\Austen Leversage\Documents\Arduino\libraries\Grove_LED_Bar/Grove_LED_Bar.h:47:7: note: candidate: constexpr Grove_LED_Bar::Grove_LED_Bar(const Grove_LED_Bar&)

 class Grove_LED_Bar

       ^~~~~~~~~~~~~

C:\Users\Austen Leversage\Documents\Arduino\libraries\Grove_LED_Bar/Grove_LED_Bar.h:47:7: note:   candidate expects 1 argument, 2 provided

C:\Users\Austen Leversage\Documents\Arduino\libraries\Grove_LED_Bar/Grove_LED_Bar.h:47:7: note: candidate: constexpr Grove_LED_Bar::Grove_LED_Bar(Grove_LED_Bar&&)

C:\Users\Austen Leversage\Documents\Arduino\libraries\Grove_LED_Bar/Grove_LED_Bar.h:47:7: note:   candidate expects 1 argument, 2 provided

exit status 1
no matching function for call to 'Grove_LED_Bar::Grove_LED_Bar(int, int)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

binaryfissiongames:
You can see the constructors signature needs a boolean and LedType.

I would recommend looking in the 'examples' folder of the git repo where you found this code to get a better idea on how to use this library.

The first example you posted is now 6 years old. The git repo that has the source for the library you're using is only 5 years old. Things change with time.

It is defined, you can see it in that enum.

The code you posted that gives you the "LED_BAR_10 was not declared" error should be correct -- so it is confusing to me why it would say it's not declared. Are you sure the .h file you have on your filesystem matches the one in the git repo? I know that's an annoying question, but it could be a mismatch.

Hell, this library got a 40% rewrite just a little under a year ago that added that variable.

Edit:
looking back at the error message you got, you are using an outdated version. nix the last parameter of the constructor (LED_BAR_10) and try that out.

binaryfissiongames:
The first example you posted is now 6 years old. The git repo that has the source for the library you're using is only 5 years old. Things change with time.

It is defined, you can see it in that enum.

The code you posted that gives you the "LED_BAR_10 was not declared" error should be correct -- so it is confusing to me why it would say it's not declared. Are you sure the .h file you have on your filesystem matches the one in the git repo? I know that's an annoying question, but it could be a mismatch.

Hell, this library got a 40% rewrite just a little under a year ago that added that variable.

Edit:
looking back at the error message you got, you are using an outdated version. nix the last parameter of the constructor (LED_BAR_10) and try that out.

I have tried it by nixing the LED_BAR_10 and it now compiles perfectly!

The only problem it doesn't work! The LED bar is showing no indication and it only logs a single value between 300 - 600 a second or so after it is uploaded to the arduino. There is no constant stream of data.

I guess this is a good introduction to github

If you're copying the same code above verbatim (just swapping out the LED_Bar library), I can tell you that I don't see any serial.prints in your loop function - putting one there would help debugging if it's a problem with the display or possibly the EMG connection/setup.

It could also be entirely possible that the old library isn't compatible with the LED bar you have, and you'll have to pull it straight from github.