STM32-Zombie-0.1.1: control a STM32F103 microcontroller

LicenseBSD3
Stabilityexperimental
PortabilityGHC-only
Safe HaskellNone
LanguageHaskell2010

App.LCD

Contents

Description

The LCD module has been copied from the hArduino package. This is the System.Hardware.Arduino.Parts.LCD ((c) Levent Erkok) with some minor adaption for STM32.

Synopsis

LCD types and registration

data LCD Source #

data LCDController 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 

Fields

lcdRegister :: LCDController -> MI LCD Source #

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

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

lcdAutoScrollOn :: LCD -> MI () Source #

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.

lcdAutoScrollOff :: LCD -> MI () Source #

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.

lcdScrollDisplayLeft :: LCD -> MI () Source #

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.

lcdScrollDisplayRight :: LCD -> MI () Source #

Scroll the display to the right by 1 character

Display properties

lcdLeftToRight :: LCD -> MI () Source #

Set writing direction: Left to Right

lcdRightToLeft :: LCD -> MI () Source #

Set writing direction: Right to Left

lcdBlinkOn :: LCD -> MI () Source #

Blink the cursor

lcdBlinkOff :: LCD -> MI () Source #

Do not blink the cursor

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

lcdDisplayOff :: LCD -> MI () Source #

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

lcdInternalSymbol :: Word8 -> LCDSymbol Source #

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).

lcdWriteSymbol :: LCD -> LCDSymbol -> MI () Source #

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

lcdCreateSymbol :: LCD -> [String] -> MI LCDSymbol Source #

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

lcdFlash Source #

Arguments

:: LCD 
-> Int

Flash count

-> Int

Delay amount (in milli-seconds)

-> MI () 

Flash contents of the LCD screen