text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|> #ifndef _BOARD_CONFIG_H_ #define _BOARD_CONFIG_H_ #include <driver/gpio.h> #define AUDIO_INPUT_SAMPLE_RATE 16000 #define AUDIO_OUTPUT_SAMPLE_RATE 24000 #define AUDIO_I2S_MIC_GPIO_WS GPIO_NUM_4 <|fim_suffix|>S_SPK_GPIO_DOUT GPIO_NUM_7 #define AUDIO_I2S_SPK_GPIO_BCLK GPIO_NUM_15 #define AUDIO_I2S_SPK_...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#pragma once #include <vector> #include <functional> #include <esp_log.h> #include <esp_timer.h> #include <driver/gpio.h> #include <esp_adc/adc_oneshot.h> #include <driver/temperature_sensor.h> #include "application.h" #include "zhengchen_lcd_display.h" class PowerManager { private: // 定时器句柄 esp...
fim
78/xiaozhi-esp32
c
#include "wifi_board.h" #include "codecs/no_audio_codec.h" #include "zhengchen_lcd_display.h" #include "system_reset.h" #include "application.h" #include "button.h" #include "config.h" #include "power_save_timer.h" #include "led/single_led.h" #include "assets/lang_config.h" #include "power_manager.h" #include <esp_log...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef ZHENGCHEN_LCD_DISPLAY_H #define ZHENGCHEN_LCD_DISPLAY_H #include "display/lcd_display.h" #include "lvgl_theme.h" #include <esp_lvgl_port.h> class ZHENGCHEN_LcdDisplay : public SpiLcdDisplay { protected: lv_obj_t* high_temp_popup_ = nullptr; // 高温警告弹窗 lv_obj_t* high_temp_label_ = nullptr...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#ifndef _BOARD_CONFIG_H_ #define _BOARD_CONFIG_H_ #include <driver/gpio.h> #define AUDIO_INPUT_SAMPLE_RATE 24000 #define AUDIO_OUTPUT_SAMPLE_RATE 24000 #define AUDIO_INPUT_REFERENCE true #define AUDIO_I2S_GPIO_MCLK GPIO_NUM_38 #define AUDIO_I2S_GPIO_WS GPIO_NUM_13 #define AUDIO_I2S_GPIO_BCLK GPIO_...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include <cJSON.h> #include <esp_log.h> #include <cstring> #include "application.h" #include "board.h" #include "config.h" #include "mcp_server.h" #include "sdkconfig.h" #include "settings.h" #include "display.h" #define TAG "MCPController" class MCPController { public: MCPController() { R...
fim
78/xiaozhi-esp32
cpp
#pragma once #include <vector> #include <functional> #include <esp_log.h> #include <esp_timer.h> #include <driver/gpio.h> #include <esp_adc/adc_oneshot.h> #include <driver/temperature_sensor.h> #include "application.h" class PowerManager { private: // 定时器句柄 esp_timer_handle_t timer_handle_; std::function<...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>button_(VOLUME_UP_BUTTON_GPIO), volume_down_button_(VOLUME_DOWN_BUTTON_GPIO) { InitializeI2c(); InitializeSpi(); InitializeSt7789Display(); InitializeButtons(); InitializeCamera(); InitializeController(); GetBacklight()->RestoreBrightness(); } ...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef _BOARD_CONFIG_H_ #define _BOARD_CONFIG_H_ #include <driver/gpio.h> #define AUDIO_INPUT_SAMPLE_RATE 24000 #define AUDIO_OUTPUT_SAMPLE_RATE 24000 #define AUDIO_INPUT_REFERENCE true #define AUDIO_I2S_GPIO_MCLK GPIO_NUM_38 #define AUDIO_I2S_GPIO_WS GPIO_NUM_13 #define AUDIO_I2S_GPIO_BCLK GPIO_...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include <cJSON.h> #include <esp_log.h> #include <cstring> #include "application.h" #include "board.h" #include "config.h" #include "mcp_server.h" #include "sdkconfig.h" #include "settings.h" #include "display.h" #define TAG "MCPController" class MCPController { public: MCPController() { R...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#pragma once #include <vector> #include <functional> #include <esp_log.h> #include <esp_timer.h> #include <driver/gpio.h> #include <esp_adc/adc_oneshot.h> #include <driver/temperature_sensor.h> #include "application.h" class PowerManager { private: // 定时器句柄 esp_timer_handle_t timer_handle_; ...
fim
78/xiaozhi-esp32
c
#include "dual_network_board.h" #include "audio/codecs/box_audio_codec.h" #include "display/lcd_display.h" #include "application.h" #include "button.h" #include "led/single_led.h" #include "config.h" #include "i2c_device.h" #include "esp32_camera.h" #include "assets/lang_config.h" #include <esp_log.h> #include <esp_lc...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef _DEVICE_STATE_H_ #define _DEVICE_STATE_H_ enum DeviceState { kDevice<|fim_suffix|> kDeviceStateActivating, kDeviceStateAudioTesting, kDeviceStateFatalError }; #endif // _DEVICE_STATE_H_ <|fim_middle|>StateUnknown, kDeviceStateStarting, kDeviceStateWifiConfiguring, kDe...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>ad(); // No-op if already in the target state if (old_state == new_state) { return true; } // Validate transition if (!IsValidTransition(old_state, new_state)) { ESP_LOGW(TAG, "Invalid state transition: %s -> %s", GetStateName(old_state), GetState...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>lback = std::function<void(DeviceState, DeviceState)>; /** * Add a state change listener (observer pattern) * Callback is invoked in the context of the caller of TransitionTo() * @return listener id for removal */ int AddStateChangeListener(StateCallback callback); /** ...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include <es<|fim_suffix|>ode: %d", on); } <|fim_middle|>p_log.h> #include <esp_err.h> #include <string> #include <cstdlib> #include <cstring> #include <font_awesome.h> #include "display.h" #include "board.h" #include "application.h" #include "audio_codec.h" #include "settings.h" #include "assets/lang_co...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef DISPLAY_H #define DISPLAY_H #include "emoji_collection.h" #ifndef CONFIG_USE_EMOTE_MESSAGE_STYLE #define HAVE_LVGL 1 #include <lvgl.h> #endif #include <esp_timer.h> #include <esp_log.h> #include <esp_pm.h> #include <string> #include <chrono> class Theme { public: Theme(const std::string& ...
fim
78/xiaozhi-esp32
c
<|fim_suffix|> emote_set_anim_emoji(emote_handle_, emotion); } } void EmoteDisplay::SetChatMessage(const char* const role, const char* const content) { ESP_LOGI(TAG, "SetChatMessage: %s, %s", role, content); if (emote_handle_ && content && strlen(content) > 0) { if ((std::strcmp(role, "system")...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>; virtual void ShowNotification(const char* notification, int duration_ms = 3000) override; virtual void UpdateStatusBar(bool update_all = false) override; virtual void SetPowerSaveMode(bool on) override; virtual void SetPreviewImage(const void* image); bool StopAnimDialog(); bool...
fim
78/xiaozhi-esp32
c
#include "lcd_display.h" #include "gif/lvgl_gif.h" #include "settings.h" #include "lvgl_theme.h" #include "assets/lang_config.h" #include <vector> #include <algorithm> #include <font_awesome.h> #include <esp_log.h> #include <esp_err.h> #include <esp_lvgl_port.h> #include <esp_psram.h> #include <cstring> #include <src/...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>h, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy); }; // MIPI LCD display class MipiLcdDisplay : public LcdDisplay { public: MipiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, int width, int height...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "emoji_collection.h" #include <esp_log.h> #include <unordered_map> #include <string> #define TAG "EmojiCollection" void EmojiCollection::AddEmoji(const std::string& name, LvglImage* image) { emoji_collection_[name] = image; } const LvglImage* EmojiCollection::GetEmojiImage(const char* nam...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>lic: Twemoji32(); }; class Twemoji64 : public EmojiCollection { public: Twemoji64(); }; #endif <|fim_prefix|>#ifndef EMOJI_COLLECTION_H #define EMOJI_COLLECTION_H #include "lvgl_image.h" #include <lvgl.h> #include <map> #include <string> #include <memory> // Define interface for emoji colle...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>e + gif->fx]; ptr_row_start = ptr_base; ptr = ptr_row_start; sub_len = shift = 0; /* decoder */ pass = 0; y = 0; p_stack = gif->lzw_cache; p_suffix = gif->lzw_cache + LZW_TABLE_SIZE; p_prefix = (uint16_t*)(gif->lzw_cache + LZW_TABLE_SIZE * 2); frm_off = 0; frm_s...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>6_t tw, uint16_t th, uint8_t cw, uint8_t ch, uint8_t fg, uint8_t bg ); void (*comment)(struct _gd_GIF * gif); void (*application)(struct _gd_GIF * gif, char id[8], char auth[3]); uint16_t fx, fy, fw, fh; uint8_t bgindex; uint8_t * canvas, * frame; #if LV_GIF_CACHE_DECODE_DA...
fim
78/xiaozhi-esp32
c
/** * @file gifdec_mve.h * */ #ifndef GIFDEC_MVE_H #define GIFDEC_MVE_H #ifdef __cplusplus extern "C" { #endif /********************* * INCLUDES *********************/ #include <stdint.h> #include "../../misc/lv_color.h" /********************* * DEFINES *********************/ #define GIFDEC_FILL_B...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "lvgl_gif.h" #include <esp_log.h> #include <cstring> #define TAG "LvglGif" LvglGif::LvglGif(const lv_img_dsc_t* img_dsc) : gif_(nullptr), timer_(nullptr), last_call_(0), playing_(false), loaded_(false), loop_delay_ms_(0), loop_waiting_(false), loop_wait_start_(0) { if (!img_dsc ||...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>_ms); /** * Get GIF dimensions */ uint16_t width() const; uint16_t height() const; /** * Set frame update callback */ void SetFrameCallback(std::function<void()> callback); private: // GIF decoder instance gd_GIF* gif_; // LVGL image descriptor ...
fim
78/xiaozhi-esp32
c
#include <esp_attr.h> #include <esp_heap_caps.h> #include <esp_log.h> #include <stddef.h> #include <string.h> #include <utility> #include "esp_jpeg_common.h" #include "esp_jpeg_enc.h" #include "esp_imgfx_color_convert.h" #if CONFIG_XIAOZHI_ENABLE_HARDWARE_JPEG_ENCODER #include "driver/jpeg_encode.h" #endif #include "...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|> * @param width 图像宽度 * @param height 图像高度 * @param format 图像格式 * @param quality JPEG质量 (1-100) * @param cb 输出回调函数 * @param arg 传递给回调函数的用户参数 * * @return true 成功, false 失败 */ bool image_to_jpeg_cb(uint8_t *src, size_t src_len, uint16_t ...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include <esp_check.h> #include <esp_err.h> #include <esp_heap_caps.h> #include <sys/param.h> #include "esp_jpeg_common.h" #include "esp_jpeg_dec.h" #include "jpeg_to_image.h" #ifdef CONFIG_XIAOZHI_ENABLE_CAMERA_DEBUG_MODE #undef LOG_LOCAL_LEVEL #define LOG_LOCAL_LEVEL MAX(CONFIG_LOG_DEFAULT_LEVEL, ESP...
fim
78/xiaozhi-esp32
c
<|fim_suffix|> - When CONFIG_XIAOZHI_ENABLE_HARDWARE_JPEG_DECODER is enabled, hardware acceleration is attempted first * - Both hardware and software paths allocate memory that requires heap_caps_free() for deallocation * - The decoded image format is always RGB565 (2 bytes per pixel) * * @note Whe...
fim
78/xiaozhi-esp32
c
#include <esp_log.h> #include <esp_err.h> #include <string> #include <cstdlib> #include <cstring> #include <font_awesome.h> #include "lvgl_display.h" #include "board.h" #include "application.h" #include "audio_codec.h" #include "settings.h" #include "assets/lang_config.h" #include "jpg/image_to_jpeg.h" #define TAG "D...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef LVGL_DISPLAY_H #define LVGL_DISPLAY_H #include "display.h" #include "lvgl_image.h" #include <lvgl.h> #include <esp_timer.h> #include <esp_log.h> #include <esp_pm.h> #include <string> #include <chrono> class LvglDisplay : public Display { public: LvglDisplay(); virtual ~LvglDisplay(); ...
fim
78/xiaozhi-esp32
c
<|fim_suffix|> cbin_font_delete(font_); } }<|fim_prefix|>#include "lvgl_font.h" #include <cbin_font.h> LvglCBinFont::LvglCBinFont(void* data) { font_ = cbin_font_create(static_ca<|fim_middle|>st<uint8_t*>(data)); } LvglCBinFont::~LvglCBinFont() { if (font_ != nullptr) { <|endoftext|>
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#pragma once #include <lvgl.h> class LvglFont { p<|fim_suffix|>~LvglFont() = default; }; // Built-in font class LvglBuiltInFont : public LvglFont { public: LvglBuiltInFont(const lv_font_t* font) : font_(font) {} virtual const lv_font_t* font() const override { return font_; } private: con...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>(void* data, size_t size, int width, int height, int stride, int color_format) { bzero(&image_dsc_, sizeof(image_dsc_)); image_dsc_.data_size = size; image_dsc_.data = static_cast<uint8_t*>(data); image_dsc_.header.magic = LV_IMAGE_HEADER_MAGIC; image_dsc_.header.cf = color_format; ...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|> lv_img_dsc_t image_dsc_; };<|fim_prefix|>#pragma once #include <lvgl.h> // Wrap around lv_img_dsc_t class LvglImage { public: virtual const lv_img_dsc_t* image_dsc() const = 0; virtual bool IsGif() const { return false; } virtual ~LvglImage() = default; }; class LvglRawImage : public Lvg...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>rt #112233 to lv_color_t uint8_t r = strtol(color.substr(1, 2).c_str(), nullptr, 16); uint8_t g = strtol(color.substr(3, 2).c_str(), nullptr, 16); uint8_t b = strtol(color.substr(5, 2).c_str(), nullptr, 16); return lv_color_make(r, g, b); } return lv_color_black(); ...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#pragma once #include "display.h" #include "lvgl_image.h" #include "lvgl_font.h" #include "emoji_collection.h" #include <lvgl.h> #include <memory> #include <map> #include <string> class LvglTheme : public Theme { public: static lv_color_t ParseColor(const std::string& color); LvglTheme(const ...
fim
78/xiaozhi-esp32
c
#include "oled_display.h" #include "assets/lang_config.h" #include "lvgl_theme.h" #include "lvgl_font.h" #include <string> #include <algorithm> #include <esp_log.h> #include <esp_err.h> #include <esp_lvgl_port.h> #include <font_awesome.h> #define TAG "OledDisplay" LV_FONT_DECLARE(BUILTIN_TEXT_FONT); LV_FONT_DECLARE...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>nel_io.h> #include <esp_lcd_panel_ops.h> class OledDisplay : public LvglDisplay { private: esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr; lv_obj_t* top_bar_ = nullptr; lv_obj_t* status_bar_ = nullptr; lv_obj_t* content_ = nullptr; lv_obj_...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>void CircularStrip::FadeOut(int interval_ms) { StartStripTask(interval_ms, [this]() { bool all_off = true; for (int i = 0; i < max_leds_; i++) { colors_[i].red /= 2; colors_[i].green /= 2; colors_[i].blue /= 2; if (colors_[i].red != 0 || ...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef _CIRCULAR_STRIP_H_ #define _CIRCULAR_STRIP_H_ #include "led.h" #include <driver/gpio.h> #include <led_strip.h> #<|fim_suffix|><void()> strip_callback_ = nullptr; uint8_t default_brightness_ = DEFAULT_BRIGHTNESS; uint8_t low_brightness_ = LOW_BRIGHTNESS; void StartStripTask(int inter...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "gpio_led.h" #include "application.h" #include "device_state.h" #include <esp_log.h> #define TAG "GpioLed" #define DEFAULT_BRIGHTNESS 50 #define HIGH_BRIGHTNESS 100 #define LOW_BRIGHTNESS 10 #define IDLE_BRIGHTNESS 5 #define SPEAKING_BRIGHTNESS 75 #define UPGRADING_BRIGHTNESS 25 #define ACTIVA...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef _GPIO_LED_H_ #define _GPIO_LED_H_ #include <freertos/FreeRTOS.h> #include <freertos/task.h> #include "led.h" #include <driver/gpio.h> #include <driver/ledc.h> #include <esp_timer.h> #include <atomic> #include <mutex> class GpioLed : public Led { public: GpioLed(gpio_num_t gpio); GpioLed...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#ifndef _LED_H_ #define _LED_H_ class Led { public: virtual ~Led() = <|fim_suffix|> : public Led { public: virtual void OnStateChanged() override {} }; #endif // _LED_H_ <|fim_middle|>default; // Set the led state based on the device state virtual void OnStateChanged() = 0; }; class No...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "single_led.h" #include "application.h" #include <esp_log.h> #define TAG "SingleLed" #define DEFAULT_BRIGHTNESS 4 #define HIGH_BRIGHTNESS 16 #define LOW_BRIGHTNESS 2 #define BLINK_INFINITE -1 SingleLed::SingleLed(gpio_num_t gpio) { if (gpio == GPIO_NUM_NC) { ESP_LOGW(TAG, "Singl...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>t8_t g, uint8_t b); }; #endif // _SINGLE_LED_H_ <|fim_prefix|>#ifndef _SINGLE_LED_H_ #define _SINGLE_LED_H_ #include "led.h" #include <driver/gpio.h> #include <led_strip.h> #include <esp_timer.h> #include <atomic> #include <mutex> class SingleLed : public Led { public: SingleLed(gpio_n<|fim_middle|...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include <esp_log.h> #include <esp_err.h> #incl<|fim_suffix|>nclude <nvs_flash.h> #include <driver/gpio.h> #include <esp_event.h> #include <freertos/FreeRTOS.h> #include <freertos/task.h> #include "application.h" #define TAG "main" extern "C" void app_main(void) { // Initialize NVS flash for WiFi c...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|> }); #endif // CONFIG_LV_USE_SNAPSHOT } #endif // HAVE_LVGL // Assets download url (always registered — Settings storage works regardless of partition layout) AddUserOnlyTool("self.assets.set_download_url", "Set the download url for the assets", PropertyList({ ...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>ing& name() const { return name_; } inline const std::string& description() const { return description_; } inline const PropertyList& properties() const { return properties_; } inline bool user_only() const { return user_only_; } std::string to_json() const { std::vector<std::stri...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "ota.h" #include "system_info.h" #include "settings.h" #include "assets/lang_config.h" #include <freertos/FreeRTOS.h> #include <freertos/task.h> #include <cJSON.h> #include <esp_log.h> #include <esp_partition.h> #include <esp_ota_ops.h> #include <esp_app_format.h> #include <esp_efuse.h> #include...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>age_; std::string activation_code_; bool has_new_version_ = false; bool has_mqtt_config_ = false; bool has_websocket_config_ = false; bool has_server_time_ = false; bool has_activation_code_ = false; bool has_serial_number_ = false; bool has_activation_challenge_ = false; ...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "mqtt_protocol.h" #include "board.h" #include "application.h" #include "settings.h" #include <esp_log.h> #include <cstring> #include <arpa/inet.h> #include "assets/lang_config.h" #define TAG "MQTT" MqttProtocol::MqttProtocol() { event_group_handle_ = xEventGroupCreate(); // Initialize...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|> #endif // MQTT_PROTOCOL_H <|fim_prefix|>#ifndef MQTT_PROTOCOL_H #define MQTT_PROTOCOL_H #include "protocol.h" #include <mqtt.h> #include <udp.<|fim_middle|>h> #include <cJSON.h> #include <mbedtls/aes.h> #include <freertos/FreeRTOS.h> #include <freertos/event_groups.h> #include <esp_timer.h> #include ...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>oad\":" + payload + "}"; SendText(message); } bool Protocol::IsTimeout() const { const int kTimeoutSeconds = 120; auto now = std::chrono::steady_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::seconds>(now - last_incoming_time_); bool timeout = duration.count() >...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>t)> callback); void OnAudioChannelOpened(std::function<void()> callback); void OnAudioChannelClosed(std::function<void()> callback); void OnNetworkError(std::function<void(const std::string& message)> callback); void OnConnected(std::function<void()> callback); void OnDisconnected(std:...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>_t*)bp2->payload; on_incoming_audio_(std::make_unique<AudioStreamPacket>(AudioStreamPacket{ .sample_rate = server_sample_rate_, .frame_duration = server_frame_duration_, .timestamp = bp2->timestamp, ...
fim
78/xiaozhi-esp32
cpp
<|fim_prefix|>#ifndef _WEBSOCKET_PROTOCOL_H_ #define _WEBSOCKET_PROTOCOL_H_ #include "protocol.h" #include <web_socket.h> #include <freertos/FreeRTOS.h> #include <freertos/event_groups.h> #define WEBSOCKET_PROTOCOL_SERVER_HELLO_EVENT (1 << 0) <|fim_suffix|>tProtocol(); bool Start() override; bool SendAudio...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "settings.h" #include <esp_log.h> #include <nvs_flash.h> #define TAG "Settings" Settings::Settings(const std::string& ns, bool read_write) : ns_(ns), read_write_(read_write) { nvs_open(ns.c_str(), read_write_ ? NVS_READWRITE : NVS_READONLY, &nvs_handle_); } Settings::~Settings() { if ...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>ult_value = ""); void SetString(const std::string& key, const std::string& value); int32_t GetInt(const std::string& key, int32_t default_value = 0); void SetInt(const std::string& key, int32_t value); bool GetBool(const std::string& key, bool default_value = false); void SetBool(const...
fim
78/xiaozhi-esp32
c
<|fim_prefix|>#include "system_info.h" #include <freertos/task.h> #include <esp_log.h> #include <esp_flash.h> #include <esp_mac.h> #include <esp_system.h> #include <esp_partition.h> #include <esp_app_desc.h> #include <esp_ota_ops.h> #include <esp_pm.h> #if CONFIG_IDF_TARGET_ESP32P4 #include "esp_wifi_remote.h" #endif ...
fim
78/xiaozhi-esp32
cpp
<|fim_suffix|>nclude <string> #include <esp_err.h> #include <freertos/FreeRTOS.h> class SystemInfo { public: static size_t GetFlashSize(); static size_t GetMinimumFreeHeapSize(); static size_t GetFreeHeapSize(); static std::string GetMacAddress(); static std::string GetChipModelName(); static ...
fim
78/xiaozhi-esp32
c
<|fim_suffix|>count += repeat_cnt break return nonrepeat_count class RAWImage(): ''' RAW image is an exception to LVGL image, it has color format of RAW or RAW_ALPHA. It has same image header as LVGL image, but the data is pure raw data from file. It does not support stride ad...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import tkinter as tk from tkinter import ttk, filedialog, messagebox from PIL import Image import os import tempfile import sys from LVGLImage import LVGLImage, ColorFormat, CompressMethod HELP_TEXT = """LVGL图片转换工具使用说明: 1. 添加文件:点击“添加文件”按钮选择需要转换的图片,支持批量导入 2. 移除文件:在列表中选中文件前的复选框“[ ]”(选中后会变成“[√]”),点击“移除选中”...
fim
78/xiaozhi-esp32
python
""" 实时AFSK解调器 - 基于Goertzel算法 """ import numpy as np from collections import deque class TraceGoertzel: """实时Goertzel算法实现""" def __init__(self, freq: float, n: int): """ 初始化Goertzel算法 Args: freq: 归一化频率 (目标频率/采样频率) n: 窗口大小 """ self.f...
fim
78/xiaozhi-esp32
python
import sys import numpy as np import asyncio import wave from collections import deque import qasync import matplotlib matplotlib.use('qtagg') from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar # no...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>#!/usr/bin/env python3 """ 音频实时监听与绘图系统主程序 基于Qt GUI + Matplotlib + UDP接收 + AFSK解码字符串 """ import sys import asyncio from graphic import main if __name__ == '__main__': try: asyncio.run(main(<|fim_suffix|>: print(f"程序执行出错: {e}") sys.exit(1) <|fim_middle|>)) except KeyboardIn...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import socket import wave import argparse ''' Create a UDP socket and bind it to the server's IP:8000. Listen for incoming messages and print them to the console. Save the audio to a WAV file. ''' def ma<|fim_suffix|>rser.add_argument('--samplerate', '-s', type=int, default=16000, ...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>#!/usr/bin/env python3 """ Build default assets based on configuration This script reads configuration from sdkconfig and builds the appropriate assets.bin for the current board configuration. Usage: ./build_default_assets.py --sdkconfig <path> --builtin_text_font <font_name> \ --default_emo...
fim
78/xiaozhi-esp32
python
<|fim_suffix|>t: releases/<version> relative to script location output_dir = get_default_releases_dir() / args.version # Create output directory output_dir.mkdir(parents=True, exist_ok=True) # Download and rename each artifact downloaded_count = 0 sk...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>#!/usr/bin/env python3 import argparse import json import os HEADER_TEMPLATE = """// Auto-generated language config // Language: {lang_code} with en-US fallback #pragma once #include <string_view> #ifndef {lang_code_for_font} #define {lang_code_for_font} // 預設語言 #endif namespace Lang {{ // 语言...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import tkinter as tk from tkinter import ttk, filedialog, messagebox import os import threading import sys import ffmpeg class AudioConverterApp: def __init__(self, master): self.master = master master.title("小智AI OGG音频批量转换工具") master.geometry("680x600") # 调整窗口高度 # 初...
fim
78/xiaozhi-esp32
python
<|fim_suffix|> else: thread = threading.Thread(target=self.convert_p3_to_audio, args=(input_files,)) thread.start() except Exception as e: print(f"转换初始化失败: {str(e)}") def convert_audio_to_p3(self, target_lufs, input_files): """音频转P3转换逻辑""...
fim
78/xiaozhi-esp32
python
<|fim_prefix|># convert audio files to protocol v3 stream import librosa import opuslib import struct import sys import tqdm import numpy as np import argparse import pyloudnorm as pyln def encode_audio_to_opus(input_file, output_file, target_lufs=None): # Load audio file using librosa audio, sample_rate = lib...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import struct import sys import opuslib import numpy as np from tqdm import tqdm import soundfile as sf def decode_p3_to_audio(input_file, output_file): sample_rate = 16000 channels = 1 decoder = opuslib.Decoder(sample_rate, channels) pcm_frames = [] frame_size = int(sample_rate * 6...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import tkinter as tk from tkinter import filedialog, messagebox import threading import time import opuslib import struct import numpy as np import sounddevice as sd import os def play_p3_file(input_file, stop_event=None, pause_event=None): """ 播放p3格式的音频文件 p3格式: [1字节类型, 1字节保留, 2字节长度, Opus数据]...
fim
78/xiaozhi-esp32
python
<|fim_suffix|>ounddevice as sd import argparse def play_p3_file(input_file): """ 播放p3格式的音频文件 p3格式: [1字节类型, 1字节保留, 2字节长度, Opus数据] """ # 初始化Opus解码器 sample_rate = 16000 # 采样率固定为16000Hz channels = 1 # 单声道 decoder = opuslib.Decoder(sample_rate, channels) # 帧大小 (60ms) frame_siz...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import sys import os import json import zipfile import argparse import re from pathlib import Path from typing import Optional # Switch to project root directory os.chdir(Path(__file__).resolve().parent.parent) ################################################################################ # Common uti...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>#!/usr/bin/env python3 """ Build the spiffs assets partition Usage: ./build.py --wakenet_model <wakenet_model_dir> \ --text_font <text_font_file> \ --emoji_collection <emoji_collection_dir> Example: ./build.py --wakenet_model ../../managed_components/espressif__esp-sr/model/waken...
fim
78/xiaozhi-esp32
python
<|fim_suffix|>ollections = [ "none", "emojis_32", "emojis_64", ] # Get script directory script_dir = os.path.dirname(os.path.abspath(__file__)) # Set directory paths build_dir = os.path.join(script_dir, "build") final_dir = os.path.join(build_dir, "final") ...
fim
78/xiaozhi-esp32
python
<|fim_prefix|>import os import struct import argparse def struct_pack_string(string, max_len=None): """ pack string to binary data. if max_len is None, max_len = len(string) + 1 else len(string) < max_len, the left will be padded by struct.pack('x') string: input python string max_len: outpu...
fim
78/xiaozhi-esp32
python
<|fim_suffix|>le) converted = True break if not converted and config.row_enable: convert_image_to_raw(target_file) os.remove(target_file) else: print(f'No match found for file: {filename}, format_tuple: {format_tupl...
fim
78/xiaozhi-esp32
python
<|fim_suffix|>der) extract_zip(os.path.join(release_dir, name), folder) info = read_binary(folder) target_dir = os.path.join("firmwares", tag) info["tag"] = tag info["url"] = os.path.join(os.environ['OSS_BUCKET_URL'], target_dir, "xiaoz...
fim
78/xiaozhi-esp32
python
<|fim_suffix|>nt("\n\033[32mokke\033[0m") sys.exit(1) <|fim_prefix|>#!/usr/bin/env python3 # takes arguments from launch.json # is used by no_dbg in tasks.json # launches 10x faster than mspython debugpy # and is stoppable with ^C import re import os import sys print(sys.executable) import json5 import shlex import...
fim
9001/copyparty
python
<|fim_suffix|> 't:mtp'", (w2s,)) d2.commit() print(f"copied {ncopy} {tag} tags over, skipped {nskip}") def examples(): print( """ # clearing the journal ./dbtool.py up2k.db # copy tags ".bpm" and "key" from old.db to up2k.db, and remove the mtp flag from matching files (so copyparty won't run an...
fim
9001/copyparty
python
<|fim_prefix|># /!\ Warning: be careful, as webdav clients often generate a large numb<|fim_suffix|>] msg = "\nfail2ban: %s %s" if not vn and not rem: # got called by --xban cli["log"](msg % (now, cli["ip"]), 3) return {"rc": 0} cond = cli.args.dont_ban if ( cond == "any...
fim
9001/copyparty
python
<|fim_suffix|>i.conn, "hacapo_req_s", None) or requests.Session() setattr(cli.conn, "hacapo_req_s", req_s) try: os.makedirs(os.path.dirname(abspath), exist_ok=True) with req_s.get(url, stream=True, timeout=69) as r: r.raise_for_status() with open(abspath, "wb", 64 * 1024...
fim
9001/copyparty
python
<|fim_suffix|> return "allow" <|fim_prefix|># disable permission checks and allow access if client-ip is 1.2.3.4 def main(cl<|fim_middle|>i, vn, rem): if cli.ip == "1.2.3.4": <|endoftext|>
fim
9001/copyparty
python
<|fim_prefix|># create a dummy file and let copyparty return it def main(cli, vn, <|fim_suffix|>spath = vn.canonical(rem) with open(abspath, "wb") as f: f.write(b"404? not on MY watch!") return "retry" <|fim_middle|>rem): print("hello", cli.ip) ab<|endoftext|>
fim
9001/copyparty
python
<|fim_suffix|>096 def main(cli, vn, rem): cli.send_headers("oh_f", None, 404, "text/plain") for chunk in say_no(): cli.s.sendall(chunk) return "false" <|fim_prefix|>#<|fim_middle|> reply with an endless "noooooooooooooooooooooooo" def say_no(): yield b"n" while True: yield b"o"...
fim
9001/copyparty
python
<|fim_prefix|>import os import random from urllib.parse import quote # assuming /foo/bar/ is a valid URL but /foo/bar/randpic.png does not exist, # hijack the 404 with a redirect to a random<|fim_suffix|> x.lower().endswith(file_ext)] if not files_in_dir: return selected_file = random.choice(files_i...
fim
9001/copyparty
python
<|fim_prefix|># if someone hits a 404, redirect them to another location def send_http_302_temporary_redirect(cli, new_path): """ replies with an HTTP 302, which is a temporary redirect; "new_path" can be any of the follow<|fim_suffix|>" cli.reply(b"redirecting...", 301, headers={"Location": new_path}...
fim
9001/copyparty
python
<|fim_suffix|>, "text/plain")) <|fim_prefix|># sends a custom response <|fim_middle|>instead of the usual 404 def main(cli, vn, rem): msg = f"sorry {cli.ip} but {cli.vpath} doesn't exist" return str(cli.reply(msg.encode("utf-8"), 404<|endoftext|>
fim
9001/copyparty
python
<|fim_prefix|>#!/usr/bin/env python3 import sys import json import requests from copyparty.util import humansize, quotep _ = r""" announces a new upload on discord example usage as global config: --xau f,t5,j,bin/hooks/discord-announce.py parameters explained, xau = execute after upload f = fork; don'...
fim
9001/copyparty
python
<|fim_suffix|>md) print("image-noexif: stripped") if __name__ == "__main__": try: main() except: pass <|fim_prefix|>#!/usr/bin/env python3 import os import sys import subprocess as sp _ = r""" remove exif tags from uploaded images; the eventhook edition of https://github.com/9001/copypa...
fim
9001/copyparty
python
<|fim_prefix|>#!/usr/bin/env python3 from typing import Any _ = r""" the fastest hook in the west (runs directly inside copyparty, not as a subprocess) example usage as global config: --xbu I,bin/hooks/import-me.py example usage as a volflag (per-volume config): -v srv/inc:inc:r:rw,ed:c,xbu=I,bin/hooks/impo...
fim
9001/copyparty
python
<|fim_prefix|>#!/usr/bin/env python3 import sys import json import shutil import platform import subprocess as sp from urllib.parse import quote _ = r""" try to avoid race conditions in caching proxies (primarily cloudflare, but probably others too) by means of the most obvious solution possible: just as each file ...
fim
9001/copyparty
python
<|fim_suffix|> msg_info["datetime"] = dt.strftime("%Y-%m-%d, %H:%M:%S") msg_text = TEMPLATE % msg_info filepath = os.path.join(msg_info["ap"], FILENAME) if DESCENDING and os.path.exists(filepath): write_descending(filepath, msg_text) else: write_ascending(filepath, msg_text) pri...
fim
9001/copyparty
python