From 583854e37efde7f461e073e735a1736b02d28c70 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 17 Apr 2023 00:08:32 -0600 Subject: switched the rest of FSM + Anduril to use SPDX license headers instead of full GPL headers (or all too often, nothing at all) There are a few "FIXME" entries where I'm not sure about the correct copyright. --- spaghetti-monster/fsm-misc.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 9a10a9c..626ad43 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -1,25 +1,8 @@ -/* - * fsm-misc.c: Miscellaneous function for SpaghettiMonster. - * - * Copyright (C) 2017 Selene ToyKeeper - * - * 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 . - */ - -#ifndef FSM_MISC_C -#define FSM_MISC_C +// fsm-misc.c: Miscellaneous function for SpaghettiMonster. +// Copyright (C) 2017-2023 Selene ToyKeeper +// SPDX-License-Identifier: GPL-3.0-or-later +#pragma once #ifdef USE_DYNAMIC_UNDERCLOCKING void auto_clock_speed() { @@ -302,4 +285,3 @@ void reboot() { } #endif -#endif -- cgit v1.2.3 From e84d6a51cc3c52e95af1267f6013f3410de09484 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Wed, 26 Apr 2023 01:41:39 -0600 Subject: whitespace cleanup --- spaghetti-monster/fsm-misc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 626ad43..5a8a9fc 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -184,7 +184,7 @@ void button_led_set(uint8_t lvl) { break; #else - + case 0: // LED off BUTTON_LED_DDR &= 0xff ^ (1 << BUTTON_LED_PIN); BUTTON_LED_PUE &= 0xff ^ (1 << BUTTON_LED_PIN); @@ -214,7 +214,7 @@ void rgb_led_set(uint8_t value) { uint8_t lvl = (value >> (i<<1)) & 0x03; uint8_t pin = pins[i]; switch (lvl) { - + #ifdef AVRXMEGA3 // ATTINY816, 817, etc case 0: // LED off @@ -232,7 +232,7 @@ void rgb_led_set(uint8_t value) { break; #else - + case 0: // LED off AUXLED_RGB_DDR &= 0xff ^ (1 << pin); AUXLED_RGB_PUE &= 0xff ^ (1 << pin); @@ -248,8 +248,8 @@ void rgb_led_set(uint8_t value) { AUXLED_RGB_PUE |= (1 << pin); AUXLED_RGB_PORT |= (1 << pin); break; - - #endif // MCU type + + #endif // MCU type } } } -- cgit v1.2.3 From eee06ae626a90a2d05aca3a2255c313f3900ed98 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 29 Apr 2023 00:44:17 -0600 Subject: just a todo note for later --- spaghetti-monster/fsm-misc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 5a8a9fc..80652b3 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -33,6 +33,7 @@ uint8_t blink_digit(uint8_t num) { if (!num) { ontime = 8; num ++; } for (; num>0; num--) { + // TODO: allow setting a blink channel mode per build target set_level(BLINK_BRIGHTNESS); nice_delay_ms(ontime); set_level(0); -- cgit v1.2.3 From e8d7e8ea11696bb2cad60c309527d02f130f7687 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 2 May 2023 05:19:50 -0600 Subject: added ability to set channel mode for number readouts (batt check, temp check, version check) Press 3C in batt check mode to change the blink channel. Also fixed TS10 stepped ramp ceiling value. --- spaghetti-monster/fsm-misc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 80652b3..1c40b81 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -32,6 +32,11 @@ uint8_t blink_digit(uint8_t num) { uint8_t ontime = BLINK_SPEED * 2 / 12; if (!num) { ontime = 8; num ++; } + #ifdef BLINK_CHANNEL + uint8_t old_channel = CH_MODE; + set_channel_mode(BLINK_CHANNEL); + #endif + for (; num>0; num--) { // TODO: allow setting a blink channel mode per build target set_level(BLINK_BRIGHTNESS); @@ -39,6 +44,11 @@ uint8_t blink_digit(uint8_t num) { set_level(0); nice_delay_ms(BLINK_SPEED * 3 / 12); } + + #ifdef BLINK_CHANNEL + set_channel_mode(old_channel); + #endif + return nice_delay_ms(BLINK_SPEED * 8 / 12); } #endif -- cgit v1.2.3 From d12e533a547d95a3ac340d59aa0dd6f6765de3f5 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 2 May 2023 08:37:07 -0600 Subject: fixed bug: channel change could stick when activating a config menu from battcheck (the blink function changed the channel, then the config menu saved it, then the blink function restored it, then the config menu restored it to the value it saved, which was wrong) --- spaghetti-monster/fsm-misc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 1c40b81..dacca85 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -33,15 +33,29 @@ uint8_t blink_digit(uint8_t num) { if (!num) { ontime = 8; num ++; } #ifdef BLINK_CHANNEL + // channel is set per blink, to prevent issues + // if another mode interrupts us (like a config menu) uint8_t old_channel = CH_MODE; - set_channel_mode(BLINK_CHANNEL); #endif for (; num>0; num--) { // TODO: allow setting a blink channel mode per build target + #ifdef BLINK_CHANNEL + set_channel_mode(BLINK_CHANNEL); + #endif set_level(BLINK_BRIGHTNESS); + #ifdef BLINK_CHANNEL + CH_MODE = old_channel; + #endif nice_delay_ms(ontime); + + #ifdef BLINK_CHANNEL + set_channel_mode(BLINK_CHANNEL); + #endif set_level(0); + #ifdef BLINK_CHANNEL + CH_MODE = old_channel; + #endif nice_delay_ms(BLINK_SPEED * 3 / 12); } -- cgit v1.2.3 From d8f8f849076ab9be75451f20dbe52ab3907a1c01 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 30 May 2023 07:59:02 -0600 Subject: make sure blink_digit(0) uses the same timing as the rest of the UI (BLINK_ONCE_TIME) --- spaghetti-monster/fsm-misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index dacca85..0aeb7c3 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -30,7 +30,7 @@ uint8_t blink_digit(uint8_t num) { // "zero" digit gets a single short blink uint8_t ontime = BLINK_SPEED * 2 / 12; - if (!num) { ontime = 8; num ++; } + if (!num) { ontime = BLINK_ONCE_TIME; num ++; } #ifdef BLINK_CHANNEL // channel is set per blink, to prevent issues -- cgit v1.2.3 From 04a48e44b25d1c42dc26f837586a7503bb74b749 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 24 Aug 2023 17:08:01 -0600 Subject: added channel mode per strobe mode, and made FSM channel mode more flexible, and fixed issue in tactical mode where strobes wouldn't stop on button release --- spaghetti-monster/fsm-misc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 0aeb7c3..bc10ea1 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -35,7 +35,7 @@ uint8_t blink_digit(uint8_t num) { #ifdef BLINK_CHANNEL // channel is set per blink, to prevent issues // if another mode interrupts us (like a config menu) - uint8_t old_channel = CH_MODE; + uint8_t old_channel = channel_mode; #endif for (; num>0; num--) { @@ -45,7 +45,7 @@ uint8_t blink_digit(uint8_t num) { #endif set_level(BLINK_BRIGHTNESS); #ifdef BLINK_CHANNEL - CH_MODE = old_channel; + channel_mode = old_channel; #endif nice_delay_ms(ontime); @@ -54,7 +54,7 @@ uint8_t blink_digit(uint8_t num) { #endif set_level(0); #ifdef BLINK_CHANNEL - CH_MODE = old_channel; + channel_mode = old_channel; #endif nice_delay_ms(BLINK_SPEED * 3 / 12); } -- cgit v1.2.3