Call out to Musicians or 'wanna be' Musicians

No, I swear :stuck_out_tongue: the first try was 16 bytes less but behaved incorrectly. I may be able to get those 16 bytes back by adding just a tiny bit to inline asm.

1 Like

When do you think the library will be released? It holds a lot of promise!

I need to talk to @JayGarcia about that. As far as I am concerned people could start using right now to get feedback with the proviso that released application based on ATMlib2 use git submodules to point to a specific version or include their own copy so we are free to make changes to the API if necessary.

i promise that this is on my “To do” list. =)

@filmote

I’ve tried to stuff in ATMLib2 to allow music but the base sketch is already 98% full. :frowning:
IDK what to do here. If i add ATMLib2, we go over 100%.

I shot you a PM, if you remove ArduboyTones you get back a more respectable:

Sketch uses 27518 bytes (95%) of program storage space. Maximum is 28672 bytes.

That should give you a bit of space!

@filmote I don’t know if you’re already aware of this, but you can free up about 2kb just by changing:

class Arduboy2Ext : public Arduboy2

into

class Arduboy2Ext : public Arduboy2Base
1 Like

OMG … no I didn’t. Thanks!! Now I can put back a scene I dropped and the credit page (to the original author).

2 Likes

Oh yeah. You made my day. Thanks for this hint. I also regained so much flash space due to this… :star_struck:
A thousand thanks!

2 Likes

The Ways to make more code space available to sketches section, Remove the text functions subsection of the Arduboy2 library documentation describes this. I always find it helpful to review the documentation for something I’m using, to be aware of this sort of thing.

1 Like

You are right. Should have read the manual. I am not really the C++ expert and I was not sure what to do with the friend class thing in Arduboy2Base. Seeing that creating a friend of class named Arduboy2Ex with base class Arduboy2Base reduced the code size so much kind of hit me. After thinking about it, it makes sense but it took a while to understand.

Not exactly.

The reason using Arduboy2Base as a parent (instead of Arduboy2) saves memory is because Arduboy2 inherits from Arduboy2Base and adds more features, so inheriting from Arduboy2Base excludes those extra features.

Regarding the use of friend and inheritance:

Any class inheriting Arduboy2Base will get access to its protected members.

What friend Arduboy2Ex; means is that if you create a class called Arduboy2Ex it will be able to access the protected members of Arduboy2 (and Arduboy2Base, and Arduboy2Core) without needing inheritance.

For example the following code compiles only because Arduboy2Ex is marked friend.

class Arduboy2Ex
{
public:
  void manipulateArduboy(Arduboy2 & arduboy)
  {
    arduboy.textWrap = !arduboy.textWrap; // textWrap is protected
  }
};

The important distinction is that a class inheriting Arduboy2Base also gains all the variables and functions of Arduboy2Base, whereas a class named Arduboy2Ex (without inheritance) doesn’t inherit those things.
Instead, Arduboy2Ex is just allowed to access the protected parts of another Arduboy2, Arduboy2Base or Arduboy2Core.


Edit:

Also inheriting Arduboy2Ex won’t pass on the friendship.

So the following code wouldn’t work:

class Arduboy2Ex
{
public:
  void manipulateArduboy(Arduboy2 & arduboy)
  {
    arduboy.textWrap = !arduboy.textWrap; // textWrap is protected
  }
};

class Arduboy2ExChild : public Arduboy2Ex
{
public:
  void attemptToManipulateArduboy(Arduboy2 & arduboy)
  {
    arduboy.textWrap = !arduboy.textWrap; // access violation, can't access the protected member
  }
}
2 Likes