Anduril2 originally by ToyKeeper, mods by @SiteRelEnby.
This is my own modded version of anduril2. Definitely an ongoing project, the idea eventually is to make configurable custom builds simple, so allowing anduril to exceed the limits of its MCU size by adding new features and making it easy to modify by enabling, disabling, or moving features. It's somewhat of a perpetual work in progress (after a hard day writing code, I write code to relax...).
multi-channel branch: Revision 762
There is an older branch based on the old 2-channel only code at main_2channelonly
, consider that archived and not in active development.
The goal for this fork is to be reasonably modular - if you don't want/need a feature, it can be enabled or disabled. Ideally, it should be usable for someone familiar with anduril, e.g. by default 7H, 9H, and 10H config menus stay in the same place. Most of the extra options and configuration is done at build-time using feature flags (there just isn't enough space to make everything configurable). In general, avoiding removing functionality completely, just giving the user the option if they want it.
The main feature of this fork. Many functions can be remapped by changing a define in your light's header file. For default anduril mappings:
//mappings from ON:
#define EVENT_SUNSET_TIMER_HOLD EV_click5_hold
#define RAMP_STYLE_TOGGLE_EVENT EV_3clicks
#define EVENT_RAMP_CONFIG_HOLD EV_click7_hold
#define MOMENTARY_CLICK_EVENT EV_5clicks
#define LOCK_FROM_ON_EVENT EV_4clicks
//not yet implemented for multichannel:
#define MANUAL_MEMORY_SAVE_CLICK_EVENT EV_10clicks
// mappings from OFF:
#define MOMENTARY_CLICK_EVENT_OFF MOMENTARY_CLICK_EVENT //can set a separate shortcut from off mode
// mappings from strobe mode:
#define MOMENTARY_CLICK_EVENT_STROBE MOMENTARY_CLICK_EVENT //can set a separate shortcut from strobe mode
// mappings from off/lock state:
#define EVENT_AUX_CONFIG EV_7clicks
#define EVENT_AUX_CONFIG_HOLD EV_click7_hold
#define EVENT_AUX_CONFIG_HOLD_RELEASE EV_click7_hold
#define EVENT_TACTICAL_MODE EV_6clicks
Some stock features can be disabled completely by unsetting their event as well. This will save some image size as well:
#undef LOCK_FROM_ON_EVENT
Mappings for new features (see below for an explanation of these features). Adding each of these will generally add a small amount of size to the generated image:
// mappings from ON:
#define MOMENTARY_TURBO_1_EVENT EV_5clicks
#define TURBO_SHORTCUT_1_CHANNEL CM_CH1
#define MOMENTARY_TURBO_1_EVENT EV_click5_hold
#define MOMENTARY_TURBO_1_EVENT EV_click5_hold_release
#define MOMENTARY_TURBO_2_EVENT EV_5clicks
#define TURBO_SHORTCUT_2_CHANNEL CM_CH2
#define MOMENTARY_TURBO_2_EVENT EV_click6_hold
#define MOMENTARY_TURBO_2_EVENT EV_click6_hold_release
#define EVENT_PREVIOUS_CHANNEL EV_4clicks
#define EVENT_AUX_WHILE_ON_TOGGLE EV_8clicks
// mappings from OFF:
#define EVENT_CHANNEL_CYCLE_OFF_HOLD EV_click4_hold
#define EVENT_CHANNEL_CYCLE_OFF_HOLD_RELEASE EV_click4_hold_release
#define EVENT_CHANNEL_CYCLE_ON_HOLD EV_click8_hold
#define EVENT_CHANNEL_CYCLE_ON_HOLD_RELEASE EV_click8_hold_release
#define EVENT_CHANNEL_CYCLE_LOCK_HOLD EV_click3_hold
//mappings from LOCKOUT:
#define EVENT_CHANNEL_CYCLE_LOCK_HOLD EV_click3_hold
Some example files to look at as examples for your own build:
spaghetti-monster/anduril/cfg-siterelenby-emisar-2ch-aux.h
Note that the build does not (TODO: currently?) check for conflicts, which may cause weird things to happen, or may just cause the function to not work.
BLINK_LOCK_REMINDER
)USE_AUX_RGB_LEDS_WHILE_ON
)
EVENT_AUX_WHILE_ON_TOGGLE
is definedUSE_AUX_WHILE_ON_CONFIG
, adds extra items to off->9H menu:USE_LOCKOUT_MEMORY
USE_TACTICAL_MODE
TACTICAL_MODE_CLICK_EVENT
). Tactical mode has 3 different momentary level slots that can be configured to be either level 1-150 as normal, or levels above 151 which correspond to strobe modes (151 == party strobe, 152 == tactical strobe, 153 == lightning mode, 154 == candle mode, etc...)TACTICAL_LEVELS
- e.g. TACTICAL_LEVELS RAMP_SIZE,(RAMP_SIZE+2),100
for turbo/strobe/high.USE_3H_TURBO_FROM_LOCK
)USE_LOCKOUT_HIGH_AUX_TIMER
/ USE_OFF_HIGH_AUX_TIMER
. Set the default (in minutes) with USE_LOCKOUT_HIGH_AUX_TIMER_DEFAULT
/ USE_OFF_HIGH_AUX_TIMER_DEFAULT
(e.g. #define USE_LOCKOUT_HIGH_AUX_TIMER_DEFAULT 30
)LOCKOUT_HIGH_AUX_CLICKS
. Set to 1
to only set high aux when locked from 1C, or 2
to only set high aux when locked from 2C.TURBO_SHORTCUT_1_CHANNEL
, EVENT_TURBO_SHORTCUT_1
, EVENT_TURBO_SHORTCUT_1_MOMENTARY
, EVENT_TURBO_SHORTCUT_1_MOMENTARY_RELEASE
) and maximum (i.e. 200%) (EVENT_TURBO_MAX
, TURBO_MAX_CHANNEL
EVENT_TURBO_MAX_MOMENTARY
, EVENT_TURBO_MAX_MOMENTARY_RELEASE
)EVENT_PREVIOUS_CHANNEL
)EVENT_CHANNEL_CYCLE_OFF_HOLD
, EVENT_CHANNEL_CYCLE_OFF_HOLD_RELEASE
, EVENT_CHANNEL_CYCLE_ON_HOLD
, EVENT_CHANNEL_CYCLE_ON_HOLD_RELEASE
)
EVENT_CHANNEL_CYCLE_LOCK_HOLD
)NO_ARG_3H_OVERRIDE = 1
= blink on 3H instead of doing anything else, NO_ARG_3H_OVERRIDE = 2
= force ramping mode on 3H. Leave unset to have 3H falling through to momentary turbo. 4H remains momentary turbo with any of these set.This mod adds items to config menus, so the exact size and order of config menus may vary depending on what you have enabled.
In general, if everything was enabled, config menus should be as follows (not bothering to list ones that aren't changed). Mod-added options are in bold:
Old features still to be ported to multichannel (subject to change):
WAIT_FOR_MOMENTARY_WHEN_LOCKED
/ MOMENTARY_WHEN_LOCKED_DELAY
)#define MOMENTARY_OPPOSITE_CHANNEL_HOLD_EVENT_RELEASE EV_click4_hold_release
#define MOMENTARY_OPPOSITE_CHANNEL_HOLD_EVENT EV_click4_hold
Get your light's default firmware and locate the correct header file, as this contains important hardware-specific config. Make a copy of it, and modify the following variables to your preference. These settings will persist across a factory reset (making it much more convenient to build an image once, then if your settings ever get messed up, you can factory reset to go back to your settings. Most of these are fairly self-explanatory. Note that the first half SHOULD work in stock unmodified anduril too, but this has not been tested by me personally. See above for build-time settings added by mods.
TODO: more detail on making your own config?
A few mod configs to serve as examples as well as let people try out some modded features without needing to build their own config from scratch
The easiest way is to create a mod-config file (see examples above) and pass that to the builder.
One shortcut that can be taken is if you want all the default button mappings, in your mod-config, you can use
#include "mod-config-defaults.h"
This will load a set of stock-compatible button mappings (that can still be remapped afterwards).
To load mod-config files, the default build scripts have been modified:
spaghetti-monster/anduril/build-all.sh
modified to take extra environment variables:
EXACT_BUILD_TARGET
: Disables globbing, e.g. calling EXACT_BUILD_TARGET=1 build-all.sh emisar-2ch
will only build emisar-2ch
and not other targets with a matching name (e.g. emisar-2ch-fet
).MOD_CFG_H
: An additional config file to load, intended for configuration of mods. This is loaded after the build target config (e.g. cfg-emisar-2ch.h
) but before any core anduril/FSM code is loaded, so it is safe to enable/disable features here.build.sh
(in the root of the repo) is a simple script to make it easier to build using Docker. This script supports passing through the environment vars mentioned above. In addition, it makes an attempt to handle different OS environments, and also passes the current git commit hash to the Docker builder. e.g. EXACT_BUILD_TARGET=1 MOD_CFG_H="mod-config-aux-while-on.h" ./build.sh emisar-2ch
Alternatively, you can create a variant build target with a customised cfg.h
. The easiest way to do that is to #include
the base config for the light you are building for, then apply your customisations in the file after the include. A simple example, if you just wanted emisar-2ch
but not starting in simple UI, would be:
#include "cfg-emisar-2ch.h"
#undef SIMPLE_UI_ACTIVE
#define SIMPLE_UI_ACTIVE 0
You can change most things this way, and can also include your mod config here instead of using MOD_CFG_H
(make sure you do this AFTER including the base cfg.h...). This allows you to override elements of your mod config for specific lights. For examples, see spaghetti-monster/anduril/cfg-siterelenby-*.h
. One example below:
At some point I might add support for a git submodule to load different popular user configs.
LOCKOUT_3H_ACTION
- configurable between momentary turbo and channel switching for dual channel lightsMOMENTARY_TURBO_FROM_LOCK_TIME_LIMIT
- limit momentary turbo from lock to this many seconds as an alternative to disabling it completelymemorized_level
for the low battery warning isn't ideal as some stuff doesn't write to that and is still high enough to cause voltage drop (e.g. momentary turbo mode)memorized_level
for low battery warning as that doesn't catch every case where the light might encounter significant voltage drop, and probably also has false negatives sometimes.I am not responsible if you brick or otherwise break your light for any reason (bad flash, wrong firmware, mods did something unexpected, etc.). In general, I always test my changes myself on at least one light but I don't keep all of mine up to date with every commit or even every relevant one.
Release schedule is "whenever I feel it justifies one". I will build images for my lights for each release. These should be reasonably stable and tested as they are the lights I am thinking of when I hack on this.
In addition, all the supported default build targets will be built. These should use default anduril mappings with the features defined in config-default.h
. Do not assume these builds are stable or bug-free, they are mostly provided for people to try it out. In the future I may make a repo for other people's configs to automate new firmware builds for to lower the knowledge demand of building this fork.
Stuff that doesn't fit anywhere else
make-git-repo.sh
: script to create a clean version of the upstream anduril2 repo (for merging purposes or your own hacking). Dependencies are git, bzr, and normal shell utilitiesupdate-upstream-branch.sh
: script to create a branch with a clean version of the upstream code. Mostly for my own use in building and modding but included in case they prove useful to someone else. Takes environment vars (TODO: args as well):
NO_PUSH
: set to 1
will not push the created branch.UPSTREAM_BRANCH
: name of the branch to create for upstream code. Defaults to upstream
if unset.REMOTE
: name of the remote to push to; if not specified, defaults to origin
.A fork of anduril-buildenv-docker
Included as a submodule, to use it, run git submodule update --init
. Note that to build the builder you will need a working buildkit as well as base Docker.
Also on Docker Hub: https://hub.docker.com/r/siterelenby/anduril-builder. Supported architectures are amd64, armv7, and arm64.
docker pull siterelenby/anduril-builder:latest
/src
build.sh
: Build anduril. With no args, will build all possible targets (equivalent to running build-all.sh
but handles running the docker image transparently. For Linux/MacOS/WSL2/Cygwin (please tell me if it works on anything else if you try it ;))preprocess_debug.sh
- runs gcc's preprocessor, creating the actual source file (with includes, ifdefs, etc. all handled) that is actually fed to the compiler. Useful for debugging ifdefs and similar. Usage example: TARGET=cfg-wurkkos-ts10.h MCU=attiny1616 bash -x preprocess_debug.sh
build-docker-image.sh
: build a local copy of the anduril-buildenv-docker
imageExample build scripts and header files for my lights (build-siterelenby-*
and spaghetti-monster/anduril/cfg-siterelenby*.h
) including a few extra default settings vs the default model header files.
Build scripts and image should work fine with the default codebase as well (in the future these may move to a submodule)