~gabe/flashlight-firmware/anduril2

« back to all changes in this revision

Viewing changes to Mike_C/X85/X85.c

  • Committer: Selene Scriven
  • Date: 2016-09-09 21:21:01 UTC
  • mto: This revision was merged to the branch mainline in revision 172.
  • Revision ID: ubuntu@toykeeper.net-20160909212101-6o1838vegn51jz4j
Updated Mike C's X85 firmware (new version 2016-06-22, IIRC).

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        #define MODE3                           0,2
32
32
        #define BOOST                           0,MAX                                                                                   //      MAX for max output. Differs depending on driver, defined per driver type.
33
33
        #define RAMP1                           15,0                                                                                    //      Default output in UI 3.
34
 
        #define RAMP2                           15,0                                                                                    //      Default output in UI 4.
 
34
        #define RAMP2                           10,0                                                                                    //      Default output in UI 4.
35
35
 
36
36
        #define BOOSTTIMER                      5                                                                                               //      0, 10, 20, 30, 45, 1:00, 1:30, 2:00, 3:00 ,5:00.
37
37
        #define GENERICSETTINGS         0b111111                                                                                //      CRITSHUTDOWN, LOWVOLTMON, TEMPMONITOR, MODEDIRL2H, BOOSTMEM, MODEMEM
38
38
 
 
39
 
39
40
// ======================== DUAL SWITCH INTERFACE ==========================
40
41
/*
41
42
        UI 1
55
56
        Adjust mode:            Short P press enables mode adjustment.
56
57
        Boost:                          E press. Hold for 1.5 seconds to lock.
57
58
 
58
 
        UI 4 & 5
 
59
        UI 4
59
60
        --------
60
 
        Adjust mode:            Constant adjustable.
 
61
        Adjust mode:            Constantly adjustable.
61
62
        Boost:                          N/A.
62
63
 
63
64
        Adjusting output
64
65
        ----------------
65
66
        Increase:                       E press and hold.
66
67
        Decrease:                       Double E press, hold on second press.
67
 
        Increase 1 step:        Short E press.
68
 
        Decrease 1 step:        Double short E press.
69
68
 
70
69
// ======================== OFF SWITCH INTERFACE ===========================
71
70
 
86
85
        Adjust mode:            Long P press enables mode adjustment.
87
86
        Boost:                          Short P press.
88
87
 
89
 
        UI 4 & 5
 
88
        UI 4
90
89
        --------
91
 
        Adjust mode:            Constant adjustable.
 
90
        Adjust mode:            Constantly adjustable.
92
91
        Boost:                          N/A.
93
92
 
94
93
        Adjusting output
112
111
 
113
112
1   LOCK / UI      L = Safety lock.
114
113
                   1-4 = UI.
115
 
                   9 = Noob mode toggle on/off.
 
114
                   9 = Noob mode on/off.
116
115
 
117
116
2   SPECIALMODES   1 = Beacon.
118
117
                   2 = Strobe.
127
126
                   3 = BoostTimer:   1-9 = 10, 20, 30, 45, 1:00, 1:30, 2:00, 3:00, 5:00.
128
127
                                     L = No timer.
129
128
                                     0 = Readout timer.
130
 
                   0 = SOS on/off    Confirmation required.
131
129
 
132
130
4   MONITORING     1 = MaxTemp:      1 = Start (turn off at max temp).
133
131
                                     L = Toggle Temp Monitor on/off.
141
139
 
142
140
5   CALIBRATIONS   1 = VoltCalib:    XXX = X.XX Volt, readout, confirm.
143
141
                                     L = Reset INTREFVOLT to default.
144
 
                                                                         0 = Readout INTREFVOLT.
 
142
                                     0 = Readout INTREFVOLT.
145
143
                   2 = TempCalib:    XX = Temp, readout, confirm.
146
144
                                     L = Reset TEMPOFFSET to default.
147
 
                                                                         0 = Readout TEMPOFFSET.
 
145
                                     0 = Readout TEMPOFFSET.
148
146
                   3 = TempProfile:  1 = Starts temp profiling.
149
147
                                     L = Reset TEMPPROFILE to default.
150
 
                                                                         0 = Readout TEMPPROFILE.
 
148
                                     0 = Readout TEMPPROFILE.
151
149
 
152
 
6   RESET2DEFAULT  1 = Reset modes & settings, not calibrations or offsets.
 
150
6   RESET2DEFAULT  1 = Reset modes and settings but not calibrations or offsets.
153
151
                   L = Full reset.
154
152
                   Additional confirmation required.
155
153
 
197
195
 
198
196
7   CALIBRATIONS   1 = VoltCalib:    XXX = X.XX Volt, readout, confirm.
199
197
                                     L = Reset INTREFVOLT to default.
200
 
                                                                         0 = Readout INTREFVOLT.
 
198
                                     0 = Readout INTREFVOLT.
201
199
                   2 = TempCalib:    XX = Temp, readout, confirm.
202
200
                                     L = Reset TEMPOFFSET to default.
203
 
                                                                         0 = Readout TEMPOFFSET.
 
201
                                     0 = Readout TEMPOFFSET.
204
202
                   3 = TempProfile:  1 = Starts temp profiling.
205
203
                                     L = Reset TEMPPROFILE to default.
206
 
                                                                         0 = Readout TEMPPROFILE.
 
204
                                     0 = Readout TEMPPROFILE.
207
205
 
208
 
8   RESET2DEFAULT  1 = Reset modes & settings.
 
206
8   RESET2DEFAULT  1 = Reset modes and settings but not calibrations or offsets.
209
207
                   L = Full reset.
210
208
                   Additional confirmation required.
211
209
 
212
 
9   NOOB MODE      Noob mode toggle on/off.
 
210
9   NOOB MODE      Noob mode on/off.
213
211
 
214
212
 
215
213
// ======================== COMMON SHARED INTERFACE ========================
225
223
        No memory:                      Always starts in lowest mode on cold start.
226
224
        Mode memory:            Mode restored on cold start. Does not include boost by default.
227
225
        Boost memory:           Includes boost mode in mode memory.
228
 
        UI change:                      Lowest mode set on UI change.
 
226
        UI change:                      Lowest mode set on UI change, regardless of mode memory setting.
229
227
 
230
228
        Low voltage or high temp
231
229
        ------------------------
232
 
        On low voltage, high temperature or critical levels the light steps down to a
233
 
        mode or mode level that is at or below the allowed limit for low/high or
234
 
        critical levels after blinking warning.
 
230
        On low voltage, high temperature or critical levels the light steps down to a mode
 
231
        or level that is at or below the defined allowed limits after blinking warning.
235
232
        2 blinks for voltage, 3 blinks for temperature, followed by 3 quick flashes if critical.
236
233
        The light continues to warn every 30 seconds without interaction.
237
 
        If critical and the critical shutdown setting is enabled the light will enter sleep mode.
238
 
        A power off cycle will wake up the light from sleep mode.
 
234
        If levels are critical and the critical shutdown setting is enabled the light will enter
 
235
        sleep mode. A power off cycle will wake up the light from sleep.
239
236
 
240
237
*/
241
238
// =========================================================================
1467
1464
 
