mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 07:07:38 +03:00
disable battery measurement on emulation
This commit is contained in:
parent
db359b2798
commit
5783faed33
@ -3,21 +3,42 @@ FROM debian:12
|
|||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
ARG ESP_IDF_VERSION=v5.5.2
|
||||||
|
ARG ESP_QEMU_VERSION=esp-develop-9.2.2-20250817
|
||||||
|
|
||||||
# Update container
|
# Update container
|
||||||
RUN apt-get update && apt-get upgrade -y
|
RUN apt-get update && apt-get upgrade -y
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 \
|
RUN apt-get install -y git wget flex bison gperf python3 python3-pip python3-setuptools python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 \
|
||||||
libgcrypt20 libglib2.0-0 libpixman-1-0 libsdl2-2.0-0 libslirp0 -y
|
libgcrypt20 libglib2.0-0 libpixman-1-0 libsdl2-2.0-0 libslirp0 \
|
||||||
|
libglib2.0-dev libpixman-1-dev libgcrypt20-dev libslirp-dev libsdl2-dev
|
||||||
|
|
||||||
# Install ESP-IDF
|
# Install ESP-IDF
|
||||||
ENV PATH="~/.local/bin:${PATH}"
|
ENV PATH="~/.local/bin:${PATH}"
|
||||||
RUN mkdir -p ~/esp && cd ~/esp && git clone --quiet --recursive https://github.com/espressif/esp-idf.git && ln -s /usr/bin/python3 /usr/bin/python
|
RUN mkdir -p ~/esp && \
|
||||||
|
cd ~/esp && git clone --recursive https://github.com/espressif/esp-idf.git -b ${ESP_IDF_VERSION} --depth 1 -j $(nproc) && \
|
||||||
|
ln -s /usr/bin/python3 /usr/bin/python
|
||||||
RUN cd ~/esp/esp-idf && export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets" && ./install.sh && /bin/bash -c "source ./export.sh"
|
RUN cd ~/esp/esp-idf && export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets" && ./install.sh && /bin/bash -c "source ./export.sh"
|
||||||
|
|
||||||
# Install qemu
|
# Install qemu
|
||||||
RUN cd ~/esp/esp-idf && python tools/idf_tools.py install qemu-riscv32
|
RUN cd ~/esp/esp-idf && python tools/idf_tools.py install qemu-riscv32 qemu-xtensa
|
||||||
|
|
||||||
|
# Or, build qemu from source
|
||||||
|
# RUN git clone https://github.com/espressif/qemu.git -b ${ESP_QEMU_VERSION} --depth 1 \
|
||||||
|
# && cd qemu \
|
||||||
|
# && mkdir -p build \
|
||||||
|
# && cd build \
|
||||||
|
# && ../configure --target-list=riscv32-softmmu \
|
||||||
|
# --enable-gcrypt \
|
||||||
|
# --enable-slirp \
|
||||||
|
# --enable-debug \
|
||||||
|
# --enable-sdl \
|
||||||
|
# --disable-strip --disable-user \
|
||||||
|
# --disable-capstone --disable-vnc \
|
||||||
|
# --disable-gtk \
|
||||||
|
# && make -j $(nproc) vga=no \
|
||||||
|
# && make install
|
||||||
|
|
||||||
RUN echo "alias idf='source /root/esp/esp-idf/export.sh'" >> .bashrc
|
RUN echo "alias idf='source /root/esp/esp-idf/export.sh'" >> .bashrc
|
||||||
|
|
||||||
|
|||||||
@ -380,7 +380,7 @@ async def spawn_qemu():
|
|||||||
"-nographic",
|
"-nographic",
|
||||||
"-M", "esp32c3",
|
"-M", "esp32c3",
|
||||||
"-drive", "file=flash.bin,if=mtd,format=raw",
|
"-drive", "file=flash.bin,if=mtd,format=raw",
|
||||||
"-global", "driver=timer.esp32c3.timg,property=wdt_disable,value=true", # got panic if we don't disable WDT, why?
|
# "-global", "driver=timer.esp32c3.timg,property=wdt_disable,value=true", # got panic if we don't disable WDT, why?
|
||||||
]
|
]
|
||||||
|
|
||||||
# Get working directory from environment or use /tmp
|
# Get working directory from environment or use /tmp
|
||||||
|
|||||||
@ -3,4 +3,16 @@
|
|||||||
|
|
||||||
#define BAT_GPIO0 0 // Battery voltage
|
#define BAT_GPIO0 0 // Battery voltage
|
||||||
|
|
||||||
static BatteryMonitor battery(BAT_GPIO0);
|
class Battery {
|
||||||
|
public:
|
||||||
|
uint16_t readPercentage() const {
|
||||||
|
#if CROSSPOINT_EMULATED == 0
|
||||||
|
static const BatteryMonitor hwBattery = BatteryMonitor(BAT_GPIO0);
|
||||||
|
return hwBattery.readPercentage();
|
||||||
|
#else
|
||||||
|
return 100;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static Battery battery;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user