- #1
Lancelot59
- 646
- 1
This is something that has had me stumped for quite a while. I'm working with a microchip microcontroller to control this LCD: http://www.varitronix.com/Product/LCD/VIM-332-DP(R0).pdf
As you can see it has no controller. I'm manually controlling the segments. Now the issue is that I need to write a function to print to it. From some research I did I learned that I can't just modify the "putch" function because I need to manually define characters (after I learned what putch does). Now I have made functions which will create numbers and letters on the display where I tell them to, but that's only good for manually defining outputs.
What I want is to create a function like printf, where I can pass it a string and then it passes that string further down to some processing where I check to make sure the string will fit on the display, and then if it passes writes the string to the display. In the examples here "print" is when I'm referring to the function I want to write.
So I want the input to look like the printf function in stdio.h:
However I can't just write the function as:
because C doesn't have strings as a type, you use a character array.
My question is, how can I write the function such that I can call it like the normal printf.
Everyone keeps telling me to use a pointer, however the string isn't originating outside the function, therefore I think a pointer would be useless. Unless I have another function above which reads a variable, and parses it in as a string. However this leads to the issue where I wouldn't be able to print short messages on the screen unless I defined functions for each word I would want to make, which actually wouldn't be too terrible if it really came down to it.
I haven't had luck finding example code for it that I can understand, because all the stuff I've found is written in assembly. I'm at the point with assembly where I can follow individual steps, but I can't see what the code is doing overall.
I've been stuck on this problem for a while and I'm out of ideas at the moment.
As you can see it has no controller. I'm manually controlling the segments. Now the issue is that I need to write a function to print to it. From some research I did I learned that I can't just modify the "putch" function because I need to manually define characters (after I learned what putch does). Now I have made functions which will create numbers and letters on the display where I tell them to, but that's only good for manually defining outputs.
What I want is to create a function like printf, where I can pass it a string and then it passes that string further down to some processing where I check to make sure the string will fit on the display, and then if it passes writes the string to the display. In the examples here "print" is when I'm referring to the function I want to write.
So I want the input to look like the printf function in stdio.h:
Code:
printf("my string");
Code:
print(String INPUT);
My question is, how can I write the function such that I can call it like the normal printf.
Code:
print(%f,float_variable);
print("PIC");
I haven't had luck finding example code for it that I can understand, because all the stuff I've found is written in assembly. I'm at the point with assembly where I can follow individual steps, but I can't see what the code is doing overall.
I've been stuck on this problem for a while and I'm out of ideas at the moment.
Last edited by a moderator: