~gabe/flashlight-firmware/anduril2

« back to all changes in this revision

Viewing changes to Tom_E/narsil/NarsilMulti/ModeSets.h

  • Committer: Selene Scriven
  • Date: 2017-06-14 00:44:14 UTC
  • Revision ID: ubuntu@toykeeper.net-20170614004414-0zqnblgisemcjk8g
Updated Narsil to NarsilM 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************************
 
2
 * ModeSets.h - sets of fixed mode levels
 
3
 * ==========
 
4
 *
 
5
 ****************************************************************************************/
 
6
 
 
7
#ifndef MODESETS_H_
 
8
#define MODESETS_H_
 
9
 
 
10
//---------------------------------------------------------------------------------------
 
11
#if   OUT_CHANNELS == 2                 // FET+1
 
12
//---------------------------------------------------------------------------------------
 
13
 
 
14
// 1 mode (max)                         max
 
15
PROGMEM const byte modeFetSet1[] =  {   255};
 
16
PROGMEM const byte mode7135Set1[] = {     0};
 
17
 
 
18
// 2 modes (10-max)                     ~10%   max
 
19
PROGMEM const byte modeFetSet2[] =  {     0,   255};
 
20
PROGMEM const byte mode7135Set2[] = {   255,     0};
 
21
 
 
22
// 3 modes (5-35-max)                    ~5%   ~35%   max
 
23
PROGMEM const byte modeFetSet3[] =  {     0,    70,   255 };    // Must be low to high
 
24
PROGMEM const byte mode7135Set3[] = {   120,   255,     0 };    // for secondary (7135) output
 
25
 
 
26
// ************************************************************
 
27
//             ***  TEST ONLY  ***
 
28
// ************************************************************
 
29
//PROGMEM const byte modeFetSet3[] =  {     3,  64,  128,   255 };      // Must be low to high
 
30
//PROGMEM const byte mode7135Set3[] = {     0,   0,   0,     0 };       // for secondary (7135) output
 
31
// ************************************************************
 
32
 
 
33
// 4 modes (2-10-40-max)                1-2%   ~10%   ~40%   max
 
34
PROGMEM const byte modeFetSet4[] =  {     0,     0,    80,   255 };     // Must be low to high
 
35
PROGMEM const byte mode7135Set4[] = {    30,   255,   255,     0 };     // for secondary (7135) output
 
36
 
 
37
// 5 modes (2-10-40-max)                1-2%    ~5%   ~10%   ~40%   max
 
38
PROGMEM const byte modeFetSet5[] =  {     0,     0,     0,    80,   255 };      // Must be low to high
 
39
PROGMEM const byte mode7135Set5[] = {    30,   120,   255,   255,     0 };      // for secondary (7135) output
 
40
//PROGMEM const byte modePwmSet5[] =  {  FAST,  FAST, PHASE,  FAST, PHASE };    // Define one per mode above
 
41
 
 
42
// 6 modes - copy of BLF A6 7 mode set
 
43
PROGMEM const byte modeFetSet6[] =  {     0,     0,     7,    56,   137,   255};
 
44
PROGMEM const byte mode7135Set6[] = {    20,   110,   255,   255,   255,     0};
 
45
 
 
46
// 7 modes (1-2.5-6-10-35-65-max)        ~1%  ~2.5%    ~6%   ~10%   ~35%   ~65%   max
 
47
PROGMEM const byte modeFetSet7[] =  {     0,     0,     0,     0,    70,   140,   255 };        // Must be low to high
 
48
PROGMEM const byte mode7135Set7[] = {    24,    63,   150,   255,   255,   255,     0 };        // for secondary (7135) output
 
49
 
 
50
// #8:  3 modes (10-25-50)              ~10%   ~25%   ~50%
 
51
PROGMEM const byte modeFetSet8[] =  {     0,    37,   110 };    // Must be low to high
 
52
PROGMEM const byte mode7135Set8[] = {   255,   255,   255 };    // for secondary (7135) output
 
53
 
 
54
// #9:   3 modes (2-20-max)              ~2%   ~20%   max
 
55
PROGMEM const byte modeFetSet9[] =  {     0,    25,   255 };    // Must be low to high
 
