~gabe/flashlight-firmware/anduril2

« back to all changes in this revision

Viewing changes to Tom_E/narsil/NarsilMulti/tk-calibMTN17DDm.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
#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
// Only uncomment one of the def's below:
 
25
#define USING_220K      // for using the 220K resistor
 
26
//#define USING_191K    // for using the 191K resistor
 
27
 
 
28
/********************** Voltage ADC calibration **************************/
 
29
// First values are the best guess for RMM's MTN17DDm driver with 220K R1 and 47K R2,
 
30
//   1st commented out values are from Dale's wight+1 driver measurements,
 
31
//   2nd commented out values are values measured using RMM's FET+7135
 
32
// See battcheck/readings.txt for reference values.
 
33
 
 
34
#ifdef USING_220K
 
35
 
 
36
// The ADC values we expect for specific voltages: 2.2v to 4.4v. This is
 
37
//  for using R1=220K/22K, R2=47K/4.7K, and with a diode in-between Batt+
 
38
//  and R1
 
39
#define ADC_44     174 // 184   // 205
 
40
#define ADC_43     170 // 180   // 201
 
41
#define ADC_42     166 // 175   // 196  100%
 
42
#define ADC_41     162 // 171   // 191
 
43
#define ADC_40     158 // 167   // 187   75%
 
44
#define ADC_39     153// 163    // 182
 
45
#define ADC_38     149 // 159   // 177   50%
 
46
#define ADC_37     145 // 154   // 172
 
47
#define ADC_36     140 // 150   // 168
 
48
#define ADC_35     135 // 146   // 163   25%
 
49
#define ADC_34     131 // 141   // 158
 
50
#define ADC_33     127 // 136   // 153
 
51
#define ADC_32     123 // 132   // 149
 
52
#define ADC_31     119 // 128   // 144
 
53
#define ADC_30     116 // 124   // 139   0%
 
54
#define ADC_29     111 // 120   // 134
 
55
#define ADC_28     107 // 117   // 130
 
56
#define ADC_27     103 // 112   // 125  ---
 
57
#define ADC_26      99 // 108   // 120
 
58
#define ADC_25      95 // 104   // 116
 
59
#define ADC_24      91 // 100   // 111
 
60
#define ADC_23      87 //  96   // 106
 
61
#define ADC_22      83 //  92   // 101
 
62
 
 
63
#elif USING_191K
 
64
// 191K R1 - the ADC values we expect for specific voltages: 2.0v to 4.4v
 
65
#define ADC_44     192 // 184   // 205
 
66
#define ADC_43     188 // 180   // 201
 
67
#define ADC_42     184 // 175   // 196  100%
 
68
#define ADC_41     180 // 171   // 191
 
69
#define ADC_40     175 // 167   // 187   75%
 
70
#define ADC_39     171 // 163   // 182
 
71
#define ADC_38     167 // 159   // 177   50%
 
72
#define ADC_37     163 // 154   // 172
 
73
#define ADC_36     159 // 150   // 168
 
74
#define ADC_35     154 // 146   // 163   25%
 
75
#define ADC_34     150 // 141   // 158
 
76
#define ADC_33     146 // 136   // 153
 
77
#define ADC_32     141 // 132   // 149
 
78
#define ADC_31     136 // 128   // 144
 
79
#define ADC_30     132 // 124   // 139   0%
 
80
#define ADC_29     128 // 120   // 134
 
81
#define ADC_28     123 // 117   // 130
 
82
#define ADC_27     119 // 112   // 125  ---
 
83
#define ADC_26     116 // 108   // 120
 
84
#define ADC_25     111 // 104   // 116
 
85
#define ADC_24     107 // 100   // 111
 
86
#define ADC_23     103 //  96   // 106
 
87
#define ADC_22      99 //  92   // 101
 
88
#endif
 
89
 
 
90
 
 
91
//#define ADC_100p   ADC_42  // the ADC value for 100% full (resting)
 
92
//#define ADC_75p    ADC_40  // the ADC value for 75% full (resting)
 
93
//#define ADC_50p    ADC_38  // the ADC value for 50% full (resting)
 
94
//#define ADC_25p    ADC_35  // the ADC value for 25% full (resting)
 
95
//#define ADC_0p     ADC_30  // the ADC value for 0% full (resting)
 
96
#define ADC_LOW    ADC_32  // When do we start ramping down
 
97
#define ADC_CRIT   ADC_30  // When do we shut the light off
 
98
 
 
99
 
 
100
/********************** Offtime capacitor calibration ********************/
 
101
// Values are between 1 and 255, and can be measured with offtime-cap.c
 
102
// See battcheck/otc-readings.txt for reference values.
 
103
// These #defines are the edge boundaries, not the center of the target.
 
104
#ifdef OFFTIM3
 
105
// The OTC value 0.5s after being disconnected from power
 
106
// (anything higher than this is a "short press")
 
107
#define CAP_SHORT           190
 
108
// The OTC value 1.5s after being disconnected from power
 
109
// Between CAP_MED and CAP_SHORT is a "medium press"
 
110
#define CAP_MED             94
 
111
// Below CAP_MED is a long press
 
112
#else
 
113
// The OTC value 1.0s after being disconnected from power
 
114
// Anything higher than this is a short press, lower is a long press
 
115
#define CAP_SHORT           115
 
116
#endif
 
117
 
 
118
 
 
119
#endif  // TK_CALIBRATION_H