Skip to content

Commit

Permalink
Rpi-hw v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Wicker25 committed Dec 24, 2013
2 parents b67e0f3 + eea4281 commit 7167292
Show file tree
Hide file tree
Showing 15 changed files with 811 additions and 171 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required( VERSION 2.6 )
# Set the version of the library
set( RPI_HW_VERSION_MAJOR 0 )
set( RPI_HW_VERSION_MINOR 7 )
set( RPI_HW_VERSION_PATCH 0 )
set( RPI_HW_VERSION_PATCH 1 )
set( RPI_HW_VERSION "${RPI_HW_VERSION_MAJOR}.${RPI_HW_VERSION_MINOR}.${RPI_HW_VERSION_PATCH}" )

# Project directories
Expand Down
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
ChangeLog of Rpi-hw - A free C++ library designed to manage the Raspberry Pi's GPIO connector and its other buses.

============ Rpi-hw 0.7.1 - urgency=low ===========

2013-12-24 Wicker25 < [email protected] >

* all: Added `__ENUM` and `__ENUM_PARAMS` macros.

* utils.hpp: Added support for UTF-16 and UTF-32 string to the `utils::align`.

* hd44780.hpp: Added support for Unicode strings.

============ Rpi-hw 0.7.0 - urgency=low ===========

2013-12-07 Wicker25 < [email protected] >
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Rpi-hw v0.7.0
Rpi-hw v0.7.1
=============

