Memory memory memory!

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jim_lee
 
Posts: 709
Joined: Thu May 24, 2012 8:24 pm

Memory memory memory!

Post by jim_lee »

Bumping the top of my RAM memory on this arduino project. Read the stuff here about tricks to help. First was the F("xx") macro. That seems to be broken. Is there any info on this? Second was chopping the Hardware serial buffer and for the life of me I can't find it. Searched and commented out all Serial statements, not using serial. Removed all the SD card stuff. Even went as far as to comment out the button code in the Adafruit graphics library. I'd kill for 100 bytes of RAM! Is there any more hidden ram eaters out there that anyone can think of?

Many thanks in advance!

Oh the hardware is a arduino uno with Adafruit capacitive touch screen.
Built my own touch screen RPN HP Calculator.

Image

-jim lee

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Memory memory memory!

Post by adafruit_support_bill »

First was the F("xx") macro. That seems to be broken.
Really? Seems to be working fine here. What version of the IDE are you using? If you post your code, we can take a look for other potential savings.
I'd kill for 100 bytes of RAM! ... Oh the hardware is a arduino uno
A Leonardo would give you another 512 bytes.

User avatar
jim_lee
 
Posts: 709
Joined: Thu May 24, 2012 8:24 pm

Re: Memory memory memory!

Post by jim_lee »

Here's the package in here.

https://github.com/leftCoast/Arduino

The bits you want are.. HP_Calc folder

/libraries/LC_RPNCalculator
/libraries/LC_TFTTools
/libraries/LC_baseTools

Of course you'll need to add your stuff to it.
Adafruit_FT6206
Adafruit_GFX
Adafruit_ILI9341

-jim lee

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Memory memory memory!

Post by adafruit_support_bill »

[Moved to General Project Help]
That is a lot of stuff to cram into an Arduino. It probably can be done if you are meticulous with your memory usage.
The F() macro is a great, easy to use tool. But it is not a universal solution. You will probably need to master PROGMEM to squeeze out the last few bytes of SRAM.
http://www.arduino.cc/en/Reference/PROGMEM

User avatar
jim_lee
 
Posts: 709
Joined: Thu May 24, 2012 8:24 pm

Re: Memory memory memory!

Post by jim_lee »

Ok, in a desperate attempt to lesson my memory load, I've been attempting to add Pro Trinket to the mix to offload the calculator code. The calculator code very well suited to this, it takes in a string as a button press and updates its registers. The calling program just reads the Xreg and fixReg to update its display. Perfect for client server.

So the big Arduino with the touch screen has the screen stuff along with the window manager and it just stuffs button presses out the serial port and reads in the display info. Simple simple.

Image

But of course its not working. Even wiring in a power switch to the co-processor I can't reprogram anything. I think they are stomping on each other's serial lines. Sigh..

User avatar
jim_lee
 
Posts: 709
Joined: Thu May 24, 2012 8:24 pm

Re: Memory memory memory!

Post by jim_lee »

Alright..

I rewired it so I now have an unplug-able serial line. Yelllow is output, Blue is input. Even made the input male & output female so I can't mix 'em up.

Now I can reprogram the two processors.

Image

Main Processor (The Uno with the screen) :

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_FT6206.h>
#include <Adafruit_ILI9341.h>
#include <colorObj.h>
#include <idlers.h>
#include <lists.h>
#include <mapper.h>
#include <timeObj.h>

#include <drawObj.h>
#include <label.h>
#include <screenObj.h>


void setup() {
 
  if (initScreen(INV_PORTRAIT)) {
    screen->fillScreen(BLACK);
  }
  screen->setTextSize(1);
  screen->setTextWrap(true);
  screen->setCursor(10, 10);
  screen->println("waiting for data");
  screen->print(">");

  Serial.begin(9600);
  Serial.setTimeout(50);
  
}

void loop() {

  char buff[20];

  Serial.readBytes(buff,20);
  screen->print(buff);
}
Co-processer (The Pro-Trinket inside) :

Code: Select all

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.write("Help!!\n");
  delay(250);
}
And the result..

Image

Seems they are not talkin' the same lingo.

So here I sit, hat in hand, wondering if anyone can give me a hint? Why can't one not read the other when they -seemingly- are set up the same?

Thanks!

-jim lee

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Memory memory memory!

Post by adafruit_support_mike »

Try catching the number of bytes read from Serial.readBytes() and printing that to the display. Let's make sure the Pro Trinket is reading data and not timing out.

User avatar
jim_lee
 
Posts: 709
Joined: Thu May 24, 2012 8:24 pm

Re: Memory memory memory!

Post by jim_lee »

It was timing out. Either the uno couldn't hear or the trinket wasn't sending. I won't be able to work on it for a few days though.

Thanks for the reply

- Jim lee

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Memory memory memory!

Post by adafruit_support_bill »

What pins on the Uno do you have Rx & Tx connected to? I don't see any software-serial in your code and it doesn't look like they are connected to the hardware serial pins (0 & 1)

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”