Hi all,
I am working on something and got a little problem.
I’ve got a LCD and a PS/2 Keyboard.
and I’m trying to write/type on the LCD.
But the Problem is That I use X (Horizontal Position) to know where I am on the Horizontal place of the screen.
When I go the the next line I reset X so the Cursor is again on the Left of the screen.
The screen is 16 chars wide 0 to 15, if I go over 15 the screen scrolls to see what your writing of course
when I go to the New line X is 0, so that when I use Backspace, and X=0 it goes to the line above, but just goes to X=15 on the line above.
So I need to find a Way to remember the Number of chars(X) I used on the previous line.
So if you guys would help me out With this that would be really great,
also I know that if type/write more then 16 and push enter the screen doesn’t scroll the the first place on the second line,
This is something I am still working on, so Don’t spoil it for me
Just need help on a Way to remember the Previous amount of Chars is used on the previous line.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 8, 7, 6, 5);
#include <PS2Keyboard.h>
const int DataPin = 4;
const int IRQpin = 3;
int x; //x position on screen
int y; //y position on screen
PS2Keyboard keyboard;
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
lcd.begin(16,2);
Serial.begin(9600);
Serial.println("keyboard available?");
}
void loop() {
if (keyboard.available()) {
char c = keyboard.read();
if(c == PS2_ENTER){
y=1;
x=0;
lcd.setCursor(x,y);
}
if(x>=15){
if(!(c == PS2_BACKSPACE)){
lcd.scrollDisplayLeft();
}
}
if(c == PS2_BACKSPACE && x > 0){
x--;
lcd.setCursor(x,y);
lcd.print(" ");
if(x>15){
lcd.scrollDisplayRight();
}
if(x==0 && y==1){
y=0;
x=15;
}
lcd.setCursor(x,y);
}
else if(!(c == PS2_ENTER)){
lcd.print(c);
x++;
}
lcd.cursor();
}
}
also I know that if type/write more then 16 and push enter the screen doesn't scroll the the first place on the second line, This is something I am still working on, so Don't spoil it for me
I know there Is a certain way the places are addressed on the lcd,
But I'm learning as I go, and if I get stuck, I will most certainly look at the link
Thank
What I did was dirty and quick: fill up the rest of the line with spaces when you strike enter so there is no need to track number of characters per line. This is the end product I made. I wonder if you are making something similar:
Yea I guess you can fill the rest with spaces, in fact I didn't even think I could do it that way.
But I've learned something on Arrays which were my weak point anyway, it works it does the job
My ultimate goal is to make a Device with a LCD, that I can use as a "Portable" Serial Monitor, that has In/Output Capability.
duality:
My ultimate goal is to make a Device with a LCD, that I can use as a “Portable” Serial Monitor, that has In/Output Capability.
So your goal is to make a device I already made but with a keyboard on it?
Darn you !!! ]
The reasons I didn’t go with a full-size keyboards: too large to carry, too old have to get ps/2 ones and I don’t have mini-din sockets in suppliers I typically go.
So instead I made my keypad with multi-tap. Now you tantalized? Maybe you should buy one and check out what you are missing on your project
And I thought that I had a original Idea
It doesn't matter, and please don't let me see your source code, I want to make this myself
I had a look on your site earlier I like the Idea behind your device
duality:
please don't let me see your source code, I want to make this myself
Not a chance
That's the work of my last summer. It's several thousand lines of code and I didn't write enough comments. I think I've written enough free code and libs (over 10k lines of code) to keep this one to myself.
I think our idea(s) are to enable standard input and output on arduino to make it more like a computer, enable simple printf and scanf if you like C.
ultimately I want to go independently from from a PC or laptop, cause you can't always have one on you
I've seen something really interesting though, A Basic interpreter for the arduino, could be really interesting to see if I might be able to implement that