User Tools

Site Tools


module:micropython:esp32displaykey:esp32displaykey

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
module:micropython:esp32displaykey:esp32displaykey [2021/12/25 14:11] – [Library-Module: Uart.py] omdevelopmodule: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: ZeitTIME_KEYREPETITION = 0.5   * minimale Zeit zur Erkennung von Tastenwiederholungen: ZeitTIME_KEYREPETITION = 0.5
   * 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 ===== 
-{{:module:micropython:Esp32DisplayKey:2112251329_Esp32DisplayKey_01V02.zip | 2112251329_Esp32DisplayKey_01V02.zip}} +{{:module:micropython:Esp32DisplayKey:2112251413_Esp32DisplayKey_01V03.zip | 2112251413_Esp32DisplayKey_01V03.zip}} 
  
 ===== Beschreibung ===== ===== Beschreibung =====
  
 +{{:module:micropython:Esp32DisplayKey:2112251421_Esp32DisplayKey_01V03.png?600|2112251421_Esp32DisplayKey_01V03.png}}
 ==== Ausgabe MicroPython-Terminal: Esp32CheckDisplayKey.py ==== ==== Ausgabe MicroPython-Terminal: Esp32CheckDisplayKey.py ====
   * Ausgabe der KeyCodes (mit Wiederholungen)   * Ausgabe der KeyCodes (mit Wiederholungen)
Line 670: Line 673:
 </code> </code>
  
-==== Library-Module: .py ==== +==== Library-Module: ThreadDisplay.py ====
-<code python> +
-</code> +
- +
-==== Library-Module: .py ==== +
-<code python> +
-</code> +
- +
-==== Library-Module: .py ====+
 <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, lcdisplay):
 +        self.LCDisplay = lcdisplay
 +        return
 +    #
 +    def Execute(self):
 +        return
 +    #
 +class CClear(CCommandDisplay):
 +    def __init__(self, lcdisplay):
 +        super(CClear, self).__init__(lcdisplay)
 +        return
 +    def Execute(self):
 +        self.LCDisplay.Clear()
 +        return
 +#
 +class CWrite(CCommandDisplay):
 +    def __init__(self, lcdisplay, row, col, text):
 +        super(CWrite, self).__init__(lcdisplay)
 +        self.Row = row
 +        self.Col = col
 +        self.Text = text
 +        return
 +    def Execute(self):
 +        self.LCDisplay.MoveTo(self.Row, self.Col)
 +        self.LCDisplay.PutText(self.Text)
 +        return
 +#
 +class CThreadDisplay(THR.CThread):
 +    #
 +    def __init__(self, i2cdisplay, lcdisplay):
 +        super(CThreadDisplay, self).__init__(self.OnStart, self.OnBusy, self.OnAbort, self.OnEnd)
 +        self.I2CDisplay = i2cdisplay
 +        self.LCDisplay = lcdisplay
 +        self.CommandList = []
 +        return
 +    #---------------------------------------------
 +    def OnStart(self, thread):
 +        return
 +    def OnBusy(self, thread):
 +        while (THR.stBusy == thread.State):
 +            self.Clear()
 +            Col = 0
 +            while (Col <= 19):
 +                self.Write(0, Col, ' Hello0')
 +                self.Write(1, Col, ' Hello1')
 +                self.Write(2, Col, ' Hello2')
 +                self.Write(3, Col, ' Hello3')
 +                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, thread):
 +        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, row, col, text))
 +        return
 +    #
 +#
 +#------------------------------------------------------------------------------------------
 +if ('__main__' == __name__):
 +    print('*** CheckEsp32DisplayKey: begin'   
 +    #
 +    I2CDisplay = machine.SoftI2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=2000000) 
 +    LCDisplay = LCD.CLCDisplayI2C(I2CDisplay, DEF.I2CADDRESS_LCDISPLAY_T, \
 +                                  DEF.LCDISPLAY_COUNT_ROWS, DEF.LCDISPLAY_COUNT_COLUMNS)
 +    TD = CThreadDisplay(I2CDisplay, LCDisplay)
 +    TD.Open()
 +    #
 +    time.sleep(10.0)
 +    #
 +    TD.Close()
 +    #
 +    print('*** CheckEsp32DisplayKey: end')
 +    #
 +#
 </code> </code>
  
Line 686: Line 782:
  
  
 +
 +==== 211225 : "echte" Parallelisierung ====
 +  * {{:module:micropython:Esp32DisplayKey:2112251329_Esp32DisplayKey_01V02.zip | 2112251329_Esp32DisplayKey_01V02.zip}} 
  
 ==== 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)