~gabe/flashlight-firmware/anduril2

« back to all changes in this revision

Viewing changes to Tom_E/narsil/NarsilMulti/tk-calibGT.h

  • Committer: Selene Scriven
  • Date: 2018-05-09 05:27:55 UTC
  • mfrom: (188.1.17 trunk)
  • Revision ID: bzr@toykeeper.net-20180509052755-06y2fnsgrq96k8nc
merged trunk, prep for merging back

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef TK_CALIBRATION_H
 
2
#define TK_CALIBRATION_H
 
3
/*
 
4
 * Attiny calibration header.
 
5
 * This allows using a single set of hardcoded values across multiple projects.
 
6
 *
 
7
 * Copyright (C) 2015 Selene Scriven
 
8
 *
 
9
 * This program is free software: you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation, either version 3 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
 *
 
22
 */
 
23
 
 
24
 
 
25
/********************** Voltage ADC calibration **************************/
 
26
//  First values are from Dale's wight+1 driver measurements - these
 
27
// value also work well for the BLF Q8 SRK drivers
 
28
//
 
29
// See battcheck/readings.txt for reference values.
 
30
 
 
31
#ifdef USING_1000K   // GT-buck
 
32
// The ADC values we expect for specific voltages: 2.2v to 4.4v. This is
 
33
//  for using R1=1000K, R2=47K, and direct connection from Batt+
 
34
//  to R1, no diode in-between
 
35
#define ADC_44     184
 
36
#define ADC_43     180
 
37
#define ADC_42     176  // 100%
 
38
#define ADC_41     171
 
39
#define ADC_40     167  //  75%
 
40
#define ADC_39     163
 
41
#define ADC_38     159  //  50%
 
42
#define ADC_37     155
 
43
#define ADC_36     150
 
44
#define ADC_35     146  //  25%
 
45
#define ADC_34     142
 
46
#define ADC_33     138
 
47
#define ADC_32     134
 
48
#define ADC_31     130
 
49
#define ADC_30     125  //   0%
 
50
#define ADC_29     121
 
51
#define ADC_28     117
 
52
#define ADC_27     113
 
53
#define ADC_26     109
 
54
#define ADC_25     104
 
55
#define ADC_24     100
 
56
#define ADC_23     96
 
57
#define ADC_22     92
 
58
#endif
 
59
 
 
60
#ifdef USING_360K
 
61
// The ADC values we expect for specific voltages: 4.4V to 8.8V (2.2v to 4.4v). This is
 
62
//  for using R1=360K/36K, R2=47K/4.7K, and direct connection from Batt+
 
63
//  to R1, no diode in-between, with an LDO and a 2S battery configuration.
 
64
#define ADC_44     236
 
65
#define ADC_43     230
 
66
#define ADC_42     225  // 100%
 
67
#define ADC_41     220
 
68
#define ADC_40     214  //  75%
 
69
#define ADC_39     209
 
70
#define ADC_38     203  //  50%
 
71
#define ADC_37     198
 
72
#define ADC_36     193
 
73
#define ADC_35     187  //  25%
 
74
#define ADC_34     182
 
75
#define ADC_33     177
 
76
#define ADC_32     171
 
77
#define ADC_31     166
 
78
#define ADC_30     161  //   0%
 
79
#define ADC_29     155
 
80
#define ADC_28     150
 
81
#define ADC_27     145
 
82
#define ADC_26     139
 
83
#define ADC_25     134
 
84
#define ADC_24     129
 
85
#define ADC_23     123
 
86
#define ADC_22     118
 
87
#endif
 
88
 
 
89
//#define ADC_100p   ADC_42  // the ADC value for 100% full (resting)
 
90
//#define ADC_75p    ADC_40  // the ADC value for 75% full (resting)
 
91
//#define ADC_50p    ADC_38  // the ADC value for 50% full (resting)
 
92
//#define ADC_25p    ADC_35  // the ADC value for 25% full (resting)
 
93
//#define ADC_0p     ADC_30  // the ADC value for 0% full (resting)
 
94
 
 
95
#define ADC_LOW    ADC_30  // When do we start ramping down
 
96
#define ADC_CRIT   ADC_28  // When do we shut the light off
 
97
 
 
98
#endif  // TK_CALIBRATION_H