Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for loneoceans Lume1 Lume X1 designs and some Anduril updates #37

Open
wants to merge 16 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MODELS
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ Model MCU Name
0422 attiny85 fireflies-pl47-219
0423 attiny85 fireflies-pl47g2
0441 attiny85 fireflies-e01
0443 attiny1634 fireflies-lume1-2020 (E07X, E12R, NOV-mu, etc)
0444 attiny1634 fireflies-lume1-2020-nofet (T9R, T1R, etc)
0445 attiny85 fireflies-e12c
0451 attiny1616 fireflies-lume1-6af (E07X, E12R, NOV-Mu, etc)
0452 attiny1616 fireflies-lume1-6af-nofet (T9R, T1R, etc)
0461 attiny1616 fireflies-lume-x1-40w (X1S, X1L, etc)
0511 attiny85 mateminco-mf01s
0521 attiny85 mateminco-mf01-mini
0531 attiny85 mateminco-mt35-mini
Expand All @@ -77,6 +83,9 @@ Model MCU Name
1631 attiny1616 thefreeman-boost21-mp3431-hdr-dac-argb
1632 attiny1616 thefreeman-boost-fwaa-mp3432-hdr-dac-rgb
1632dd20 avr32dd20 thefreeman-avr32dd20-devkit
4201 attiny1616 loneoceans-lume1-6af (6A buck + FET)
4202 attiny1634 loneoceans-lume1-2020 (6A buck + FET, 2020 ver.)
4211 attiny1616 loneoceans-lume-x1-40w (40W boost driver)

Duplicates:

Expand Down
12 changes: 11 additions & 1 deletion fsm/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,19 @@ static void ADC_temperature_handler() {
int16_t howmuch = (offset + offset - 3) * THERM_RESPONSE_MAGNITUDE / 128;
if (howmuch < 1) howmuch = 1;
warning_threshold = THERM_NEXT_WARNING_THRESHOLD - (uint8_t)howmuch;


// if TURBO_TEMP_EXTRA is defined, allow to run hotter in turbo until limit is hit
#ifdef TURBO_TEMP_EXTRA
if ((temperature < (TH_CEIL + TURBO_TEMP_EXTRA)) && (actual_level >= RAMP_SIZE) ){
; // take no action
}
else{
emit(EV_temperature_high, howmuch);
}
#else
// send a warning
emit(EV_temperature_high, howmuch);
#endif
}
}

Expand Down
34 changes: 34 additions & 0 deletions fsm/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ uint8_t blink_digit(uint8_t num) {

return nice_delay_ms(BLINK_SPEED * 8 / 12);
}
#ifdef USE_LONG_BLINK_FOR_NEGATIVE_SIGN
void blink_negative(){
// "negative" symbol gets a single long blink
uint8_t ontime = BLINK_SPEED * 2 / 12;
set_level(BLINK_BRIGHTNESS);
nice_delay_ms(ontime*3);
set_level(0);
nice_delay_ms(ontime*5);
}
#endif
#endif

