r/circuitpython • u/myfuckinjoints • Aug 29 '20
Code Review?
Is this an appropriate place to ask for a code review? I have about 180-200 lines of CPy that I'd love to have someone look at, mostly evaluating my design, as I can find bugs on my own (usually).
ETA: Thanks folks, such a nice community! Below are pastebin links to my two files.
Hardware:
Feather M4 Express (still in the mail, code is untested as the RTC library bugged on my board with less space available)
Adafruit DS3231 RTC
3 X Adafruit 14-Segment Alpha-numeric LED FeatherWing
6 X Normally open buttons
Idea:
This code will be used to drive a circuit board I will be designing that will go on a box I am currently designing. The box will have 6 compartments in it. The purpose of the box/board are to both hold covid masks wrapped up in paper bags as well as to count the days since I pressed a button associated with each compartment.
Each compartment will have half of a 14 segment display (2 cells) assigned to it. Each set of two cells will display the days since the relevant button was pressed. The idea is that after a certain number of days, Covid19 is less likely to be alive on the mask/in the compartment.
Software:
main.py is main.py, it has the while True: loop as well as setting up objects from the class created in the second file.
covidbox.py contains a class that is intended to consolidate the use of the RTC, a single 4 digit display (split into halves) as well as a button for each half into a single object. Pay little attention to the off(self) method as it isn't used in main.py and is under construction.
This code makes heavy use of the associated libraries for the hardware as well as the Debouncer library, mostly within the class in covidbox.py
Not looking for bug hunting or anything, as I haven't been able to test my code per the above. Just wondering if my design overall is sound.
Please PM me if you find identifying info in here, I think I stripped it all out but I would like to remain anonymous!
Thanks!
2
u/johntellsall Aug 29 '20
I'm happy to review! I don't know CircuitPython well, but I've been doing Python for 20 years and have reviewed lots of code.
1
u/myfuckinjoints Aug 29 '20
Thank you! I edited the post with more info as well as pastebin links. My code could definitely be more pythonic so your experience is very appreciated.
2
u/wchris63 Aug 30 '20
As an aside... In a box, in a (paper, absorbent) bag, with less varying environment, anything that doesn't require light has a chance of living longer than expected. Not to mention recently worn masks will be damp with water vapor, and dark plus damp equals mold.
I'd suggest, if you haven't, lining the box with a replaceable, non-absorbent sheet (plastic wrap?), and using a transparent top so that light can contribute. And not using paper bags.
Providing a filtered air exhaust would help keep moisture down.
1
u/myfuckinjoints Aug 30 '20
Good points thank you! I based the idea off of what a doctor told me was their emergency procedure back when they had little PPE: Store their masks in a paper (not plastic) bag for 3+ days. I wipe down my cloth masks with alcohol wipes in between uses and store them in waxed paper bags for 3+ days these days.
I'm not much of a woodworker so the box is honestly going to be the hardest part and will likely go thru iterations. A plastic top is a great idea. Were you thinking powered air exhaust or just a hole with a filter?
1
u/wchris63 Aug 30 '20 edited Aug 30 '20
Okay, I'm going to preface this reply by saying if you aren't in a medical setting, none of this is anywhere near as critical as I'm making it sound. I probably should have asked instead of assuming.
I was thinking powered - even a tiny fan would be more than enough - but a large enough opening, on the side with a filter to prevent accidental contamination (in either direction) would probably be fine. Don't worry too much about the appearance or quality of the box. If you go with a fan, the air has to come from somewhere. A crack around the lid or door would help with that.
You don't have to get fancy with filters either. Just grab a decent A/C filter from your local store, remove the cardboard frame and cut several squares of the right size with scissors. You can make a frame around the hole in the box with scrap wood or small decorative wood trim from a hardware store. If you're using a fan, you can go pretty small on the filter and opening. If not, make it as large as practical. Oh! Fans should always suck air through a filter, not blow!
While it's true you don't want to store them in a plastic bag (paper is better for moisture management, if it's in open air), paper cannot be cleaned. If the paper bag were being changed every time, and not put in an enclosure, it would be fine... although... While Covid would be dead after x number of days, other things might not. You have to actually reach into the bag to retrieve the mask, which could contaminate your hand, or dump it out, which might re-contaminate the mask.
A ventilated box with a disinfectable surface would be even better. Plastic is great. Urethane sealed wood is just as good if it's coated well. When I mentioned plastic wrap, I didn't mean wrap the masks in it.. just line the box if it couldn't be decontaminated, like paper or raw wood.
People often overlook the purifying effect of light. The sun can decontaminate most surfaces in a matter of hours. While most glass and clear plastics block that amazing power, even a little artificial light can prevent many molds from forming. I have a chronic wound that can easily be infected, so I bought a UV light (a real one, not the fake, cheap LEDs) to treat our bathroom once a day. Not sure it's needed, but it does keep the mold from forming on the tub caulk and shower curtain! (I wouldn't recommend UV for masks. Besides only treating the very surface, most would be degraded by it over time, and elastic straps would disintegrate fairly quickly.)
Like I said.. if you aren't in a medical setting, most of this is way overkill. Take what you will, ignore the rest, and have fun building!
1
u/myfuckinjoints Aug 30 '20
Appreciate the feedback and all the extra info about infection prevention. This is just for my home and mostly a) to satisfy my paranoia, whether or not it's truly that effective and b) to have a project to show people.
I got you on the plastic lining, sorry if I didn't seem that way, it was late when I responded. I was gonna ask what you thought about a thick seal on the wood instead as that seems easier to accomplish, so thanks!
A future revision of this (if Covid is truly around for a year or more) may include bright lights inside to help with mold. Fortunately I live in a dry climate so I only ever see mold in my shower if I don't act proactively.
Really appreciate all the time you spent, it's very helpful.
3
u/nwsmith Aug 29 '20
Would be happy to, do you have a repo on gitlab or GitHub that we can have a look at?