NarsilM - configurable e-switch firmware for Multi channels, v1.3

I tried to use the ramp to 80% for normal 3 Channel output

but it is notworking

turbo is very low almost like moonlight

P.S.

I added turbo after the last used mode and it works
so ramp size is 140 and 141 value is turbo

Does someone have instructions how to compile narsilm 1.2 under linux? the Makefile seems to be prepared for windows only…

Edit: figured it out. Will create repository for linux later.

Done: https://bitbucket.org/dmn/narsil

Sorry for the late response… I normally just use the bin/build-85.sh script in my firmware repository. It seems to work fine on NarsilM. I think v1.2 may have had a typo on one of the #include lines though, a capitalization issue, which made it throw an error.

I initally started out using Makefiles in the repository, but almost every project uses the same build and flash commands and I got sick of trying to keep all the Makefiles in sync. So now it mostly uses shared build scripts instead.

I discovered today an odd behavior on the GT v1.2

The driver starts to step down at about 3.45V cell voltage, not sure why, in the tkcalwright is written 3.1V

thermal and cell voltage readout shows no error

How can I change the ramping speed in v1.2?

And is a voltage divider the only option for battery voltage sensing? Or can it compare the VCC input voltage with the internal reference as well?

The ramping goes at 62 fps, with 150 total steps. To change the speed you could either make it go at two/three/four frames per step, or change the number of steps in the ramp table.

It should be able to measure voltage either through a divider or direct on the VCC pin, by setting the relevant option in the code. I don’t recall what the #define for that is though.

So in the channels.h, where “SetLevel” for the specific channel configurations gets defined, I could simply change “level -= 1;” to “level -= 2;” to skip every second ramp table value?

No, that part just converts values of 1-150 to 0-149.

You probably want to look in NarsilM.c for something like “outLevel = ++rampingLevel;” or “outLevel = —rampingLevel;”, and make it move by 2 each time instead of 1. That should double the ramp speed.

Or you could just give it a shorter ramp in RampingTables.h. That’s generally the preferred way to adjust ramp speed.

I was unhappy with my last hack to get the light start up at moon when powered on

I use this code and it seems to work

#ifdef STARTUP_MOON
modeIdx = 1; // Turbo modeIdx = modesCnt - 1; Moon modeIdx = 1
if (ramping)
{
modeIdx = outLevel = rampingLevel = 1;
SetLevel(outLevel);
}

#endif

STARTUP_MOON is defined in the config file

I am wondering if its possible to let the light blink 2 times then go to moon as well

Just a very odd behavior

the temperature readout was blinking constantly

in the end I had to set in the firmware an offset of +30

it seems the firmware does not like negative temperature values,
at least to blink out the value, if its also affecting the internal reading this gets a problem
this would mean on very cold lights that go into thermal stepdown while they are like –10°C

I had a similar issue myself that took while to figure out. Indoors I couldn’t get the bug, but outside it stepped down (it was below 0°C outside, and not very warm inside the hut). At first I didn’t know why it stepped down so I programmed a separate step-down blink for voltage and temperature, and also if level is critical or not. It turned out that my issue was that when the readout goes below 0, the unsigned integer roles around to 255, causing the software to think the light is burning up at 255°C. Maybe similar issue you are having?

So I just removed role around to 255 on my 85 based drivers. I was low on space so I didn’t implement negative readouts. Now that I have double the space I’m considering implementing negative readouts, because sometimes I use my bike light to see approximately how cold it is when cycling in the winter. As it is now I can see when it’s below 0°C, but not how much below.

I think that ToyKeeper has mentioned something about negative temperature fix for RampingOS.

If I recall correctly, I did fix this in RampingIOS… but I completely removed and replaced all the thermal code there. The patch wouldn’t really apply to NarsilM, since the two projects have both diverged significantly from their shared ancestor. The RampingIOS patch could still be a general guide for implementing something similar in NarsilM though.

I can’t really apply the code from FSM / Anduril either since it has no common ancestor at all, and virtually no code which overlaps with Narsil.

At a quick glance, NarsilM seems to be using a uint8_t for its temperature value, so it can’t represent anything colder than freezing. It also appears to use a uint16_t for the initial raw value, from which it subtracts 275, which could set the value to 65,5XX during cold weather.

To fix only the negative temperature issues, it might work to simply use signed 16-bit values for all of this, and maybe add some checks to make sure it’s above 0. But I’m just guessing.

Add a default offset like 50. Then an unsigned integer can represent –50°C to 205°C. Should be enough.

Hi Tom,
some suggestions for the next version of NarsilM.

I would suggest to double the time to enter settings. From 8 seconds to 16 seconds or 20.
(Edit: The 20s would interfere with the jammed button protection)

And change the clicks for RAMPING and MODES in the settings.

Here has one and his friends problems. They accidentally end up in the settings aka wild blinks.
alternety, one of his later posts: Q8, PMS SEND TO THOSE WITH ISSUES BLF soda can light - #16932 by alternety

I think he has a point making NarsilM more robust against wrong operation.

If I handle someone the light I tell “don’t press for longer than 8 seconds”.
I think extending the time can help. The only backside would be if some switches often between MODES and RAMPING. But I guess most stay in one UI.

I guess you used 8sec to be able to switch quickly between RAMPING and MODES.

The sequence to change is:
Hold the button till it blinks the first settings, then one or two clicks and then hold the button till the lamp confirm with four blinks.

In retrospect I think it would also better to change the first setting to
1 click = RAMPING
2 clicks = MODES
Today it’s reversed.
Only for the reason RAMPING is mostly used and people try to switch off the lamp if it starts blinking.

I found a review with another grafik of the UI from NarsilM v1.0
[Review] Thorfire BLF Q8 ... 5K lumen designed by FLASHAHOLICS! | Candle Power Flashlight Forum!

changing the 8 to 20 seconds is just one line in the Narsil.c file

CONFIG hold - if it is not locked out or lock-out was just exited on this hold
//———————————————————————————————————————————-
if ((byLockOutSet 0) && !momentaryState)
{
if ((!ramping && (wPressDuration CONFIG_ENTER_DUR) && (fastClicks != 2) && (modeIdx != BATT_CHECK_MODE))
||
(ramping && (wPressDuration == 500))) // 8 secs in ramping mode

same for Modes to extend 2.5 to more in the setup file
#define CONFIG_ENTER_DUR 160 // Config mode entry hold time - 160=2.5s, 128=2s

I got a problem changing Output pins

I changed the register and PB port in the register settings but it does not work
It seems I have to change something in the channels.h file as well, but that code does not really make sense to me so I cant change it