module:micropython:esp32displaykey:esp32displaykey
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
module:micropython:esp32displaykey:esp32displaykey [2021/12/25 14:11] – [Library-Module: Uart.py] omdevelop | module:micropython:esp32displaykey:esp32displaykey [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 18: | Line 18: | ||
* minimale Zeit zur Erkennung von Tastenwiederholungen: | * minimale Zeit zur Erkennung von Tastenwiederholungen: | ||
* Eigener Thread mit permanenter Tastatur-Abfrage | * Eigener Thread mit permanenter Tastatur-Abfrage | ||
+ | * Entprellung über TIME_KEYPRESSES | ||
+ | * Tasten-Wiederholung über TIME_KEYREPETITION | ||
* MainLoop: periodische Abfrage GetKeyCode() | * MainLoop: periodische Abfrage GetKeyCode() | ||
* Keys beim IT01: | * Keys beim IT01: | ||
Line 42: | Line 44: | ||
===== Version ===== | ===== Version ===== | ||
- | {{: | + | {{: |
===== Beschreibung ===== | ===== Beschreibung ===== | ||
+ | {{: | ||
==== Ausgabe MicroPython-Terminal: | ==== Ausgabe MicroPython-Terminal: | ||
* Ausgabe der KeyCodes (mit Wiederholungen) | * Ausgabe der KeyCodes (mit Wiederholungen) | ||
Line 670: | Line 673: | ||
</ | </ | ||
- | ==== Library-Module: | + | ==== Library-Module: |
- | <code python> | + | |
- | </ | + | |
- | + | ||
- | ==== Library-Module: | + | |
- | <code python> | + | |
- | </ | + | |
- | + | ||
- | ==== Library-Module: | + | |
<code python> | <code python> | ||
+ | # | ||
+ | import machine | ||
+ | import time | ||
+ | # | ||
+ | import Define as DEF | ||
+ | import Thread as THR | ||
+ | import LCDisplayI2C as LCD | ||
+ | # | ||
+ | class CCommandDisplay(): | ||
+ | def __init__(self, | ||
+ | self.LCDisplay = lcdisplay | ||
+ | return | ||
+ | # | ||
+ | def Execute(self): | ||
+ | return | ||
+ | # | ||
+ | class CClear(CCommandDisplay): | ||
+ | def __init__(self, | ||
+ | super(CClear, | ||
+ | return | ||
+ | def Execute(self): | ||
+ | self.LCDisplay.Clear() | ||
+ | return | ||
+ | # | ||
+ | class CWrite(CCommandDisplay): | ||
+ | def __init__(self, | ||
+ | super(CWrite, | ||
+ | self.Row = row | ||
+ | self.Col = col | ||
+ | self.Text = text | ||
+ | return | ||
+ | def Execute(self): | ||
+ | self.LCDisplay.MoveTo(self.Row, | ||
+ | self.LCDisplay.PutText(self.Text) | ||
+ | return | ||
+ | # | ||
+ | class CThreadDisplay(THR.CThread): | ||
+ | # | ||
+ | def __init__(self, | ||
+ | super(CThreadDisplay, | ||
+ | self.I2CDisplay = i2cdisplay | ||
+ | self.LCDisplay = lcdisplay | ||
+ | self.CommandList = [] | ||
+ | return | ||
+ | # | ||
+ | def OnStart(self, | ||
+ | return | ||
+ | def OnBusy(self, | ||
+ | while (THR.stBusy == thread.State): | ||
+ | self.Clear() | ||
+ | Col = 0 | ||
+ | while (Col <= 19): | ||
+ | self.Write(0, | ||
+ | self.Write(1, | ||
+ | self.Write(2, | ||
+ | self.Write(3, | ||
+ | while (0 < len(self.CommandList)): | ||
+ | Command = self.CommandList.pop(0) | ||
+ | Command.Execute() | ||
+ | time.sleep(0.5) | ||
+ | Col += 1 | ||
+ | if (THR.stBusy != thread.State): | ||
+ | break | ||
+ | return | ||
+ | def OnAbort(self, | ||
+ | return | ||
+ | def OnEnd(self, thread): | ||
+ | return | ||
+ | # | ||
+ | def Open(self): | ||
+ | self.Start() | ||
+ | return | ||
+ | def Close(self): | ||
+ | self.Abort() | ||
+ | return | ||
+ | # | ||
+ | def Clear(self): | ||
+ | self.CommandList.append(CClear(self.LCDisplay)) | ||
+ | return | ||
+ | def Write(self, row, col, text): | ||
+ | self.CommandList.append(CWrite(self.LCDisplay, | ||
+ | return | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | if (' | ||
+ | print(' | ||
+ | # | ||
+ | I2CDisplay = machine.SoftI2C(scl=machine.Pin(22), | ||
+ | LCDisplay = LCD.CLCDisplayI2C(I2CDisplay, | ||
+ | DEF.LCDISPLAY_COUNT_ROWS, | ||
+ | TD = CThreadDisplay(I2CDisplay, | ||
+ | TD.Open() | ||
+ | # | ||
+ | time.sleep(10.0) | ||
+ | # | ||
+ | TD.Close() | ||
+ | # | ||
+ | print(' | ||
+ | # | ||
+ | # | ||
</ | </ | ||
Line 686: | Line 782: | ||
+ | |||
+ | ==== 211225 : " | ||
+ | * {{: | ||
==== 211224 : Versuch zur Thread-Entkopplung ==== | ==== 211224 : Versuch zur Thread-Entkopplung ==== |
module/micropython/esp32displaykey/esp32displaykey.1640437864.txt.gz · Last modified: 2021/12/25 15:11 (external edit)