def __init__(self, i2c): self._drv = axp202.PMU(i2c) self._bm = bytearray(_BM_PMU_MAX) self._drv.setPowerOutPut(axp202.AXP202_LDO2, False) self._drv.setPowerOutPut(axp202.AXP202_LDO3, False) self._drv.setShutdownTime(axp202.AXP_POWER_OFF_TIME_4S) self._drv.setChgLEDMode(axp202.AXP20X_LED_OFF) self._drv.setPowerOutPut(axp202.AXP202_EXTEN, False) self._drv.setChargeControlCur(_CHARG_CURR)
def __init__(self, fastboot=False): self.__i2c__ = I2C(1, scl=Pin(22), sda=Pin(21)) self.pmu = axp202.PMU(self.__i2c__) self.tft = self.__init_display__() self.touch = self.__init_touch__() self.motor = None self.rtc = None self.bma = None self.ticker = None self.__fastboot__ = fastboot if fastboot: _thread.start_new_thread(self.__init_prep__, ()) else: self.__init_prep__()
import time import axp202 import machine GPS_RX_PIN = 34 GPS_TX_PIN = 12 axp = axp202.PMU(address=axp202.AXP192_SLAVE_ADDRESS) # axp.setDCDC1Voltage(3300) # esp32 core VDD 3v3 axp.setLDO2Voltage(3300) # T-Beam LORA VDD 3v3 axp.setLDO3Voltage(3300) # T-Beam GPS VDD 3v3 axp.enablePower(axp202.AXP192_LDO3) axp.enablePower(axp202.AXP192_LDO2) uart = machine.UART(2, rx=GPS_RX_PIN, tx=GPS_TX_PIN, baudrate=9600, bits=8, parity=None, stop=1, timeout=1500, buffer_size=1024, lineend='\r\n') gps = machine.GPS(uart) gps.init() gps.startservice() gps.service() while True: gps.getdata() time.sleep(1)
import lvgl as lv import lvgl_helper as lv_h import lvesp32 import display import time import machine import touchscreen as ts import axp202 import random i2c0 = machine.I2C(scl=22, sda=21) pmu = axp202.PMU(i2c0) pmu.enablePower(axp202.AXP202_LDO2) pmu.setLDO2Voltage(3300) tft = display.TFT() sda_pin = machine.Pin(23) scl_pin = machine.Pin(32) i2c = machine.I2C(id=1, scl=scl_pin, sda=sda_pin, speed=400000) ts.init(i2c) tft.init(tft.ST7789,width=240, invrot=3,rot=1,bgr=False, height=240, miso=2, mosi=19, clk=18, cs=5, dc=27,speed=40000000,color_bits=tft.COLOR_BITS16,backl_pin=12,backl_on=1) tft.clear(tft.RED) time.sleep(1) tft.clear(tft.GREEN) time.sleep(1) tft.clear(tft.BLUE) time.sleep(1)
repl.init(1500000, 8, None, 1, read_buf_len=2048, ide=True, from_ide=False) sys.exit() import gc import machine from board import board_info from fpioa_manager import fm from pye_mp import pye from Maix import FPIOA, GPIO from machine import I2C import axp202 i2c = I2C(I2C.I2C0, freq=400000, scl=30, sda=31) p = None try: p = axp202.PMU(i2c, 0x35) except: p = axp202.PMU(i2c, 0x34) p.setLDO2Voltage(1800) p.enablePower(axp202.AXP192_LDO2) # detect boot.py boot_py = ''' from fpioa_manager import * import os, Maix, lcd, image from Maix import FPIOA, GPIO test_pin=16 fpioa = FPIOA() fpioa.set_function(test_pin,FPIOA.GPIO7) test_gpio=GPIO(GPIO.GPIO7,GPIO.IN)
#import esp #esp.osdebug(None) #import webrepl #webrepl.start() import axp202 from machine import I2C, Pin, SPI import st7789 as st7789 # custom modules import coreboot.wifi coreboot.wifi.autoInit() # i2c = I2C(scl=Pin(22), sda=Pin(21)) power = axp202.PMU(sda=21,scl=22,intr=35) power.enablePower(axp202.AXP202_LDO2) print('Batt charge: {}%'.format(power.getBattPercentage())) print('Batt voltage: {}mV'.format(power.getBattVoltage())) print('Batt charge: {}mA'.format(power.getBattChargeCurrent())) print('Batt discharge: {}mA'.format(power.getBattDischargeCurrent())) print('Batt input: {}mW'.format(power.getBattInpower())) # spi = SPI(1, baudrate=30000000, polarity=1, sck=Pin(18), mosi=Pin(19)) # # spi = SPI(2, baudrate=30000000, polarity=1) # tft = st7789.ST7789( # spi, # 240, 240, # reset=Pin(23, Pin.OUT), # cs=Pin(5, Pin.OUT), # dc=Pin(27, Pin.OUT),
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. axp20x.py - MicroPython library for X-Power AXP202 chip. Created by Lewis he on June 24, 2019. github:https://github.com/lewisxhe/AXP202X_Libraries ''' import axp202 import time a = axp202.PMU() a.setChgLEDMode(axp202.AXP20X_LED_BLINK_1HZ) a.enablePower(axp202.AXP202_LDO2) a.setLDO2Voltage(1800) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_VBUS_VOL_ADC1) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_VBUS_CUR_ADC1) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_BATT_VOL_ADC1) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_BATT_CUR_ADC1) while True: voltage = a.getVbusVoltage() current = a.getVbusCurrent() battCurrent = a.getBattChargeCurrent() perce = a.getBattPercentage() print("isChargeing: V: %f C:%f BC:%f perce:%d" % (voltage, current, battCurrent, perce))
import axp202 import time from machine import I2C i2c = I2C(I2C.I2C0, freq=400000, scl=30, sda=31) a = axp202.PMU(i2c, 0x35) a.setChgLEDMode(axp202.AXP20X_LED_BLINK_1HZ) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_VBUS_VOL_ADC1) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_VBUS_CUR_ADC1) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_BATT_VOL_ADC1) a.enableADC(axp202.AXP202_ADC1, axp202.AXP202_BATT_CUR_ADC1) while True: voltage = a.getVbusVoltage() current = a.getVbusCurrent() battCurrent = a.getBattChargeCurrent() perce = a.getBattPercentage() print("isChargeing: V: %f C:%f BC:%f perce:%d" % (voltage, current, battCurrent, perce)) time.sleep(1)