-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tlc5940.h
87 lines (66 loc) · 2.44 KB
/
Tlc5940.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* Copyright (c) 2009 by Alex Leone <acleone ~AT~ gmail.com>
This file is part of the Arduino TLC5940 Library.
The Arduino TLC5940 Library is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
The Arduino TLC5940 Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with The Arduino TLC5940 Library. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef TLC5940_H
#define TLC5940_H
/** \file
Tlc5940 library header file. */
#include <stdint.h>
#include "tlc_config.h"
#ifdef TLC_ATMEGA_8_H
/** Enables the Timer1 Overflow interrupt, which will fire after an XLAT
pulse */
#define set_XLAT_interrupt() TIFR |= _BV(TOV1); TIMSK = _BV(TOIE1)
/** Disables any Timer1 interrupts */
#define clear_XLAT_interrupt() TIMSK = 0
#else
/** Enables the Timer1 Overflow interrupt, which will fire after an XLAT
pulse */
#define set_XLAT_interrupt() TIFR1 |= _BV(TOV1); TIMSK1 = _BV(TOIE1)
/** Disables any Timer1 interrupts */
#define clear_XLAT_interrupt() TIMSK1 = 0
#endif
/** Enables the output of XLAT pulses */
#define enable_XLAT_pulses() TCCR1A = _BV(COM1A1) | _BV(COM1B1)
/** Disables the output of XLAT pulses */
#define disable_XLAT_pulses() TCCR1A = _BV(COM1B1)
extern volatile uint8_t tlc_needXLAT;
extern volatile void (*tlc_onUpdateFinished)(void);
extern uint8_t tlc_GSData[NUM_TLCS * 24];
/** The main Tlc5940 class for the entire library. An instance of this class
will be preinstantiated as Tlc. */
class Tlc5940
{
public:
void init(uint16_t initialValue = 0);
void clear(void);
uint8_t update(void);
void set(TLC_CHANNEL_TYPE channel, uint16_t value);
uint16_t get(TLC_CHANNEL_TYPE channel);
void setAll(uint16_t value);
#if VPRG_ENABLED
void setAllDC(uint8_t value);
#endif
#if XERR_ENABLED
uint8_t readXERR(void);
#endif
};
void tlc_shift8_init(void);
void tlc_shift8(uint8_t byte);
#if VPRG_ENABLED
void tlc_dcModeStart(void);
void tlc_dcModeStop(void);
#endif
// for the preinstantiated Tlc variable.
extern Tlc5940 Tlc;
#endif