Skip to content

Commit a1465ed

Browse files
committed
Rpi-hw v0.7.2
2 parents 7167292 + d9f914a commit a1465ed

File tree

7 files changed

+100
-13
lines changed

7 files changed

+100
-13
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cmake_minimum_required( VERSION 2.6 )
77
# Set the version of the library
88
set( RPI_HW_VERSION_MAJOR 0 )
99
set( RPI_HW_VERSION_MINOR 7 )
10-
set( RPI_HW_VERSION_PATCH 1 )
10+
set( RPI_HW_VERSION_PATCH 2 )
1111
set( RPI_HW_VERSION "${RPI_HW_VERSION_MAJOR}.${RPI_HW_VERSION_MINOR}.${RPI_HW_VERSION_PATCH}" )
1212

1313
# Project directories

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
ChangeLog of Rpi-hw - A free C++ library designed to manage the Raspberry Pi's GPIO connector and its other buses.
22

3+
============ Rpi-hw 0.7.2 - urgency=low ===========
4+
5+
2013-12-26 Wicker25 < [email protected] >
6+
7+
* hd44780.hpp: Added support for `std::wstring`.
8+
39
============ Rpi-hw 0.7.1 - urgency=low ===========
410

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Rpi-hw v0.7.1
1+
Rpi-hw v0.7.2
22
=============
33

44
[Rpi-hw](http://hackyourmind.org/projects/rpi-hw) (short for "Raspberry Pi Hardware") is a free C++ library

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.1
1+
0.7.2

include/rpi-hw/display/hd44780-inl.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ hd44780::write( uint8_t x, uint8_t y, const std::u32string &text, uint8_t flags
121121
write( text, flags );
122122
}
123123

124+
inline void
125+
hd44780::write( const std::wstring &text, uint8_t flags ) {
126+
127+
// Align the text and write it on the display
128+
write( utils::align( text, m_width, flags ) );
129+
}
130+
131+
inline void
132+
hd44780::write( uint8_t x, uint8_t y, const std::wstring &text ) {
133+
134+
// Set the position of the cursor on the display
135+
move( x, y );
136+
137+
// Write the unicode string on the display
138+
write( text );
139+
}
140+
141+
inline void
142+
hd44780::write( uint8_t x, uint8_t y, const std::wstring &text, uint8_t flags ) {
143+
144+
// Set the position of the cursor on the display
145+
move( x, y );
146+
147+
// Write the unicode string on the display
148+
write( text, flags );
149+
}
150+
124151
inline void
125152
hd44780::setTypingDelay( size_t delay ) {
126153

include/rpi-hw/display/hd44780.hpp

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
2221
#ifndef _RPI_HW_DISPLAY_HD44780_HPP_
2322
#define _RPI_HW_DISPLAY_HD44780_HPP_
2423

@@ -272,6 +271,36 @@ class hd44780 {
272271
*/
273272
void write( uint8_t x, uint8_t y, const std::u32string &text, uint8_t flags );
274273

274+
/*!
275+
@brief Writes a unicode string on the display.
276+
@param[in] text The unicode string to be written.
277+
*/
278+
void write( const std::wstring &text );
279+
280+
/*!
281+
@brief Writes a unicode string on the display.
282+
@param[in] text The string to be written.
283+
@param[in] flags The parameters of the text.
284+
*/
285+
void write( const std::wstring &text, uint8_t flags );
286+
287+
/*!
288+
@brief Moves the cursor position and writes a unicode string on the display.
289+
@param[in] x The new horizontal position of the cursor.
290+
@param[in] y The new vertical position of the cursor.
291+
@param[in] text The unicode string to be written.
292+
*/
293+
void write( uint8_t x, uint8_t y, const std::wstring &text );
294+
295+
/*!
296+
@brief Moves the cursor position and writes a unicode string on the display.
297+
@param[in] x The new horizontal position of the cursor.
298+
@param[in] y The new vertical position of the cursor.
299+
@param[in] text The unicode string to be written.
300+
@param[in] flags The parameters of the text.
301+
*/
302+
void write( uint8_t x, uint8_t y, const std::wstring &text, uint8_t flags );
303+
275304
/*!
276305
@brief Scrolls the contents of the display to the left.
277306
@param[in] cursor If \c true, will also moves the cursor.
@@ -403,19 +432,26 @@ class hd44780 {
403432
*/
404433
void putChar( uint8_t c );
405434

435+
/*!
436+
@brief Maps a unicode character to the corresponding code.
437+
@param[in] code The unicode character.
438+
@return The character code.
439+
*/
440+
uint8_t encodeChar( char32_t code );
441+
406442
/*!
407443
@brief Maps a unicode character to the corresponding code (ROM A00, Japanese version).
408444
@param[in] code The unicode character.
409445
@return The character code.
410446
*/
411-
uint8_t encode_char_a00( char32_t code );
447+
uint8_t encodeCharA00( char32_t code );
412448

413449
/*!
414450
@brief Maps a unicode character to the corresponding code (ROM A02, European version).
415451
@param[in] code The unicode character.
416452
@return The character code.
417453
*/
418-
uint8_t encode_char_a02( char32_t code );
454+
uint8_t encodeCharA02( char32_t code );
419455
};
420456

421457
} // End of displays namespace

src/display/hd44780.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,18 @@ hd44780::write( const std::u32string &text ) {
268268
for ( auto &c : text ) {
269269

270270
// Encode the character and put it on the display
271-
switch ( m_rom_code ) {
271+
write( encodeChar( c ) );
272+
}
273+
}
272274

273-
case ROM_A00: { write( encode_char_a00( c ) ); break; }
274-
case ROM_A02: { write( encode_char_a02( c ) ); break; }
275+
void
276+
hd44780::write( const std::wstring &text ) {
275277

276-
default: { write( encode_char_a00( c ) ); break; }
277-
}
278+
// Write the string on the display
279+
for ( auto &c : text ) {
280+
281+
// Encode the character and put it on the display
282+
write( encodeChar( (char32_t) c ) );
278283
}
279284
}
280285

@@ -496,7 +501,20 @@ hd44780::clear() {
496501
}
497502

498503
uint8_t
499-
hd44780::encode_char_a00( char32_t code ) {
504+
hd44780::encodeChar( char32_t code ) {
505+
506+
// Map a unicode character to the corresponding code
507+
switch ( m_rom_code ) {
508+
509+
case ROM_A00: return encodeCharA00( code );
510+
case ROM_A02: return encodeCharA02( code );
511+
512+
default: return encodeCharA00( code );
513+
}
514+
}
515+
516+
uint8_t
517+
hd44780::encodeCharA00( char32_t code ) {
500518

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

611629
uint8_t
612-
hd44780::encode_char_a02( char32_t code ) {
630+
hd44780::encodeCharA02( char32_t code ) {
613631

614632
// Standard ASCII characters
615633
if (

0 commit comments

Comments
 (0)