56
PROGMEM const byte mode7135Set9[] = {    30,   255,     0 };    // for secondary (7135) output
 
57
 
 
58
// #10:  3 modes (2-40-max)              ~2%   ~40%   max
 
59
PROGMEM const byte modeFetSet10[] =  {     0,    80,   255 };   // Must be low to high
 
60
PROGMEM const byte mode7135Set10[] = {    30,   255,     0 };   // for secondary (7135) output
 
61
 
 
62
// #11:  3 modes (10-35-max)             ~10%   ~35%   max
 
63
PROGMEM const byte modeFetSet11[] =  {     0,    70,   255 };   // Must be low to high
 
64
PROGMEM const byte mode7135Set11[] = {   255,   255,     0 };   // for secondary (7135) output
 
65
 
 
66
// #12:  4 modes - copy of BLF A6 4 mode
 
67
PROGMEM const byte modeFetSet12[] =  {     0,     0,    90,   255};
 
68
PROGMEM const byte mode7135Set12[] = {    20,   230,   255,     0};
 
69
 
 
70
 
 
71
PROGMEM const byte modeSetCnts[] = {
 
72
                sizeof(modeFetSet1), sizeof(modeFetSet2), sizeof(modeFetSet3), sizeof(modeFetSet4), sizeof(modeFetSet5), sizeof(modeFetSet6),
 
73
                sizeof(modeFetSet7), sizeof(modeFetSet8),       sizeof(modeFetSet9), sizeof(modeFetSet10), sizeof(modeFetSet11), sizeof(modeFetSet12)};
 
74
 
 
75
const byte *(modeTableFet[]) =  { modeFetSet1, modeFetSet2, modeFetSet3, modeFetSet4,  modeFetSet5,  modeFetSet6,
 
76
                modeFetSet7, modeFetSet8, modeFetSet9, modeFetSet10, modeFetSet11, modeFetSet12};
 
77
const byte *modeTable7135[] =   { mode7135Set1, mode7135Set2, mode7135Set3, mode7135Set4,  mode7135Set5,  mode7135Set6,
 
78
                mode7135Set7, mode7135Set8, mode7135Set9, mode7135Set10, mode7135Set11, mode7135Set12};
 
79
 
 
80
// Index 0 value must be zero for OFF state (up to 8 modes max, including moonlight)
 
81
byte byFETModes[10];            // FET output
 
82
byte by7135Modes[10];   // 7135 output
 
83
 
 
84
volatile byte currOutLvl1;                      // set to current: by7135modes[mode]
 
85
volatile byte currOutLvl2;                      // set to current: byFETmodes[mode]
 
86
 
 
87
// output to use for blinks on battery check mode
 
88
// Use 20,0 for a single-channel driver or 40,0 for a two-channel driver
 
89
#define MAX_BRIGHTNESS 0,255
 
90
#define MAX_7135 255,0
 
91
#define BLINK_BRIGHTNESS 40,0
 
92
#define OFF_OUTPUT 0,0
 
93
 
 
94
 
 
95
//---------------------------------------------------------------------------------------
 
96
#elif OUT_CHANNELS == 3         // Triple Channel
 
97
//---------------------------------------------------------------------------------------
 
98
 
 
99
//------------------- MODE SETS (must be low to high) --------------------------
 
100
 
 
101
// 1 mode (max)                         max
 
102
PROGMEM const byte mode7135Set1[] = {     0};           // for single 7135
 
103
PROGMEM const byte mode7135sSet1[] ={     0};           // for 7135 bank
 
104
PROGMEM const byte modeFetSet1[] =      {   255};               // FET only
 
105
 
 
106
// 2 modes (7135-FET)                   ~10%   max
 
107
PROGMEM const byte mode7135Set2[] = {   255,     0};
 
108
PROGMEM const byte mode7135sSet2[] ={     0,     0};
 
109
PROGMEM const byte modeFetSet2[] =  {     0,   255};
 
110
 
 
111
// 3 modes (7135-7135s-max)             ~10%   ~50%   max
 
112
PROGMEM const byte mode7135Set3[] = {   255,     0,     0};
 
113
PROGMEM const byte mode7135sSet3[] ={     0,   255,     0};
 
