Go Down

Topic: Editing .h library files (Read 1 time) previous topic - next topic

NickPyner

I am trying to edit the PCD8544 library in order to define different pins to interface with the Nokia. This is to avoid clashing with the Ethernet shield. 5110 display.

I understand that the library typically consists of two files and the header, .h, file is the one to work on. I have seen the lines I need to change.

I opened PSC8544.h with notepad but the editing it was not a proposition.  I thought I had things sorted when I opened it in Word 2000 as everything looked OK and I could edit it, but the sketch would not work with the edited file. I suspect that some hidden or format stuff has been stripped out as the file now looks no different if it is opened in NotePad.

So my questions are

1. is there a practical way to edit a *.h file?

2. failing that, does defining the pins in the sketch trump the definitions in the library?

SurferTim

I use KWrite with Linux, and it does great. I used WordPad with Windows because the Linux compiler version was having problems when I joined the forum. The Linux version is fine now.

Do not use Word. It puts formatting characters in the text. The compiler does not like that.

Quote
...but the sketch would not work with the edited file.

What is the indication it is not working?

NickPyner


I
Quote
...but the sketch would not work with the edited file.

What is the indication it is not working?


A blank screen. I am just using the hello world example as found apart from ensuring it will write six lines of text.

SurferTim

Why do you need to edit a header file to run a sketch called "Hello World"? I did not see that in the examples included with IDE v1.0.2, so I made one up.
Code: [Select]
int loopCount = 0;

void setup() {
  Serial.begin(9600);
  Serial.println("Hello World");
}

void loop() {
  Serial.print("Loop ");
  Serial.println(loopCount);
  loopCount = loopCount++;
  delay(1000);
}


dhenry

Those header files are in text format so any editor will work on them.

NickPyner


Those header files are in text format so any editor will work on them.


Perhaps any editor except Notepad and MSWord.

Jimmy60

On WIndows get notepad++ http://notepad-plus-plus.org/

You can also copy the library files directly into your actual sketch's folder. When you open the sketch with the Aruino IDE, they will open up in tabs. This can be the best method sometimes.

NickPyner


Why do you need to edit a header file to run a sketch called "Hello World"? I did not see that in the examples included with IDE v1.0.2, so I made one up.


I wasn't clear enough. It was not just a sketch called hello world that I wanted to use, it was the hello world example that came with the PCD8544 library.  It is the best I have found for the Nokia 5110 LCD, giving me six very readable lines of text and data.

Be that as it may, the edit works and the sketch is running, so thanks for that. It is clear that using Word or Notepad would just send you on a fool's errand, and it would never have occurred to me to use Wordpad. I think I last used it in Windows 3.0 and have never seen the point of it since. So we all learn.

Thanks

PaulS

Using Notepad should have worked. Of course, you haven't shown the before and after version of the file, nor much evidence for "it didn't work", so we have nothing to go in to try to help you.

NickPyner


On WIndows get notepad++ http://notepad-plus-plus.org/

You can also copy the library files directly into your actual sketch's folder. When you open the sketch with the Aruino IDE, they will open up in tabs. This can be the best method sometimes.


Thanks for your comment. Right now I have a great swag of sketches and I would rather stick with the conventional procedure. I will eventually junk about 95% of them, and then it might be time to look at a more sophisticated way of dealing with libraries, particularly as it may be a better way to do thing when on the road.

dhenry

Quote
It is clear that using Word or Notepad would just send you on a fool's errand,


I routinely use notepad or wordpad to edit header / source files, without any problem. Wordpad has the added benefit of dealing with wrapped lines.

If you have problems with either of them, the issue is somewhere else.

NickPyner

#11
Dec 08, 2012, 03:40 pm Last Edit: Dec 08, 2012, 03:45 pm by NickPyner Reason: 1

Using Notepad should have worked. Of course, you haven't shown the before and after version of the file, nor much evidence for "it didn't work", so we have nothing to go in to try to help you.


Everybody is telling me it should, but it doesn't. This fact is as clear as the fact that editing with Wordpad does. Of course I haven't shown you, there is nothing to show and, as I said, I thought it was OK and you won't know there is anything wrong with the .h until you try to use it. However, I guess there is a hint of the crocodiles in the billabong when you see how Notepad opens the file. I have no idea if this is normal or merely exclusive to this file, or this particular author.

PaulS

Quote
However, there is a hint of the crocodiles in the billabong when you see how Notepad opens the file. I have no idea if this is normal or merely exclusive to this file, or this particular author.

It is evidence that the file was developed on a system that uses \n between records, as opposed to a system that uses \n\r (as Windows does) between records.

Notepad is a what you see is what you get editor. It does not convert \n to \n\r as Wordpad and notepad++ do. You can still use it to edit the file, although it is not as easy to find the data to change, when it looks like that.

wildbill

Grab yourself a copy of pfe (programmers file editor). It (like notepad++) will deal with whichever separator is used in the file.

NickPyner

Thank you. I have had a copy of Notepad+ for years, but the opening defaulted to the standard Windowws version. This was from that guy in Ljubljana and I guess an older version. Notepad+ opened the file OK. I will get Notepad++. I see it has colour! 

Go Up