/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * text.h
 *
 * Copyright (C) 2011 Tim Marston <tim@ed.am> and Dan Marston.
 *
 * This file is part of propeller-clock (hereafter referred to as "this
 * program"). See http://ed.am/dev/software/arduino/propeller-clock for more
 * information.
 *
 * This program 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, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef _TEXT_H_
#define _TEXT_H_


#include <PString.h>


#define NUM_MESSAGE_BUFFERS 4
#define MESSAGE_LEN 32


namespace Text
{
	enum {
		// one of these to select face
		MODE_TOP = 0,
		MODE_BOTTOM = 64,

		// one of these to select size
		MODE_ONEQUARTER = 1,
		MODE_ONETHIRD = 2,
		MODE_HALF = 3,
		MODE_TWOTHIRDS = 4,
		MODE_THREEQUARTERS = 5,
		MODE_ALL = 6,

		// flag to turn on horizontal scrolling
		MODE_HSCROLL = 32,

		// text scale constants
		SCALE_VSMALL = 1,
		SCALE_SMALL = 2,
		SCALE_NORMAL = 3,
		SCALE_FAT = 4,
		SCALE_VFAT = 5,
	};

	/**
	 * Reset internal state, for a new text display. This deactivates all
	 * messages and they will need to be enabled again with set_up_message().
	 */
	void reset();

	/**
	 * Activate the display of a message and specify its display parameters.
	 *
	 * @param message_num the message to reset
	 * @param mode the new mode for this message
	 * @param scale text
	 */
	void set_up_message( int message_num, char mode, char scale = SCALE_NORMAL );

	/**
	 * After modifying a message buffer, call this to reset the internal state
	 * of the text renderer with regard to this message.
	 *
	 * @param message_num the buffer number
	 * @param pstring the PString that represents this message's buffer
	 */
	void set_message_text( int message_num, PString &pstring );

	/**
	 * Call at the start of each frame.
	 */
	void draw_reset();

	/**
	 * Call after drawing each frame
	 */
	void post_draw();

	/**
	 * Draw segment for the specified message number using whatever mode that
	 * message is set to.
	 *
	 * @param segment to draw
	 */
	void draw( int segment );

	/** internal message buffers */
	extern char _messages[ NUM_MESSAGE_BUFFERS ][ MESSAGE_LEN ];
};


#endif //_TEXT_H_