diff options
| author | Selene ToyKeeper | 2023-04-07 17:06:08 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-04-07 17:06:08 -0600 |
| commit | f4430bb7f2bcef62e6563f9c436b9a24d4482532 (patch) | |
| tree | fdf8d73cebe9193147c9922d5152df54f3171020 | |
| parent | added a "tactical mode" on "Off -> 6C" (diff) | |
| download | anduril-f4430bb7f2bcef62e6563f9c436b9a24d4482532.tar.gz anduril-f4430bb7f2bcef62e6563f9c436b9a24d4482532.tar.bz2 anduril-f4430bb7f2bcef62e6563f9c436b9a24d4482532.zip | |
merging gchart's changes, part 1...
+ added Sofirn LT1S Pro
+ added Sofirn SC21 Pro
+ added Wurkkos TS10
+ added Wurkkos TS25
* small changes to other models
* improved dual voltage support
+ added attiny1616 flashing python script w/ pymcuprog
These changes are incomplete. It does not yet include:
- extended simple UI
- t1616 WDT reset detection
- gchart's OUTPUT_MUX code (I plan to rewrite the entire tint system)
Diffstat (limited to '')
| -rw-r--r-- | bin/flash-1616.py | 76 | ||||
| -rw-r--r-- | hwdef-Sofirn_LT1S-Pro.h | 114 | ||||
| -rw-r--r-- | hwdef-Wurkkos_TS10.h | 117 | ||||
| -rw-r--r-- | hwdef-Wurkkos_TS25.h | 119 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/BRANDS | 1 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/MODELS | 4 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/aux-leds.c | 11 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h | 5 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.c | 22 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h | 90 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-sc21-pro.h | 10 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h | 6 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-wurkkos-ts10.h | 82 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/cfg-wurkkos-ts25.h | 78 |
14 files changed, 735 insertions, 0 deletions
diff --git a/bin/flash-1616.py b/bin/flash-1616.py new file mode 100644 index 0000000..6b3e2ee --- /dev/null +++ b/bin/flash-1616.py @@ -0,0 +1,76 @@ +# Use with Python3, make sure to have the pymcuprog module installed (via pip) + +# Read out the pymcuprog version +from pymcuprog.version import VERSION as pymcuprog_version +print("pymcuprog version {}".format(pymcuprog_version)) + + +# List out the available ports +import serial.tools.list_ports as ls; +#ports = ls.comports() +ports = [] +for p in ls.comports(): + if "COM" in p.device or "USB" in p.device: + ports.append(p) + +if len(ports) == 0: + print("No serial ports found, exiting") + exit() +elif len(ports) == 1: + print("Found one serial port:", ports[0].device, "-", ports[0].description) + port = ports[0].device +else: # found more than one serial port + print("Found multiple serial ports:") + for p in ports: + print(" *", p.device, "-", p.description) + print("Which serial port would you like to use? (default: " + ports[0].device + ") ", end="") + port = input() + if not port: + port = ports[0].device + + +import sys +args = sys.argv +if len(args) == 1: # only the program name, no arguements: ask for the hex file + print("Which hex file would you like to flash? ", end="") + hexfile = input() +else: + hexfile = args[1] + + +# pymcuprog uses the Python logging module +import logging +logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING) + +# Configure the session +from pymcuprog.backend import SessionConfig +sessionconfig = SessionConfig("attiny1616") + +# Instantiate Serial transport (only 1 tool connected) +from pymcuprog.toolconnection import ToolSerialConnection +transport = ToolSerialConnection(serialport=port) + +# Instantiate backend +from pymcuprog.backend import Backend +backend = Backend() + +# Connect to tool using transport +backend.connect_to_tool(transport) + +# Start the session +backend.start_session(sessionconfig) + +# Read the target device_id +device_id = backend.read_device_id() +print("Device ID is {0:06X}".format(int.from_bytes(device_id, byteorder="little"))) + +# Erase the device, write the hexfile, and verify the write +backend.erase() +print("Memories erased.") +print("Writing hex file to the device... ") +backend.write_hex_to_target(hexfile) +print("Writing complete.") +print("Verifying the write... ") +verify_status = backend.verify_hex(hexfile) +if verify_status is True: + print("Verification successful!")
\ No newline at end of file diff --git a/hwdef-Sofirn_LT1S-Pro.h b/hwdef-Sofirn_LT1S-Pro.h new file mode 100644 index 0000000..ce6ee3a --- /dev/null +++ b/hwdef-Sofirn_LT1S-Pro.h @@ -0,0 +1,114 @@ +#ifndef HWDEF_SOFIRN_LT1S_PRO_H +#define HWDEF_SOFIRN_LT1S_PRO_H + +/* BLF LT1S Pro driver layout using the Attiny1616 + +Driver pinout: + * eSwitch: PA5 + * Aux LED: PB5 + * WW PWM: PB0 (TCA0 WO0) + * CW PWM: PB1 (TCA0 WO1) + * Red PWM: PB2 (TCA0 WO2) + * Voltage: VCC + +*/ + + +#define LAYOUT_DEFINED + +#ifdef ATTINY +#undef ATTINY +#endif +#define ATTINY 1616 +#include <avr/io.h> + +#define PWM_CHANNELS 1 + +#ifndef SWITCH_PIN +#define SWITCH_PIN PIN5_bp +#define SWITCH_PORT VPORTA.IN +#define SWITCH_ISC_REG PORTA.PIN2CTRL +#define SWITCH_VECT PORTA_PORT_vect +#define SWITCH_INTFLG VPORTA.INTFLAGS +#endif + + +// usually PWM1_LVL would be a hardware register, but we need to abstract +// it out to a soft brightness value, in order to handle tint ramping +// (this allows smooth thermal regulation to work, and makes things +// otherwise simpler and easier) +uint8_t PWM1_LVL; + +// warm tint channel +#ifndef PWM1_PIN +#define PWM1_PIN PB0 // +#define TINT1_LVL TCA0.SINGLE.CMP0 // CMP1 is the output compare register for PB0 +#endif + +// cold tint channel +#ifndef PWM2_PIN +#define PWM2_PIN PB1 // +#define TINT2_LVL TCA0.SINGLE.CMP1 // CMP0 is the output compare register for PB1 +#endif + +// red channel +#ifndef PWM3_PIN +#define PWM3_PIN PB0 // +#define PWM3_LVL TCA0.SINGLE.CMP2 // CMP2 is the output compare register for PB2 +#endif + +// average drop across diode on this hardware +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + + +// lighted button +#ifndef AUXLED_PIN +#define AUXLED_PIN PIN5_bp +#define AUXLED_PORT PORTB +#endif + + +// with so many pins, doing this all with #ifdefs gets awkward... +// ... so just hardcode it in each hwdef file instead +inline void hwdef_setup() { + + // set up the system clock to run at 10 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm ); + + //VPORTA.DIR = ...; + VPORTB.DIR = PIN0_bm | PIN1_bm | PIN2_bm | PIN5_bm; // Outputs: Aux LED and PWMs + //VPORTC.DIR = ...; + + // enable pullups on the unused pins to reduce power + PORTA.PIN0CTRL = PORT_PULLUPEN_bm; + PORTA.PIN1CTRL = PORT_PULLUPEN_bm; + PORTA.PIN2CTRL = PORT_PULLUPEN_bm; + PORTA.PIN3CTRL = PORT_PULLUPEN_bm; + PORTA.PIN4CTRL = PORT_PULLUPEN_bm; + PORTA.PIN5CTRL = PORT_PULLUPEN_bm | PORT_ISC_BOTHEDGES_gc; // eSwitch + PORTA.PIN6CTRL = PORT_PULLUPEN_bm; + PORTA.PIN7CTRL = PORT_PULLUPEN_bm; + + //PORTB.PIN0CTRL = PORT_PULLUPEN_bm; // warm tint channel + //PORTB.PIN1CTRL = PORT_PULLUPEN_bm; // cold tint channel + //PORTB.PIN2CTRL = PORT_PULLUPEN_bm; // red LEDs + PORTB.PIN3CTRL = PORT_PULLUPEN_bm; + PORTB.PIN4CTRL = PORT_PULLUPEN_bm; + //PORTB.PIN5CTRL = PORT_PULLUPEN_bm; // Aux LED + + PORTC.PIN0CTRL = PORT_PULLUPEN_bm; + PORTC.PIN1CTRL = PORT_PULLUPEN_bm; + PORTC.PIN2CTRL = PORT_PULLUPEN_bm; + PORTC.PIN3CTRL = PORT_PULLUPEN_bm; + + // set up the PWM + // TODO: add references to MCU documentation + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_CMP2EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; + TCA0.SINGLE.PER = 255; + TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; +} + + +#endif diff --git a/hwdef-Wurkkos_TS10.h b/hwdef-Wurkkos_TS10.h new file mode 100644 index 0000000..6cfe050 --- /dev/null +++ b/hwdef-Wurkkos_TS10.h @@ -0,0 +1,117 @@ +#ifndef HWDEF_BLF_Q8_T1616_H +#define HWDEF_BLF_Q8_T1616_H + +/* BLF Q8 driver layout using the Attiny1616 + +Driver pinout: + * eSwitch: PA5 + * Aux LED: PB5 + * PWM FET: PB0 (TCA0 WO0) + * PWM 1x7135: PB1 (TCA0 WO1) + * Voltage: VCC + +*/ + + +#define LAYOUT_DEFINED + +#ifdef ATTINY +#undef ATTINY +#endif +#define ATTINY 1616 +#include <avr/io.h> + +#define PWM_CHANNELS 2 +#define PWM_BITS 16 +#define PWM_TOP 255 +#define USE_DYN_PWM + +#ifndef SWITCH_PIN +#define SWITCH_PIN PIN5_bp +#define SWITCH_PORT VPORTA.IN +#define SWITCH_ISC_REG PORTA.PIN2CTRL +#define SWITCH_VECT PORTA_PORT_vect +#define SWITCH_INTFLG VPORTA.INTFLAGS +#endif + + +// 7135 channel +#ifndef PWM1_PIN +#define PWM1_PIN PB1 // +#define PWM1_LVL TCA0.SINGLE.CMP1BUF // CMP1 is the output compare register for PB1 +#endif + +// FET channel +#ifndef PWM2_PIN +#define PWM2_PIN PB0 // +#define PWM2_LVL TCA0.SINGLE.CMP0BUF // CMP0 is the output compare register for PB0 +#endif + +// PWM parameters of both channels are tied together because they share a counter +#define PWM1_TOP TCA0.SINGLE.PERBUF // holds the TOP value for for variable-resolution PWM +// not necessary when double-buffered "BUF" registers are used +#define PWM1_CNT TCA0.SINGLE.CNT // for resetting phase after each TOP adjustment +#define PWM1_PHASE_RESET_OFF // force reset while shutting off +#define PWM1_PHASE_RESET_ON // force reset while turning on + +// average drop across diode on this hardware +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + + +// lighted button +#ifndef AUXLED_PIN +#define AUXLED_PIN PIN5_bp +#define AUXLED_PORT PORTB +#endif + + +// with so many pins, doing this all with #ifdefs gets awkward... +// ... so just hardcode it in each hwdef file instead +inline void hwdef_setup() { + + // set up the system clock to run at 10 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm ); + + //VPORTA.DIR = ...; + VPORTB.DIR = PIN0_bm | PIN1_bm | PIN5_bm; // Outputs: Aux LED and PWMs + //VPORTC.DIR = ...; + + // enable pullups on the unused pins to reduce power + PORTA.PIN0CTRL = PORT_PULLUPEN_bm; + PORTA.PIN1CTRL = PORT_PULLUPEN_bm; + PORTA.PIN2CTRL = PORT_PULLUPEN_bm; + PORTA.PIN3CTRL = PORT_PULLUPEN_bm; + PORTA.PIN4CTRL = PORT_PULLUPEN_bm; + PORTA.PIN5CTRL = PORT_PULLUPEN_bm | PORT_ISC_BOTHEDGES_gc; // eSwitch + PORTA.PIN6CTRL = PORT_PULLUPEN_bm; + PORTA.PIN7CTRL = PORT_PULLUPEN_bm; + + //PORTB.PIN0CTRL = PORT_PULLUPEN_bm; // FET channel + //PORTB.PIN1CTRL = PORT_PULLUPEN_bm; // 7135 channel + PORTB.PIN2CTRL = PORT_PULLUPEN_bm; + PORTB.PIN3CTRL = PORT_PULLUPEN_bm; + PORTB.PIN4CTRL = PORT_PULLUPEN_bm; + //PORTB.PIN5CTRL = PORT_PULLUPEN_bm; // Aux LED + + PORTC.PIN0CTRL = PORT_PULLUPEN_bm; + PORTC.PIN1CTRL = PORT_PULLUPEN_bm; + PORTC.PIN2CTRL = PORT_PULLUPEN_bm; + PORTC.PIN3CTRL = PORT_PULLUPEN_bm; + + // set up the PWM + // https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-16-17-DataSheet-DS40002204A.pdf + // PB0 is TCA0:WO0, use TCA_SINGLE_CMP0EN_bm + // PB1 is TCA0:WO1, use TCA_SINGLE_CMP1EN_bm + // PB2 is TCA0:WO2, use TCA_SINGLE_CMP2EN_bm + // For Fast (Single Slope) PWM use TCA_SINGLE_WGMODE_SINGLESLOPE_gc + // For Phase Correct (Dual Slope) PWM use TCA_SINGLE_WGMODE_DSBOTTOM_gc + // See the manual for other pins, clocks, configs, portmux, etc + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; + PWM1_TOP = PWM_TOP; + TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; +} + + +#endif diff --git a/hwdef-Wurkkos_TS25.h b/hwdef-Wurkkos_TS25.h new file mode 100644 index 0000000..cadd366 --- /dev/null +++ b/hwdef-Wurkkos_TS25.h @@ -0,0 +1,119 @@ +#ifndef HWDEF_WURKKOS_TS25_T1616_H +#define HWDEF_WURKKOS_TS25_T1616_H + +/* BLF Q8 driver layout using the Attiny1616 + +Driver pinout: + * eSwitch: PA5 + * PWM FET: PB0 (TCA0 WO0) + * PWM 1x7135: PB1 (TCA0 WO1) + * Voltage: VCC + * Aux Blue: PC1 + * Aux Red: PC2 + * Aux Green: PC3 + +*/ + + +#define LAYOUT_DEFINED + +#ifdef ATTINY +#undef ATTINY +#endif +#define ATTINY 1616 +#include <avr/io.h> + +#define PWM_CHANNELS 2 +#define PWM_BITS 16 +#define PWM_TOP 255 +#define USE_DYN_PWM + +#ifndef SWITCH_PIN +#define SWITCH_PIN PIN5_bp +#define SWITCH_PORT VPORTA.IN +#define SWITCH_ISC_REG PORTA.PIN2CTRL +#define SWITCH_VECT PORTA_PORT_vect +#define SWITCH_INTFLG VPORTA.INTFLAGS +#endif + + +// 7135 channel +#ifndef PWM1_PIN +#define PWM1_PIN PB1 // +#define PWM1_LVL TCA0.SINGLE.CMP1BUF // CMP1 is the output compare register for PB1 +#endif + +// FET channel +#ifndef PWM2_PIN +#define PWM2_PIN PB0 // +#define PWM2_LVL TCA0.SINGLE.CMP0BUF // CMP0 is the output compare register for PB0 +#endif + +// PWM parameters of both channels are tied together because they share a counter +#define PWM1_TOP TCA0.SINGLE.PERBUF // holds the TOP value for for variable-resolution PWM +// not necessary when double-buffered "BUF" registers are used +#define PWM1_CNT TCA0.SINGLE.CNT // for resetting phase after each TOP adjustment +#define PWM1_PHASE_RESET_OFF // force reset while shutting off +#define PWM1_PHASE_RESET_ON // force reset while turning on + +// average drop across diode on this hardware +#ifndef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V +#endif + + +// this driver allows for aux LEDs under the optic +#define AUXLED_B_PIN PIN1_bp // pin 1 +#define AUXLED_R_PIN PIN2_bp // pin 2 +#define AUXLED_G_PIN PIN3_bp // pin 3 +#define AUXLED_RGB_PORT PORTC // PORTA or PORTB or PORTC + + +// with so many pins, doing this all with #ifdefs gets awkward... +// ... so just hardcode it in each hwdef file instead +inline void hwdef_setup() { + + // set up the system clock to run at 10 MHz instead of the default 3.33 MHz + _PROTECTED_WRITE( CLKCTRL.MCLKCTRLB, CLKCTRL_PDIV_2X_gc | CLKCTRL_PEN_bm ); + + //VPORTA.DIR = ...; + VPORTB.DIR = PIN0_bm | PIN1_bm; // Outputs: PWMs + VPORTC.DIR = PIN1_bm | PIN2_bm | PIN3_bm; + + // enable pullups on the unused pins to reduce power + PORTA.PIN0CTRL = PORT_PULLUPEN_bm; + PORTA.PIN1CTRL = PORT_PULLUPEN_bm; + PORTA.PIN2CTRL = PORT_PULLUPEN_bm; + PORTA.PIN3CTRL = PORT_PULLUPEN_bm; + PORTA.PIN4CTRL = PORT_PULLUPEN_bm; + PORTA.PIN5CTRL = PORT_PULLUPEN_bm | PORT_ISC_BOTHEDGES_gc; // eSwitch + PORTA.PIN6CTRL = PORT_PULLUPEN_bm; + PORTA.PIN7CTRL = PORT_PULLUPEN_bm; + + //PORTB.PIN0CTRL = PORT_PULLUPEN_bm; // FET channel + //PORTB.PIN1CTRL = PORT_PULLUPEN_bm; // 7135 channel + PORTB.PIN2CTRL = PORT_PULLUPEN_bm; + PORTB.PIN3CTRL = PORT_PULLUPEN_bm; + PORTB.PIN4CTRL = PORT_PULLUPEN_bm; + PORTB.PIN5CTRL = PORT_PULLUPEN_bm; + + PORTC.PIN0CTRL = PORT_PULLUPEN_bm; + //PORTC.PIN1CTRL = PORT_PULLUPEN_bm; // RGB Aux + //PORTC.PIN2CTRL = PORT_PULLUPEN_bm; // RGB Aux + //PORTC.PIN3CTRL = PORT_PULLUPEN_bm; // RGB Aux + + // set up the PWM + // https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-16-17-DataSheet-DS40002204A.pdf + // PB0 is TCA0:WO0, use TCA_SINGLE_CMP0EN_bm + // PB1 is TCA0:WO1, use TCA_SINGLE_CMP1EN_bm + // PB2 is TCA0:WO2, use TCA_SINGLE_CMP2EN_bm + // For Fast (Single Slope) PWM use TCA_SINGLE_WGMODE_SINGLESLOPE_gc + // For Phase Correct (Dual Slope) PWM use TCA_SINGLE_WGMODE_DSBOTTOM_gc + // See the manual for other pins, clocks, configs, portmux, etc + TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP1EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; + PWM1_TOP = PWM_TOP; + TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; +} + + +#endif diff --git a/spaghetti-monster/anduril/BRANDS b/spaghetti-monster/anduril/BRANDS index 4e73002..059f311 100644 --- a/spaghetti-monster/anduril/BRANDS +++ b/spaghetti-monster/anduril/BRANDS @@ -7,4 +7,5 @@ Lumintop 0300 - 0399 Fireflies 0400 - 0499 Mateminco 0500 - 0599 Sofirn 0600 - 0699 +Wurkkos 0700 - 0799 gChart 1600 - 1699 diff --git a/spaghetti-monster/anduril/MODELS b/spaghetti-monster/anduril/MODELS index 3071b60..dfe1190 100644 --- a/spaghetti-monster/anduril/MODELS +++ b/spaghetti-monster/anduril/MODELS @@ -59,7 +59,11 @@ Model Name MCU 0614 sofirn-sp36-t1616 attiny1616 0621 blf-lantern attiny85 0622 blf-lantern-t1616 attiny1616 +0623 sofirn-lt1s-pro attiny1616 0631 sofirn-sp10-pro attiny1616 +0632 sofirn-sc21-pro attiny1616 +0714 wurkkos-ts10 attiny1616 +0715 wurkkos-ts25 attiny1616 1618 gchart-fet1-t1616 attiny1616 Duplicates: diff --git a/spaghetti-monster/anduril/aux-leds.c b/spaghetti-monster/anduril/aux-leds.c index a3b905e..bb184f9 100644 --- a/spaghetti-monster/anduril/aux-leds.c +++ b/spaghetti-monster/anduril/aux-leds.c @@ -27,14 +27,21 @@ void indicator_led_update(uint8_t mode, uint8_t tick) { //uint8_t volts = voltage; // save a few bytes by caching volatile value // turn off when battery is too low + #ifdef DUAL_VOLTAGE_FLOOR + if (((voltage < VOLTAGE_LOW) && (voltage > DUAL_VOLTAGE_FLOOR)) + || (voltage < DUAL_VOLTAGE_LOW_LOW)) { + #else if (voltage < VOLTAGE_LOW) { + #endif indicator_led(0); } //#ifdef USE_INDICATOR_LOW_BAT_WARNING + #ifndef DUAL_VOLTAGE_FLOOR // this isn't set up for dual-voltage lights like the Sofirn SP10 Pro // fast blink a warning when battery is low but not critical else if (voltage < VOLTAGE_RED) { indicator_led(mode & (((tick & 0b0010)>>1) - 3)); } + #endif //#endif // normal steady output, 0/1/2 = off / low / high else if ((mode & 0b00001111) < 3) { @@ -96,7 +103,11 @@ void rgb_led_update(uint8_t mode, uint8_t arg) { // turn off aux LEDs when battery is empty // (but if voltage==0, that means we just booted and don't know yet) uint8_t volts = voltage; // save a few bytes by caching volatile value + #ifdef DUAL_VOLTAGE_FLOOR + if ((volts) && (((voltage < VOLTAGE_LOW) && (voltage > DUAL_VOLTAGE_FLOOR)) || (voltage < DUAL_VOLTAGE_LOW_LOW))) { + #else if ((volts) && (volts < VOLTAGE_LOW)) { + #endif rgb_led_set(0); #ifdef USE_BUTTON_LED button_led_set(0); diff --git a/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h b/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h index c5b40e2..d7264a2 100644 --- a/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h +++ b/spaghetti-monster/anduril/cfg-mateminco-mt35-mini.h @@ -51,4 +51,9 @@ #define USE_SIMPLE_UI_RAMPING_TOGGLE // too big, turn off extra features +//#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_MODE diff --git a/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.c b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.c new file mode 100644 index 0000000..571bbdc --- /dev/null +++ b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.c @@ -0,0 +1,22 @@ +// this is inserted into fsm-ramping.c :: set_level() +// (it overrides part of the function, but not all of it) +uint8_t output_mux; // pre-define this variable since the overrides file gets included before the ramp-mode.h file +inline void set_level_override(uint8_t level) { + if (level == 0) { // off + TINT1_LVL = 0; // disable the first white channel + TINT2_LVL = 0; // disable the second white channel + PWM3_LVL = 0; // disable the red LEDs + } else { + level --; + + if (output_mux == 0) { // main white LEDs + PWM3_LVL = 0; // disable the red LEDs + PWM1_LVL = PWM_GET(pwm1_levels, level); // get the PWM value + update_tint(); // set the warm-cool level balance + } else { // red LEDs + TINT1_LVL = 0; // disable the first white channel + TINT2_LVL = 0; // disable the second white channel + PWM3_LVL = PWM_GET(pwm1_levels, level); // set the red LED PWM + } + } +}
\ No newline at end of file diff --git a/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h new file mode 100644 index 0000000..4e5993b --- /dev/null +++ b/spaghetti-monster/anduril/cfg-sofirn-lt1s-pro.h @@ -0,0 +1,90 @@ +// Sofirn LT1S Pro +#define MODEL_NUMBER "0623" +#include "hwdef-Sofirn_LT1S-Pro.h" +// ATTINY: 1616 +// this model requires some special code +#define OVERRIDES_FILE cfg-sofirn-lt1s-pro.c +#define OVERRIDE_SET_LEVEL +inline void set_level_override(uint8_t level); + +// uses 4C action while On to switch between white and red channels (overrides lockout action) +#define USE_OUTPUT_MUX + +// the button lights up +#define USE_INDICATOR_LED +// the button is visible while main LEDs are on +#define USE_INDICATOR_LED_WHILE_RAMPING +// off mode: high (1) +// lockout: blinking (3) +#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1) + +// the lantern has two PWM channels, but they drive different sets of emitters +// (one channel for warm emitters, one channel for cold) +// so enable a special ramping mode which changes tint instead of brightness +#define USE_TINT_RAMPING +// how much to increase total brightness at middle tint +// (0 = 100% brightness, 64 = 200% brightness) +#define TINT_RAMPING_CORRECTION 10 // 115% + +#ifdef RAMP_LENGTH +#undef RAMP_LENGTH +#endif + +// level_calc.py 1 150 7135 1 30 800 +#define RAMP_LENGTH 150 +#define PWM1_LEVELS 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,11,11,12,13,13,14,15,15,16,17,18,18,19,20,21,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,48,49,50,51,53,54,56,57,58,60,61,63,64,66,67,69,70,72,74,75,77,79,80,82,84,85,87,89,91,93,95,97,98,100,102,104,106,108,111,113,115,117,119,121,124,126,128,130,133,135,137,140,142,145,147,150,152,155,157,160,163,165,168,171,173,176,179,182,185,188,190,193,196,199,202,205,209,212,215,218,221,224,228,231,234,238,241,245,248,251,255 +#define MAX_1x7135 65 +#define HALFSPEED_LEVEL 256 // red LEDs use a QX7138 chip which has max PWM speed of 10 kHz, so never run faster than halfspeed +#define QUARTERSPEED_LEVEL 5 + +// the default of 26 looks a bit flat, so increase it +#define CANDLE_AMPLITUDE 40 + +// override default ramp style +#undef RAMP_STYLE +#define RAMP_STYLE 1 // 0 = smooth, 1 = stepped +// set floor and ceiling as far apart as possible +// because this lantern isn't overpowered +#define RAMP_SMOOTH_FLOOR 1 +#define RAMP_SMOOTH_CEIL 150 +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 5 + +// LT1S can handle heat well, so don't limit simple mode +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL +#define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS + +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + +// allow Aux Config and Strobe Modes in Simple UI +#define USE_EXTENDED_SIMPLE_UI + +// enable 2 click turbo (Anduril 1 style) +#define DEFAULT_2C_STYLE 1 + +#define USE_SOS_MODE +#define USE_SOS_MODE_IN_BLINKY_GROUP + +// the sensor (attiny) is nowhere near the emitters +// so thermal regulation can't work +#ifdef USE_THERMAL_REGULATION +#undef USE_THERMAL_REGULATION +#endif + +// don't blink while ramping +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif +#ifdef BLINK_AT_RAMP_FLOOR +#undef BLINK_AT_RAMP_FLOOR +#endif +#ifdef BLINK_AT_RAMP_CEIL +#undef BLINK_AT_RAMP_CEIL +#endif + +#ifndef USE_SOFT_FACTORY_RESET +#define USE_SOFT_FACTORY_RESET +#endif
\ No newline at end of file diff --git a/spaghetti-monster/anduril/cfg-sofirn-sc21-pro.h b/spaghetti-monster/anduril/cfg-sofirn-sc21-pro.h new file mode 100644 index 0000000..cee8172 --- /dev/null +++ b/spaghetti-monster/anduril/cfg-sofirn-sc21-pro.h @@ -0,0 +1,10 @@ +// Sofirn SC21 Pro - same setup as a Wurkkos TS10, but with the aux indicator on while ramping +#include "cfg-wurkkos-ts10.h" +#undef MODEL_NUMBER +#define MODEL_NUMBER "0632" +// ATTINY: 1616 + +// turn on the aux LED while main LED is on +#ifndef USE_INDICATOR_LED_WHILE_RAMPING +#define USE_INDICATOR_LED_WHILE_RAMPING +#endif diff --git a/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h b/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h index bcfc80e..c1f1ed8 100644 --- a/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h +++ b/spaghetti-monster/anduril/cfg-sofirn-sp10-pro.h @@ -3,7 +3,13 @@ #include "hwdef-Sofirn_SP10-Pro.h" // ATTINY: 1616 +// don't blink during the ramp or at the ceiling +#ifdef BLINK_AT_RAMP_MIDDLE #undef BLINK_AT_RAMP_MIDDLE +#endif +#ifdef BLINK_AT_RAMP_CEIL +#undef BLINK_AT_RAMP_CEIL +#endif #define USE_DYNAMIC_UNDERCLOCKING diff --git a/spaghetti-monster/anduril/cfg-wurkkos-ts10.h b/spaghetti-monster/anduril/cfg-wurkkos-ts10.h new file mode 100644 index 0000000..6f92abf --- /dev/null +++ b/spaghetti-monster/anduril/cfg-wurkkos-ts10.h @@ -0,0 +1,82 @@ +// Wurkkos TS10 (originally used Sofirn SP36-t1616 firmware) config options for Anduril using the Attiny1616 +// same as the BLF Q8 T1616, mostly (added Dynamic PWM) +#define MODEL_NUMBER "0714" +#include "hwdef-Wurkkos_TS10.h" +// ATTINY: 1616 + +// uses forward-facing aux LEDs +#define USE_INDICATOR_LED +// don't turn on the aux LEDs while main LEDs are on +#ifdef USE_INDICATOR_LED_WHILE_RAMPING +#undef USE_INDICATOR_LED_WHILE_RAMPING +#endif +// the high button LED mode on this light uses too much power, default to low +// off mode: low (1) +// lockout: blinking (3) +#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1) + +// voltage readings were a little high with the Q8 value +#undef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V, not 0.35V + +/* +// copied from Emisar D4 ramp +// ../../bin/level_calc.py 1 65 7135 1 0.8 150 +// ... mixed with this: +// ../../bin/level_calc.py 2 150 7135 4 0.33 150 FET 1 10 1500 +#define RAMP_LENGTH 150 +#define PWM1_LEVELS 1,1,2,2,3,3,4,4,5,6,7,8,9,10,12,13,14,15,17,19,20,22,24,26,29,31,34,36,39,42,45,48,51,55,59,62,66,70,75,79,84,89,93,99,104,110,115,121,127,134,140,147,154,161,168,176,184,192,200,209,217,226,236,245,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,0,0,0,0,0,0,0,0,1,3,4,5,7,8,9,11,12,14,15,17,19,20,22,24,25,27,29,31,33,35,37,39,41,43,45,48,50,52,55,57,59,62,64,67,70,72,75,78,81,84,87,90,93,96,99,102,105,109,112,115,119,122,126,129,133,137,141,144,148,152,156,160,165,169,173,177,182,186,191,195,200,205,209,214,219,224,229,234,239,244,250,255 +#define MAX_1x7135 65 +#define HALFSPEED_LEVEL 14 +#define QUARTERSPEED_LEVEL 5 +*/ +// level 1 by hand, for the rest +// level_calc.py 7.01 2 149 7135 3 0.5 125 FET 1 10 1200 --pwm dyn:63:2048:255 +#define RAMP_LENGTH 150 +#define USE_DYN_PWM +#define PWM1_LEVELS 1,3,3,4,5,6,7,8,9,10,12,13,14,16,17,19,20,22,24,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,64,67,70,72,75,77,80,82,85,87,89,91,93,95,96,98,99,100,100,101,100,100,99,97,95,93,90,86,82,87,91,96,100,106,111,116,122,128,134,141,147,155,162,169,177,186,194,203,213,222,232,243,254,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,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,1,3,4,6,7,9,11,12,14,16,18,20,22,24,27,29,31,34,37,39,42,45,48,51,54,57,61,64,68,72,75,79,83,88,92,97,101,106,111,116,121,126,132,138,144,150,156,162,169,176,183,190,197,205,213,221,229,237,246,255 +#define PWM_TOPS 2047,2047,1198,1322,1584,1676,1701,1691,1662,1622,1774,1703,1631,1692,1613,1639,1558,1564,1559,1478,1464,1444,1420,1392,1361,1329,1331,1293,1256,1246,1207,1192,1152,1133,1094,1074,1035,1013,991,954,932,897,875,842,820,790,760,731,704,678,646,622,593,566,534,510,478,452,423,393,364,338,310,280,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 +#define MAX_1x7135 90 +#define HALFSPEED_LEVEL 2 +#define QUARTERSPEED_LEVEL 2 + +#define RAMP_SMOOTH_FLOOR 1 +#define RAMP_SMOOTH_CEIL 120 +// 10 28 46 [65] 83 101 120 +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +// at Wurkkos's request, reduce the Simple UI ceiling a little bit +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL 144 +#define SIMPLE_UI_STEPS 5 + +// enable 2 click turbo (Anduril 1 style) +#define DEFAULT_2C_STYLE 1 + +// enable SOS in the blinkies group +#define USE_SOS_MODE +#define USE_SOS_MODE_IN_BLINKY_GROUP + +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + +// allow Aux Config and Strobe Modes in Simple UI +#define USE_EXTENDED_SIMPLE_UI + +// enable factory reset on 13H without loosening tailcap +#define USE_SOFT_FACTORY_RESET + +// stop panicking at ~55% power +#define THERM_FASTER_LEVEL 130 // throttle back faster when high + +// don't blink during the ramp or at the ceiling +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif +#ifdef BLINK_AT_RAMP_CEIL +#undef BLINK_AT_RAMP_CEIL +#endif
\ No newline at end of file diff --git a/spaghetti-monster/anduril/cfg-wurkkos-ts25.h b/spaghetti-monster/anduril/cfg-wurkkos-ts25.h new file mode 100644 index 0000000..a339cdb --- /dev/null +++ b/spaghetti-monster/anduril/cfg-wurkkos-ts25.h @@ -0,0 +1,78 @@ +// Wurkkos TS25, modelled after the TS10 but with RGB Aux +#define MODEL_NUMBER "0715" +#include "hwdef-Wurkkos_TS25.h" +// ATTINY: 1616 + +// this light has three aux LED channels: R, G, B +#define USE_AUX_RGB_LEDS + +// don't turn on the aux LEDs while main LEDs are on +#ifdef USE_INDICATOR_LED_WHILE_RAMPING +#undef USE_INDICATOR_LED_WHILE_RAMPING +#endif + +// voltage readings were a little high with the Q8 value +#undef VOLTAGE_FUDGE_FACTOR +#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V, not 0.35V + +/* +// copied from Emisar D4 ramp +// ../../bin/level_calc.py 1 65 7135 1 0.8 150 +// ... mixed with this: +// ../../bin/level_calc.py 2 150 7135 4 0.33 150 FET 1 10 1500 +#define RAMP_LENGTH 150 +#define PWM1_LEVELS 1,1,2,2,3,3,4,4,5,6,7,8,9,10,12,13,14,15,17,19,20,22,24,26,29,31,34,36,39,42,45,48,51,55,59,62,66,70,75,79,84,89,93,99,104,110,115,121,127,134,140,147,154,161,168,176,184,192,200,209,217,226,236,245,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,0,0,0,0,0,0,0,0,1,3,4,5,7,8,9,11,12,14,15,17,19,20,22,24,25,27,29,31,33,35,37,39,41,43,45,48,50,52,55,57,59,62,64,67,70,72,75,78,81,84,87,90,93,96,99,102,105,109,112,115,119,122,126,129,133,137,141,144,148,152,156,160,165,169,173,177,182,186,191,195,200,205,209,214,219,224,229,234,239,244,250,255 +#define MAX_1x7135 65 +#define HALFSPEED_LEVEL 14 +#define QUARTERSPEED_LEVEL 5 +*/ +// level 1 by hand, for the rest +// level_calc.py 7.01 2 149 7135 3 0.5 125 FET 1 10 1200 --pwm dyn:63:2048:255 +#define RAMP_LENGTH 150 +#define USE_DYN_PWM +#define PWM1_LEVELS 1,3,3,4,5,6,7,8,9,10,12,13,14,16,17,19,20,22,24,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,64,67,70,72,75,77,80,82,85,87,89,91,93,95,96,98,99,100,100,101,100,100,99,97,95,93,90,86,82,87,91,96,100,106,111,116,122,128,134,141,147,155,162,169,177,186,194,203,213,222,232,243,254,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,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,1,3,4,6,7,9,11,12,14,16,18,20,22,24,27,29,31,34,37,39,42,45,48,51,54,57,61,64,68,72,75,79,83,88,92,97,101,106,111,116,121,126,132,138,144,150,156,162,169,176,183,190,197,205,213,221,229,237,246,255 +#define PWM_TOPS 2047,2047,1198,1322,1584,1676,1701,1691,1662,1622,1774,1703,1631,1692,1613,1639,1558,1564,1559,1478,1464,1444,1420,1392,1361,1329,1331,1293,1256,1246,1207,1192,1152,1133,1094,1074,1035,1013,991,954,932,897,875,842,820,790,760,731,704,678,646,622,593,566,534,510,478,452,423,393,364,338,310,280,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 +#define MAX_1x7135 90 +#define HALFSPEED_LEVEL 2 +#define QUARTERSPEED_LEVEL 2 + +#define RAMP_SMOOTH_FLOOR 1 +#define RAMP_SMOOTH_CEIL 120 +// 10 28 46 [65] 83 101 120 +#define RAMP_DISCRETE_FLOOR 10 +#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL +#define RAMP_DISCRETE_STEPS 7 + +// at Wurkkos's request, reduce the Simple UI ceiling a little bit +#define SIMPLE_UI_FLOOR RAMP_DISCRETE_FLOOR +#define SIMPLE_UI_CEIL 135 +#define SIMPLE_UI_STEPS 5 + +// enable 2 click turbo (Anduril 1 style) +#define DEFAULT_2C_STYLE 1 + +// enable SOS in the blinkies group +#define USE_SOS_MODE +#define USE_SOS_MODE_IN_BLINKY_GROUP + +// Allow 3C in Simple UI for switching between smooth and stepped ramping +#define USE_SIMPLE_UI_RAMPING_TOGGLE + +// allow Aux Config and Strobe Modes in Simple UI +#define USE_EXTENDED_SIMPLE_UI + +// enable factory reset on 13H without loosening tailcap +#define USE_SOFT_FACTORY_RESET + +// stop panicking at ~55% power +#define THERM_FASTER_LEVEL 130 // throttle back faster when high + +// don't blink during the ramp or at the ceiling +#ifdef BLINK_AT_RAMP_MIDDLE +#undef BLINK_AT_RAMP_MIDDLE +#endif +#ifdef BLINK_AT_RAMP_CEIL +#undef BLINK_AT_RAMP_CEIL +#endif
\ No newline at end of file |
