m5stack / M5Unified

Unified library for M5Stack series
MIT License
328 stars 58 forks source link

AXP2101 Voltage for DLDO1 (LCD BL) with M5Stack CoreS3 #125

Closed lboue closed 2 months ago

lboue commented 2 months ago

Hello,

I'm trying to find out what voltage to apply to the CoreS3 LCD backlight? Could you tell me the voltage for DLDO1 (LCD BL)?

I couldn't find here: https://github.com/m5stack/M5Unified/blob/da414308b728a9c4d9478d1ff88bc48411bec69b/src/utility/Power_Class.cpp#L64-L74

Nor did I find in this table: https://github.com/m5stack/M5Unified?tab=readme-ov-file#axp2101-usage

image

Regards

felmue commented 2 months ago

Hello @lboue

I think LCD brightness is handled here.

You don't need to care about the actual voltage - just use setBrightness() function.

Thanks Felix

lboue commented 2 months ago

Thanks @felmue. I'd like to understand how it's managed because I need it to implement it in Meshtastic.

felmue commented 2 months ago

Hello @lboue

well, the AXP2101 datasheet states that the voltage on DLDO1 is the value written to register 0x99 plus an offset of 0.5 V. From the datasheet:

dldo1 output voltage configuration
0.5~3.4V,100mV/step,29steps
00000: 0.5V
00001: 0.6V
……
11100: 3.3V
11101~11111: reserved

The function setBrightness(brightness) takes an 8 bit value so the range is 0 to 255. A value of 0 turns DLDO1 off via register 0x90. A value from 1 to 255 turns DLDO1 on (reg 0x90) and sets a voltage of 0.6 V to 3.3 V (using register 0x99) via this calculation: brightness = ((brightness + 641) >> 5);

So for the max value 255 the value written to 0x99 is: ((255 + 641) / 32) = 28 (equals 0b00011100)

BTW: Isn't Meshtastic written in C as well? Maybe you could just copy the complete function over?

Thanks Felix

lboue commented 2 months ago

Thanks for your help. Meshtastic depends on XPowersLib lib.