Pages: [1] 2   Go Down
Author Topic: Editing .h library files  (Read 993 times)
0 Members and 1 Guest are viewing this topic.
Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5985
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5985
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int loopCount = 0;

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

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

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Perhaps any editor except Notepad and MSWord.
Logged

Saskatchewan
Offline Offline
Sr. Member
****
Karma: 19
Posts: 364
When the going gets weird, the weird turn pro. - Hunter S. Thompson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49080
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* Image1.jpg (502.92 KB, 1116x917 - viewed 14 times.)
« Last Edit: December 08, 2012, 09:45:02 am by NickPyner » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49080
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3679
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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! 
Logged

Pages: [1] 2   Go Up
Jump to: