Adsense HTML/JavaScript

Saturday, March 26, 2022

CircuitPython 7 on Seeed XIAO BLE Sense

TO install CircuitPython on XIAO BLE Sense, follow the page XIAO BLE with CircuitPython.

cpyX_info.py, get system info.
"""
CircuitPython 7 exercise run on XIAO BLE Sense,
get system info.
"""
import board
import sys
import os
import microcontroller
# ref:
# The entire table of ANSI color codes working in C:
# https://gist.github.com/RabaDabaDoba/145049536f815903c79944599c6f952a
class color:
   RED = '\033[1;31;48m'
   BLUE = '\033[1;34;48m'
   BLACK = '\033[1;30;48m'
   END = '\033[1;37;0m'

print(sys.implementation[0] + ' ' +
      str(sys.implementation[1][0]) +'.'+
      str(sys.implementation[1][1]) +'.'+
      str(sys.implementation[1][2]))
print("=====================================")
info = color.RED + \
       sys.implementation[0] + ' ' + \
       os.uname()[3] + color.END + '\n' + \
       'run on ' + color.BLUE + os.uname()[4] + color.END
print(info)
print("=====================================")
print("microcontroller.cpu.frequency:\t\t" + color.RED +
      str(microcontroller.cpu.frequency) + color.END + " Hz")
print("microcontroller.cpu.temperature:\t" + color.RED +
      str(microcontroller.cpu.temperature) + color.END + " C")
print("microcontroller.cpu.voltage:\t\t" + color.RED +
      str(microcontroller.cpu.voltage) + color.END + " V")
print()



cpyX_pins_name.py, list pins name.
"""CircuitPython Essentials Pin Map Script"""
import microcontroller
import board

board_pins = []
for pin in dir(microcontroller.pin):
    if isinstance(getattr(microcontroller.pin, pin), microcontroller.Pin):
        pins = []
        
        pins.append("microcontroller.{}".format(pin))
        pins.append('\t-')
        
        for alias in dir(board):
            if getattr(board, alias) is getattr(microcontroller.pin, pin):
                pins.append("board.{}\t".format(alias))
        if len(pins) > 0:
            board_pins.append(" ".join(pins))
for pins in sorted(board_pins):
    print(pins)


output:

microcontroller.P0_00 	-
microcontroller.P0_01 	-
microcontroller.P0_02 	- board.A0	 board.D0	
microcontroller.P0_03 	- board.A1	 board.D1	
microcontroller.P0_04 	- board.A4	 board.D4	 board.SDA	
microcontroller.P0_05 	- board.A5	 board.D5	 board.SCL	
microcontroller.P0_06 	- board.LED_BLUE	
microcontroller.P0_07 	- board.IMU_SDA	
microcontroller.P0_08 	-
microcontroller.P0_09 	- board.NFC1	
microcontroller.P0_10 	- board.NFC2	
microcontroller.P0_11 	- board.IMU_INT1	
microcontroller.P0_12 	-
microcontroller.P0_13 	-
microcontroller.P0_14 	- board.READ_BATT_ENABLE	
microcontroller.P0_15 	-
microcontroller.P0_16 	- board.PDM_DATA	
microcontroller.P0_17 	- board.CHARGE_STATUS	
microcontroller.P0_18 	-
microcontroller.P0_19 	-
microcontroller.P0_20 	-
microcontroller.P0_21 	-
microcontroller.P0_22 	-
microcontroller.P0_23 	-
microcontroller.P0_24 	-
microcontroller.P0_25 	-
microcontroller.P0_26 	- board.LED	 board.LED_RED	
microcontroller.P0_27 	- board.IMU_SCL	
microcontroller.P0_28 	- board.A2	 board.D2	
microcontroller.P0_29 	- board.A3	 board.D3	
microcontroller.P0_30 	- board.LED_GREEN	
microcontroller.P0_31 	- board.VBATT	
microcontroller.P1_00 	- board.PDM_CLK	
microcontroller.P1_01 	-
microcontroller.P1_02 	-
microcontroller.P1_03 	-
microcontroller.P1_04 	-
microcontroller.P1_05 	-
microcontroller.P1_06 	-
microcontroller.P1_07 	-
microcontroller.P1_08 	- board.IMU_PWR	
microcontroller.P1_09 	-
microcontroller.P1_10 	- board.MIC_PWR	
microcontroller.P1_11 	- board.D6	 board.TX	
microcontroller.P1_12 	- board.D7	 board.RX	
microcontroller.P1_13 	- board.D8	 board.SCK	
microcontroller.P1_14 	- board.D9	 board.MISO	
microcontroller.P1_15 	- board.D10	 board.MOSI






reference:

more exercise:
Seeed XIAO BLE Sense (nRF52840)/CircuitPython 7.2.3 display on SSD1306 I2C OLED
XIAO BLE Sense (nRF52840)/CircuitPython generate QR Code and display on SSD1306 I2C OLED
CircuitPython BLE UART between XIAO BLE Sense and ESP32-C3/S3

No comments:

Post a Comment