STM32-Zombie-0.2.0: control a STM32F103 microcontroller

App.LCD

Description

The LCD module has been copied from System.Hardware.Arduino.Parts.LCD in the hArduino package. The original Author of this code is Levent Erkok. There have been some minor adaption for STM32.

Synopsis

# LCD types and registration

data LCD Source #

Hitachi LCD controller: See: http://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller. We model only the 4-bit variant, with RS and EN lines only. (The most common Arduino usage.) The data sheet can be seen at: http://lcd-linux.sourceforge.net/pdfdocs/hd44780.pdf.

Constructors

 Hitachi44780 FieldslcdRS :: WireHitachi pin  4: Register-selectlcdEN :: WireHitachi pin  6: EnablelcdD4 :: WireHitachi pin 11: Data line 4lcdD5 :: WireHitachi pin 12: Data line 5lcdD6 :: WireHitachi pin 13: Data line 6lcdD7 :: WireHitachi pin 14: Data line 7lcdRows :: IntNumber of rows (typically 1 or 2, upto 4)lcdCols :: IntNumber of cols (typically 16 or 20, upto 40)dotMode5x10 :: BoolSet to True if 5x10 dots are used

Instances

 Source # MethodsshowList :: [LCDController] -> ShowS #

Register an LCD controller. When registration is complete, the LCD will be initialized so that:

• Set display ON (Use lcdDisplayOn / lcdDisplayOff to change.)
• Set cursor OFF (Use lcdCursorOn / lcdCursorOff to change.)
• Set blink OFF (Use lcdBlinkOn / lcdBlinkOff to change.)
• Clear display (Use lcdClear to clear, lcdWrite to display text.)
• Set entry mode left to write (Use lcdLeftToRight / lcdRightToLeft to control.)
• Set autoscrolling OFF (Use lcdAutoScrollOff / lcdAutoScrollOn to control.)
• Put the cursor into home position (Use lcdSetCursor or lcdHome to move around.)

# Writing text on the LCD

lcdClear :: LCD -> MI () Source #

Clear the LCD

lcdWrite :: LCD -> String -> MI () Source #

Write a string on the LCD at the current cursor position

# Moving the cursor

lcdHome :: LCD -> MI () Source #

Send the cursor to home position

lcdSetCursor :: LCD -> (Int, Int) -> MI () Source #

Set the cursor location. The pair of arguments is the new column and row numbers respectively:

• The first value is the column, the second is the row. (This is counter-intuitive, but is in line with what the standard Arduino programmers do, so we follow the same convention.)
• Counting starts at 0 (both for column and row no)
• If the new location is out-of-bounds of your LCD, we will put it the cursor to the closest possible location on the LCD.

# Scrolling

Turn on auto-scrolling. In the context of the Hitachi44780 controller, this means that each time a letter is added, all the text is moved one space to the left. This can be confusing at first: It does not mean that your strings will continuously scroll: It just means that if you write a string whose length exceeds the column-count of your LCD, then you'll see the tail-end of it. (Of course, this will create a scrolling effect as the string is being printed character by character.)

Having said that, it is easy to program a scrolling string program: Simply write your string by calling lcdWrite, and then use the lcdScrollDisplayLeft and lcdScrollDisplayRight functions with appropriate delays to simulate the scrolling.

Turn off auto-scrolling. See the comments for lcdAutoScrollOn for details. When turned off (which is the default), you will not see the characters at the end of your strings that do not fit into the display.

Scroll the display to the left by 1 character. Project idea: Using a tilt sensor, scroll the contents of the display left/right depending on the tilt.

Scroll the display to the right by 1 character

# Display properties

Set writing direction: Left to Right

Set writing direction: Right to Left

lcdBlinkOn :: LCD -> MI () Source #

lcdBlinkOff :: LCD -> MI () Source #

lcdCursorOn :: LCD -> MI () Source #

Show the cursor

lcdCursorOff :: LCD -> MI () Source #

Hide the cursor. Note that a blinking cursor cannot be hidden, you must first turn off blinking.

lcdDisplayOn :: LCD -> MI () Source #

Turn the display on

Turn the display off. Note that turning the display off does not mean you are powering it down. It simply means that the characters will not be shown until you turn it back on using lcdDisplayOn. (Also, the contents will not be forgotten when you call this function.) Therefore, this function is useful for temporarily hiding the display contents.

# Accessing internal symbols,

data LCDSymbol Source #

An abstract symbol type for user created symbols

Access an internally stored symbol, one that is not available via its ASCII equivalent. See the Hitachi datasheet for possible values: http://lcd-linux.sourceforge.net/pdfdocs/hd44780.pdf, Table 4 on page 17.

For instance, to access the symbol right-arrow:

• Locate it in the above table: Right-arrow is at the second-to-last row, 7th character from left.
• Check the upper/higher bits as specified in the table: For Right-arrow, upper bits are 0111 and the lower bits are 1110; which gives us the code 01111110, or 0x7E.
• So, right-arrow can be accessed by symbol code lcdInternalSymbol 0x7E, which will give us a LCDSymbol value that can be passed to the lcdWriteSymbol function. The code would look like this: lcdWriteSymbol lcd (lcdInternalSymbol 0x7E).

Display a user created symbol on the LCD. (See lcdCreateSymbol for details.)

Create a custom symbol for later display. Note that controllers have limited capability for such symbols, typically storing no more than 8. The behavior is undefined if you create more symbols than your LCD can handle.

The input is a simple description of the glyph, as a list of precisely 8 strings, each of which must have 5 characters. Any space character is interpreted as a empty pixel, any non-space is a full pixel, corresponding to the pixel in the 5x8 characters we have on the LCD. For instance, here's a happy-face glyph you can use:

  [ "     "
, "@   @"
, "     "
, "     "
, "@   @"
, " @@@ "
, "     "
, "     "
]


# Misc helpers

Arguments

 :: LCD -> Int Flash count -> Int Delay amount (in milli-seconds) -> MI ()

Flash contents of the LCD screen