Angle8 Unit
UNIT 8Angle is an input unit integrating 8 adjustable potentiometers, internal STM32F030 microcomputer as acquisition and communication processor, and the host computer adopts I2C communication interface, each adjustable potentiometer corresponds to 1 RGB LED light, and there is also a physical toggle switch and its corresponding RGB LED light, containing 5V->3V3 DCDC circuit.
Support the following products:
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import * 9from unit import Angle8Unit 10import m5utils 11import time 12 13 14title0 = None 15label0 = None 16label1 = None 17label2 = None 18i2c0 = None 19angle8_0 = None 20 21 22import math 23 24map_value = None 25 26 27def setup(): 28 global title0, label0, label1, label2, i2c0, angle8_0, map_value 29 30 M5.begin() 31 Widgets.fillScreen(0x222222) 32 title0 = Widgets.Title( 33 "8AngleUnit CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18 34 ) 35 label0 = Widgets.Label("label0", 0, 58, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 36 label1 = Widgets.Label("label1", 0, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 37 label2 = Widgets.Label("label2", 0, 160, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 38 39 i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000) 40 angle8_0 = Angle8Unit(i2c0, 0x43) 41 angle8_0.set_led_rgb_from(1, 9, 0x33FF33, 100, 0) 42 map_value = 0 43 44 45def loop(): 46 global title0, label0, label1, label2, i2c0, angle8_0, map_value 47 M5.update() 48 map_value = round(m5utils.remap(angle8_0.get_adc8_raw(8), 0, 255, 0, 100)) 49 label0.setText(str((str("Switch:") + str((angle8_0.get_switch_status()))))) 50 label1.setText(str((str("CH1 8bit:") + str((angle8_0.get_adc8_raw(1)))))) 51 label2.setText(str((str("CH8 map value:") + str(map_value)))) 52 angle8_0.set_led_rgb_from(1, 9, 0x33FF33, map_value, 0) 53 time.sleep(1) 54 55 56if __name__ == "__main__": 57 try: 58 setup() 59 while True: 60 loop() 61 except (Exception, KeyboardInterrupt) as e: 62 try: 63 from utility import print_error_msg 64 65 print_error_msg(e) 66 except ImportError: 67 print("please update to latest firmware")
UIFLOW2 Example:
angle8unit_cores3_example.m5f2
class Angle8Unit
Constructors
Methods
- Angle8Unit.available()
Check if the device is available on the I2C bus.
- Angle8Unit.get_adc12_raw(channel)
Get the raw 12-bit ADC value from the specified channel.
- Parameters:
channel (int) – The channel number (1 to 8).
UIFLOW2:
- Angle8Unit.get_adc8_raw(channel)
Get the raw 8-bit ADC value from the specified channel.
- Parameters:
channel (int) – The channel number (1 to 8).
UIFLOW2:
- Angle8Unit.get_switch_status()
Get the status of the switch button.
UIFLOW2:
- Angle8Unit.set_led_rgb(channel, rgb, bright)
Set the RGB color and brightness of the specified LED channel.
- Parameters:
UIFLOW2:
- Angle8Unit.set_led_rgb_from(begin, end, rgb, bright, per_delay)
Set the RGB color and brightness for a range of LED channels.
- Parameters:
UIFLOW2:
- Angle8Unit.set_angle_sync_bright(channel, rgb)
Set the LED brightness synchronized with the angle value.
- Parameters:
UIFLOW2:
- Angle8Unit.get_device_spec(mode)
Get device specifications such as firmware version or I2C address.
- Parameters:
mode (int) – The register to read (FW_VER_REG or I2C_ADDR_REG).
UIFLOW2:
- Angle8Unit.set_i2c_address(address)
Set a new I2C address for the device.
- Parameters:
address (int) – The new I2C address (1 to 127).
UIFLOW2:
- Angle8Unit.readfrommem(reg, num)
Read a specified number of bytes from a device register.
- Parameters:
reg – The register address to read from.
num – The number of bytes to read.