Where is the begin() code?

Most sketches begin with setup(), which itself begins with arduboy.begin(), but where is the code for the begin()?

I looked in arduboy.h, found the public methods begin() and beginNoLogo() in the arduboy class definition, but there’s no code there.

So, what exactly executes when begin() is called?

Thanks in advance for helping an old, confused, COBOL programmer. :slight_smile:

1 Like

For the actual code you’ll want to look in Arduboy.cpp the .h is only the header file for the definitions.

1 Like

I see it now. Looks like I’m trying to run before I can walk. Thanks a million!

1 Like

If anyone else stumbles upon this and also wants a deeper understanding, read this post: .cpp and how to use em

1 Like

If you’re looking at Arduboy.h it sounds like you’re using the Arduboy library. This library is for legacy sketches and is no longer being maintained. For new sketches, you should use the Arduboy2 library

If you read my post following the one above, you’ll see that for sketches you don’t have to deal with .h and .cpp files. It’s usually easier to only use .ino files for sketches.

.h .cpp .c and other file types are used by Arduino libraries, such as Arduboy2, but they aren’t required in Arduino sketches.

Thanks, Scott. I’ll switch to the new library. Could I ask one more noob question, though?

How can Arduboy.cpp’s begin() function call boot(), when it’s declared as protected in core.h? I see that the Arduboy class inherits ArduboyCore, but what’s the distinction between public and private if the inheriting class can call the private function? I was under the impression that boot() could only be called by another function within ArduboyCore.

I’m guessing that while I couldn’t create an instance of ArduboyCore and call instance.boot(), I can create an instance of Arduboy, which inherits from ArduboyCore, and call boot() from within it. Is that correct?

Public: visible to everything.
Private: visible only to the defining class and any friend classes.
Protected: visible to the defining class, any friend classes and any classes that inherit it.

Either way though, boot is in the public section, it can be called from anywhere that knows about it.
Only 5 of the ArduboyCore functions are protected.

2 Likes

Thanks Pharap.

That’s the part I hadn’t realized.

1 Like