8encoder bug on cores3
-
There is a bug in 8encoder.
The method get_counter_value at line 68 throws an error when the encoder is left > 30 secs and a rotary encoder is turned
( image url)
not sure if it just happens with debugger attached
works fine when restarted until its next left a while then rotatedHere is my code
import os, sys, io
import M5
from M5 import *
from hardware import *
from unit import *label1 = None
title0 = None
label2 = None
label3 = None
label4 = None
label5 = None
label6 = None
label7 = None
label8 = None
label9 = None
label11 = None
label12 = None
label13 = None
label10 = None
label14 = None
label15 = None
label16 = None
label17 = None
label18 = None
label19 = None
label20 = None
label21 = None
label22 = None
label23 = None
label24 = None
label25 = None
label26 = None
label27 = None
label28 = None
i2c0 = None
encoder8_0 = NonebtnNo = None
btn = None
val = NoneDescribe this function...
def dosomething(btnNo):
global btn, val, label1, title0, label2, label3, label4, label5, label6, label7, label8, label9, label11, label12, label13, label10, label14, label15, label16, label17, label18, label19, label20, label21, label22, label23, label24, label25, label26, label27, label28, i2c0, encoder8_0
if btnNo == 1:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label11.setText(str((str(btn))))
label21.setText(str((str(val))))
if btnNo == 2:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label12.setText(str((str(btn))))
label22.setText(str((str(val))))
if btnNo == 3:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label13.setText(str((str(btn))))
label23.setText(str((str(val))))
if btnNo == 4:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label14.setText(str((str(btn))))
label24.setText(str((str(val))))
if btnNo == 5:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label15.setText(str((str(btn))))
label25.setText(str((str(val))))
if btnNo == 6:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label16.setText(str((str(btn))))
label26.setText(str((str(val))))
if btnNo == 7:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label17.setText(str((str(btn))))
label27.setText(str((str(val))))
if btnNo == 8:
btn = encoder8_0.get_button_status(btnNo)
val = encoder8_0.get_counter_value(btnNo)
label18.setText(str((str(btn))))
label28.setText(str((str(val))))def setup():
global label1, title0, label2, label3, label4, label5, label6, label7, label8, label9, label11, label12, label13, label10, label14, label15, label16, label17, label18, label19, label20, label21, label22, label23, label24, label25, label26, label27, label28, i2c0, encoder8_0, btn, btnNo, vali2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
encoder8_0 = ENCODER8(i2c0, 0x41)
M5.begin()
Widgets.fillScreen(0xffe834)
label1 = Widgets.Label("#1", 25, 50, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
title0 = Widgets.Title("Encoder Test", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18)
label2 = Widgets.Label("#2", 25, 69, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label3 = Widgets.Label("#3", 25, 92, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label4 = Widgets.Label("#4", 25, 116, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label5 = Widgets.Label("#5", 25, 141, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label6 = Widgets.Label("#6", 25, 166, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label7 = Widgets.Label("#7", 25, 189, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label8 = Widgets.Label("#8", 25, 215, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label9 = Widgets.Label("Btn", 24, 34, 1.0, 0x000008, 0xf1e68d, Widgets.FONTS.DejaVu12)
label11 = Widgets.Label("Text", 108, 50, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label12 = Widgets.Label("Text", 108, 68, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label13 = Widgets.Label("Text", 108, 95, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label10 = Widgets.Label("v1.0", 277, 1, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
label14 = Widgets.Label("Text", 108, 120, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label15 = Widgets.Label("Text", 108, 143, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label16 = Widgets.Label("Text", 108, 166, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label17 = Widgets.Label("Text", 108, 189, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label18 = Widgets.Label("Text", 108, 215, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label19 = Widgets.Label("Text", 365, -164, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
label20 = Widgets.Label("Text", 328, -105, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
label21 = Widgets.Label("Text", 181, 52, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label22 = Widgets.Label("Text", 181, 70, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label23 = Widgets.Label("Text", 181, 95, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label24 = Widgets.Label("Text", 181, 120, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label25 = Widgets.Label("Text", 180, 145, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label26 = Widgets.Label("Text", 180, 166, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label27 = Widgets.Label("Text", 180, 189, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)
label28 = Widgets.Label("Text", 180, 215, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu12)def loop():
global label1, title0, label2, label3, label4, label5, label6, label7, label8, label9, label11, label12, label13, label10, label14, label15, label16, label17, label18, label19, label20, label21, label22, label23, label24, label25, label26, label27, label28, i2c0, encoder8_0, btn, btnNo, val
M5.update()
dosomething(1)
dosomething(2)
dosomething(3)
dosomething(4)
dosomething(5)
dosomething(6)
dosomething(7)
dosomething(8)if name == 'main':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")Im using uiflow 2.0 alpha 19 with cores3