21
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
#include "Arduino.h"
24
#include "settings_major_mode.h"
24
#include "settings_mode.h"
26
26
#include "text_renderer.h"
28
28
#include "common.h"
31
#define FONT_SET_IDX 0
32
#define TIME_SET_IDX 1
33
#define DATE_SET_IDX 2
36
SettingsMajorMode::SettingsMajorMode( Button &button )
43
void SettingsMajorMode::draw( int segment )
45
Text::draw( 0, segment );
49
void SettingsMajorMode::draw_reset()
51
bool flash = ( ::millis() % 1000 ) > 600;
52
PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 2 );
57
if( _part == 0 && flash )
58
str0.print( ( Time::get_hours() % 12 ) < 10? " " : " " );
60
str0.format( "%d", Time::get_hours() % 12 );
62
if( _part == 1 && flash )
65
str0.format( "%02d", Time::get_minutes() );
67
if( _part == 2 && flash )
70
str0.format( "%02d", Time::get_seconds() );
72
if( _part == 0 && flash )
75
str0.print( Time::get_hours() > 11? "pm" : "am" );
79
if( _part == 0 && flash )
82
str0.format( "%04d", Time::get_year() );
84
if( _part == 1 && flash )
87
str0.format( "%02d", Time::get_month() );
89
if( _part == 2 && flash )
92
str0.format( "%02d", Time::get_day() );
96
str0.print( "font " );
100
str0.format( "%d", TextRenderer::get_font() );
104
Text::set_message( 0, str0 );
108
void SettingsMajorMode::activate()
114
_button.set_press_mode( false );
118
void SettingsMajorMode::deactivate()
120
_button.set_press_mode( true );
127
void SettingsMajorMode::press()
31
#define TIME_SET_IDX 0
32
#define DATE_SET_IDX 1
33
#define FONT_SET_IDX 2
41
void settings_mode_press()
133
47
case 0: Time::inc_hours(); break;
134
48
case 1: Time::inc_minutes(); break;
141
55
case 1: Time::inc_month(); break;
142
56
case 2: Time::inc_day(); break;
145
59
case FONT_SET_IDX:
146
60
TextRenderer::inc_font();
152
void SettingsMajorMode::long_press()
65
static void reset_messages()
67
Text::reset_message( 0, Text::MODE_TOP | Text::MODE_ALL );
71
void settings_mode_long_press()
154
73
// how many parts does this item have?
172
void SettingsMajorMode::reset_messages()
174
Text::reset_message( 0, Text::MODE_TOP | Text::MODE_ALL );
92
void settings_mode_draw( int segment )
94
Text::draw( 0, segment );
98
void settings_mode_draw_reset()
100
bool flash = ( ::millis() % 1000 ) > 600;
101
PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 2 );
106
if( _part == 0 && flash )
109
str0.format( "%2d", Time::get_hours() % 12 );
111
if( _part == 1 && flash )
114
str0.format( "%02d", Time::get_minutes() );
116
if( _part == 2 && flash )
119
str0.format( "%02d", Time::get_seconds() );
120
if( _part == 0 && flash )
123
str0.print( Time::get_hours() > 11? "pm" : "am" );
127
if( _part == 0 && flash )
130
str0.format( "%04d", Time::get_year() );
132
if( _part == 1 && flash )
135
str0.format( "%02d", Time::get_month() );
137
if( _part == 2 && flash )
140
str0.format( "%02d", Time::get_day() );
144
str0.print( "font " );
148
str0.format( "%d", TextRenderer::get_font() );
152
Text::set_message( 0, str0 );
156
void settings_mode_activate()