Is it useful to creaty my own library to save up space?

Hello :slight_smile:

I'm a beginner at Arduino and I have been trying to make my own MIDI controller using the Control surface library by Pieter P. I would like to include a number of buttons and a Nokia 5110 Graphic LCD to display drawings each time a button is pressed.

I came across a blog which explains how to upload drawings by specifying the position of every pixel that is to be filled (or not) into the screen. And it looked like endless lines of hexadecimal ennumeration:

"const unsigned char drawing [] PROGMEM ={0x00, 0x00, 0x00, 0x7f, 0x00, 0x02, 0xfe, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x00.."

So I thought, what if I make this array an object and store it within a user library to save up space? Does it make sense, and if it does, how can I do it?

Or are there any other tricks to reduce space while using multiple libraries?

Thanx for reading.

Nope… the array, wether in your main code or a library will end up occupying the same amount of flash…

When you use multiple libraries, only the needed functions are part of your final code. If you are short of space and your code is not badly written qnd you picked trusted libraries , then it might be time to get a more capable arduino.

As mentioned by J-M-L, moving the array to a library won't help.

There are some tricks you can use to lower the memory footprint of the Control Surface library, see https://tttapa.github.io/Control-Surface-doc/Doxygen/da/dc1/FAQ.html#faq-save-memory.

However, in the development of Control Surface, ease of use usually comes before memory footprint, so for more complex controllers with displays etc., it is worth upgrading to a more powerful 32-bit microcontroller with more memory. It also means that you could write special-purpose code with similar features and significantly lower memory consumption.

Ok, I will check out those tricks and finish up the code to see if I need to upgrade to another microcontroller. I'm using an Pro micro because I need to have a small circuit so I implemented some multiplexers. And I wanted to ask you;

  • I have 2 (74HC4051) multiplexers with the same address pins and diferent input pins but I don't know where to specify the second input.
CD74HC4051 mux {
A0,                 <------- I tried here but it didn't compile
{3, 4, 5} 
};

Also, I am so glad you could answer, thank you so much for creating Control surface. I am new to the open source community and to see so much work shared encourages me to keep learning >.<

Do you need to save 'space'?

Usually, most Ops are worried about SRAM. Due to the say the SRAM memory is utilized by Arduino, programmers attempt to not utilize all of the SRAM.
Arduino Memories | Memories of an Arduino | Adafruit Learning System

Flash (and EEPROM) are different, you can generally assume that if you can get the IDE to successfully upload to the microcontroller, then everything is good. (It is not like you get money back for not using all the Flash.)

Added:
use "two" CD74HC4051 with Arduino - Search (bing.com)

You'll have to create two instances of the CD74HC4051 class, both with the same list of address pins, but with a different input pin.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.