Copyright | (c) Hong Quach and Norah Alballa, 2015 |
---|---|
License | MIT | This source file is licensed under the | "MIT License." Please see the LICENSE | in this distribution for license terms. |
Maintainer | hong dot t dot quach at g m a i l dot com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
LEDDisplay
Description
The user would submit a string through the GHCi terminal on the computer and it will be scroll across on the LED matrix. This project can be extended to drive LED Cube and other large I/O projects (e.g. more LED 8xN) with little to no modification. The string to be displayed on the matrix can also come from another source, such as an email notification or system status.
- arduinoPath :: String
- renderMatrixToTerminal :: LEDDisplaySettings -> [[Bool]] -> IO ()
- promptForever :: LEDDisplaySettings -> SerialPort -> IO (Maybe Int)
- clockForever :: LEDDisplaySettings -> SerialPort -> IO (Maybe Int)
- promptForeverTerminal :: LEDDisplaySettings -> IO (Maybe Int)
- clockForeverTerminal :: LEDDisplaySettings -> IO (Maybe Int)
- renderMatrix :: LEDDisplaySettings -> SerialPort -> [[Bool]] -> IO ()
- scrollLeftFrames :: LEDDisplaySettings -> [[Bool]] -> [[[Bool]]]
- renderFrameOntoHW :: LEDDisplaySettings -> SerialPort -> String -> IO Int
- renderFrameOntoTerminal :: LEDDisplaySettings -> String -> IO ()
- hexFrameToTerminal :: Char -> Char -> Int -> Int -> String -> String
- borderHorizontal :: Int -> String
- insertSpace :: String -> String
- hexToBin :: Char -> Char -> String -> String
- padLeft :: Char -> Int -> String -> String
- matrixToHexFrame :: Int -> [[Bool]] -> String
- toHexString :: [Bool] -> String
- emptyFrame :: LEDDisplaySettings -> [[Bool]]
- padMatrix :: LEDDisplaySettings -> [[Bool]] -> [[Bool]]
- padFrameLeft :: Int -> [[Bool]] -> [[Bool]]
- padFrameRight :: Int -> [[Bool]] -> [[Bool]]
- padFrameCenter :: Int -> [[Bool]] -> [[Bool]]
- data LEDDisplaySettings
- = LEDMatrix {
- name :: String
- width :: Int
- height :: Int
- scrDelayMicroSec :: Int
- scrColumnsCount :: Int
- serSpeed :: CommSpeed
- serPortPath :: FilePath
- fStartChar :: Char
- fEndChar :: Char
- | LEDMatrixSim {
- name :: String
- width :: Int
- height :: Int
- scrDelayMicroSec :: Int
- scrColumnsCount :: Int
- onChar :: Char
- offChar :: Char
- = LEDMatrix {
- defaultLedMatrix :: LEDDisplaySettings
- defaultSimulator :: LEDDisplaySettings
- fastLedMatrix :: LEDDisplaySettings
- fastSimulator :: LEDDisplaySettings
- slowLedMatrix :: LEDDisplaySettings
- slowSimulator :: LEDDisplaySettings
- wideLedMatrix :: LEDDisplaySettings
- wideSimulator :: LEDDisplaySettings
- exit :: MaybeT IO a
- class LEDDisplay a where
- promptAndDisplay :: a -> IO (Maybe Int)
- clock :: a -> IO (Maybe Int)
- runArduino :: IO (Maybe Int)
- runTerminal :: IO (Maybe Int)
- runTerminalClock :: IO (Maybe Int)
Documentation
arduinoPath :: String
Change this value to point to your HW device Be sure to install the Arduino driver (www.arduino.cc) Here are some commands to help find your arduinoPath Windows: Open device manager Linux: $ dmesg | grep tty Mac: $ ls devtty.*
renderMatrixToTerminal :: LEDDisplaySettings -> [[Bool]] -> IO ()
Render the matrix to terminal instead of onto the actual HW
promptForever :: LEDDisplaySettings -> SerialPort -> IO (Maybe Int)
Prompt for string and render it to the Arduino Board
clockForever :: LEDDisplaySettings -> SerialPort -> IO (Maybe Int)
Display the ticking clock updated every second
promptForeverTerminal :: LEDDisplaySettings -> IO (Maybe Int)
Prompt for string and render it onto the Terminal
clockForeverTerminal :: LEDDisplaySettings -> IO (Maybe Int)
Display the ticking clock updated every second
renderMatrix :: LEDDisplaySettings -> SerialPort -> [[Bool]] -> IO ()
Render the matrix on the Matrix LED
scrollLeftFrames :: LEDDisplaySettings -> [[Bool]] -> [[[Bool]]]
Each matrix has many frames to animate scrolling from right to left
renderFrameOntoHW :: LEDDisplaySettings -> SerialPort -> String -> IO Int
The dataToRender is a string of hex encoded bits to send for render.
renderFrameOntoTerminal :: LEDDisplaySettings -> String -> IO ()
Render the hex encoded data onto the terminal as a matrix
hexFrameToTerminal :: Char -> Char -> Int -> Int -> String -> String
Convert a frame in hex format to matrix string
borderHorizontal :: Int -> String
A horizontal border to wrap arround the frame
insertSpace :: String -> String
A blank space between each char including the last one.
hexToBin :: Char -> Char -> String -> String
Convert a hex encoded string into a string of binary with OnChar and offChar
padLeft :: Char -> Int -> String -> String
Pad the left side of the string with the specified Char until it satistfies the specified length
matrixToHexFrame :: Int -> [[Bool]] -> String
Truncate a matrix to fit in the frame then convert it to a hex string
toHexString :: [Bool] -> String
Convert a String of Bools into a String of Hex 11110000 -> 0xF0
emptyFrame :: LEDDisplaySettings -> [[Bool]]
An empty Frame to show all blank
padMatrix :: LEDDisplaySettings -> [[Bool]] -> [[Bool]]
Pad the matrix with empty frame at the beginning and at the end of the matrix
padFrameLeft :: Int -> [[Bool]] -> [[Bool]]
Pad the left side of the frame with blank columns to fill the frame
padFrameRight :: Int -> [[Bool]] -> [[Bool]]
Pad the right side of the frame with blank columns to fill the frame
padFrameCenter :: Int -> [[Bool]] -> [[Bool]]
Pad both sides of the frame with blank columns to fill the frame
data LEDDisplaySettings
The datatype that would represent an LED Display settings the constructor that would represent an LED Display for the hardware
Constructors
LEDMatrix | A constructor for a two dimensions LED display (matrix) |
Fields
| |
LEDMatrixSim | A constructor for simulating a two dimensions display |
Fields
|
Instances
Eq LEDDisplaySettings | |
Show LEDDisplaySettings | |
LEDDisplay LEDDisplaySettings | An instance of the LED Display simulator to render to terminal |
defaultLedMatrix :: LEDDisplaySettings
The default settings for an 8x32 Matrix LED
defaultSimulator :: LEDDisplaySettings
The default setting for a Terminal display 8x32
fastLedMatrix :: LEDDisplaySettings
This is for a fast scrolling 8x32 matrix LED
fastSimulator :: LEDDisplaySettings
This is for a fast scrolling 8x32 terminal simulator
slowLedMatrix :: LEDDisplaySettings
This is for a slow scrolling 8x32 matrix LED
slowSimulator :: LEDDisplaySettings
This is for a slow scrolling 8x32 terminal simulator
wideLedMatrix :: LEDDisplaySettings
This is for a wide 8x40 matrix LED
wideSimulator :: LEDDisplaySettings
This is for a wide 8x40 terminal simulator
exit :: MaybeT IO a
An line of code to break out of the forever
loop
class LEDDisplay a where
An LED Display class that has various methods for displaying
Methods
promptAndDisplay :: a -> IO (Maybe Int)
Prompt user to input a string to be shown on the display
clock :: a -> IO (Maybe Int)
Display a ticking clock
Instances
LEDDisplay LEDDisplaySettings | An instance of the LED Display simulator to render to terminal |
runArduino :: IO (Maybe Int)
The main program to run with the Arduino hardware
runTerminal :: IO (Maybe Int)
The main program to run the display on the terminal
runTerminalClock :: IO (Maybe Int)
Display the current time on the terminal