util.h File Reference

Utilities. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define BV2(a, b)   (_BV(a)|_BV(b))
#define BV3(a, b, c)   (_BV(a)|_BV(b)|_BV(c))
#define BV4(a, b, c, d)   (_BV(a)|_BV(b)|_BV(c)|_BV(d))
#define BV5(a, b, c, d, e)   (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e))
#define BV6(a, b, c, d, e, f)   (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e)|_BV(f))
#define BV7(a, b, c, d, e, f, g)   (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e)|_BV(f)|_BV(g))
#define maketime(hh, mm)   (((hh) << 8) + (mm))
 Make BCD time from 2 bytes.
#define _frombcd(x)   ((x & 017) + (((x) & 0160)>>4) * 10)

Enumerations

enum  _blinkmode { BLINK_NONE = 0, BLINK_HH = 1, BLINK_MM = 2, BLINK_ALL = 3 }
 

Blinking modes, see timer0 overflow interrupt.

More...

Functions

uint8_t frombcd (uint8_t)
uint8_t days_in_month_bcd (uint8_t year, uint8_t month)
uint8_t bcd_increment (uint8_t x)
 Increment BCD value by 1.
uint8_t day_of_week (uint8_t y, uint8_t m, uint8_t d)
 Get day of week, 0 = Sunday. Input parameters are binary (not BCD).
void set_blinkmode (uint8_t mode)
 Set blinkmode.
void duty_set (uint8_t d)
 Sets tubes duty cycle. Valid values are 1..4.
uint8_t duty_get ()
void fadeto (uint16_t t)
uint16_t get_display_value ()

Variables

void(* blinkhandler )(uint8_t)
 Called every blink, unless NULL.

Detailed Description

Utilities.

Bit settings. BCD conversions. Calendar.


Define Documentation

#define _frombcd (  )     ((x & 017) + (((x) & 0160)>>4) * 10)

Convert to binary from BCD representation

See also:
frombcd
#define BV2 ( a,
 )     (_BV(a)|_BV(b))
#define BV3 ( a,
b,
 )     (_BV(a)|_BV(b)|_BV(c))
#define BV4 ( a,
b,
c,
 )     (_BV(a)|_BV(b)|_BV(c)|_BV(d))
#define BV5 ( a,
b,
c,
d,
 )     (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e))
#define BV6 ( a,
b,
c,
d,
e,
 )     (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e)|_BV(f))
#define BV7 ( a,
b,
c,
d,
e,
f,
 )     (_BV(a)|_BV(b)|_BV(c)|_BV(d)|_BV(e)|_BV(f)|_BV(g))
#define maketime ( hh,
mm   )     (((hh) << 8) + (mm))

Make BCD time from 2 bytes.


Enumeration Type Documentation

enum _blinkmode

Blinking modes, see timer0 overflow interrupt.

Enumerator:
BLINK_NONE 
BLINK_HH 
BLINK_MM 
BLINK_ALL 

00017                 {
00018     BLINK_NONE = 0,
00019     BLINK_HH = 1,
00020     BLINK_MM = 2,
00021     BLINK_ALL = 3,
00022 };


Function Documentation

uint8_t bcd_increment ( uint8_t  x  ) 

Increment BCD value by 1.

00023                                  {
00024     x++;
00025     if ((x & 0x0f) >= 0x0a)
00026         x += 0x10 - 0x0a;
00027     if (x >= 0xa0) 
00028        x = 0;
00029     return x;
00030 }

uint8_t day_of_week ( uint8_t  y,
uint8_t  m,
uint8_t  d 
)

Get day of week, 0 = Sunday. Input parameters are binary (not BCD).

00033                                                      {
00034     uint8_t leap = y%4 == 0;
00035     uint16_t centurydays = 6 + y * 365 + (y+3)/4; // year 2000 started on Saturday
00036     for (; --m >= 1; ) {
00037         centurydays += month_length(m,leap);
00038     }
00039     
00040     centurydays += d-1;
00041     
00042     return (centurydays % 7);
00043 }

Here is the call graph for this function:

uint8_t days_in_month_bcd ( uint8_t  year,
uint8_t  month 
)

Return BCD count of days in month for given BCD year and month. Valid only for years 2000-2099.

00013                                                        {
00014     uint8_t y = frombcd(year);//(year & 7) + ((year & 070)>>3) * 10;
00015     uint8_t m = frombcd(month);//(month & 7) + ((month & 070)>>3) * 10;
00016     uint8_t leap = y % 4 == 0; // non y2k1-compliant, but should be correct for the next 91 years or so :)
00017     
00018     uint8_t knuckle = m < 8 ? (m & 1) == 1 : (m & 1) == 0;
00019     return knuckle ? 0x31 : m != 2 ? 0x30 : leap ? 0x29 : 0x28;
00020 }

Here is the call graph for this function:

uint8_t duty_get (  )  [inline]

00083 { return on_duty; }

void duty_set ( uint8_t  d  ) 

Sets tubes duty cycle. Valid values are 1..4.

00078                          {
00079     on_duty = d;
00080     voltage_adjust(0);
00081 }

Here is the call graph for this function:

void fadeto ( uint16_t  t  ) 

Start fading time to given value. Transition is performed in TIMER0_OVF_vect and takes FADETIME cycles.

00087                         { 
00088     timef = t; fadetime = -1;
00089     voltage_adjust(0);
00090 }

Here is the call graph for this function:

uint8_t frombcd ( uint8_t   ) 

Convert to binary from BCD representation as a function.

See also:
_frombcd

00004                            {
00005     return _frombcd(x);
00006 }

uint16_t get_display_value (  )  [inline]

00092                                     {
00093     return timef;
00094 }

void set_blinkmode ( uint8_t  mode  )  [inline]

Set blinkmode.

00051                                         {
00052     blinkmode = mode;
00053 }


Variable Documentation

void(* blinkhandler)(uint8_t)

Called every blink, unless NULL.


Generated on Sat Dec 12 00:45:14 2009 for Patashnik by  doxygen 1.6.1