Show Posts
Pages: 1 2 [3] 4 5 6
31  Development / Other Software Development / Re: In what IDE do you write libraries for Arduino? on: May 17, 2012, 08:58:34 am
Quote
emacs
I didn't know that anyone had gone and done an arduino-mode !

It looks like there is an "arduino-mode.el" that does basic C-style stuff, but compilation/upload is part of CEDET instead?
http://www.emacswiki.org/emacs/CollectionOfEmacsDevelopmentEnvironmentTools

I had CEDET installed and Semaintic and EDE enabled. The frustrating thing is that initially the compilation and upload to an arduino worked so well!

Jim
32  Development / Other Software Development / Re: In what IDE do you write libraries for Arduino? on: May 16, 2012, 08:48:30 am
Is anyone using the arduino-mode for Emacs?

I installed it in emacs 23 (and also a 24 snapshot), and initially it worked fine. I got highlighting of the code and best of all was able to compile and upload it to the arduino using EDE. I also got a serial window. It seems to be broken now, and all I get is the highlighting, but not the compile/upload/serial window functions.

I've tried uninstalling and reinstalling emacs, but it makes no difference.

Does anyone know what the problem might be, please?

Jim
33  Using Arduino / Project Guidance / Re: Anyone using Emacs with the CEDET package for project management? on: April 23, 2012, 01:03:46 pm
I decided to install emacs 24 to try to get the full features of CEDET, and grabbed the 24.1.50.1 snapshot.

It installed fine and initially I was able to compile, upload to the board and display a serial terminal, it worked well and looked like I was in business.

I now find that I can't get the EDE arduino features - upload and serial terminal, and for the life of me can't find out why!

I've tried un-installing and re-installing  all the emacs stuff, including renaming the ~/.emacs file and ~/.emacs.d directory, to no effect. I'm now at a loss as to what to try next and would welcome suggestions.

Jim
34  Using Arduino / Project Guidance / Re: Anyone using Emacs with the CEDET package for project management? on: April 17, 2012, 11:25:07 am
Thanks for the reply, Eric.

I'm try altering the version number as you suggest and see how I get on. I'll have a look at joining the mailing list as well.
35  Using Arduino / Project Guidance / Anyone using Emacs with the CEDET package for project management? on: April 13, 2012, 08:12:57 am
I like Emacs for text editing and have used it for years. I'm currently using it as an external editor from Arduino projects.

I've installed the CEDET package, which should enable me to manage an Arduino project fully from within Emacs. but am having trouble getting a handle on it. I've had a google, but can't find a tutorial on using EDET with the Arduino.

I've had a tentative play with the EDE tools, but whatever I do I seem to get the error:

"Invalid versions syntax: '0022ubuntu0.1' "

Which appears to refer to the Arduino IDE version number.

Can anyone suggest a tutorial to get me started, or have any other suggestions, please?

Jim
36  Using Arduino / Programming Questions / Re: Global variables and scope on: April 12, 2012, 05:07:04 pm
Thanks for the reply 'skyjumper' - I'll give it a try.

Jim
37  Using Arduino / Programming Questions / Re: Global variables and scope on: April 12, 2012, 02:57:58 pm
Thanks for the reply.

I was afraid the 'e' word would get mentioned - I've never really got to grips with the subject!

I thought variables defined outside of any function were external anyway, and are visible throughout the program!

Jim
38  Using Arduino / Programming Questions / Global variables and scope on: April 12, 2012, 01:49:48 pm
I've always understood that variables declared outside of a function, including setup() and loop() had global scope and are accessible from any function, but are variables global if they're declared in separate project files, but still outside of a function?

My project is spilt into several 'pde' files and in each file I have a variable that's outside of any function. I assumed that these variables would have global scope and be visible to all functions, but it seem not to be so as the compiler is complaining that they haven't been declared where I want to use them. Is there a 'workaround' for this problem, please?

Jim
39  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 12, 2012, 01:37:09 pm
Thanks again Nick, you've been a great help.

As you demonstrated, the answer was to break the code down into smaller chunks.

Jim
40  General Category / General Discussion / Re: If a program could program itself?.... (AI) on: April 11, 2012, 03:00:23 pm
Quote
with just one more pair of square brackets needed to push them over the edge!
LISP uses round parentheses, hence the acronym Lots of Infuriating Silly Parentheses

Yeah I forgot. The memory had been mercifully erased from my brain!

Jim
41  General Category / General Discussion / Re: If a program could program itself?.... (AI) on: April 11, 2012, 11:48:45 am
I suspect that if such a program could be written, it would be done using 'LISP'.

LISP is (or has been) much used for 'Expert Systems'. I had a look at it years ago, but left it feeling that it could push a person to the edge of insanity - with just one more pair of square brackets needed to push them over the edge!

Jim
42  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 11, 2012, 11:39:54 am
I've stripped my problem down to the bare bones and it appears to be related to a simple loop as shown in this example:

The following program just prints out character by character parts of the strings. I want to be able to do this rather than do a string copy, because I need to select just the elements that I need.   

With the outer loop commented out, the following works and I can 'hard-wire'  various indexes (within range) for the string_table, and it works fine. If I uncomment the outer loop I just get rubbish printed - not even sensible values for the index 'i'.

