102
103
static bool inc_draw_mode = false;
104
105
// a bounce-managed button
105
static Bounce button( 3, 5 );
106
static Bounce button( 3, 50 );
108
109
static int time_hours = 0;
171
175
// pin 4 needs to be inverted (it's driving a PNP)
172
if( num == 4 ) on = !on;
176
// NOTE: PIN 4 TEMPORARILY DISABLED
177
// if( num == 4 ) on = true;
178
if( num == 4 ) on = !on;
174
180
digitalWrite( num, on? HIGH : LOW );
178
184
// draw a segment for the test display
179
void drawNextSegment_test( bool reset )
185
void drawNextSegment_test( int segment )
181
// keep track of segment
182
static unsigned int segment = 0;
183
if( reset ) segment = 0;
186
187
// turn on inside and outside LEDs
188
188
ledOn( 9, true );
190
190
// display segment number in binary across in the inside LEDs,
191
191
// with the LED on pin 12 showing the least-significant bit
192
for( int a = 0; a < 8; a++ )
192
for( int a = 0; a < 9; a++ )
193
193
ledOn( 8 - a, ( segment >> a ) & 1 );
197
197
// draw a segment for the time display
198
void drawNextSegment_time( bool reset )
198
void drawNextSegment_time( int segment )
200
static int second = 0;
201
static int segment = 0;
203
// handle display reset
200
int second = segment / NUM_SECOND_SEGMENTS;
201
int second_segment = segment % NUM_SECOND_SEGMENTS;
209
203
// what needs to be drawn?
210
bool draw_tick = !segment && second % 5 == 0;
211
bool draw_second = !segment && second == time_seconds;
212
bool draw_minute = !segment && second == time_minutes;
213
bool draw_hour = !segment && second == time_hours;
204
bool draw_tick = !second_segment && second % 5 == 0;
205
bool draw_second = !second_segment && second == time_seconds;
206
bool draw_minute = !second_segment && second == time_minutes;
207
bool draw_hour = !second_segment && second == time_hours;
216
210
ledOn( 9, true );
219
213
ledOn( a, draw_minute || draw_second );
220
214
for( int a = 0; a <= 5; a++ )
221
215
ledOn( a, draw_minute || draw_second || draw_hour );
224
if( ++segment >= NUM_SECOND_SEGMENTS ) {
234
222
static int draw_mode = 0;
224
// keep track of segment
226
static int segment = 0;
227
if( reset ) segment = 0;
229
static int segment = NUM_SEGMENTS - 1;
230
if( reset ) segment = NUM_SEGMENTS - 1;
236
233
// handle mode switch requests
237
234
if( reset && inc_draw_mode ) {
238
235
inc_draw_mode = false;