Need Help With Arduino Programming

I am new to Arduino programming, but have done a bunch of pre–programmed UNO projects, and can understand the simple C/C++ Arduino programs. Pretty good for an 80 year old right? I have the Ringo by CircuitMess board installed in the Arduino IDE, and version 1.0.2 of the library installed (although I really don’t know how to use the library function).

In order to learn, I would like to have an example of an Arduino sketch that shows how to run a simple program (just a text message) as a Ringo App that works like the existing games on the phone. I want to return the Ringo to its own firmware (maybe by pushing button B) when exiting the App. I am really good at bricking the phone, and re-loading the firmware but tired of doing it.

Any help is really appreciated.

Kent

kfixman, here’s an Arduino example I wrote that just about exercises all the things you’re trying to learn: PI

Hint
 if you want to try before you buy (i.e.: before you get into compiling it from source), just put the .bin file from the last post of that topic, and Robert’s icon from the zip file in the 4th post in that topic into a new application directory on the SD card named PI.

Thank You Frank. I was hoping that you would reply. I was able to create a new application directory on the SD card with my own made up icon .bmp file and borrowed a .bin file from one of the existing games just to see if it worked - it did, but that is as far as I got.
I will study your PI example - really appreciate it.

Hey Kent,

Here, under the ‘Examples’ you can find many simple programs that allow you to check out how functions work.

I do recommend using CircuitBlocks however since it’s much more user-friendly especially for beginners and offers you pretty much everything that is available in our library.

We’re going to release a new version soon which is going to feature a whole lot of new things and will allow you to use it both as a block and as a code builder! :smiley:

Recommendation: Start small and just build your way up.

Robert

Thanks much Robert. You are always helpful, and your posts are much appreciated.

1 Like

Where do I find a list of the contents of the Arduino MAKERphone library. The only thing I can find is the firmware?

As of right now, we still haven’t released official library reference.

Our plan is to rewrite some functions and change the whole library up before doing so, because in this way it wouldn’t be as understandable as it is supposed to be.

I recommend opening the whole folder as a workspace in some other editor (ex. VSCode) which makes it easier to navigate the files. That way you can check out all of the functions that are used in the Ringo firmware. :slight_smile:

Robert

Once again thanks Robert. I will wrestle with that along with a lot of other stuff. I have the time, and the desire, now all I have to work on is the smarts :face_with_monocle:

1 Like

Great then - I’ll be happy to help and explain some things the best way I can!

Enjoy learning! :smiley:

Robert

kfixman, because the library isn’t documented, I just looked at firmware and/or app source code that does something like I wanted to do and used the same or related functions in my code (after perusing the .h files for the library to see what else was available). With C++ it’s pretty easy to see what-all capabilities are included in a class once you’ve found it in a .h file.

I am beginning to understand parts of your code Frank. You include the MAKERphone library, but tell me the lines of code where you call it to reinstall the firmware.

I am reading the book Beginning C for Arduino by Jack Purdum. Hope that is a good one.

When you put a .bin file (like pi.bin) in a directory named pi along with an icon.bmp file, it forms an application that is loaded by the firmware upon request. When a program is loaded in this way, the firmware loads it into a second memory partition, while the firmware remains in the original memory partition. Then your program runs until it calls the MAKERphone::loader() member function. You’ll see in my code that it does this if it detects that you’ve pressed the B button while it’s waiting for the number of digits to be typed in (mp.loader() call on line 50). This library call causes the firmware in the original memory partition to be executed from the beginning again (it doesn’t have to be reloaded).

If you just compile and upload the sketch directly from the Arduino IDE (which doesn’t understand the firmware’s partitions), then it really does overwrite the firmware and the B button will only restart the PI program (the firmware is gone). In that case, you really do need to use the Tools/Burn Bootloader capability of the Ringo board package on the Arduino IDE to restore the firmware to factory (which will be the latest if you have the latest Ringo board package installed on the IDE).

As far as a coding reference for C++, the C reference is a good start but will only get you so far. You’ll really need to understand C++ classes to use the Ringo/Makerphone library. I highly recommend the C++ tutorial(s) found at http://www.cplusplus.com.

Please feel free to ask me any programming questions you may have (though I’ll be skiing for the next week so won’t be checking this community very often until I get back).

Ahhh, I am slowly beginning to understand. The .bmp is no problem, I have done a bunch of those. I have also downloaded some programs to the phone requiring a reload of the firmware. The existence of the second memory partition answers most of my questions, and eventually I will look at the Ringo firmware as recommended by Robert to see how the second partition is created.

When I get good enough I hope to create a simple Arduino sketch, convert it to a .bin, put it in the proper named folder with the .bmp, and have it return to the firmware after pushing a button.

Thanks for the C++ reference. It will be next on my study list.

That’s done simply in the Arduino IDE with Sketch/Export compiled Binary (instead of Sketch/Upload). Puts the .bin file in the same directory as the source code. And you don’t need to have the phone plugged in while you do this.

Yep, I tried that awhile back, but the code wasn’t right and it didn’t work. I will be borrowing a bunch of your code after a little more study. I know you don’t mind.

I am trying to come up with some RINGO API functions (if I am even using the term correctly) that I will be using. I don’t think I am ready to delve into the firmware .bin yet (hopefully someday soon), but if I am thinking correctly, these functions from Frank’s PI code will be some that I will use after I reference MAKERphone.h

MAKERphone mp
mp.begin
mp.display
mp.buttons
mp.update
mp.loader
mp.display.print

I am such a newbie, that I don’t even know if my thinking about this is in the right direction or not. Still having fun though.

MAKERphone is a class (type) that encapsulates all the unique functionality of the MAKERphone. This functionality is provided by member functions and objects. In this case, the member functions you mentioned do the following:

begin() - Initializes the object (a MAKERphone) and tells it whether to display the moving splash screen during initialization or not.

update() - Called periodically, this syncs the hardware with the software library. This is rather time consuming and should not be called unnecessarily.

loader() - restarts firmware if it is still available in the other memory partition.

while the object members (in your case, display and buttons) provide their own member functions to affect sub-parts of the MAKERphone:

display.print() - for example, write text to display (overloaded to support string type and assorted numeric type arguments)

buttons.released() - for example, returns whether a specific button has been released.

If you read MAKERphone.h, you’ll see lots more members of the MAKERphone class, and for those members that are objects (of a particular other class), those objects will have their own member functions and object members. And so on and so on.

I agree this is a TERRIBLE way to try to understand the MAKERphone library, so hopefully CircuitMess will soon publish a library reference manual similar to that for other Arduino libraries.

Thanks Frank. That helps a lot. I am struggling a bit trying to open the firmware.bin as a .txt file. Is that what I have to do to get into MAKERphone.h, or am I on the wrong trail?

No, firmware.bin is the binary load image
 it can’t be opened as a text file. You want to open this file: MAKERphone.h

Thank you Frank. Back to my studies.