PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
HD44780_Demo.cpp
Utilize the
PropWare::Printer
class to print formatted text to an LCD
cmake_minimum_required(VERSION 3.3)
find_package(
PropWare
REQUIRED)
project(HD44780_Demo)
create_simple_executable(${PROJECT_NAME} HD44780_Demo.cpp)
#include <
PropWare/PropWare.h
>
#include <
PropWare/printer/printer.h
>
#include <
PropWare/hd44780.h
>
// Control pins
const
PropWare::Port::Mask
RS =
PropWare::Port::P16
;
const
PropWare::Port::Mask
RW =
PropWare::Port::P17
;
const
PropWare::Port::Mask
EN =
PropWare::Port::P18
;
// Data pins
const
PropWare::Port::Mask
FIRST_DATA_PIN =
PropWare::Port::P19
;
const
PropWare::HD44780::Bitmode
BITMODE
=
PropWare::HD44780::BM_8
;
const
PropWare::HD44780::Dimensions
DIMENSIONS =
PropWare::HD44780::DIM_16x2
;
int
main
() {
// Create and initialize our LCD object
PropWare::HD44780
lcd;
lcd.
start
(FIRST_DATA_PIN, RS, RW, EN,
BITMODE
, DIMENSIONS);
// Create a printer for easy, formatted writing to the LCD
PropWare::Printer
lcdPrinter(&lcd);
// Print to the LCD (exactly 32 characters so that we fill up both lines)
lcdPrinter.
printf
(
"%u %s%d 0x%07X"
, 123456789,
"Hello!"
, -12345, 0xabcdef);
return
0;
}
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12