|
Here's a quick run-down of the NEC protocol. http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol[^]
And here's some more general stuff: https://en.wikipedia.org/wiki/Consumer_IR[^]
A good place to look for the actual data/commands sent using the various protocols is in the microcontroller community. The Arduino/8501 forums/libraries have plenty of code available.
I once setup an arduino to record the incoming pulses from a remote. I then swapped the IR receiver module for a cheap 1mw laser - I can control the IR equipment from over 100m away now.
Unfortunately, the code's on a machine I dont have access to now and I've long since forgotten where I got the info from, sorry.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Thank. 
|
|
|
|
|
|
Hello there. I have this structure in Header1.h and instantiating this structure in Header2.h. When I try to initialize this instance, I get this runtime exception. Here is my skeleton of code
HEADER1.h
struct Student {
CString Name;
CString Address;
CString Phone;
};
HEADER2.h
class CHeader2Dlg {
Student student;
}
HEADER2.cpp
void CHeader2Dlg::SomeFunction()
{
student.Name = "";
student.Address = "";
student.Phone = "";
}
|
|
|
|
|
Are you perhaps using the Unicode character set but assigning an ascii string?
Maybe it should be:
student.Name = L"";
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I changed that to L"" but in vein. Does it have to do anything with project settings ?
|
|
|
|
|
I suspect there is something more going on than just the code you have posted. It sounds as if the CString object is not being instantiated.
Maybe if you could post more, relevant code.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Header1.h
struct Account {
CString Name;
CString Address;
CString Phone;
};
Header2.h
class AccountDlg : public CDialog
{
Account account;
}
Header2.cpp
void AccountDlg::Load(int id)
{
CEdit* edit;
CComboBox *combobox;
account.Name= "asd"; account.Address= "asd";
account.Phone = "asd";
accountId = id;
accountSettings.AccountLoad(accountId,account);
}
|
|
|
|
|
That doesn't reveal anything more than the first post. I think you should post the actual code, not an obfuscated version of it.
Show the "#includes" as well.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Have you tried explicitly calling the struct's constructors in the class constructor?
class AccountDlg: public CDialog
{
Account account;
public:
AccountDlg() : account() {}
}
|
|
|
|
|
Django_Untaken wrote: Here I am getting the said exception What exception?
|
|
|
|
|
Access violation reading location. Just before this exception, if I debug the application, I see that member variables of this object dont show and Error reading characters of string shows up instead, in the intellisense.
|
|
|
|
|
That suggests that you have not initialised the object. Have you checked that the constructor is called and sets all the variables correctly?
|
|
|
|
|
It does not look like you are reading the string, you are actually assigning values. It seems the exception is from somewhere else.. Is this the complete code you are debugging ?? Could you please share the full code if possible ?
|
|
|
|
|
I am still struggling with pointers arithmetic.
Here is my crude test code.
I want to use pointers to access ( double - need triple eventually) the array of characters and do not get two things.
Problem #1 is probably how does the LCD class do the "print" and I can figure that one by myself. I do not expect this forum to be familiar with Arduino "library".
Problem # 2
I can print single characters in simple array by incrementing the pointer, but I cannot figure out why I cannot use same method on double array.
I really do not understand what is this error telling me
"error lvalue required as increment operand" - what is "lvalue" ?
Please keep in mind that English is not my native language so go easy on
" pointers to array..." "array of pointers" etc.
As always , I appreciate your help.
Cheers
Vaclav
Addendum
OK, I did some more reading about how the array is initialized and how the NAME of the array cannot be used the way I did try it.
So I did this - it "works" , but I am still not sure if it is correct or just a fluke.
char *pointer = stringTable[0];
lcd_i2c.print((char*) pointer++); // prints entire line
lcd_i2c.print((char*) pointer); // prints entire line starting with second character - expected that
Original post code starts here
char line[MAX_LINE] = "A TEST B";
int ncharacters = strlen(line);
char *sptr; // pointer to memory block returned by malloc
char *stringTable[NLINES]; // array of pointers to string
int i = 0;
sptr = (char*) malloc((unsigned) strlen(line) + 1);
lcd_i2c.clear();
lcd_i2c.print("Index ");
lcd_i2c.print(i);
lcd_i2c.setCursor(0, 1);
lcd_i2c.print("Length ");
lcd_i2c.print(ncharacters );
lcd_i2c.setCursor(0, 2);
lcd_i2c.print("pointer ");
lcd_i2c.print(sptr); // problem #1 prints the entire line - not really a problem here
strcpy(sptr, line); // copy line to pointed memory
lcd_i2c.print(sptr); // TOK prints pointer value ?
// copy pointer to first table array
stringTable[0] = sptr;
lcd_i2c.setCursor(0, 3);
i = 0;
do
{
// TOK prints first character from stringTable[0]
lcd_i2c.print((char) * (*stringTable)); // problem #1 prints only the first character - why it would be nice to print the entire line using pointers!
} while (*(*++stringTable)); error lvalue required as increment operand
-- modified 26-Jul-15 11:18am.
|
|
|
|
|
It's really rather difficult to figure out what you are trying to do since some of the above code makes no real sense. You are using casts on pointers that are already pointers, so do nothing except add confusion. You allocate a block of memory and then try to print it before it contains anything. You create an array of ponters for no apparent reason and then use only the first one, you copy data from one memory block to another, again for no real reason, etc. Maybe you should show exactly what problem you are trying to solve, without all this code and we can advise on the best option. And an explanation of what the print function actually does, or is supposed to do.
Also please use <pre> and </pre> tags around your code so it is more readable, like this:
lcd_i2c.clear();
lcd_i2c.print("Index ");
lcd_i2c.print(i);
lcd_i2c.setCursor(0, 1);
|
|
|
|
|
Well, you can easily look at the data-sheet for the I2C chip on the LCD board and at the one for the 1602/1604/2002/2004 LCD you're using. Once done, you can see that the LCD has a hardware cursor, and knows at which position on the display it is. It also has a means to write a character to the current cursor position.
Here's a quick list of the available commands: http://www.8051projects.net/lcd-interfacing/commands.php[^]
Not covered in that particular document, is the fact that you define custom bitmaps for characters - up to 4 or so at any one time. You could for instance, make a bitmap of a battery and then animate a charging display by changing the bitmap used for the battery 'character'.(but not actually changing the character drawn - it's the bitmap that this character refers to that is changed)
Here's a tool I whipped-up a couple of years back that makes drawing such custom characters easy. I've used this for both ascii/graphical LCDs - I don't remember if the output was suitable for both or just one or the other.
Lcd Character designer The 'save' button causes the changes made to a character in the top-pane to be written to the 'memory' of the LCD panel and causes the appearance of the currently chosen character to change.
As for the pointer stuff, you seem to be making it considerably more complex than it needs to be.
Here's a quick sample. I dont have access to an arduino this moment, so have used printf instead.
int main()
{
char *stringTable[] = { "string 1", "string two", "string three", NULL };
int i, n = sizeof(stringTable) / sizeof(*stringTable);
for (i=0; i<n-1; i++)
printf("(%d chars): %s\n", strlen(stringTable[i]), stringTable[i]);
printf("-------------\n");
char **curPtr = stringTable;
do
{
printf("%s\n", *curPtr); curPtr++; } while ( *curPtr ); }
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Thanks,
basically you confirmed that I need a pointer to the double dimension array.
That is all I wanted to know.
Cheers
Vaclav
|
|
|
|
|
Why are you using both a sentinel value and the array size (just out of curiosity)?
|
|
|
|
|
Simply to show two ways of doing the same thing. Vaclav's code expects a sentinel, while I prefer to work without one.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Ok I think I am getting the picture.
But I cannot figure out how to implement same pointer arithmetic in double array.
I got the first "record" working fine, can access all strings / fields, but cannot get to the next one.
I am still not sure how does the pointer , and not the char in array , get incremented.
I have deleted the LCD code which confused many and added printf , which is not part of "core" Arduino code , so this should pass by them now.
I still would like some verbal description of the assignment of pointer to the array.
Appreciate your help very much.
Cheers
Vaclav
<pre lang="c++"> // double array of pointers
char *stringTable[][5] = {{ "string 1", "string two", "string three", NULL },
{ "second string 1", "second string two", "second string three", NULL }
};
char **curPtr = *stringTable; // pointer to array of pointers
do
{
printf("%s\n", *curPtr++); // dereference to get the ptr to the string
} while ( *curPtr ); // quit loop when we get to our NULL pointer.<pre lang="c++"><pre lang="c++"></pre></pre></pre>
|
|
|
|
|
No problem, it's one of the problems that seems to beat-up people regularly. I more or less started with ASM, so it was a matter of sink or swim in short order.
How about this, does it help?
int main()
{
char *stringTable[][4] = {
{ "string 1", "string two", "string three", NULL },
{ "second string 1", "second string two", "second string three", NULL }
};
int y;
for (y=0; y<sizeof(stringTable)/sizeof(stringTable[0]); y++) {
char **curPtr = stringTable[y];
do
{
printf("%s\n", *curPtr++);
} while (*curPtr);
printf("----\n");
}
}
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Thanks,
problem solved.
Actually while "programming in my sleep" I thought that I must be missing advancing the "main" pointer by the whole record. But stringTable[y] is nice "trick".
I really appreciate your help and as soon as I figure out how to add the characters into the record ( one at a time ) I'll be all set.
You have a great day.
Cheers
Vaclav
PS When I get ambitious I will try to figure out how to replace stringTable[y] using pointer.
|
|
|
|
|
Vaclav_Sal wrote: Problem #1 is probably how does the LCD class do the "print" and I can figure that one by myself. I do not expect this forum to be familiar with Arduino "library". I use a 4x20 LCD display on my Arduino Uno and Mega boards. What are you trying to do?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Try asking one question at a time. If I have to spend 30 minutes trying to figure out what you're really getting at, I'm not too inclined to help. Help us help you. Keep the questions straightforward.
Jeremy Falcon
|
|
|
|