Smart single-button switch (Logic)

Oxygen Not Included733 views2 favorites4 min readby HECBETOBUpdated Aug 2, 2024View on Steam ↗

Introduction (Вступление)

Right off the bat! The goal was to create a simple one-button switch to save energy and avoid excessive heating in the area without using a visually unattractive and bulky motion sensor. I couldn’t find a ready-made solution. Maybe I didn’t search well enough, so if it exists and if it’s better than mine, please share it in the comments.

RU: Сразу главное! Целью было создание простейшего однокнопочного выключателя, дабы экономить энергию и не допускать избыточного нагрева области можно было не прибегая к услугам объективно уродливого и громоздкого датчика движения. Готового решения я не нашёл. Возможно плохо искал, потому, если оно существует и, если оно лучше моего, просьба поделиться в комментариях.

To avoid unnecessary questions, let me explain right away - I created this switch right before the release of an update that adds many automation elements, such as a counter, 4-bit buses, and others. However, they are not utilized in this circuit. Perhaps, based on those elements, a more elegant and, most importantly, more efficient logic can be developed. But even with the use of an extended toolkit, I still can’t come up with a way to avoid using timing, which is the main problem of this circuit - false triggering of short/long presses.

RU: Во избежание лишних вопросов, тут же поясню - данный выключатель я смастерил аккурат к выходу обновления, добавляющего множество элементов автоматизации, такие как счетчик, 4-битные шины и прочие, а потому они здесь никак не задействованы. Возможно, на их основе можно выстроить элегантную, а главное более эффективную логику, но я всё равно сходу не могу придумать, как даже с использованием расширенного инструментария обойтись без таймингов, в которых и кроется главная проблема этой схемы - ложные срабатывания короткого/продолжительного нажатия.


So, this is how it looks, so to speak, in the interior.
Вот так это выглядит, так сказать, в интерьере.

Logic (Логика)

The logic is elementary (so elementary that I spent several days trying to understand it, needlessly complicating it along the way) - we divide it into short (input) and long (output, delay associated with waiting for the duplicate to open the partition) button presses. We calculate the duration of the last duplicate’s stay in the restroom while allowing the lights to be turned off only after the last visitor presses the button.

RU: Логика элементарна (настолько элементарна, что я шёл к ней несколько дней, попутно неоправданно усложняя её) - разделяем короткое (на входе) и продолжительное (на выходе, задержка связана с ожиданием открытия перегородки дубликантом) нажатия на кнопку и отсчитываем таким образом время пребывания в (пардон) сортире последнего вошедшего дубликанта, допуская выключение света только после того, как на кнопке окажется последний посетитель.


It should be clear in the screenshot, but I’ll explain it in more detail. The next element after the button, the filter, is responsible for filtering the long press (in my case - 0.4s). It has two functions - sending signals to the input of the second memory element, which turns off the light through inversion, and resetting the first one, thus filtering only short presses. These short presses then pass through the buffer (11s) located between this filter and the reset of the second memory element, which initially turns on the light and prevents it from being turned off later. The second buffer (0.1s) is a non-functional element, a workaround that prevents the signal from passing in the reverse direction. Therefore, from the moment of the last short button press, there is a 12-second prohibition on turning off the lights (taking into account the delay on the filter). You can adjust the timings as you see fit. The configuration mentioned here, in my opinion, is the most resilient.

RU: Должно быть понятно и на скриншоте, но распишу подробнее. Следующий за кнопкой элемент, фильтр, отвечает именно за фильтрацию продолжительного нажатия (в моём случае - 0.4с), у него две функции - передавать сигналы на вход второго элемента памяти, выключающего через инверсию светильник и на сброс первого, отфильтровывая таким образом только короткие нажатия, которые в дальнейшем (через 1с, за это отвечает второй фильтр в схеме), поступают на буфер (11с) расположенный между этим фильтром и сбросом второго элемента памяти, который включает свет изначально и препятствует выключению в дальнейшем. Второй буфер (0.1с) - элемент не функциональный, это костыль, препятствующий прохождению сигнала в обратном направлении. Т.о. с момента последнего короткого нажатия на кнопку 12 секунд (с учетом задержки на фильтре) действует запрет на выключение света. Тайминги можно корректировать по своему усмотрению, указанная здесь конфигурация, на мой взгляд, является наиболее отказоустойчивой.

This guide was created by its original author on the Steam Community. Are you the author and want it removed? Request removal.