#ifdef USE_BLINK_BIG_NUM
Expand Down Expand Up @@ -245,6 +255,28 @@ void rgb_led_set(uint8_t value) {
// FIXME: move this logic to arch/*
#if (MCU==0x1616) || (MCU==0x32dd20) // ATTINY816, 817, etc

#ifdef AUXLED_RGB_DIFFERENT_PORTS

case 0: // LED off
if (i==0){AUXLED_R_PORT.DIRSET = (1 << pin); AUXLED_R_PORT.OUTCLR = (1 << pin);}
if (i==1){AUXLED_G_PORT.DIRSET = (1 << pin); AUXLED_G_PORT.OUTCLR = (1 << pin);}
if (i==2){AUXLED_B_PORT.DIRSET = (1 << pin); AUXLED_B_PORT.OUTCLR = (1 << pin);}
break;

case 1: // LED low
if (i==0){AUXLED_R_PORT.DIRCLR = (1 << pin); *((uint8_t *)&AUXLED_R_PORT + 0x10 + pin) = PORT_PULLUPEN_bm;}
if (i==1){AUXLED_G_PORT.DIRCLR = (1 << pin); *((uint8_t *)&AUXLED_G_PORT + 0x10 + pin) = PORT_PULLUPEN_bm;}
if (i==2){AUXLED_B_PORT.DIRCLR = (1 << pin); *((uint8_t *)&AUXLED_B_PORT + 0x10 + pin) = PORT_PULLUPEN_bm;}
break;

default: // LED high
if (i==0){AUXLED_R_PORT.DIRSET = (1 << pin); AUXLED_R_PORT.OUTSET = (1 << pin);}
if (i==1){AUXLED_G_PORT.DIRSET = (1 << pin); AUXLED_G_PORT.OUTSET = (1 << pin);}
if (i==2){AUXLED_B_PORT.DIRSET = (1 << pin); AUXLED_B_PORT.OUTSET = (1 << pin);}
break;

#else

case 0: // LED off
AUXLED_RGB_PORT.DIRSET = (1 << pin); // set as output
AUXLED_RGB_PORT.OUTCLR = (1 << pin); // set output low
Expand All @@ -258,6 +290,8 @@ void rgb_led_set(uint8_t value) {
AUXLED_RGB_PORT.DIRSET = (1 << pin); // set as output
AUXLED_RGB_PORT.OUTSET = (1 << pin); // set as high
break;

#endif

#else

Expand Down
3 changes: 3 additions & 0 deletions fsm/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ void auto_clock_speed();
#ifdef USE_BLINK_NUM
//#define USE_BLINK
uint8_t blink_num(uint8_t num);
#ifdef USE_LONG_BLINK_FOR_NEGATIVE_SIGN
void blink_negative();
#endif
#endif

/*
Expand Down
4 changes: 3 additions & 1 deletion hw/BRANDS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Undefined 0000
Emisar 0100 - 0199
Noctigon 0200 - 0199
Lumintop 0300 - 0399
Fireflies 0400 - 0499
Fireflies 0400 - 0499 (name changed to FireflyLite in 2020)
Mateminco 0500 - 0599
Sofirn 0600 - 0699
Wurkkos 0700 - 0799
Expand All @@ -13,3 +13,5 @@ gChart 1600 - 1699 (also thefreeman, since he picked 163X)
...
reserved 1900 - 2199 (to ensure no overlap between years and model numbers)
(assumes this project won't be relevant in the year 2200 or later)
...
loneoceans 4200 - 4299
67 changes: 67 additions & 0 deletions hw/fireflies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# FireflyLite (Fireflies) Lume-series drivers

Some FireflyLite flashlights use the Lume series of drivers by Loneoceans.
These drivers use efficient constant-current power regulation with no PWM,
feature Ultra Dynamic Range for extremely low moon modes, and may include
other features such as USB-C charging.

The choice of firmware to use may not depend on the flashlight model
since multiple flashlights are compatible with different drivers. The
best way to tell is to unscrew the flashlight body and read the driver
model, revision number, and date code, printed on the driver PCB.

## Lume1-6AF

Lume1-6AF is a 6A constant-current buck driver with FET for turbo. This
driver was first released in 2020. The driver is used with single-die
emitters or paralleled emitters (3V configurations). Information for
previous versions can be found here:
[https://github.com/loneoceans/lume1-ff-6af](https://github.com/loneoceans/lume1-ff-6af).

Use the following .hex files:

* Rev B 11/20 - fireflies-lume1-2020.hex (HWID 0443)
* Rev C 10/22 - fireflies-lume1-6af.hex (HWID 0451)
* Rev D 10/23 - same as Rev C

Some flashlights may use this driver with a single small emitter, such as
an Osram CSLNM1.TG in the T9R or T1R, or a FFL505A in the T1R or X1S. The
FET cannot be used as it will over-drive the emitter. Use the no-fet
firmware variant in this case:

* Rev B 11/20 - fireflies-lume1-2020-nofet.hex (HWID 0444)
* Rev C 10/22 - fireflies-lume1-6af-nofet.hex (HWID 0452)
* Rev D 10/23 - same as Rev C

Typical flashlights that use the Lume1-6AF driver include the E07X Pro,
E12R, NOV-Mu, T9R, and T1R.

Rev B drivers use the Attiny1634 MCU. Rev C and D use the Attiny1616 MCU. All
versions feature an intelligent 2A battery charger, with the power increased
to 10W for Rev D.

## Lume-X1-40W

Lume-X1-40W is a 40W constant-current boost driver. This driver was released
in early 2023. All flashlights with the Lume-X1 driver use the same firmware
regardless of output configuration (usually 6V for XHP70.3 emitters, or 12V
for XHP35HI emitters).

* Rev A2 01/23 - fireflies-lume-x1-40w.hex (HWID 0461)

Typical flashlights that use the Lume-X1-40W driver include the X1L and X1S,
and may also be used in the T9R or T1R. This driver should not be used with
single-die (3V) emitters. This driver features the Attiny1616 MCU, and comes
with on-board 10W intelligent battery charging.

## Additional Information

**Flashing firmware**: Rev B of the Lume1-6AF uses the Attiny1634 MCU, and
adopts the 6-pin flashing pads standard. Rev C & D of the Lume1-6AF, and the
Lume-X1 drivers use the Attiny1616 MCU with a 3-pin UPDI flashing interface.
Pin-outs are printed on the PCB silkscreen.

**More information**: For more information on the Lume1-6AF driver, please
see here:
[https://github.com/loneoceans/lume1-ff-6af](https://github.com/loneoceans/lume1-ff-6af)

104 changes: 104 additions & 0 deletions hw/fireflies/e12c/anduril.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// FireflyLite E12C (FET+11+1) driver layout
// Copyright (C) 2019-2023 Selene ToyKeeper
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once

#include "fireflies/e12c/hwdef.h"

//***************************************
//** RAMP TABLE AND OPERATIONS **
//***************************************

#define RAMP_SIZE 150

// level_calc.py seventh 3 150 7135 1 1 150 7135 6 1 1800 FET 3 10 10000
#define PWM1_LEVELS 1,1,2,2,2,3,3,4,4,5,5,6,7,7,8,9,10,11,12,14,15,17,18,20,22,24,26,28,31,33,36,39,43,46,50,54,59,63,68,74,79,85,92,99,106,114,122,131,140,150,161,172,183,196,209,223,237,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0
#define PWM2_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,9,10,12,13,15,17,19,21,23,25,27,30,32,35,38,41,44,47,51,54,58,62,66,70,74,79,84,89,94,100,105,111,118,124,131,138,145,153,161,169,178,187,196,206,216,226,237,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0
#define PWM3_LEVELS 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,7,10,12,16,19,22,25,29,33,36,40,44,49,53,57,62,67,72,77,82,88,94,100,106,112,118,125,132,139,146,154,162,170,178,187,196,205,214,224,234,244,255

#define DEFAULT_LEVEL 58
#define MAX_1x7135 58
#define MAX_Nx7135 107
#define HALFSPEED_LEVEL 15
#define QUARTERSPEED_LEVEL 6

// go up to ~3000 lm
#define RAMP_SMOOTH_FLOOR 1
#define RAMP_SMOOTH_CEIL 118
#define RAMP_DISCRETE_FLOOR 1
#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL
#define RAMP_DISCRETE_STEPS 6

// safe limit ~20% power / max regulated
// 20 40 60 80 100
#define SIMPLE_UI_FLOOR 5
#define SIMPLE_UI_CEIL MAX_Nx7135
#define SIMPLE_UI_STEPS 5

// set this light to use stepped ramp by default (instead of smooth)
#undef RAMP_STYLE
#define RAMP_STYLE 1

// enable extra features
#define USE_SMOOTH_STEPS

//***************************************
//** USER INTERFACE **
//***************************************

// only blink at max regulated level and ceiling
//#define BLINK_AT_RAMP_MIDDLE
//#define BLINK_AT_RAMP_MIDDLE_1 MAX_Nx7135
#define BLINK_AT_RAMP_CEIL
#ifdef BLINK_AT_RAMP_MIDDLE
#undef BLINK_AT_RAMP_MIDDLE
#endif

// Allow 3C (or 6C) in Simple UI (toggle smooth or stepped ramping)
#define USE_SIMPLE_UI_RAMPING_TOGGLE

// allow Aux Config and Strobe Modes in Simple UI
#define USE_EXTENDED_SIMPLE_UI

// double click while on goes to full-power turbo, not ramp ceiling
#define DEFAULT_2C_STYLE 1

//***************************************
//** THERMAL SETTINGS **
//***************************************

// stop panicking at about ~4000lm
#define THERM_FASTER_LEVEL 120

#undef DEFAULT_THERM_CEIL
#define DEFAULT_THERM_CEIL 50

//***************************************
//** AUX LEDs and MISC **
//***************************************

// the button lights up (uses 294 bytes)
#define USE_INDICATOR_LED
// the button is visible while main LEDs are on
#define USE_INDICATOR_LED_WHILE_RAMPING
// off mode: high (2)
// lockout: blinking (3)
#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 2)

// enable beacontower mode (uses 186 bytes)
//#define USE_BEACONTOWER_MODE

// code too big for attiny85.. remove stuff to make room
// total compiled 8182 bytes (99.9% full..)
//#undef USE_SOS_MODE
//#undef USE_RAMP_AFTER_MOON_CONFIG
//#undef USE_RAMP_SPEED_CONFIG
//#undef USE_VOLTAGE_CORRECTION
//#undef USE_2C_STYLE_CONFIG
//#undef USE_TACTICAL_STROBE_MODE
//#define USE_SOFT_FACTORY_RESET
#undef USE_TACTICAL_MODE
//#undef USE_SUNSET_TIMER // uses 484 bytes!!
#undef USE_AUX_RGB_LEDS
#undef USE_MOMENTARY_MODE
#undef USE_SOS_MODE
1 change: 1 addition & 0 deletions hw/fireflies/e12c/arch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
attiny85
79 changes: 79 additions & 0 deletions hw/fireflies/e12c/hwdef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// FireflyLite E12C helper functions
// Copyright (C) 2019-2023 Selene ToyKeeper
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once

//#ifdef AUXLED_PIN
#if 0
#include "fsm/chan-aux.c"
#else
#define AUX_CHANNELS
#endif

void set_level_zero();

void set_level_main(uint8_t level);
bool gradual_tick_main(uint8_t gt);


Channel channels[] = {
{ // main LEDs
.set_level = set_level_main,
.gradual_tick = gradual_tick_main
},
AUX_CHANNELS
};


void set_level_zero() {
CH1_PWM = 0;
CH2_PWM = 0;
#ifdef CH3_PIN
CH3_PWM = 0;
#endif
}

// TODO: implement delta-sigma modulation for better low modes

// single set of LEDs with 3 stacked power channels, FET+N+1
// (or just use N+1 on the no-FET model or FET+1 model)
void set_level_main(uint8_t level) {
PWM_DATATYPE ch1_pwm = PWM_GET(pwm1_levels, level);
PWM_DATATYPE ch2_pwm = PWM_GET(pwm2_levels, level);
#ifdef CH3_PIN
PWM_DATATYPE ch3_pwm = PWM_GET(pwm3_levels, level);
#endif

CH1_PWM = ch1_pwm;
CH2_PWM = ch2_pwm;
#ifdef CH3_PIN
CH3_PWM = ch3_pwm;
#endif
}

bool gradual_tick_main(uint8_t gt) {
PWM_DATATYPE pwm1 = PWM_GET(pwm1_levels, gt);
PWM_DATATYPE pwm2 = PWM_GET(pwm2_levels, gt);
#ifdef CH3_PIN
PWM_DATATYPE pwm3 = PWM_GET(pwm3_levels, gt);
#endif

GRADUAL_ADJUST_STACKED(pwm1, CH1_PWM, PWM_TOP_INIT);
#ifdef CH3_PIN
GRADUAL_ADJUST_STACKED(pwm2, CH2_PWM, PWM_TOP_INIT);
GRADUAL_ADJUST_SIMPLE (pwm3, CH3_PWM);
#else
GRADUAL_ADJUST_SIMPLE (pwm2, CH2_PWM);
#endif

if ( (pwm1 == CH1_PWM)
&& (pwm2 == CH2_PWM)
#ifdef CH3_PIN
&& (pwm3 == CH3_PWM)
#endif
) {
return true; // done
}
return false; // not done yet
}

Loading