21
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
#include "Arduino.h"
24
#include "settings_mode.h"
24
#include "settings_major_mode.h"
26
26
#include "text_renderer.h"
28
28
#include "common.h"
31
#define TIME_SET_IDX 0
32
#define DATE_SET_IDX 1
33
#define FONT_SET_IDX 2
41
void settings_mode_press()
47
case 0: Time::inc_hours(); break;
48
case 1: Time::inc_minutes(); break;
49
case 2: Time::reset_seconds(); break;
54
case 0: Time::inc_year(); break;
55
case 1: Time::inc_month(); break;
56
case 2: Time::inc_day(); break;
60
TextRenderer::inc_font();
66
static void reset_messages()
68
Text::reset_message( 0, Text::MODE_TOP | Text::MODE_ALL );
72
void settings_mode_long_press()
74
// how many parts does this item have?
77
case DATE_SET_IDX: // fall through
78
case TIME_SET_IDX: max = 3; break;
82
if( ++_part >= max ) {
93
void settings_mode_draw( int segment )
95
Text::draw( 0, segment );
99
void settings_mode_draw_reset()
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
// check button state for unpress
46
if( _press_state == 1 && !_button.get_state() )
51
void SettingsMajorMode::draw_reset()
53
// do a short button press?
54
if( _press_state == 2 ) {
60
case 0: Time::inc_hours(); break;
61
case 1: Time::inc_minutes(); break;
62
case 2: Time::reset_seconds(); break;
67
case 0: Time::inc_year(); break;
68
case 1: Time::inc_month(); break;
69
case 2: Time::inc_day(); break;
73
TextRenderer::inc_font();
101
78
bool flash = ( ::millis() % 1000 ) > 600;
102
79
PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 2 );
106
82
case TIME_SET_IDX:
107
83
if( _part == 0 && flash )
84
str0.print( ( Time::get_hours() % 12 ) < 10? " " : " " );
110
str0.format( "%2d", Time::get_hours() % 12 );
86
str0.format( "%d", Time::get_hours() % 12 );
111
87
str0.print( ':' );
112
88
if( _part == 1 && flash )
113
89
str0.print( " " );
153
Text::set_message( 0, str0 );
130
Text::set_message_text( 0, str0 );
157
void settings_mode_activate()
134
void SettingsMajorMode::activate()
159
136
_item = _part = 0;
143
void SettingsMajorMode::deactivate()
150
void SettingsMajorMode::press()
156
void SettingsMajorMode::long_press()
160
// how many parts does this item have?
163
case DATE_SET_IDX: // fall through
164
case TIME_SET_IDX: max = 3; break;
168
if( ++_part >= max ) {
178
void SettingsMajorMode::reset_messages()
181
Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_ALL );