8.0.0-beta.6 on 2022-12-21 defaults

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
blakebr
 
Posts: 942
Joined: Tue Apr 17, 2012 6:23 pm

8.0.0-beta.6 on 2022-12-21 defaults

Post by blakebr »

Good Afternoon,

My code.py file has the following in it:

Code: Select all

# code.py selector
import time
import supervisor
import microcontroller

CODE = 'pin_scan.py'
time.sleep(1)
supervisor.set_next_code_file(CODE)
supervisor.reload() # Ctrl-C then Ctrl-D
pin_scan.py has the following in it:

Code: Select all

import time
import board
from   digitalio import *
All other code in both files is commented out with:

Code: Select all

'''
Stuff
'''
Ctrl-C gives me:
Adafruit CircuitPython 8.0.0-beta.6 on 2022-12-21; Raspberry Pi Pico W with rp2040
The RPi Pico W is mounted on a Maker Pi Pico Rev1.2 chassis.
After power has been removed and restored and the small bit of code(s) are run:
1) pins 6, 7, 8, 9, 15, 16, 17, 20, 21, 22 are shown as high by the LEDs on the chassis.
2) The LED on the Pico W flashes every 5 seconds.
3) If I set GPIO pins to a state other than the one in 1) they are returned to the state in 1) at the end of the code run.

Are there things in the OS or the supervisor code that would cause this behavior?

Bruce

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: 8.0.0-beta.6 on 2022-12-21 defaults

Post by danhalbert »

3. At the end of each virtual-machine run (when the CircuitPython program terminates), the pins are reset to floating.

1. Are your LEDs connected directly to the pins, or are the connected to some LED driver that might see floating as HIGH?
2. The LED flashing every 5 seconds means CircuitPython is running. If you do a reload your code. py is running over and over (and doing a reload each time).

User avatar
blakebr
 
Posts: 942
Joined: Tue Apr 17, 2012 6:23 pm

Re: 8.0.0-beta.6 on 2022-12-21 defaults

Post by blakebr »

Dan,

1) The Maker Pi Pico board may well have pull-up resistors on those pins on the board. Solved.

2) So code.py keeps looping in the background doing much of nothing but flashing the LED every 5 seconds. The code.py has instructions to run pin_scan.py but it does not do that. There are no instructions in code.py to flash the LED but it does that. There is nothing sent to REPL during this time. So CircuitPython just sits in the corner flashing the LED every 5 seconds waiting for a file read/write or a Ctrl-D from the keyboard. Is the flashing LED a new function of CircuitPython or one I have missed noticing for years.

I know that if I send a new file the code.py is re-interpreted/re-compiled then excited. If I hit Ctrl-D does CircuitPython re-interpret/re-compile or does it use what is already in the code buffer? Your answer may solve some behavior I have seen. Does CircuitPython do a pre-interpret and then process the tokenized result, or does it interpret the raw ASCII text as it goes along each time.

The behavior is: code.py runs and then loads pin_scan.py with supervisor.reload(). If I have not edited either file and pin_scan.py has focus. If I hit Ctrl-S while in the editor, pin_scan.py reruns not code.py.

Bruce

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: 8.0.0-beta.6 on 2022-12-21 defaults

Post by danhalbert »

blakebr wrote: Sun Jan 29, 2023 3:42 pm Dan,

1) The Maker Pi Pico board may well have pull-up resistors on those pins on the board. Solved.
Good. That makes sense.
2) So code.py keeps looping in the background doing much of nothing but flashing the LED every 5 seconds. The code.py has instructions to run pin_scan.py but it does not do that. There are no instructions in code.py to flash the LED but it does that. There is nothing sent to REPL during this time. So CircuitPython just sits in the corner flashing the LED every 5 seconds waiting for a file read/write or a Ctrl-D from the keyboard. Is the flashing LED a new function of CircuitPython or one I have missed noticing for years.
It has been this way since 7.0.0. It used to use a solid color or pulsing LED, but that used more power and was more distracting. Details of what the LED behavior: https://learn.adafruit.com/welcome-to-c ... ht-2978455
I know that if I send a new file the code.py is re-interpreted/re-compiled then excited. If I hit Ctrl-D does CircuitPython re-interpret/re-compile or does it use what is already in the code buffer? Your answer may solve some behavior I have seen. Does CircuitPython do a pre-interpret and then process the tokenized result, or does it interpret the raw ASCII text as it goes along each time.
Each time you do a soft-reload, it re"compiles" (converts to byte code) the text program.
The behavior is: code.py runs and then loads pin_scan.py with supervisor.reload(). If I have not edited either file and pin_scan.py has focus. If I hit Ctrl-S while in the editor, pin_scan.py reruns not code.py.
CircuitPython doesn't know what's going on the editor. All it knows is that some file changed. So it does an auto-reload. Your code.py runs, and then it forces a reload after specifying pin_scan.py should run next, so it runs pin_scan.py on the reload. If you put print statements at the top and bottom of code.py and pin_scan.py, I think what is happening will become clearer.

User avatar
danhalbert
 
Posts: 4613
Joined: Tue Aug 08, 2017 12:37 pm

Re: 8.0.0-beta.6 on 2022-12-21 defaults

Post by danhalbert »

The status indications do not monopolize the use of the RGB LED. If you use it yourself, with board.NEOPIXEL, etc., the status indications will not be shown.

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

Return to “Adafruit CircuitPython”