I’m working on integrating the Qwiic button (which I think is a great product idea) into a CircuitPython project. So I figured I’d create a CP module for it. I have the basics working, but from looking at the Arduino code, I have not been able to fully comprehend the pressed and clicked queues. I get that one writes a 1 to pop the queue, but that’s about all I have figured out. I don’t understand the _front and _back values, which I think are time ticks of some sort. Is there a reference sheet that explains the operation of these queues? Thanks.
I don’t know if this will help as I have done little with micro python, but I am trying to convert Arduino code to Python. What I have done so far is to use Thonny, Geany or Leafpad to open the Arduino code and first convert all the comments. This gets me reading the code. Then I bit by bit convert the statements to Python.
Also I do bit of short test programs to test a idea at a time before putting it all together. If you can you might try to convert to Python before going to circuit python so you don’t have to load it on anything.
Dale
Hi, thanks for that thought, much appreciated. I’m not translating the Arduino library method for method though; that’s not going to be very Pythonic. For example, several of the methods return a status code, whereas in Python one would generally expect a method to work or raise an exception.
My question is about how the queues function, which I haven’t been able to grasp from the code. Maybe further study will enlighten me, but I figure somebody must have the functional spec explaining what the hardware is doing. That’s what I am looking for.
It is interesting that you mentioned MicroPython. I have been thinking about that too. I started with CircuitPython because that’s what my project is based on, but an MP library would be similar. It depends on the differences between the CP and MP I2C object methods, which can’t be very much different.
I’m still not sure about how the queues are supposed to work, but I think I have the functionality I need working.
Anyone interested in a CircuitPython library for the Sparkfun Qwiic Button/Switch/Arcade products can find mine here: https://github.com/gmparis/CircuitPython_I2C_Button. Enjoy!
You may want to alter the i2c library to report a 0 or a 1 for a button press. a lot of the other scripts you might integrate things into have severe issues with text strings, but numerical values are much easier to work with due to the way that python likes to play with things.
I have been having a painful time of things getting it to play with a minipitft spi tft display.