Skip to content

Commit

Permalink
Rpi-hw v0.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wicker25 committed Dec 26, 2013
2 parents 7167292 + 7f5c4fe commit 5beaf39
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 13 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 1 )
set( RPI_HW_VERSION_PATCH 2 )
set( RPI_HW_VERSION "${RPI_HW_VERSION_MAJOR}.${RPI_HW_VERSION_MINOR}.${RPI_HW_VERSION_PATCH}" )

# Project directories
Expand Down
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
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.2 - urgency=low ===========

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

* hd44780.hpp: Added support for `std::wstring`.

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

2013-12-24 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.1
Rpi-hw v0.7.2
=============

[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.1
0.7.2
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 @@ -121,6 +121,33 @@ hd44780::write( uint8_t x, uint8_t y, const std::u32string &text, uint8_t flags
write( text, flags );
}

inline void
hd44780::write( const std::wstring &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::wstring &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::wstring &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
42 changes: 39 additions & 3 deletions include/rpi-hw/display/hd44780.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef _RPI_HW_DISPLAY_HD44780_HPP_
#define _RPI_HW_DISPLAY_HD44780_HPP_

Expand Down Expand Up @@ -272,6 +271,36 @@ class hd44780 {
*/
void write( uint8_t x, uint8_t y, const std::u32string &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::wstring &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::wstring &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::wstring &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::wstring &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 @@ -403,19 +432,26 @@ class hd44780 {
*/
void putChar( uint8_t c );

/*!
@brief Maps a unicode character to the corresponding code.
@param[in] code The unicode character.
@return The character code.
*/
uint8_t encodeChar( char32_t code );

/*!
@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 );
uint8_t encodeCharA00( 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 );
uint8_t encodeCharA02( char32_t code );
};

} // End of displays namespace
Expand Down
32 changes: 25 additions & 7 deletions src/display/hd44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,18 @@ hd44780::write( const std::u32string &text ) {
for ( auto &c : text ) {

// Encode the character and put it on the display
switch ( m_rom_code ) {
write( encodeChar( c ) );
}
}

case ROM_A00: { write( encode_char_a00( c ) ); break; }
case ROM_A02: { write( encode_char_a02( c ) ); break; }
void
hd44780::write( const std::wstring &text ) {

default: { write( encode_char_a00( c ) ); break; }
}
// Write the string on the display
for ( auto &c : text ) {

// Encode the character and put it on the display
write( encodeChar( (char32_t) c ) );
}
}

Expand Down Expand Up @@ -496,7 +501,20 @@ hd44780::clear() {
}

uint8_t
hd44780::encode_char_a00( char32_t code ) {
hd44780::encodeChar( char32_t code ) {

// Map a unicode character to the corresponding code
switch ( m_rom_code ) {

case ROM_A00: return encodeCharA00( code );
case ROM_A02: return encodeCharA02( code );

default: return encodeCharA00( code );
}
}

uint8_t
hd44780::encodeCharA00( char32_t code ) {

// Standard ASCII characters
if ( code <= 0x7d && code != 0x5c )
Expand Down Expand Up @@ -609,7 +627,7 @@ hd44780::encode_char_a00( char32_t code ) {
}

uint8_t
hd44780::encode_char_a02( char32_t code ) {
hd44780::encodeCharA02( char32_t code ) {

// Standard ASCII characters
if (
Expand Down

0 comments on commit 5beaf39

Please sign in to comment.