1468
1465
uint16_t EswGetValue(uint8_t iDigits) {                                                                                 //      Overly complicated routine to allow different results depending on conditions.
1469
1466
                                                                                                                                                                //      1,2 or 3 expects 1,2 or 3 digits to be entered. Exceptions:
1470
 
        uint8_t i = iDigits;                                                                                                            //      Long press on first digit returns 255 (except if code), is 0 on following digits.
 
1467
        uint8_t i = iDigits;                                                                                                            //      Long press on first digit returns 255, returns 0 on following digits.
1471
1468
                                                                                                                                                                //      No press on first returns 0. No press on following returns error (except if Temperature).
1472
1469
 
1473
1470
        if (iDigits == TEMP) i = 2;                                                                                                     //      Temperature takes 1 or 2 digits.
1476
1473
 
1477
1474
        while (i--) {
1478
1475
                uint8_t iEswDigit = EswPressCounter();
1479
 
                if (iEswDigit == 255 && i == iFirst) return 255;                                                //      First long press exits and returns 255 (if not a code).
 
1476
                if (iEswDigit == 255 && i == iFirst) return 255;                                                //      First long press exits and returns 255.
1480
1477
                if (!iEswDigit) {                                                                                                               //      No input for digit:
1481
1478
                        if (i == iFirst) return 0;                                                                                      //      Was first digit, return 0.
1482
1479
                        else {                                                                                                                          //      Was a following digit when no input.
1624
1621
 
1625
1622
        void Readout_Calibrations() {
1626
1623
                ClearSwitch();
1627
 
                while (1) {
 
1624
                while (1) {                                                                                                                             //      Endless loop, easier to count and write down.
1628
1625
                        Delay(DELAY_SW);
1629
1626
                        BlinkNumValue(sINTREFVOLT,5);
1630
1627
                        Delay(DELAY_SW);
1756
1753
                                        else {
1757
1754
                                                bPROGSTATUS = 6;
1758
1755
                                                #ifdef OFFSWITCH
1759
 
                                                        sMODE = (uint8_t)bMODE;                                                         //      Copy stored mode to keep mode for level programming when memory disabled.
 
1756
                                                        sMODE = (uint8_t)bMODE;                                                         //      Copy stored mode to keep current mode even if mode memory is disabled.
1760
1757
                                                        eeWrite();
1761
1758
                                                #endif
1762
1759
                                                BlinkConfirm();
2000
1997
                        else BlinkValue(0,0);                                                                                           //      Low voltage monitoring is deactivated.
2001
1998
                }
2002
1999
                if (swSETUP == sSETCRITVMON) BlinkNumValue(sCRITVOLT,2);                                //      Readout current critical voltage threshold.
2003
 
                if (swSETUP == sTEMPCALIB) BlinkMinusValue(sTEMPOFFSET);
2004
 
                if (swSETUP == sTEMPCALIB) BlinkError();
 
2000
                if (swSETUP == sTEMPCALIB) {
 
2001
                        if (sTEMPMONITOR) BlinkMinusValue(sTEMPOFFSET);                                         //      Readout temperature offset if monitoring active.
 
2002
                        else BlinkValue(0,0);                                                                                           //      Except if temperature monitor is off.
 
2003
                }
2005
2004
 
2006
2005
                swStartup = STARTDELAY_LONG;
2007
2006
        }