Nano with LCD12864 libraries to heavy

Hi I need some help, I am a long way into a project using Nano with LCD12864 (ST7920) using U8g2lib.
I have now got major stability issues due to low memory. When I broke it down the U8g2Lib with almost nothing else uses 1332 bytes or 65% of what the nano has.
I have tried reducing memory in other areas using F() and avoiding Strings but it only leaves 216bytes before memory warnings :frowning:

#include <U8g2lib.h>
#include <SPI.h> 

#define clockPin 13 //Connect to pin'E' on LCD
#define dataPin 12  //Connect to pin R/W on LCD
#define csPin 10    //Connect to RS on LCD
#define resetPin 8  //Actually not connected not sure why it need to be delcared

U8G2_ST7920_128X64_F_SW_SPI *_u8g2;

void setup() {
   _u8g2 = new U8G2_ST7920_128X64_F_SW_SPI(U8G2_R0, clockPin, dataPin, csPin, resetPin);
   _u8g2->begin();
   _u8g2->setFont(u8g2_font_logisoso46_tn); 
   _u8g2->setFont(u8g2_font_t0_22b_tr);
}

void loop() {
}

I decided I needed to take a big backwards step and try another library in the hope I could free up memory. I found the old U8glib which when I tried a similar sized sketch only used a fraction of the memory 265 bytes 12% unfortunitlly after adding any large sized font it instantly exceeded the entire Flash memory.

So one library uses too much SRAM and the other uses too much Flash either way the Nano cannot handle it.

Does anyone know how to reduce the resourse hunger of either of these two libraries or offer another library?
The large font only needs to be numbers so if there is a number only large font that is smaller for U8glib that could help (I couldn't see any)

Having to change from a Nano would be a disaster given PCBs etc are already manufactured.

Please help if you can. :confused:

after adding any large sized font

do you need all the characters in the font?

Having to change from a Nano would be a disaster given PCBs etc are already manufactured.

no comment on this... (but thinking to myself it was not that smart to go to manufacture without having a proven prototype...)

Just prototype manufacture low cost but a big time waster, I had prroven the concept but ran out of memory with final screens.

OK worked it out myself, just posting for the next person with this issue.

The U8G2lib allows multiple constructers and I chose(copied from example) one designed for performance, after reading more documentation I found contructers with 'F' mean they have a full buffer for all pages and will suck up 1024bytes(50%) of the Nano memory. There are two other Versions '1' and '2' which hold just 1 and 2 pages or 128bytes and 256bytes respectively.

This made a massive difference and solved the issue. another saving in memory I found along the way was for functions that recieve strings (like ones to write to LCD) you can use

void functionName(const __FlashStringHelper *varName){
...

}

and call it with

functionName(F("My Text"));

and it will effectivly never touch sram memory. I am sure someone who know this better will explain or correct this last bit.

Thanks

Great - and thanks for documenting for the next person. Karma added !