[Rpi-hw](http://hackyourmind.org/projects/rpi-hw) (short for "Raspberry Pi Hardware") is a free C++ library
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0
0.7.1
10 changes: 5 additions & 5 deletions doxygen/doxy.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------

ENABLE_PREPROCESSING = NO
MACRO_EXPANSION = NO
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
INCLUDE_PATH = include/
INCLUDE_FILE_PATTERNS = *.hpp
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
SKIP_FUNCTION_MACROS = NO

#---------------------------------------------------------------------------
# Configuration::additions related to external references
Expand Down
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ target_link_libraries( m7seg1 ${RpiHw_LIBRARIES} )
add_executable( lcd16x2 ${CMAKE_SOURCE_DIR}/display/lcd16x2.cpp )
target_link_libraries( lcd16x2 ${RpiHw_LIBRARIES} )

add_executable( lcd16x2_unicode ${CMAKE_SOURCE_DIR}/display/lcd16x2_unicode.cpp )
target_link_libraries( lcd16x2_unicode ${RpiHw_LIBRARIES} )

add_executable( lcd20x4demo ${CMAKE_SOURCE_DIR}/display/lcd20x4demo.cpp )
target_link_libraries( lcd20x4demo ${RpiHw_LIBRARIES} )

Expand Down
43 changes: 43 additions & 0 deletions examples/display/lcd16x2_unicode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Title --- lcd16x2_unicode.cpp [examples]
Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
This file is part of Rpi-hw.
Rpi-hw is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation version 3 of the License.
Rpi-hw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
*/


// Include Rpi-hw headers
#include <rpi-hw.hpp>
#include <rpi-hw/display/hd44780.hpp>

// Use Rpi-hw namespace
using namespace rpihw;

int
main( int argc, char *args[] ) {

// Create the display controller
display::hd44780 dev( 14, 18, 4, 17, 21, 22 );

// Initialize the 16x2 display
dev.init( 16, 2, display::hd44780::ROM_A00 );

// Write a string on the display
dev.write( U"ハローワールト゜" );

return 0;
}

4 changes: 1 addition & 3 deletions include/rpi-hw/designer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
#ifndef _RPI_HW_DESIGNER_HPP_
#define _RPI_HW_DESIGNER_HPP_

#include <array>
#include <algorithm>
#include <vector>
#include <array>
#include <locale>

#include <rpi-hw/types.hpp>
Expand Down Expand Up @@ -84,7 +82,7 @@ class designer {
@param[in] x The new horizontal pen position.
@param[in] y The new vertical pen position.
*/
void setPenPosition( T x, T y );
virtual void setPenPosition( T x, T y );

/*!
@brief Sets the text font.
Expand Down
27 changes: 27 additions & 0 deletions include/rpi-hw/display/hd44780-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@ hd44780::write( uint8_t x, uint8_t y, const std::string &text, uint8_t flags ) {
write( text, flags );
}

inline void
hd44780::write( const std::u32string &text, uint8_t flags ) {

// Align the text and write it on the display
write( utils::align( text, m_width, flags ) );
}

inline void
hd44780::write( uint8_t x, uint8_t y, const std::u32string &text ) {

// Set the position of the cursor on the display
move( x, y );

// Write the unicode string on the display
write( text );
}

inline void
hd44780::write( uint8_t x, uint8_t y, const std::u32string &text, uint8_t flags ) {

// Set the position of the cursor on the display
move( x, y );

// Write the unicode string on the display
write( text, flags );
}

inline void
hd44780::setTypingDelay( size_t delay ) {

Expand Down
85 changes: 70 additions & 15 deletions include/rpi-hw/display/hd44780.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <rpi-hw/utils.hpp>
#include <rpi-hw/time.hpp>

#include <rpi-hw/preprocessor/enumerate.hpp>

#include <rpi-hw/iface/base.hpp>
#include <rpi-hw/iface/output.hpp>
#include <rpi-hw/iface/input.hpp>
Expand All @@ -44,12 +46,20 @@ namespace display { // Begin displays namespace
@brief Hitachi HD44780 LCD controller.
@example display/lcd16x2.cpp
@example display/lcd16x2_unicode.cpp
@example display/lcd20x4demo.cpp
*/
class hd44780 {

public:

//! The ROM codes.
enum RomCodes {

ROM_A00 = 0, //!< Japanese version.
ROM_A02 = 1 //!< European version.
};

//! The controller command set.
enum Commands {

Expand Down Expand Up @@ -84,14 +94,14 @@ class hd44780 {
//! The custom characters.
enum CustomCharacters {

CCHAR0 = 0,
CCHAR1 = 1,
CCHAR2 = 2,
CCHAR3 = 3,
CCHAR4 = 4,
CCHAR5 = 5,
CCHAR6 = 6,
CCHAR7 = 7
CCHAR0 = 0, //!< Custom character #0.
CCHAR1 = 1, //!< Custom character #1.
CCHAR2 = 2, //!< Custom character #2.
CCHAR3 = 3, //!< Custom character #3.
CCHAR4 = 4, //!< Custom character #4.
CCHAR5 = 5, //!< Custom character #5.
CCHAR6 = 6, //!< Custom character #6.
CCHAR7 = 7 //!< Custom character #7.
};

//! The cursor modes (bitwise flags).
Expand Down Expand Up @@ -120,8 +130,7 @@ class hd44780 {
@param[in] d6 The GPIO pin connected to the d6 pin.
@param[in] d7 The GPIO pin connected to the d7 pin.
*/
hd44780( uint8_t rs, uint8_t e,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
hd44780( uint8_t rs, uint8_t e, __ENUM_PARAMS( uint8_t, d, 4, 7 ) );

/*!
@brief Constructor method (8-bit mode).
Expand All @@ -136,9 +145,7 @@ class hd44780 {
@param[in] d6 The GPIO pin connected to the d6 pin.
@param[in] d7 The GPIO pin connected to the d7 pin.
*/
hd44780( uint8_t rs, uint8_t e,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7 );
hd44780( uint8_t rs, uint8_t e, __ENUM_PARAMS( uint8_t, d, 0, 7 ) );

//! Destructor method.
virtual ~hd44780();
Expand All @@ -147,16 +154,17 @@ class hd44780 {
@brief Initializes the display.
@param[in] cols Number of the display columns.
@param[in] rows Number of the display rows.
@param[in] rom_code The ROM code (\c ROM_A00 or \c ROM_A02).
@param[in] font If \c true uses 5x10 dots font, else uses 5x8 dots font.
*/
void init( uint8_t cols, uint8_t rows, bool font = 0 );
void init( uint8_t cols, uint8_t rows, RomCodes rom_code = ROM_A00, bool font = 0 );

/*!
@brief Sends a command to the display.
@param[in] data The command.
*/
void cmd( uint8_t data );

//! Homes the cursor.
void home();

Expand Down Expand Up @@ -234,6 +242,36 @@ class hd44780 {
*/
void write( uint8_t x, uint8_t y, const std::string &text, uint8_t flags );

/*!
@brief Writes a unicode string on the display.
@param[in] text The unicode string to be written.
*/
void write( const std::u32string &text );

/*!
@brief Writes a unicode string on the display.
@param[in] text The string to be written.
@param[in] flags The parameters of the text.
*/
void write( const std::u32string &text, uint8_t flags );

/*!
@brief Moves the cursor position and writes a unicode string on the display.
@param[in] x The new horizontal position of the cursor.
@param[in] y The new vertical position of the cursor.
@param[in] text The unicode string to be written.
*/
void write( uint8_t x, uint8_t y, const std::u32string &text );

/*!
@brief Moves the cursor position and writes a unicode string on the display.
@param[in] x The new horizontal position of the cursor.
@param[in] y The new vertical position of the cursor.
@param[in] text The unicode string to be written.
@param[in] flags The parameters of the text.
*/
void write( uint8_t x, uint8_t y, const std::u32string &text, uint8_t flags );

/*!
@brief Scrolls the contents of the display to the left.
@param[in] cursor If \c true, will also moves the cursor.
Expand Down Expand Up @@ -322,6 +360,9 @@ class hd44780 {
uint8_t m_width, m_height;
//@}

//! ROM code.
RomCodes m_rom_code;

//! Font height.
uint8_t m_font_height;

Expand Down Expand Up @@ -361,6 +402,20 @@ class hd44780 {
@param[in] c The 8-bit character.
*/
void putChar( uint8_t c );

/*!
@brief Maps a unicode character to the corresponding code (ROM A00, Japanese version).
@param[in] code The unicode character.
@return The character code.
*/
uint8_t encode_char_a00( char32_t code );

/*!
@brief Maps a unicode character to the corresponding code (ROM A02, European version).
@param[in] code The unicode character.
@return The character code.
*/
uint8_t encode_char_a02( char32_t code );
};

} // End of displays namespace
Expand Down
Loading

0 comments on commit 7167292

Please sign in to comment.