Here's the config for the TA-OTSM version. Now to someone who knows nothing about this stuff this might look pretty daunting, but to you TA, there's only a small hand full of new defines here. To that other person, they should start with the default and then ask themselves what they're trying to do.
Now color coded, red for new defines, blue for comments added only in this post.
#ifndef config_bistro_H
#define config_bistro_H
/*
* Firmware configuration header.
*
* Bistro configuration file for TA driver 2017, (C) Flintrock (FR).
* USES voltage divider and OTC.
*
* To work with tk-bistro and other compatible software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
* =========================================================================
* Settings to modify per driver
*/
/////////////// Choose a layout////////////////
//#define FET_7135_LAYOUT //FET+1
#define TRIPLEDOWN_LAYOUT //TA tripple
//#define NANJG105D_LAYOUT // biscotti/convoy/nanjg105D
//#define BLFA6_LAYOUT // BLFA6, FET+1, OTC and star3
//#define NANJG_LAYOUT // specify an I/O pin layout
//#define QUADRUPLEDOWN_LAYOUT // Yes, that right :)
//#define CUSTOM_LAYOUT // go define it for however you want to wire your driver.
//**** You can now easily customize layouts in fr-tk-attiny.h :
// choose the file that defines your modegruops (so we can easily keep more)
#define MODEGROUPS_H "modegroups/modegroups-TA-tripple-v1.3plus.h"
//#define MODEGROUPS_H "modegroups/modegroups-biscotti.h"
//#define MODEGROUPS_H "modegroups/modegroups-BLFA6.h"
/************************* Misc utility configs*************************************/
//#define VOLTAGE_CAL // builds a driver that just blinks ADC reading, set the VOLTAGE mode below.
//These are new but just for debugging
//#define STRIPPED // use for debugging, strips many features to make more space for debug compiler options or testing functions.
// customize it below
//#define OTSM_debug //may require STRIPPED to fit. //Will blink out number of wakes (see SLEEP_TIME_EXPONENT) on short clicks, before entering mode.
/************************************OFF-TIME CONFIGS**********************************/
#define OFFTIM3 // Use short/med/long off-time presses instead of just short/long
// #define USE_OTC // use off time cap.
// Off-time sleep mode by -FR, thanks to flashy Mike and Mike C for early feasibility test with similar methods.
#define USE_OTSM // USE OTSM. Pin must be defined in the layout too.
//#define OTSM_USES_OTC // use OTC cap for extra power on OTSM (sets it output high to charge up)
#define OTSM_powersave // Also works without OTSM to reduce moon-mode drain.
// Squeeze out a bit more off-time by saving power during
// shutoff detection (so at all times). Implements ms resolution (could be less) idle sleeps in place of delay.
// Seems to add at 0.5s of sleep at 3.1V 30uF cap, starting with only 0.75 that matters.
// But at higher voltages, it's still only 0.5s additional, not multiplicative.
// Also adds about 12 bytes that could be used for about two more mode groups instead :P
// Traditionally Cap values defined in tk-calibration
// But wake times in OTSM are not a calibration, just a configuration, so they go here.
// Times are in decimal seconds. short (med) wakes are <, not = to wake_time_short(med)
//I will probably just remove this one from view soon:
#define SLEEP_TIME_EXPONENT 4 // OTSM clicky sleep will be increments of 16ms*2^STE
// so 0 is 16, 1 is 32, 2 is 64, 3 is 128, 4 is 0.25s, 5 is 0.5s etc.
// To allow long click times use 4. For 1/8s resolution, use 3.
// (making these orange because they aren't exactly new, just better)
#define wake_time_short 0.5 // 0.5s : Short press is up to 0.5 s
#define wake_time_med 1.5 // this is limited by cap performance, but setting it high won't hurt
// Since anything beyond the cap capacity will be read as long anyway.
// It's also the long-press off-threshold for e-switch operation.
/*****************************END OTSM CONGIGS*********************************/
//#define USE_ESWITCH // pin must be defined in the layout too.
//#define USE_ESWITCH_LOCKOUT_TOGGLE
/**********************VOLTAGE CONFIG****************************************/
#define VOLTAGE_MON // Comment out to disable LVP
//You should leave one (but only one) of the next two uncommented.
#define READ_VOLTAGE_FROM_VCC // inverted "internal" Vcc voltage monitoring
// Works well for 1S lights without worrying about resistor values.
//#define READ_VOLTAGE_FROM_DIVIDER // classic voltage reading
//#define REFERENCE_DIVIDER_READS_TO_VCC // default is 1.1V, but this is needed for divider reading with OTSM on the voltage pin.
// This should normally be used with an LDO. For 1S (non-LDO or 5.0VLDO) just avoid the problem with READ_VOLTAGE_FROM_VCC.
/*** Enable battery indicator mode? */
#define USE_BATTCHECK
// Choose a battery indicator style
//#define BATTCHECK_4bars // up to 4 blinks
//#define BATTCHECK_8bars // up to 8 blinks
#define BATTCHECK_VpT // Volts + tenths
/******theremal protection: ***/
#define TEMPERATURE_MON // You can set starting temperature in the "maxtemp" setting in config options first boot options.
#define USE_TEMP_CAL // include a TEMP_CAL mode in the menu. // include a TEMP_CAL mode in the menu.
#define TEMP_STEP_DOWN //Requires TEMPERATURE_MON, Use step-down and tap-up instead of regulate/oscillate
/*******Mode features***********/
// these do nothing new, only save space for stuff you don't want, needed only for making things like biscotti builds.
#define USE_MUGGLE_MODE // compile in use of muggle mode
#define USE_REVERSE_MODES // compile in use of reverse modes
#define USE_MOON // compile in moon mode control
// Options for first bootup/default:
#define USE_FIRSTBOOT // FR notes this only costs two bytes since not using it implements alternative checks anyway.
#define INIT_MODEGROUP 11 // which mode group will be default, mode groups below start at zero, select the mode group you want and subtract one from the number to get it by defualt here
#define INIT_ENABLE_MOON 1 // Should we add moon to the set of modes?
#define INIT_REVERSE_MODES 0 // flip the mode order?
#define INIT_MEMORY 0 // mode memory, or not
#define INIT_OFFTIM3 1 // enable medium-press by default?
#define INIT_MUGGLE_MODE 0 // simple mode designed for mugglesotsm
#define INIT_LOCKSWITCH 0 // 0 => E-swtich enabled, 1 => locked.
#define INIT_MAXTEMP 88 // maximum temperature
#define BLINK_SPEED 750
// This is used to simplify the toggle function
// eliminating mode_override, using this threshold instead:
#define MINIMUM_OVERRIDE_MODE 245 // DO NOT EDIT. DO NOT DEFINE ANY STROBES HIGER OR EQUAL TO THIS.
/******* Select Which Strobes to compile in**** *********************/
////Must still be connected to a mode group or hidden mode to be used, enabled but unused modes don't get optimized out
#define BATTCHECK 244 // Convenience code for battery check mode
//mode codes for strobes, must be less than MINIMUM_OVERRIDE_MODE
#define BIKING_STROBE 243 // Single flash biking strobe mode
//#define FULL_BIKING_STROBE // Stutter bike strobe, uncomment to enable
//#define POLICE_STROBE 242 // Dual mode alternating strobe
//#define RANDOM_STROBE 241
//#define SOS 240
//#define STROBE_8HZ 239
#define STROBE_10HZ 238
#define STROBE_16HZ 237
#define STROBE_OLD_MOVIE 236
#define STROBE_CREEPY 235 // Creepy strobe mode, or really cool if you have a bunch of friends around
//#define RAMP 234 //Ramping "strobe"
//(Ok, these are new , but just for debugging, I should maybe just remove them)
#ifdef STRIPPED // define what you want to remove in stripped mode
#undef TEMPERATURE_MON
#undef VOLTAGE_MON
#define NO_STROBES // don't use strobes (not automatically stripped from modes though, probably will produce BLINK_BRIGHTNESS)
#undef USE_BATTCHECK
#endif
/**********************************************************************************
**********************END OF CONFIGURATION*****************************************
***********************************************************************************/
So if I clean out some of the debugging options, and maybe remove that confusing wake_time_exponent option, the only new things specifically relate to adding the new features, OTSM, ESWITCH, Voltage read options, and the new thermal control option. Not sure how that can be simpler, and it's I can't imagine how you can not call it more organized.
Here is the type of stuff that is no longer cluttering the configs section, because much of the include ordering requirements have been removed, and things like progmem of ramps automatically done as needed only for ramps actually defined.
uint8_t fast_presses __attribute__ ((section (".noinit")));
// total length of current mode group's array
uint8_t mode_cnt;
// number of regular non-hidden modes in current mode group
uint8_t solid_modes;
// number of hidden modes in the current mode group
// (hardcoded because both groups have the same hidden modes)
//uint8_t hidden_modes = NUM_HIDDEN; // this is never used
uint8_t modes[9 + sizeof(hiddenmodes)]; // make sure this is long enough...
// Modes (gets set when the light starts up based on saved config values)
PROGMEM const uint8_t ramp_7135[] = { RAMP_7135 };
PROGMEM const uint8_t ramp_7135s[] = { RAMP_7135s };
PROGMEM const uint8_t ramp_FET[] = { RAMP_FET };
This was cluttering the configs section before because the configs mixed programming and defines.
That's not a criticism, it's just evolved. I should really make the modegroups themselves a define too, and do the actual progmem later, becuase that still causes a little constraint like this:
#include <avr/pgmspace.h>
//#include <avr/io.h>
//#include <avr/interrupt.h>
#include <avr/eeprom.h>
#include <avr/sleep.h>
//#include <avr/power.h>
#include <string.h>
#define OWN_DELAY // Don't use stock delay functions.
#define USE_DELAY_S // Also use _delay_s(), not just _delay_ms()
#include "tk-delay.h"
#include "tk-voltage.h"
#ifdef RANDOM_STROBE
#include "tk-random.h"
#endif
and in the layout , all more (very hard to understand) stuff you no longer need to deal with:
#define CAP_CHANNEL 0x03 // MUX 03 corresponds with PB3 (Star 4)
#define CAP_DIDR ADC3D // Digital input disable bit corresponding with PB3
#define PWM_LVL OCR0B // OCR0B is the output compare register for PB1
#define ALT_PWM_PIN PB0 // pin 5, 1x7135 PWM
#define ALT_PWM_LVL OCR0A // OCR0A is the output compare register for PB0
#define FET_PWM_LVL OCR1B // output compare register for PB4
#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2
#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2
#define ADC_PRSCL 0x06 // clk/64
That's all moved out of the layout configuration area because the user only wants to select which pins to use.