Commit Graph

28 Commits

Author SHA1 Message Date
85fb4eca6a Read support implemented
Implemented functions for reading the LCD's DDRAM/CGRAM. Which is read
is dependent on the last 'address set' instruction. The functions
implemented are as follows:

Internal use only:
- readLCDDBusByte_
  No busy flag (BF) check. Sets RS=RW=1 and the data bus lines as
  inputs, reads them regardless of mode and returns the byte read.

Externally accessable:
- readCharFromLCD
- readLCDLine
- readCharsFromLCD

Note: more thorough documentation of the aforementioned functions is
required, though all have been tested and seen to be working.

Additionally, renamed the following for clarity's sake:
 enableLCDOutput  -> setLCDDBusAsOutputs
 disableLCDOutput -> setLCDDBusAsInputs

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-28 04:30:40 -04:00
943593d963 Fix support for LCD's with 1 line
The initLCD function had the options of the function set instruction
hard coded, and thus would cause issues while initializing screens with
one line. This commit resolves this issue by checking the value of
LCD_NUMBER_OF_LINES at compile time and creating a macro LCD_LINES with
the appropriate bitmask for INSTR_FUNC_SET_N set or clear which is then
used during the definition of the initLCD function.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-27 01:02:02 -04:00
c52292c802 Support both 5x8 and 5x10 fonts
Added LCD_FONT in lcdLib.h which is the bitmask to enable 5x8 or 5x10
font when doing the function set instruction (in the definition of
initLCD).

LCD_FONT_5x8 or LCD_FONT_5x10 should be defined to enable the intended
font. One always needs to be defined.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-26 22:30:44 -04:00
827989bd51 Refactor, tidy and comment
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-26 05:13:40 -04:00
7977f14d5a Refactor naming to be more consistent
Change the name of the following functions:

writeLCDNibble_ -> writeLCDDBusNibble_
writeLCDByte_   -> writeLCDDBusByte_

Created a function 'writeLCDDBusByte' which waits for the busy flag (BF)
to be cleared and then writes the given 8-bit integer to the LCD data
bus regardless of the mode the LCD is operating in (default (8-bit
mode), 8-bit arbitrary pin mode, or 4-bit mode).

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-25 03:54:54 -04:00
7c18941836 Add boiler plate code for remaining ANSI escapes
Added function declarations and empty/implementation incomplete
definitions in lcdLib.h and lcdLib.c respectively for remaining ANSI
escape sequences; namely:

- scrollUp
- scrollDown
- eraseDisplay
- eraseInline

Prematurely edited the parsing of any ASCII escape which causes the
screen to be cleared (Eg. '\n' on the last line), to use the new (but
yet to be implemented) scrolling functions; thus after these functions have been
filled in and tested, the ANSI escape support will be complete.

Additionally, escapes that are not supported are passed over without
printing any characters. The two cases that are handled in this commit
are DSR and SGR. The parsing for DSR which when received, normally
prints the current location of the cursor to standard output in the form
"\e[n;mR", where n is the row and m is the column, is left unsupported
but may be supported in the future (thus comments have been left
indicating condition where a valid parse occurs).

The SGR ANSI escape sequence can vary in length and thus needs to be
completely consumed from the input before processing the next character.
This is taken care of correctly in this commit, and has been tested.

In a previous commit, forgot to add the declarations of the following
utility functions to the lcdLib.h header file:

- blinkCursorOff
- blinkCursorOn
- displayOff
- displayOn

There are still a few functions that will be needed for reading
data from the LCD that have not been declared/defined. These functions
are required for efficiently scrolling the screen up and down. They also
will be needed to finish the last remaining piece of this library which,
after completion of ANSI escapes and associated functions, leaves
support for custom characters. Namely writing characters to CGRAM and
displaying custom characters (from CGRAM) using ASCII codes 0-7 (or 0-3
if 5x10 font is used).

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-25 00:27:51 -04:00
307cd3358c Fix bitmasks for INSTR_MOV_SHIFT bits
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-24 04:30:32 -04:00
b32954bdae Add Show/Hide cursor function and ANSI escapes
Adds ANSI escape parsing for DECTCEM escapes (hide/show cursor) as well
as utility functions hideCursor and showCursor. To do this correctly,
the state of the LCD needs to be remembered by sofware.

Keep track of the state of the LCD using the 3 LSB of lcdState as follows:
  0: Cursor blink
  1: Cursor off/on
  2: Display off/on

In the future, the 5 MSB's may be used to store other data used for the
remembering the state of the LCD. For example, the instruction
INSTR_MOV_SHIFT and INSTR_ENTRY_SET; specifically:

