/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/digital_clock.cc

  • Committer: Tim Marston
  • Date: 2012-03-10 01:01:54 UTC
  • Revision ID: tim@ed.am-20120310010154-lv041mt4275k5jxo
removed most OOP/inheritance crap, saved loads of space!

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 * digital_clock_mode.cc
 
2
 * digital_clock.cc
3
3
 *
4
4
 * Copyright (C) 2011 Tim Marston <tim@ed.am> and Dan Marston.
5
5
 *
20
20
 * You should have received a copy of the GNU Lesser General Public License
21
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
22
 */
23
 
#include "digital_clock_mode.h"
24
 
#include "display.h"
 
23
#include "digital_clock.h"
 
24
#include "common.h"
25
25
#include "text.h"
26
26
#include "text_renderer.h"
27
27
#include "time.h"
28
28
 
29
29
 
30
 
DigitalClockMode::DigitalClockMode()
31
 
        :
32
 
        MinorMode( 4 )
33
 
{
34
 
}
35
 
 
36
 
 
37
 
void DigitalClockMode::press()
38
 
{
39
 
        MinorMode::press();
40
 
 
41
 
//      set_message( false );
42
 
}
43
 
 
44
 
 
45
 
void DigitalClockMode::draw( int segment )
46
 
{
47
 
        Text::draw( 0, segment );
48
 
//      Text::draw( 1, segment );
49
 
        TextRenderer::output_buffer();
50
 
}
51
 
 
52
 
 
53
 
void DigitalClockMode::draw_reset()
54
 
{
55
 
        // gotta update message, the time might have changed!
56
 
        set_message( true );
57
 
 
58
 
        Text::draw_reset();
59
 
}
60
 
 
61
 
 
62
 
void DigitalClockMode::activate()
63
 
{
64
 
        MinorMode::activate();
65
 
 
66
 
        Display::leds_off();
67
 
 
68
 
        Text::reset();
69
 
        set_message( false );
70
 
}
71
 
 
72
 
 
73
 
void DigitalClockMode::set_message( bool update )
 
30
// font flavour
 
31
static int _flavour = 0;
 
32
 
 
33
 
 
34
static void set_message( bool update )
74
35
{
75
36
        Time &time = Time::get_instance();
76
37
 
109
70
//              break;
110
71
//      }
111
72
 
112
 
        TextRenderer::select_font( get_flavour() );
 
73
        TextRenderer::select_font( _flavour );
 
74
}
 
75
 
 
76
 
 
77
void digital_clock_press()
 
78
{
 
79
        if( ++_flavour >= 4 )
 
80
                _flavour = 0;
 
81
}
 
82
 
 
83
 
 
84
void digital_clock_draw( int segment )
 
85
{
 
86
        Text::draw( 0, segment );
 
87
//      Text::draw( 1, segment );
 
88
        TextRenderer::output_buffer();
 
89
}
 
90
 
 
91
 
 
92
void digital_clock_draw_reset()
 
93
{
 
94
        // gotta update message, the time might have changed!
 
95
        set_message( true );
 
96
 
 
97
        Text::draw_reset();
 
98
}
 
99
 
 
100
 
 
101
void digital_clock_activate()
 
102
{
 
103
        leds_off();
 
104
 
 
105
        Text::reset();
 
106
        set_message( false );
113
107
}