pfw:togglealedwithsingletasto
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
| pfw:togglealedwithsingletasto [2025-06-21 22:12] – [Possible pitfalls with DUMP] mka | pfw:togglealedwithsingletasto [2025-06-22 00:20] (aktuell) – geöscht mka | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ===== Switch LED on and off in a button | ||
| - | Hier wird eine LED sauber an- und wieder aus geschaltet. | ||
| - | |||
| - | ==== Idea ==== | ||
| - | |||
| - | Als Modell diente der Taster, der auch schon in der Demo von tasto und clavis benutzt worden ist. Im Taster ist eine LED integriert. Die soll getoggle werden. | ||
| - | |||
| - | bild | ||
| - | |||
| - | |||
| - | ==== Implementation ==== | ||
| - | |||
| - | It's assumed that a program periodically checks whether the switch has been pressed and then changes the state of the LED. | ||
| - | |||
| - | The challenge is to eliminate switch bounce so that the user gets a smooth, reliable impression of the changes. The response should be fast enough to be instantaneous, | ||
| - | |||
| - | ==== Pseudo code for the toggleLED implementation ==== | ||
| - | |||
| - | //What [[en: | ||
| - | |||
| - | < | ||
| - | Function: init ( -- ) | ||
| - | do all initialisation for the intended operation | ||
| - | set variable ILED, set portpins ... | ||
| - | |||
| - | Function: toggleLED ( -- ) \ toggle LED in a button on and off | ||
| - | IF: edge detection tells button was pressed | ||
| - | toggle LED | ||
| - | turn off edge detection | ||
| - | IF: bottom finally has been released | ||
| - | turn on edge detection | ||
| - | </ | ||
| - | |||
| - | ==== Forth implementation of toggleLED ==== | ||
| - | |||
| - | |||
| - | <code forth> | ||
| - | |||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ==== Background information ==== | ||
| - | |||
| - | ==== Possible pitfalls ==== | ||
| - | |||
| - | |||
| - | ==== Contributions ==== | ||
| - | |||
| - | < | ||
| - | |||
| - | You have another approach to DUMP? | ||
| - | |||
| - | Please add it at the end of this document. | ||
| - | |||
| - | ~~DISCUSSION~~ | ||
pfw/togglealedwithsingletasto.1750536774.txt.gz · Zuletzt geändert: 2025-06-21 22:12 von mka