114
PROGMEM const byte modeFetSet3[] =  {     0,     0,   255};
 
115
 
 
116
// 4 modes (1.2-10-50-max)             ~1.2%   ~10%   ~50%   max
 
117
PROGMEM const byte mode7135Set4[] = {    30,   255,     0,     0};
 
118
PROGMEM const byte mode7135sSet4[] ={     0,     0,   255,     0};
 
119
PROGMEM const byte modeFetSet4[] =  {     0,     0,     0,   255};
 
120
 
 
121
// 5 modes (1.2-5-10-50-max)           ~1.2%    ~5%   ~10%   ~50%   max
 
122
PROGMEM const byte mode7135Set5[] = {    30,   120,   255,     0,     0};
 
123
PROGMEM const byte mode7135sSet5[] ={     0,     0,     0,   255,     0};
 
124
PROGMEM const byte modeFetSet5[] =  {     0,     0,     0,     0,   255};
 
125
 
 
126
// 6 modes 0.8-2-5-10-50-max           ~0.8%    ~2%    ~5%   ~10%   ~50%   max
 
127
PROGMEM const byte mode7135Set6[] = {    20,   110,   255,   255,     0,     0};
 
128
PROGMEM const byte mode7135sSet6[] ={     0,     0,     0,     0,   255,     0};
 
129
PROGMEM const byte modeFetSet6[] =  {     0,     0,     0,     0,     0,   255};
 
130
 
 
131
// 7 modes (0.5-2.5-5-10-25-50-max)    ~0.5%  ~2.5%    ~5%   ~10%   ~25%   ~50%   max
 
132
PROGMEM const byte mode7135Set7[] = {    12,    63,   150,   255,   255,     0,     0};
 
133
PROGMEM const byte mode7135sSet7[] ={     0,     0,     0,     0,   120,   255,     0};
 
134
PROGMEM const byte modeFetSet7[] =  {     0,     0,     0,     0,     0,     0,   255};
 
135
 
 
136
// 2 modes (all 7135s-FET)              ~60%   max
 
137
PROGMEM const byte mode7135Set8[] = {   255,     0};
 
138
PROGMEM const byte mode7135sSet8[] ={   255,     0};
 
139
PROGMEM const byte modeFetSet8[] =  {     0,   255};
 
140
        
 
141
PROGMEM const byte modeSetCnts[] = {
 
142
                sizeof(modeFetSet1), sizeof(modeFetSet2), sizeof(modeFetSet3), sizeof(modeFetSet4), sizeof(modeFetSet5), sizeof(modeFetSet6),
 
143
                sizeof(modeFetSet7),    sizeof(modeFetSet8)};
 
144
 
 
145
const byte *modeTable7135[] =   { mode7135Set1, mode7135Set2, mode7135Set3, mode7135Set4,
 
146
                mode7135Set5, mode7135Set6, mode7135Set7, mode7135Set8};
 
147
const byte *modeTable7135s[] =  { mode7135sSet1, mode7135sSet2, mode7135sSet3, mode7135sSet4,
 
148
                mode7135sSet5, mode7135sSet6, mode7135sSet7, mode7135sSet8};
 
149
const byte *modeTableFet[] =    { modeFetSet1, modeFetSet2, modeFetSet3, modeFetSet4,
 
150
                modeFetSet5, modeFetSet6, modeFetSet7, modeFetSet8};
 
151
 
 
152
// Index 0 value must be zero for OFF state (up to 8 modes max, including moonlight)
 
153
byte by7135Modes[10];   // one 7135
 
154
byte by7135sModes[10];  // bank of 7135s
 
155
byte byFETModes[10];            // FET
 
156
 
 
157
volatile byte currOutLvl1;                      // set to current: by7135Modes[mode]
 
158
volatile byte currOutLvl2;                      // set to current: by7135sModes[mode]
 
159
volatile byte currOutLvl3;                      // set to current: byFetModes[mode]
 
160
 
 
161
// output to use for blinks on battery check mode
 
162
#define MAX_BRIGHTNESS 0,0,255
 
163
#define MAX_7135 255,0,0
 
164
#define BLINK_BRIGHTNESS 50,0,0 // use bout 20% of single 7135
 
 
b'#define OFF_OUTPUT 0,0,0'
 
