tomacorp / edgemicscope

AdaFruit EDGE badge microphone oscilloscope
MIT License
13 stars 1 forks source link

I'm pretty sure the increment/decrement functions had incorrect logic #1

Open RufusVS opened 3 years ago

RufusVS commented 3 years ago

Hi Tom, I ended up here following a CircuitPython issue you had on the Wingware forum. I don't have the badge hardware, but I like looking at other people's code for CircuitPython as I'm pretty new. However, when I was looking at your code, the increment and decrement functions looked incorrect. I don't know how much testing you did with it, but the way it handled the limits wouldn't work correctly. I copied the code and modified those routines and am attaching a copy of the modifications. Could you check them to see if you agree, and maybe you could update your code repository (if it matters to you after over a year). code.py.txt

tomacorp commented 3 years ago

Hi Rufus,

I think you are correct that the code doesn't look exactly right. I think the offset code already works as you suggest. For the offset, I was being careful to make the trace align with the display limit. The gain and sweep time units are arbitrary and I think maybe my code is equivalent to yours, except that the limits are off-by-one in my code, given that the increments are set to 1. Also with hardware, and the way I have defined the variables, the sign of increment/decrement is arbitrary. It would take some untangling to straighten it all out and get the variable names and limits to match the hardware and desired functionality. It does seem to 'work' although the limits might be broken. Testing is not real easy without my trusty Wingware debugger. I don't think I ever got WingWare working with CircuitPython. Have you been able to make WingWare do anything with CircuitPython?

The only testing I have done is to play with it as a toy. I wrote all of this during the 2019 Hack-A-Day Superconference and I have done very little with it since. I have worked a little on:

  1. Complaining/bug filing about how the screen refresh works. I think I am using a version of CircuitPython that has since been changed, and I don't think the display updates are as good any more for the way that I am using it.
  2. Added a connector to get the microphone bits out, to see if I could improve the low-pass filter.

I did set the board up as a lanyard and have worn it a few times at parties. Good conversation starter. Not a useful instrument, it is for entertainment.

I might try your code sometime. My badge is not in great shape. The adhesive that holds the display to the backlight has failed, maybe I will re-glue. But I recommend the board as a way to learn CircuitPython anyway. The Adafruit Discord chat channels are the best place to get help.

-Tom

On Fri, Apr 30, 2021 at 6:05 PM Rufus V. Smith @.***> wrote:

Hi Tom, I ended up here following a CircuitPython issue you had on the Wingware forum. I don't have the badge hardware, but I like looking at other people's code for CircuitPython as I'm pretty new. However, when I was looking at your code, the increment and decrement functions looked incorrect. I don't know how much testing you did with it, but the way it handled the limits wouldn't work correctly. I copied the code and modified those routines and am attaching a copy of the modifications. Could you check them to see if you agree, and maybe you could update your code repository (if it matters to you after over a year). code.py.txt https://github.com/tomacorp/edgemicscope/files/6408680/code.py.txt

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tomacorp/edgemicscope/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIBSBLVD52TNTN7KKRYTDDTLNHW7ANCNFSM435YDSTA .

RufusVS commented 3 years ago

Hi Tom,

On your current code, the adjustments probably moved or scaled properly, until you hit the limits in either direction.  That was the gist of my changes: the end limits weren't calculated correctly.

I just started working with CircuitPython, but quickly decided that using the Mu editor wasn't my cup of tea.  Great for beginners and learning environments, but awful when you want to get serious.  I'm hoping to at least be able to edit and save using Wing Pro, but I don't know how easy source-level debugging will be.

In fact, I quickly found out that CircuitPython doesn't support threading, and I can't use the serial port cleanly, because it is used for the REPL.   (I was hoping to use the NeoPixel as a status-light indicator for other programs running in the desktop or on, say, a Raspberry pi box.)  So I may have to go to MicroPython, or abandon Python programming altogether for the more hardcore programs.

If I do end up getting further with the Wing-CircuitPython interface I'll let you know!

Regards,

Rufus

On 5/1/2021 1:14 AM, Tom Anderson wrote:

Hi Rufus,

I think you are correct that the code doesn't look exactly right. I think the offset code already works as you suggest. For the offset, I was being careful to make the trace align with the display limit. The gain and sweep time units are arbitrary and I think maybe my code is equivalent to yours, except that the limits are off-by-one in my code, given that the increments are set to 1. Also with hardware, and the way I have defined the variables, the sign of increment/decrement is arbitrary. It would take some untangling to straighten it all out and get the variable names and limits to match the hardware and desired functionality. It does seem to 'work' although the limits might be broken. Testing is not real easy without my trusty Wingware debugger. I don't think I ever got WingWare working with CircuitPython. Have you been able to make WingWare do anything with CircuitPython?

The only testing I have done is to play with it as a toy. I wrote all of this during the 2019 Hack-A-Day Superconference and I have done very little with it since. I have worked a little on:

  1. Complaining/bug filing about how the screen refresh works. I think I am using a version of CircuitPython that has since been changed, and I don't think the display updates are as good any more for the way that I am using it.
  2. Added a connector to get the microphone bits out, to see if I could improve the low-pass filter.

I did set the board up as a lanyard and have worn it a few times at parties. Good conversation starter. Not a useful instrument, it is for entertainment.

I might try your code sometime. My badge is not in great shape. The adhesive that holds the display to the backlight has failed, maybe I will re-glue. But I recommend the board as a way to learn CircuitPython anyway. The Adafruit Discord chat channels are the best place to get help.

-Tom

On Fri, Apr 30, 2021 at 6:05 PM Rufus V. Smith @.***> wrote:

Hi Tom, I ended up here following a CircuitPython issue you had on the Wingware forum. I don't have the badge hardware, but I like looking at other people's code for CircuitPython as I'm pretty new. However, when I was looking at your code, the increment and decrement functions looked incorrect. I don't know how much testing you did with it, but the way it handled the limits wouldn't work correctly. I copied the code and modified those routines and am attaching a copy of the modifications. Could you check them to see if you agree, and maybe you could update your code repository (if it matters to you after over a year). code.py.txt https://github.com/tomacorp/edgemicscope/files/6408680/code.py.txt

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tomacorp/edgemicscope/issues/1, or unsubscribe

https://github.com/notifications/unsubscribe-auth/AAIBSBLVD52TNTN7KKRYTDDTLNHW7ANCNFSM435YDSTA .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tomacorp/edgemicscope/issues/1#issuecomment-830541232, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUO7GSKRIE7XARRGLA5WWTTLOE5FANCNFSM435YDSTA.

tomacorp commented 3 years ago

It is no problem to edit the code in Wing and then copy the file to the CircuitPython USB interface, which looks like a USB thumb drive.

Multithreaded code in firmware quickly goes beyond simple "big while loop" systems like CircuitPython and Arduino. It is better to use a real-time operating system such as FreeRTOS.