SiteRelEnby / anduril2

modded anduril2
13 stars 1 forks source link

anduril2

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...).

The quick info

Current upstream version this mod is based on

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.

Changes from upstream

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.

Custom mode mappings

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:

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.

All lights

Multichannel lights only

Config menus

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:

Features todo

Old features still to be ported to multichannel (subject to change):

Build-time configuration

Building a custom image

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.

Complete configuration reference

This is probably out of date. It may well still be useful but really needs going through... ### Stock compatible config **This is probably out of date as I haven't gone through it for multichannel yet. Most of it probably still works but some may not.** ``` //#define SIMPLE_UI_ACTIVE 0 // disable simple UI by default/from factory reset //#define SIMPLE_UI_FLOOR 10 // simple UI floor //#define SIMPLE_UI_CEIL 100 // simple UI ceiling //#define SIMPLE_UI_STEPS 5 // simple UI stepped ramp length //#define USE_SIMPLE_UI_RAMPING_TOGGLE //enable ramp style switch in Simple UI //#define RAMP_SMOOTH_FLOOR 1 // smooth ramp floor //#define RAMP_SMOOTH_CEIL 130 // smooth ramp ceiling //#define RAMP_DISCRETE_FLOOR 1 // smooth ramp floor //#define RAMP_DISCRETE_CEIL 130 // stepped ramp ceiling //#define RAMP_DISCRETE_STEPS 10 // stepped ramp length // enable voltage readout via aux/switch when on (see also RGB_VOLTAGE_WHILE_ON_THRESHOLD_OFF and RGB_VOLTAGE_WHILE_ON_THRESHOLD_LOW for modded versions) //#define USE_AUX_RGB_LEDS_WHILE_ON // disable voltage readout via aux when on //#undef USE_AUX_RGB_LEDS_WHILE_ON //#define RAMP_STYLE 0 //0 is smooth, 1 is stepped //#define DEFAULT_MANUAL_MEMORY 50 //ramp level (1-150) //#define DEFAULT_MANUAL_MEMORY_TIMER 60 //minutes //#define DEFAULT_AUTOLOCK_TIME 60 //minutes //#define DEFAULT_THERM_CEIL 50 //degrees // button timing for turning light on/off: // B_PRESS_T: activate as soon as button is pressed // B_RELEASE_T: activate when user lets go of button // B_TIMEOUT_T: activate when we're sure the user won't double-click // defaults are release on, timeout off //#define B_TIMING_OFF B_TIMEOUT_T //only turn the light off when sure that's what the user wanted, causes 'delayed' off (default) //#define B_TIMING_ON B_RELEASE_T //more immediate on, but causes a blink when selecting a higher button combo from off mode (default) //#define B_TIMING_ON B_TIMEOUT_T //wait before coming on - prevents a blink when doing other actions (config, lock, etc.) but adds a delay to 1C -> on // NOTE: on from lockout is more complicated since there is no way to directly configure it. See `MOMENTARY_WHEN_LOCKED_DELAY` in next section. //#define DEFAULT_2C_STYLE 1 // 0: no turbo. 1: 2C always turbo. 2: 2C goes to top of ramp, or turbo if already at top //#define DEFAULT_2C_STYLE_SIMPLE 2 // same but for Simple UI. //#define USE_TACTICAL_MODE //enable tactical mode. See also TACTICAL_MODE_CLICK_EVENT //#define TACTICAL_LEVELS 150,(RAMP_SIZE+2),100 //set default tactical levels (max+1 = party strobe, max+2 = tactical strobe, etc...) //#undef USE_THERM_AUTOCALIBRATE //disable automatic thermal calibration on reset/first boot. Set this if you are going to calibrate your MCU's temperature directly and don't want anduril to change it. //#define RGB_LED_OFF_DEFAULT 0x27 //high, disco //#define RGB_LED_LOCKOUT_DEFAULT 0x18 //low, rainbow //0x00 = off Low High Blinking //R 0x10 0x20 0x30 //R+G 0x11 0x21 0x31 //G 0x12 0x22 0x32 //G+B 0x13 0x23 0x33 //B 0x14 0x24 0x34 //R+B 0x15 0x25 0x35 //R+G+B 0x16 0x26 0x36 //Disco 0x17 0x27 0x37 //Rainbow 0x18 0x28 0x38 //Voltage 0x19 0x29 0x39 //TODO: how is temperature set? this table works for both stock and modded AFAIK... :thonk: too much bit twiddling for one day. //voltage calibration //this 7 by default, value added to the measured voltage (e.g. 5 is 0.25V, 6 is 0.3V, 7 is 0.35V) before the //user's calibration setting from 7H from battcheck if any. By changing this, if you know your light's MCU is off by a bit this will allow calibration //to persist through reflashes and factory resets //#define VOLTAGE_PRECALIBRATION 7 //sets indicator LED mode, for non-RGB aux // //unmodded: //1: low, 2: high, 3: blinking (if TICK_DURING_STANDBY is set) //Format: ((lockout_mode <<2) + off_mode)) // //modded: //0: off 1: low 2: high //if TICK_DURING_STANDBY is set, 3: blinking 4: blinking low, 5: blinking high 6: breathing //Format: ((lockout_mode <<4) + off_mode) //e.g. for lockout low, off high: //#define INDICATOR_LED_DEFAULT_MODE ((1<<4) + 2) ``` ### Modded-only config TODO: redo this with multichannel. For now, check out my main development config: [cfg-siterelenby-emisar-2ch-aux](spaghetti-monster/cfg-siterelenby-emisar-2ch-aux.h), [my button mappings](spaghetti-monster/anduril/mod-config-siterelenby.h), and [stock-compatible mappings](spaghetti-monster/anduril/mod-config-defaults.h)

Example mod configs and prebuilt modded versions

Example configurations

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

Building your own modded version

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:

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:

example custom build target loading a mod-config and applying further customisations Example: ``` // include the base hwdef #include "cfg-emisar-2ch.h" // load default button mappings #include mod-config-defaults.h //make 4C previous channel instead of ramp -> lock #undef LOCK_FROM_ON_EVENT #define EVENT_PREVIOUS_CHANNEL EV_4clicks ```

At some point I might add support for a git submodule to load different popular user configs.

Roadmap

General disclaimer

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.

Builds and release

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.

Other stuff

Stuff that doesn't fit anywhere else

Git repo scripts

Build utilities

anduril-buildenv-docker

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

Changes

Scripts

Example 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)