I have been working on this problem for a little over a week, and I am not getting anywhere fast! I thought I would start by stepping back and trying to find out a solution more efficiently than just banging my head against the wall, working harder, not smarter.
Below are the steps that I put in a prior post on Personal Problem Solving Process (PPSP), and I have augmented them with additional thoughts or different approaches.
Spoiler Alert: In the process of writing this blog post I realized that there are some “lurking variables” that are impeding the debugging process and that I’m likely to go into a wormhole and never come out. So, in the end, I decided to put this issue on the shelf and move on to finish the Altimeter as this does not block a useful trial, where I will learn so much more that I know now!
1. Describe the problem & document: I want to provide altitude information on a small graphical display formatted so it is compact and readable. I’m using the Adafruit Arduino library for writing to this display. Unfortunately, when I try to write to the display using a String object, the routine displays nothing (blank). The reason for using a string object is so that I can have a fixed number of characters for a given variable, thus yielding a tighter display in a table format.
Routine: display.print(); display.print
The function properly renders floating point numbers, integers, and character arrays, but not String objects.
Problem statement: How can we consistently display a number in a fixed number of characters (4) using the display.print() library on the SSD1307?
2. Initial conditions: We had developed a test file for more rapid troubleshooting. Although it would be desirable from an iteration speed standpoint to not have to write to the OLED display, I have found that the serial display functions don’t operate the same way as the display.print() functions do. The test file is: sketch_mar27display, and the key statements are:
display.print(), String(), and toCharArray()
3. Considerations: When trying to understand the problem and better define the boundaries of disfunction, I found that inserting unrelated statements such as initializing another String object or calling the Tone function would cause the display not to work either! So I have concluded not to put in more good time after bad, and focus on different parts of the project. I could spend hours and hours on this particular problem, but I have the feeling that the solution will come to me over the course of time, not over forcing to solve this problem right here, right now.
4. Next Steps: Document this (in the brown lab notebook) and upload this post and put the problem aside. Then, the next step is to resume the Altimeter project, using the constraints that we have a simplified graphical interface and be satisfied with and or accept the challenge of limited formatting capability. We are close to having a finished project and we should outline all the steps to move it from the bench to the field.