buzzing mindfulness bracelet code plus some new functions

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Yes, that could be a problem.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

I think I found a way to code the pin.alarm, but wanted to use board.SWITCH (the feather extra onboard tactile button) as my pin.
However that same SWITCH is also used to trigger a write action, but only in very short time windows.
I am getting a “pin already in use” error when I load the code.
Is it because it cannot be used for two purposes like this?
If so, is there any workaround?
Thanks!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

You can't create more than one DigitalInOut for a single pin. Can't you reuse the DigitalInOut?

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

If I understood correctly, you are suggesting that instead of using "board.SWITCH" as argument of the pin_alarm function (forgive my argument/function terminology, which might be improper), I use the keyword that I have already associated with board.SWITCH as DigitalInOut.
So that would be "pulsante":

Code: Select all

pulsante = DigitalInOut(board.SWITCH)
pulsante.direction = Direction.INPUT
pulsante.pull = Pull.UP
And in that case I should write the pin_alarm as follows:

Code: Select all

pin_alarm = alarm.pin.PinAlarm(pin=pulsante, value=False, pull=True)
I tried to do this and got an error message "pin expected" referring to the pin_alarm line.
Did I misunderstand something?

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Yeah, that expects a Pin object, i.e. board.SWITCH in this case.

So you'll have to get rid of the other use. I'm not sure how just yet.

Dave

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Got it. Use

Code: Select all

pulsante.deinit()
That will free the Pin object (i.e. board.SWITCH) so you can then pass it to alarm.pin.PinAlarm.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

Should I just put

Code: Select all

pulsante.deinit()
right before

Code: Select all

pin_alarm = alarm.pin.PinAlarm(pin=pulsante, value=False, pull=True)
?

If so, would it retain the other use I am making of pulsante in the rest of the code?

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

You would need to do

Code: Select all

pin_alarm = alarm.pin.PinAlarm(pin=board.SWITCH, value=False, pull=True)
If you wanted to use board.SWITCH again for pulsante ... I don't see something like deinit for PinAlarm. You might not be able to use the same pin for each. That wouldn't be overly surprising.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

Update: I avoided the problem by removing completely the light sleep from the code, so I don’t need to use the pin.alarm.
I still get about 36 hours of battery life on my 350mah cell.
I’m pretty happy with how it works now!
I have been wondering for a while about trying to streamline the project to produce higher numbers and try to market it. Of course is more of a fantasy right now but should I manage to do it, could I still exploit the glider app for free or would I have to pay some rights to Adafruit?

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

"glider app"?

Dave


User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

It's in a public github repo https://github.com/adafruit/Glider-for-iOS. I don't see any licensing information but it is public and there are a couple forks so I'd say it's fair game.

That said, I'll ask to be sure.

Dave

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

The MIT license will be added to the project:
Copyright <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, BANNED FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

Cool! I understand it means the app can be used without any restriction provided the license is included.
You guys really do a great work!
Thanks Dave

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Used, redistributed, modified, etc. The MIT license is pretty open. Just inlude the license with the original copyright notice.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”