mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-03 16:41:50 +00:00 
			
		
		
		
	Compare commits
	
		
			13 Commits
		
	
	
		
			2024.11.3
			...
			jesserockz
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					fcf0761ba3 | ||
| 
						 | 
					4b9732629e | ||
| 
						 | 
					5cef11acf0 | ||
| 
						 | 
					b1ad48c824 | ||
| 
						 | 
					35b1b5fae6 | ||
| 
						 | 
					ce20b64712 | ||
| 
						 | 
					1720b2a37e | ||
| 
						 | 
					c974fbbea8 | ||
| 
						 | 
					00c5233bf4 | ||
| 
						 | 
					7efb138933 | ||
| 
						 | 
					f73435f820 | ||
| 
						 | 
					bfc55beedc | ||
| 
						 | 
					9fa057eae8 | 
							
								
								
									
										21
									
								
								esphome/components/es8388/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								esphome/components/es8388/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
import esphome.codegen as cg
 | 
			
		||||
import esphome.config_validation as cv
 | 
			
		||||
 | 
			
		||||
from esphome.components import i2c
 | 
			
		||||
from esphome.const import CONF_ID
 | 
			
		||||
 | 
			
		||||
es8388_ns = cg.esphome_ns.namespace("es8388")
 | 
			
		||||
ES8388Component = es8388_ns.class_("ES8388Component", cg.Component, i2c.I2CDevice)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CONFIG_SCHEMA = (
 | 
			
		||||
    cv.Schema({cv.GenerateID(): cv.declare_id(ES8388Component)})
 | 
			
		||||
    .extend(i2c.i2c_device_schema(0x10))
 | 
			
		||||
    .extend(cv.COMPONENT_SCHEMA)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def to_code(config):
 | 
			
		||||
    var = cg.new_Pvariable(config[CONF_ID])
 | 
			
		||||
    await cg.register_component(var, config)
 | 
			
		||||
    await i2c.register_i2c_device(var, config)
 | 
			
		||||
							
								
								
									
										75
									
								
								esphome/components/es8388/es8388_component.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								esphome/components/es8388/es8388_component.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
#include "es8388_component.h"
 | 
			
		||||
#include "esphome/core/hal.h"
 | 
			
		||||
 | 
			
		||||
#include <soc/io_mux_reg.h>
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace es8388 {
 | 
			
		||||
 | 
			
		||||
void ES8388Component::setup() {
 | 
			
		||||
  PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
 | 
			
		||||
  WRITE_PERI_REG(PIN_CTRL, READ_PERI_REG(PIN_CTRL) & 0xFFFFFFF0);
 | 
			
		||||
 | 
			
		||||
  // mute
 | 
			
		||||
  this->write_byte(0x19, 0x04);
 | 
			
		||||
  // powerup
 | 
			
		||||
  this->write_byte(0x01, 0x50);
 | 
			
		||||
  this->write_byte(0x02, 0x00);
 | 
			
		||||
  // worker mode
 | 
			
		||||
  this->write_byte(0x08, 0x00);
 | 
			
		||||
  // DAC powerdown
 | 
			
		||||
  this->write_byte(0x04, 0xC0);
 | 
			
		||||
  // vmidsel/500k ADC/DAC idem
 | 
			
		||||
  this->write_byte(0x00, 0x12);
 | 
			
		||||
 | 
			
		||||
  // i2s 16 bits
 | 
			
		||||
  this->write_byte(0x17, 0x18);
 | 
			
		||||
  // sample freq 256
 | 
			
		||||
  this->write_byte(0x18, 0x02);
 | 
			
		||||
  // LIN2/RIN2 for mixer
 | 
			
		||||
  this->write_byte(0x26, 0x00);
 | 
			
		||||
  // left DAC to left mixer
 | 
			
		||||
  this->write_byte(0x27, 0x90);
 | 
			
		||||
  // right DAC to right mixer
 | 
			
		||||
  this->write_byte(0x2A, 0x90);
 | 
			
		||||
  // DACLRC ADCLRC idem
 | 
			
		||||
  this->write_byte(0x2B, 0x80);
 | 
			
		||||
  this->write_byte(0x2D, 0x00);
 | 
			
		||||
  // DAC volume max
 | 
			
		||||
  this->write_byte(0x1B, 0x00);
 | 
			
		||||
  this->write_byte(0x1A, 0x00);
 | 
			
		||||
 | 
			
		||||
  // ADC poweroff
 | 
			
		||||
  this->write_byte(0x03, 0xFF);
 | 
			
		||||
  // ADC amp 24dB
 | 
			
		||||
  this->write_byte(0x09, 0x88);
 | 
			
		||||
  // LINPUT1/RINPUT1
 | 
			
		||||
  this->write_byte(0x0A, 0x00);
 | 
			
		||||
  // ADC mono left
 | 
			
		||||
  this->write_byte(0x0B, 0x02);
 | 
			
		||||
  // i2S 16b
 | 
			
		||||
  this->write_byte(0x0C, 0x0C);
 | 
			
		||||
  // MCLK 256
 | 
			
		||||
  this->write_byte(0x0D, 0x02);
 | 
			
		||||
  // ADC Volume
 | 
			
		||||
  this->write_byte(0x10, 0x00);
 | 
			
		||||
  this->write_byte(0x11, 0x00);
 | 
			
		||||
  // ALC OFF
 | 
			
		||||
  this->write_byte(0x03, 0x09);
 | 
			
		||||
  this->write_byte(0x2B, 0x80);
 | 
			
		||||
 | 
			
		||||
  this->write_byte(0x02, 0xF0);
 | 
			
		||||
  delay(1);
 | 
			
		||||
  this->write_byte(0x02, 0x00);
 | 
			
		||||
  // DAC power-up LOUT1/ROUT1 enabled
 | 
			
		||||
  this->write_byte(0x04, 0x30);
 | 
			
		||||
  this->write_byte(0x03, 0x00);
 | 
			
		||||
  // DAC volume max
 | 
			
		||||
  this->write_byte(0x2E, 0x1C);
 | 
			
		||||
  this->write_byte(0x2F, 0x1C);
 | 
			
		||||
  // unmute
 | 
			
		||||
  this->write_byte(0x19, 0x00);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace es8388
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
							
								
								
									
										17
									
								
								esphome/components/es8388/es8388_component.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								esphome/components/es8388/es8388_component.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "esphome/components/i2c/i2c.h"
 | 
			
		||||
#include "esphome/core/component.h"
 | 
			
		||||
 | 
			
		||||
namespace esphome {
 | 
			
		||||
namespace es8388 {
 | 
			
		||||
 | 
			
		||||
class ES8388Component : public Component, public i2c::I2CDevice {
 | 
			
		||||
 public:
 | 
			
		||||
  void setup() override;
 | 
			
		||||
 | 
			
		||||
  float get_setup_priority() const override { return setup_priority::LATE - 1; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}  // namespace es8388
 | 
			
		||||
}  // namespace esphome
 | 
			
		||||
@@ -730,3 +730,5 @@ voice_assistant:
 | 
			
		||||
max6956:
 | 
			
		||||
  - id: max6956_1
 | 
			
		||||
    address: 0x40
 | 
			
		||||
 | 
			
		||||
es8388:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user