[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Example sketch too large for pro micro? RSS feed
Forum Index » tcMenu Arduinio library
Author Message

Joined: Mar 26, 2020
Messages: 8

I ran into the problem that the example for the U8g2 library seems to need to much memory for the Sparkfun Pro Micro board (5V version) that I am using. The compiler stops with the message that I would need 109 % of the memory present (31470 bytes needed, 28672 bytes present). I generated the code with the TcMenu UI designer and used most of the example sketch "simpleU8g2".

My question: Is there an easy way to reduce memory needed? As I have a fairly easy menu in mind (just 1 layer with 4-6 selectable choices), is there an alternative that would need less space, maybe 8x8 library or some other way to create a menu?


#include "TestforTcMenu_menu.h"
#include <IoAbstraction.h>

// the width and height of the attached OLED display.
#define OLED_WIDTH 128
#define OLED_HEIGHT 64

// Here we declare the variable using exactly the name that we used in the 
// designers code generator panel for the graphics variable. The name and
// type must match exactly
U8G2_SH1106_128X64_NONAME_F_HW_I2C gfx(U8G2_R0, 5, 4);

IoAbstractionRef arduinoPins = ioUsingArduino();

// In a tcMenu application, before calling setupMenu it's your responsibility to ensure
// that the display you're going to use is ready for drawing. You also need to start
// wire if you have any I2C devices. Here I start serial for some printing in the callback.
void setup() {
    // If you use i2c devices, be sure to start wire.

    // start up the display. Important, the rendering expects this has been done.

    // This is added by tcMenu Designer automatically during the first setup.

    // Note:
    // during setup in a full menu application you'd probably load values
    // back from EEPROM and maybe initialise your remote code (see other examples)

// In any IoAbstraction based application you'll normally use tasks via taskManager
// instead of writing code in loop. You are free to write code here as long as it
// does not delay or block execution. Otherwise task manager will be blocked.
void loop() {

// this is the callback function that we declared in the designer for action
// "Start Toasting". This will be called when the action is performed. Notice
// instead of using callbacks for every toaster setting, we just get the value
// associated with the menu item directly.
void CALLBACK_FUNCTION onStartToasting(int id) {
    Serial.println("Let's start toasting");
    Serial.print("Power:  "); Serial.println(menuToasterPower.getCurrentValue());
    Serial.print("Type:   "); Serial.println(menuType.getCurrentValue());
    Serial.print("Frozen: "); Serial.println(menuFrozen.getCurrentValue());


Joined: Jan 19, 2019
Messages: 362
Unfortunately, there's probably not enough space to use any kind of U8G2 display along with TcMenu on such a small board.

There's a couple of things you could try, mainly removing any use of i2c and spi that is not needed. Remove any libraries that you could live without. Other than that, there's not much more that can be done.

The smallest 8-bit board I recommend for using with graphical displays (IE other than LiquidCrystal) is the MEGA.

With ESP and MKR boards being cheaper than the AVR boards, we recommend using either MEGA or a 32-bit board for anything graphical.

EDIT: We test Uno in our test cases with an i2c LCD backpack and up-down buttons. We keep the menu small and even manage to fit serial remote capability in, but it's very tight, around 28K used. For Uno and similar boards, keep it small, use as little extra as possible


Joined: Apr 1, 2020
Messages: 5
i think i will have the same problem.
do you plan to add more libraries in the future?
this library uses very little memory: https://github.com/greiman/SSD1306Ascii

and well done for your work.

Joined: Jan 19, 2019
Messages: 362
Good idea, I don't want to leave behind the Uno. It's used by a lot of people. I test every single release on Uno with serial support and Liquidcrystal. If this library has memory characteristics closer to that end of the spectrum, then this should work. For every release, we have a base line for that of about 28K. If it increases from there, I try and work out why and get the memory back down.

An issue has been raised against the tcMenu main project to create a plugin for that library. It will now be after the 1.4.0 release, which shouldn't be that far away. In the meantime, you could either test on a larger board, or use the Liquidcrystal library that has lower memory requirements.

Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer