M5Unit-FLASHLIGHT 0.0.1 git rev:9a14869
Loading...
Searching...
No Matches
unit_AW3641E.hpp File Reference

AW3641E Unit for M5UnitUnified. More...

#include <M5UnitComponent.hpp>

Go to the source code of this file.

Classes

class  m5::unit::UnitAW3641E
 1A flash LED driver controlled via EN-pin pulse protocol More...
 
struct  m5::unit::UnitAW3641E::config_t
 Settings for begin. More...
 

Namespaces

namespace  m5
 Top level namespace of M5Stack.
 
namespace  aw3641e
 For AW3641E.
 

Enumerations

enum class  m5::unit::aw3641e::SwitchPosition : uint8_t { Flash , Torch }
 Position of the on-board mode selection switch (silkscreen S1, SPDT type) More...
 
enum class  m5::unit::aw3641e::Brightness : uint8_t {
  Pct100 , Pct90 , Pct80 , Pct70 ,
  Pct60 , Pct50 , Pct40 , Pct30
}
 Flash brightness level (percentage of I_FLASH; Flash mode only) More...
 

Functions

constexpr uint8_t m5::unit::aw3641e::to_pulse_count (const Brightness b)
 Translate a Brightness level to the AW3641E rising-edge pulse count.
 

Variables

constexpr uint32_t m5::unit::aw3641e::PULSE_HIGH_US {4}
 Minimum logic-high pulse width in microseconds (T_HI; datasheet 0.75-10 µs)
 
constexpr uint32_t m5::unit::aw3641e::PULSE_LOW_US {4}
 Minimum logic-low pulse width in microseconds (T_LO; datasheet 0.75-10 µs)
 
constexpr uint32_t m5::unit::aw3641e::PULSE_OFF_US {600}
 Minimum EN-low delay required before a pulse sequence (T_OFF; datasheet > 500 µs)
 
constexpr uint16_t m5::unit::aw3641e::FLASH_MAX_DURATION_MS {220}
 Maximum duration for a single flash() call in milliseconds.
 
constexpr uint16_t m5::unit::aw3641e::TORCH_MAX_DURATION_MS {1300}
 Maximum duration for a single torch() call in milliseconds.
 

Detailed Description

AW3641E Unit for M5UnitUnified.

Driver for UnitFlashLight (SKU:U152). AW3641E is an Awinic 1A flash LED driver controlled via a 1-wire EN pulse protocol.

Enumeration Type Documentation

◆ Brightness

enum class m5::unit::aw3641e::Brightness : uint8_t
strong

Flash brightness level (percentage of I_FLASH; Flash mode only)

Note
On UnitFlashLight (U152) with R_SET = 100 kΩ and R_SENSE = 0.22 Ω, I_FLASH(100%) is approximately 584 mA. Torch mode uses a fixed ~214 mA regardless of this setting.
Enumerator
Pct100 

100% of I_FLASH

Pct90 

90%

Pct80 

80%

Pct70 

70%

Pct60 

60%

Pct50 

50%

Pct40 

40%

Pct30 

30% of I_FLASH

◆ SwitchPosition

enum class m5::unit::aw3641e::SwitchPosition : uint8_t
strong

Position of the on-board mode selection switch (silkscreen S1, SPDT type)

Note
The switch is wired between the AW3641E FLASH pin and either +5V (Flash side) or GND (Torch side). It is NOT connected to the host MCU and cannot be read from software, so this enum is a DECLARATION of the physical switch position — the library trusts what the user configured. A mismatch between the declared value and the physical switch results in undefined optical behavior.
Enumerator
Flash 

S1 = Flash side. FLASH pin = +5V. Use flash() to fire pulse-controlled flashes.

Torch 

S1 = Torch side. FLASH pin = GND. Use torch() to drive continuous illumination.

Function Documentation

◆ to_pulse_count()

uint8_t m5::unit::aw3641e::to_pulse_count ( const Brightness b)
constexpr

Translate a Brightness level to the AW3641E rising-edge pulse count.

Parameters
bBrightness level
Returns
Pulse count in range 1..8 (Pulse 1 = 100% / 220 ms, Pulse 8 = 30% / 220 ms)
Note
Only Pulse 1-8 (Ms220 timeout) is exposed by this library; the chip's Pulse 9-16 (1.3 s timeout) range is not used because thermal protection causes the LED to dim before the timeout expires at higher currents.

Variable Documentation

◆ FLASH_MAX_DURATION_MS

uint16_t m5::unit::aw3641e::FLASH_MAX_DURATION_MS {220}
constexpr

Maximum duration for a single flash() call in milliseconds.

Note
Matches the AW3641E Flash mode hardware timeout for Pulse 1-8 (220 ms). For longer continuous on-time use torch() instead.

◆ TORCH_MAX_DURATION_MS

uint16_t m5::unit::aw3641e::TORCH_MAX_DURATION_MS {1300}
constexpr

Maximum duration for a single torch() call in milliseconds.

Note
Library-side safety cap. Torch mode itself has no hardware time limit (EN=HIGH continuously drives ~214 mA), but the driver clamps long durations to avoid runaway on-time bugs.