Sketch too large for an ATmega68 Nano board

All, the skecth below is quoted by IDE as being too large for the ATmega168 nano boards, despite being ( on the face of it) a simple program. I am assuming that the libraries being installed are inflating the size, so how can I just pull down the size?

#define DCSBIOS_DEFAULT_SERIAL

#include <DcsBios.h>
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);


char* displayString = "----";

// onDcsBiosWrite does not exist anymore, use Int16Buffers instead
DcsBios::Int16Buffer altPressure0Buffer(0x1086);
DcsBios::Int16Buffer altPressure1Buffer(0x1088);
DcsBios::Int16Buffer altPressure2Buffer(0x108a);
DcsBios::Int16Buffer altPressure3Buffer(0x108c);

void setup() {
  
  u8g2.begin();

DcsBios::setup();
}

void loop() {
  DcsBios::loop();
  
  if (altPressure0Buffer.hasUpdatedData()) { displayString[3] = mapeo(altPressure0Buffer.getData()); }
  if (altPressure1Buffer.hasUpdatedData()) { displayString[2] = mapeo(altPressure1Buffer.getData()); }
  if (altPressure2Buffer.hasUpdatedData()) { displayString[1] = mapeo(altPressure2Buffer.getData()); }
  if (altPressure3Buffer.hasUpdatedData()) { displayString[0] = mapeo(altPressure3Buffer.getData()); }

  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_fub20_tn );
  //u8g2.setTextSize(1);
  u8g2.setCursor(0, 24);
  u8g2.print(displayString);
  u8g2.sendBuffer();

  delay (100);

}

char mapeo(unsigned int valor){

  if (valor < 6553) { return '0'; }
  if (valor < 13107) { return '1'; }
  if (valor < 19660) { return '2'; }
  if (valor < 26214) { return '3'; }
  if (valor < 32767) { return '4'; }
  if (valor < 39321) { return '5'; }
  if (valor < 45874) { return '6'; }
  if (valor < 52428) { return '7'; }
  if (valor < 58981) { return '8'; }
  return '9' ;

}

cheers

Les

Get a 328P-based Nano board...

#include <DcsBios.h>Can you read the sensor with a smaller, dedicated library?

RayLivingston:
Get a 328P-based Nano board…

I have them, and use them, but have a limited quantity and they are allocated to items that really do need the ‘brain’ power.

jremington:
#include <DcsBios.h>Can you read the sensor with a smaller, dedicated library?

The DcsBios is the output from the game, so can’t be changed. However the particular OLED I am using for some reason is incompatible with SSD1306 type libraries, hence the use of the U8g2 library. If I load the same sketch using the SSD1306 library and coding, it loads fine on a ATmega168, unfortunately though the OLED display ends up corrupted. If I change the code for a larger 128 x 32 SSD1306 compatible OLED, it loads and runs fine, but due to space needs (the OLED is actually embedded in a gauge face) it needs to be the smaller OLED.

I was wondering if maybe by modifying the U8G2 library (or part of it as it contains lots of fonts) and then saving it as a different name, it could be reduced in content to just reflect what I use in this sketch.

Thanks for looking and helping

Cheers

Les

I just see one

u8g2.print(displayString);

How much text (characters) will you print as a maximum? Why not just using a simple character based LCD? or a larger microprocessor as already pointed out.

noiasca:
I just see one

u8g2.print(displayString);

How much text (characters) will you print as a maximum? Why not just using a simple character based LCD? or a larger microprocessor as already pointed out.

If you take a look at the picture, it is the little display that says " 0006 " just below the legend " In HC "

Basically it’s far too small to get anything else in there - the gauge is 70mm in diameter. Also the white on black format of the OLED suites the gauge format, LCD’s would not look correct.

This is running off an ATmega328 for this picture, but I have a limited quantity of them and when using scrolling text, certain gauges etc there is no way the ATmega168’s can be used. It’s quite clear that something in that U8g2 library is inflating the sketch. I just looked at the properties of the U8G2 library, it’s 35Mb whereas the AdafruitSSD1306 library is below 200 Kb!

Cheers

Les

Looks like you are using a full buffer with the display, look at the examples for the U8g2 library to see how to use the display with a frame buffer, or the u8x8 text mode that uses no ram buffer but sends directly to the display.

Thanks, Will give that a go - although I think ultimately I will just have to accept that one of mt ATmega328's is going to have to be allocated to this

Cheers for the help

Les

Lesthegringo:
I have them, and use them, but have a limited quantity and they are allocated to items that really do need the 'brain' power.

They cost about $5 each. You can't just buy more? Seems like a false economy to me....

Regards,
Ray L.

Lesthegringo:
I was wondering if maybe by modifying the U8G2 library (or part of it as it contains lots of fonts) and then saving it as a different name, it could be reduced in content to just reflect what I use in this

It might be simpler to Adafruit’s text libraries.