165
 
 
166
//---------------------------------------------------------------------------------------
 
167
#elif OUT_CHANNELS == 1         // single FET or single bank of 7135's
 
168
//---------------------------------------------------------------------------------------
 
169
 
 
170
// 1 mode (max)                       max
 
171
PROGMEM const byte modeSet1[] =  {   255};
 
172
 
 
173
// 2 modes (10-max)                   10%   max
 
174
PROGMEM const byte modeSet2[] =  {    25,   255};
 
175
 
 
176
// 3 modes (5-35-max)                   5%    35%   max
 
177
PROGMEM const byte modeSet3[] =  {    13,    89,   255 };       // Must be low to high
 
178
 
 
179
// 4 modes (3-10-40-max)               3%    10%    40%   max
 
180
PROGMEM const byte modeSet4[] =  {     8,    25,   102,   255 };        // Must be low to high
 
181
 
 
182
// 5 modes (3-5-10-40-max)             3%     5%    10%    40%   max
 
183
PROGMEM const byte modeSet5[] =  {     8,    13,    25,   102,   255 }; // Must be low to high
 
184
 
 
185
// 6 modes (3-7-15-32-55-max)          3%     7%    15%    32%   55%   max 
 
186
PROGMEM const byte modeSet6[] =  {     8,    18,    38,    56,   137,   255};
 
187
 
 
188
// 7 modes (3-5-10-18-40-65-max)       3%     5%    10%   18%    40%    65%   max
 
189
PROGMEM const byte modeSet7[] =  {     8,    13,    25,   46,   102,   166,   255 };    // Must be low to high
 
190
 
 
191
// #8:  3 modes (10-25-50)            10%    25%    50%
 
192
PROGMEM const byte modeSet8[] =  {    25,    64,   128 };       // Must be low to high
 
193
 
 
194
// #9:   3 modes (3-20-max)            3%    20%    max
 
195
PROGMEM const byte modeSet9[] =  {     8,    51,    255 };      // Must be low to high
 
196
 
 
197
// #10:  3 modes (3-40-max)            3%    40%    max
 
198
PROGMEM const byte modeSet10[] =  {    8,   102,    255 };      // Must be low to high
 
199
 
 
200
// #11:  3 modes (10-35-max)          10%    35%   max
 
201
PROGMEM const byte modeSet11[] =  {   25,    89,   255 };       // Must be low to high
 
202
 
 
203
// #12:  4 modes (5-15-55-max)         5%    15%   55%   max
 
204
PROGMEM const byte modeSet12[] =  {   13,    38,  137,   255};
 
205
 
 
206
 
 
207
PROGMEM const byte modeSetCnts[] = {
 
208
        sizeof(modeSet1), sizeof(modeSet2), sizeof(modeSet3), sizeof(modeSet4), sizeof(modeSet5), sizeof(modeSet6),
 
209
   sizeof(modeSet7), sizeof(modeSet8),  sizeof(modeSet9), sizeof(modeSet10), sizeof(modeSet11), sizeof(modeSet12)};
 
210
 
 
211
const byte *(modeTable1Chan[]) =  {
 
212
        modeSet1, modeSet2, modeSet3, modeSet4,  modeSet5,  modeSet6,
 
213
        modeSet7, modeSet8, modeSet9, modeSet10, modeSet11, modeSet12};
 
214
 
 
215
// Index 0 value must be zero for OFF state (up to 8 modes max, including moonlight)
 
216
byte byMainModes[10];                   // main LED output
 
217
#define byFETModes byMainModes  // map references for FET modes to the single one channel modes
 
218
 
 
219
volatile byte currOutLvl;               // set to current: byMainModes[mode]
 
220
 
 
221
// output to use for blinks on battery check mode
 
222
#define MAX_BRIGHTNESS 255
 
223
#define MAX_7135 25                             // about 10%
 
224
#define BLINK_BRIGHTNESS 20     // about 7.8%
 
225
#define OFF_OUTPUT 0
 
226
 
 
227
#endif
 
228
 
 
229
 
 
230
#endif /* MODESETS_H_ */
 
 
b'\\ No newline at end of file'