As we've done in the previous assignments, I created an API key on SystemLink again and copied it to the previous code.
I made use of relevant commands that belong to the U8G2 library to initialize the screen (u8g2.begin), specify the String variable as an input and then further print it in a specified font (u8g2.setFont, u8g2.setCursor and u8g2.print). I decided to use the Full Screen Buffer mode to have a faster process and further included the associated constructor and clearBuffer and sendBuffer commands.
For the void loop of the function, I defined my output strings and then tags for Arduino to connect to SystemLink and retrieve information.
I used the GET_SystemLink() function to connect to SystemLink, which connects to LabVIEW to display tag values, title and ingredients of the recipe, as the user inputs food keyword and relevant ingredients.
A challenge I came across here was since some recipe titles are relatively longer, they would not fit the screen and the rest would not be visible. So in order to write the title line by line, I had to split it into pieces.
I further adjusted the coordinates so that lines would be under one another.
Going back to LabVIEW, I used the Match Pattern functions again, to split the title into 2 pieces. However, as I was testing my code on Arduino and OLED Screen, I realized there are some recipes which take more than 2 lines, so I ended up using Match Pattern function 3 times, with offset=12 and a space constant each. I had to create the third and the forth title tag called then add it to Arduino. I created 4 different tags for the title since the longest title of a recipe would occupy 4 lines on the Arduino Display.
As the last step, I had to figure out the correct + and - values to display the string of the title extracted from JSON. Looking through the code and the monitor section, I was able to understand I should add +2 to : and -1 to }. Since the string is inside the quotation marks, which was specified earlier in the code, adding these values made sense.