I need to modify a library (flavortext.h)

This library is by Zack Freedman and it's called Flavortext. It generates fake status messages.

I need help modifying it.

  1. How do I "call" the library? I can't figure out how to make the Arduino generate a status message and then print it somewhere (OLED, LCD, serial, etc.). It looks like the variable is just a string called output but how would I use it in an Arduino sketch?

  2. I need to remove the easter egg he added for his Patrons on Patreon because I don't want random Patreon usernames that are supporting someone that isn't me on my outputs. I believe I just have to remove lines 375-402.

  3. Zack uses Teensies almost exclusively in his projects so I need help identifying if there are any Teensy-specific operators used.

Which Arduino board do you use ?
If you are using a basic Arduino board (Uno, Nano, Mega, Nano Every), then you might have to change it to use PROGMEM.

This function returns the text: void getFullLine(char * buffer, bool constructive)

I don't know if there is a maximum length, you can start with 80.

char buf[80];

void loop()
  getFullLine( buf, true);
  Serial.write( buf);
  getFullLine( buf, false);
  Serial.write( buf);
  delay( 5000);

I plan to use a Micro sending it's output over I2C to a 1.3" OLED.

EDIT - Are there too many keywords in the library that can be combined? How would I reduce the amount? Obviously I would have to delete some of them, and then change #define numberOfConstructiveVerbs 100 for each category, respectively. Any other references to the number of keywords?

The 'String' object is mainly used for the easter egg. If the easter egg is not used, then the 'String' object can be changed for normal operations on text.
A Micro is also a basic Arduino board, so I suggest to put everything in PROGMEM.

1 Like

There are three #define numberOf... in the code. They are all 100 and they define the number of texts. There are better ways to do that, I would keep them as they are for now.
A mistake is easily made. Suppose you have 67 texts and set the define to 68, that could crash the sketch.

1 Like

What line of Arduino code do I use to change the library to PROGMEM?

And what datatype is the output if not a string? Because to me it looks like line 372 is the output, and it defines as a string.

Sorry if my questions are dumb, coding is my biggest weakness as a maker.


What if I had 68 texts and set the define to 67? Would that just remove one?

EDIT - Also, how much memory does this library actually use? Because this project needs a gigantic statement table to work and I don't want to waste storage on a funny ha ha joke.

I don't know if it will fit in a Micro, so I don't know if you can test it without PROGMEM.

This is PROGMEM: https://www.arduino.cc/reference/en/language/variables/utilities/progmem/
You can try a few things to understand it. It is not changing a single line.

The output is written to a char array.
The String is used temporarily, and mainly for the easter egg.

With the define set to 67 and with 68 texts, then the last one is not used.

A better way is to add a end-marker in the text, but the code gets bigger.
An end-marker can be anything that is not normal text. For example empty string or a -1 or a # or whatever:

char myData[][20] =
  "",               // empty string as end marker

Okay. Because of the Micro's small memory size I think I'll just put something similar on the Pi part of the wearable computer project when it boots. Some guy remade this script in Python so I can use an .sh in the startup script of the Pi.

That means I can just boot the Pi to command, run the script on startup, and then start the desktop.