I have an Adafruit Trinket (16mHz/5V) that I am planning to use with a quad-alphanumeric display and a DHT22 temp/humidity sensor. The goal is to display the temp read from the sensor on the display. Here is my code:
The binary sketch size is 5,322 bytes, while the maximum is 5,310 bytes; so close! Any help would be extremely appreciated, as this would allow me to finish my little project.
Look in the libraries, they are taking most of your program space, see if there is anything in them you don't really need, and remove it.
Albeit the compiler does its best to remove unused code, but sometimes there are properties of classes that you won't use but the compiler can't possibly know this.
e.g.
textsize,
rotation;
in the Adafruit_GFX.h
I'm not even sure rotation works, and if you are not changing the text size, you could hard code it.
It's hard to see how you are going to fit a decimal point, and two characters after the decimal point in two characters, and still have room for anything before the decimal point.
If the second param is the decimal place, I guess we can just drop it ( and add the two ):
alpha4.writeDigitAscii(2, d/10 + '0');
@op, what happened to the rest of the space? Or is there a bootloader on the tinkerkit?
What version of the IDE do you use? 1.5.7 will not compile without removing at least the dtostrf call.
With Robs change I get:
Sketch uses 3,958 bytes (48%) of program storage space. Maximum is 8,192 bytes.
I also have an additional method of reducing the size. The total savings could allow more stuff!
Visit my page here http://arduino.land/Code/SmallSetup/ and install the SmallSetup library ( just updated it for the tiny chips ), then use the second method to use it. Result now is (including Robs savings):
Sketch uses 3,678 bytes (44%) of program storage space. Maximum is 8,192 bytes.
Docedison:
@ Pyro...
Thank You, That is truly amazing...
You're welcome!
The library is a bit of an accident, I was only trying to learn about the memory sections, and saw some great savings.
Probably one of the only libraries that reduces a sketch size when its added, even an empty sketch.
Thanks everyone for your help! I got it compiled and working like a charm on the Trinket. I won't be using it on the final product, as I will be adding more functionality and need more pins, so I upgraded to the Pro Trinket. All your guys' help will definitely come in handy in the future!