/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
1
/*
2
 * text.h
3
 *
4
 * Copyright (C) 2011 Tim Marston <tim@ed.am> and Dan Marston.
5
 *
6
 * This file is part of propeller-clock (hereafter referred to as "this
7
 * program"). See http://ed.am/dev/software/arduino/propeller-clock for more
8
 * information.
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Lesser General Public License as published
12
 * by the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Lesser General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Lesser General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
#ifndef _TEXT_H_
24
#define _TEXT_H_
25
26
27
#include <PString.h>
28
29
30
#define NUM_MESSAGE_BUFFERS 4
31
#define MESSAGE_LEN 32
32
33
34
namespace Text
35
{
36
	enum {
37
		// one of these to select face
90 by Tim Marston
text messages are now individually enabled and draw()n automatically
38
		MODE_TOP = 0,
39
		MODE_BOTTOM = 64,
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
40
41
		// one of these to select size
90 by Tim Marston
text messages are now individually enabled and draw()n automatically
42
		MODE_ONEQUARTER = 1,
43
		MODE_ONETHIRD = 2,
44
		MODE_HALF = 3,
45
		MODE_TWOTHIRDS = 4,
46
		MODE_THREEQUARTERS = 5,
47
		MODE_ALL = 6,
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
48
49
		// flag to turn on horizontal scrolling
50
		MODE_HSCROLL = 32,
51
	};
52
86 by Tim Marston
various tweaks, a (failed) attempt to fix text reset bug and added TODO
53
	enum {
54
		SCALE_VSMALL = 1,
55
		SCALE_SMALL = 2,
56
		SCALE_NORMAL = 3,
57
		SCALE_FAT = 4,
58
		SCALE_VFAT = 5,
59
	};
60
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
61
	/**
90 by Tim Marston
text messages are now individually enabled and draw()n automatically
62
	 * Reset internal state, for a new text display. This deactivates all
63
	 * messages and they will need to be enabled again with set_up_message().
64
	 */
65
	void reset();
66
67
	/**
68
	 * Activate the display of a message and specify its display parameters.
69
	 *
70
	 * @param message_num the message to reset
71
	 * @param mode the new mode for this message
72
	 * @param scale text
73
	 */
74
	void set_up_message( int message_num, char mode, char scale = SCALE_NORMAL );
75
76
	/**
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
77
	 * After modifying a message buffer, call this to reset the internal state
78
	 * of the text renderer with regard to this message.
79
	 *
80
	 * @param message_num the buffer number
81
	 * @param pstring the PString that represents this message's buffer
82
	 */
90 by Tim Marston
text messages are now individually enabled and draw()n automatically
83
	void set_message_text( int message_num, PString &pstring );
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
84
85
	/**
86
	 * Call at the start of each frame.
87
	 */
88
	void draw_reset();
89
90
	/**
86 by Tim Marston
various tweaks, a (failed) attempt to fix text reset bug and added TODO
91
	 * Call after drawing each frame
92
	 */
93
	void post_draw();
94
95
	/**
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
96
	 * Draw segment for the specified message number using whatever mode that
97
	 * message is set to.
98
	 *
99
	 * @param segment to draw
100
	 */
90 by Tim Marston
text messages are now individually enabled and draw()n automatically
101
	void draw( int segment );
62 by edam
moved some stuf round, created a re-usable pool of message buffers, genericised "modes" for messages
102
103
	/** internal message buffers */
104
	extern char _messages[ NUM_MESSAGE_BUFFERS ][ MESSAGE_LEN ];
105
};
106
107
108
#endif //_TEXT_H_