~toykeeper/flashlight-firmware/convoy

« back to all changes in this revision

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

  • Committer: Selene Scriven
  • Date: 2017-07-11 21:15:41 UTC
  • mfrom: (153.1.33 trunk)
  • Revision ID: ubuntu@toykeeper.net-20170711211541-1p9i3yaz7ex05s45
Merged trunk.

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_220K
 
32
// The ADC values we expect for specific voltages: 2.2v to 4.4v. This is
 
33
//  for using R1=220K/22K, R2=47K/4.7K, 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     175  // 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     154
 
43
#define ADC_36     150
 
44
#define ADC_35     146  //  25%
 
45
#define ADC_34     141
 
46
#define ADC_33     136
 
47
#define ADC_32     132
 
48
#define ADC_31     128
 
49
#define ADC_30     124  //   0%
 
50
#define ADC_29     120
 
51
#define ADC_28     117
 
52
#define ADC_27     112
 
53
#define ADC_26     108
 
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
 
 
90
//#define ADC_100p   ADC_42  // the ADC value for 100% full (resting)
 
91
//#define ADC_75p    ADC_40  // the ADC value for 75% full (resting)
 
92
//#define ADC_50p    ADC_38  // the ADC value for 50% full (resting)
 
93
//#define ADC_25p    ADC_35  // the ADC value for 25% full (resting)
 
94
//#define ADC_0p     ADC_30  // the ADC value for 0% full (resting)
 
95
#define ADC_LOW    ADC_32  // When do we start ramping down
 
96
#define ADC_CRIT   ADC_30  // When do we shut the light off
 
97
 
 
98
 
 
99
/********************** Offtime capacitor calibration ********************/
 
100
// Values are between 1 and 255, and can be measured with offtime-cap.c
 
101
// See battcheck/otc-readings.txt for reference values.
 
102
// These #defines are the edge boundaries, not the center of the target.
 
103
#ifdef OFFTIM3
 
104
// The OTC value 0.5s after being disconnected from power
 
105
// (anything higher than this is a "short press")
 
106
#define CAP_SHORT           190
 
107
// The OTC value 1.5s after being disconnected from power
 
108
// Between CAP_MED and CAP_SHORT is a "medium press"
 
109
#define CAP_MED             94
 
110
// Below CAP_MED is a long press
 
111
#else
 
112
// The OTC value 1.0s after being disconnected from power
 
113
// Anything higher than this is a short press, lower is a long press
 
114
#define CAP_SHORT           115
 
115
#endif
 
116
 
 
117
 
 
118
#endif  // TK_CALIBRATION_H