INSTR_MOV_SHIFT
  3+1=4: Move cursor/shift display
  3+2=5: Shift left/right

INSTR_ENTRY_SET
  3+3=6: decrement/increment cursor position
  3+4=7: display shift off/on

The LCD state information could then be read for the correct instruction
using bit shifting. Note that this would require modifying the functions
defined in this commit to do the appropriate bit shifting.

Additionally, utility functions (that don't have associated ANSI
escapes) have been defined:

- blinkCursorOff
- blinkCursorOn
- displayOff
- displayOn

Note: care needs to be taken to check whether the display is actually on
before sending data to it, as during testing the data will not show up
after the display has been sent the display off instruction, and it will
not write any incoming data to DDRAM. Whether it will accept other
instructions besides writing to DDRAM is unknown but suspected to also
not work. This issue still needs to be rectified after further testing.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-24 04:30:26 -04:00
958a337032 Add cursor save and restore ANSI sequence
Add support for ANSI escape sequence for saving the current location of
the cursor "\e[s" and for recalling the last saved location "\e[u".

Note: if no location had been saved yet and the restore cursor
position (RPC) ANSI escape is received, defaults to 1,1 (top left of the
screen).

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-24 00:42:54 -04:00
4285c9223f Fixed various motion functions and parsing
Fixed ansii parsing (some issues still remain), and tested cursor
movement functions, though they don't seem to work properly through
serial yet. Also now when '\e' is read through serial, pause and
accumulate a the possible ansi escape to send to writeStringToLCD.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-20 05:21:03 -04:00
d63c250630 Initial pass on implementing ANSI escape sequences
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-19 05:04:53 -04:00
4f9462e983 Move led flashing code from lcdLib to lcdOutput
Refactor led flashing code from lcdLib.c and lcdLib.h to lcdOutput.c.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-15 05:39:07 -04:00
bc48704477 First pass setting up doxygen documentation
There are a few things that still need to be commented, furthermore,
usage of the library needs to be explained in more detail. Also things
are still somewhat unorganized as the lcdLib library is packaged up with
the lcdOutput application for testing. Also a tiny USART library is
included but has nothing to do with the lcdLib except that its used by
the lcdOutput demo program. When the lcdLib library is ready it will be
split into its own repository with accompanying examples (one of which
may be the USART echo example (lcdOutput.c as of this commit).

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-15 01:23:11 -04:00
f84eb1ddda Comment and clean-up lcdLib.c and lcdLib.h
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-15 00:26:46 -04:00
c29ef36638 Comment lcdLib.h
At some point perhaps switch to using doxygen to output nice
documentation. This will require using doxygen conventions, which aren't
currently used but easily adapted to.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-09 02:59:21 -04:00
45797f1164 Refactor lcdLib.h
Move mode and settings sanity check to end of file.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-05 05:03:26 -04:00
68d60151dc Initial commit to branch; split done but untested
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-04 22:49:15 -04:00
2a1073f658 Code cleanup of lcdLib.h
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-04 21:20:51 -04:00
8281b3c28e Forgot to turn off FOUR_BIT_MODE after testing
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-02 03:46:57 -04:00
c52fa746e0 Removed repeated #defines for data lines
Removed the repeated #defines for LCD_DBUS*[,_PORT,_DDR,_PIN] used for
both FOUR_BIT_MODE and EIGHT_BIT_ARBITRARY_PIN_MODE.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-02 03:27:57 -04:00
9fda49a40a Forgot to change back to default mode after tests
After trying FOUR_BIT_MODE to ensure it worked properly, forgot to
comment it out so that the default mode is enabled as expected and
documented.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-02 02:48:42 -04:00
04be2b85da Tested operational 4-bit mode
Cleaned up a few comments and tested and verified operation of 4-bit mode.

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-02 02:46:23 -04:00
0a36d6cf77 All 8-bit modes functional
Tested mode 1 (default 8-bit mode), and mode 2 (8-bit mode with
arbitrary pins for the data lines).

Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-01 04:06:08 -04:00
5777e2b831 Prepare for 4 bit mode of operation
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-10-01 03:04:33 -04:00
3ba737fc7b Fixed timing issues, working again
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-09-30 05:02:43 -04:00
047c4b5c31 Broken likely due to timing
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-09-30 04:46:49 -04:00
1acda4a55a Some cleanup
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-09-29 06:06:37 -04:00
bfb78be425 Initial commit
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
2015-09-29 02:48:09 -04:00