I can't understand it - it's as if the outer loop somehow corrupts the inner one.

Code:
#include <avr/pgmspace.h>

const char string_0[] PROGMEM = "String 0";
const char string_1[] PROGMEM = "String 1";
const char string_2[] PROGMEM = "String 2";
const char string_3[] PROGMEM = "String 3";

const char *string_table[] PROGMEM =  \
{   
  string_0,
  string_1,
  string_2,
  string_3
};

char buffer[40];

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

  int i = 0; // Counter for string_table.
 
  // while(i < 4) {

    Serial.println(i); // Show position in string_table.

    int j = 2; // Counter for characters in strings (starting at 'r').
   
    char c;
   
    while((c = pgm_read_word(&string_table[i][j++])))
      Serial.print(c); // Show string character by character, starting at 'r'.
   
    //i++;
  //}
}

void loop() {}


I'm not sure where to go to next. I might just have to copy each string into a buffer in flash memory in turn, and do the substring stuff there, if it's a restriction in using PROGMEM.

Jim
43  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 11, 2012, 09:40:52 am
Hang on!

while((c = pgm_read_word(&rcs_strings[array_index][string_index++]))" _Does_ work - 'c' returns the characters in the  strings OK, but I've got some extreme weirdness going on in the outer loop!

Embedding it into a loop breaks it. Basically I can hard wire any numbers I like into the array subscript and get sensible results, but as soon as I set up an outer loop to step through the array of strings it falls over.

I'll try to set up an example stripped own to the bare bones to illustrate it!

Jim
44  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 11, 2012, 04:19:59 am
Thanks again Nick.

It's still got me beat - the lie down didn't help!

You mean from:

"while((c = pgm_read_byte(pgm_read_word(&rcs_strings[array_index][string_index++])))"

to:

"while((c = pgm_read_word(&rcs_strings[array_index][string_index++]))"

which doesn't work.

I'm starting to get desperate and using every combination of pgm_read_word, pgm_read_byte, &, (char*) and brackets that I can think of!

Jim
45  Using Arduino / Programming Questions / Re: PROGMEM problems. on: April 10, 2012, 09:28:03 am
Thanks a lot Nick.

My main problem was that I had the PROGMEM string inside setup().

I quoted the array subscript because I wanted to access individual characters, so it really should have had:

char character = pgm_read_byte(&(greet[j])); where j is the subscript for the character I'm interested in. I'd omitted the reference operator!

All this is to get a handle on what I really want to do - that is to access individual characters in an array of strings - this sort of thing:
Code:
#include <avr/pgmspace.h>

/* Program to extract just the file name and version number from RCS strings
and display in the form of:

menu.pde:1.2
meter.pde:1.1
current.pde:1.3
temp.pde:1.3

*/

char buffer[100];

const char menu_rcs[] PROGMEM = \
  "$Id: menu.pde,v 1.2 2012/03/22 17:40:06 jim Exp $";
const char meter_rcs[] PROGMEM = \
  "$Id: meter.pde,v 1.1 2012/03/22 17:40:06 jim Exp $";
const char current_rcs[] PROGMEM = \
  "$Id: current.pde,v 1.3 2012/03/22 17:40:06 jim Exp $";
const char temp_rcs[] PROGMEM = \
  "$Id: temp.pde,v 1.3 2012/03/22 17:40:06 jim Exp $";

/* Array of pointers to above, also in progmem.
NULL to stop from falling off the end of the array.
*/
const char* rcs_strings[] PROGMEM = {menu_rcs, meter_rcs, current_rcs, temp_rcs, NULL};

void setup() {

  Serial.begin(9600);

  int array_index = 0; // Counter for rcs_strings array.
  int buffer_index = 0; 
  int i = 0;

  while (pgm_read_word(&rcs_strings[i++])) { // Do for each rcs string.

    int string_index = 5; // Index of first file name char.
    char c;
    while((c = pgm_read_byte(pgm_read_word(&rcs_strings[array_index][string_index++]))) \
  != ',') buffer[buffer_index++] = c; // Copy string up until ','.
   
    string_index += 3; // Skip ",v " and point to 1st char of version number.
    buffer[buffer_index++] = ':'; // Write a separating colon.
    // String_index now pointing to first digit in version number

    while((c = pgm_read_byte(pgm_read_word(&rcs_strings[array_index][string_index++]))) \
  != ' ') buffer[buffer_index++] = c; // Copy string until next space.
   
    buffer[buffer_index++] = '\n';  // write newline and increment to next location
    array_index++; // Select next version string.
  }
    buffer[buffer_index] = '\0'; // All done - write terminating null.
    // Show what we've done.
    Serial.println(buffer);
}

void loop() {}


It's the inner 'while' loops that have got me stumped:

"while((c = pgm_read_byte(pgm_read_word(&rcs_strings[array_index][string_index++])))"

I'm hoping to get the address of the string character with "pgm_read_word(&rcs_strings[array_index][string_index++]" and use that to read the character at that location with the outer "pgm_read_byte" - but its not working. It's pretty ugly and the referencing and de-referencing has got my head swimming!

I'm going to have a lie down now!

Jim
Pages: 1 2 [3] 4 5 6