功能:
原型:
bool begin(Ltr5xx_Init_Basic_Para *init_base_para)
bool begin(Ltr5xx_Init_Interrupt_Para *init_interrupt_para)
参数:
パラメータです | タイプです | 記述します |
---|---|---|
init_base_para | Ltr5xx_Init_Basic_Para * | 基本監視の初期化 |
init_interrupt_para | Ltr5xx_Init_Interrupt_Para * | 割込み監視の初期化 |
戻り値:
戻り値 | 説明 |
---|---|
true | 初期化に成功しました |
false | 初期化に失敗します |
功能:
原型:
bool setPsMode(uint8_t mode)
参数:
パラメータです | タイプです | 記述します |
---|---|---|
mode | uint8_t | 1: 启用接近传感器监测 0:传感器待机 |
戻り値:
戻り値 | 記述します |
---|---|
true | 初期化に成功しました |
false | 初期化に失敗します |
功能:
-接近センサーを初期化
原型:
bool setAlsMode(uint8_t mode)
参数:
パラメータです | タイプです | 記述します |
---|---|---|
mode | uint8_t | 1: 環境光センサー監視を有効にする 0:センサーを待機状態にする |
戻り値:
戻り値 | 説明 |
---|---|
true | 初期化に成功しました |
false | 初期化に失敗します |
功能:
原型:
uint16_t getPsValue(void)
参数:
None
戻り値:
戻り値 | 説明 |
---|---|
uint16_t | 監視距離の模拟値 |
功能:
原型:
uint16_t getAlsValue(void)
参数:
None
戻り値:
戻り値 | 記述します |
---|---|
uint16_t | 監視された環境光のlux |
使用示例:
#include "M5CoreS3.h" Ltr5xx_Init_Basic_Para device_init_base_para = LTR5XX_BASE_PARA_CONFIG_DEFAULT; uint16_t read_ps_value;uint16_t read_als_value; void setup() { auto cfg = M5.config(); CoreS3.begin(cfg); CoreS3.Display.setTextColor(GREEN); CoreS3.Display.setTextDatum(middle_center); CoreS3.Display.setFont(&fonts::Orbitron_Light_24); CoreS3.Display.setTextSize(1); device_init_base_para.ps_led_pulse_freq = LTR5XX_LED_PULSE_FREQ_40KHZ; device_init_base_para.ps_measurement_rate = LTR5XX_PS_MEASUREMENT_RATE_50MS; device_init_base_para.als_gain = LTR5XX_ALS_GAIN_48X; if (!CoreS3.Ltr553.begin(&device_init_base_para)) { CoreS3.Display.drawString("Ltr553 Init Fail", CoreS3.Display.width() / 2, CoreS3.Display.height() / 2); while (1) { delay(10); } } CoreS3.Display.drawString("Ltr553 Init Success", CoreS3.Display.width() / 2, CoreS3.Display.height() / 2); // active ps CoreS3.Ltr553.setPsMode(LTR5XX_PS_ACTIVE_MODE); // active als CoreS3.Ltr553.setAlsMode(LTR5XX_ALS_ACTIVE_MODE); // not active ps // CoreS3.Ltr553.setPsMode(LTR5XX_PS_STAND_BY_MODE); // not active als // CoreS3.Ltr553.setAlsMode(LTR5XX_ALS_STAND_BY_MODE);} void loop() { CoreS3.Display.clear(); read_ps_value = CoreS3.Ltr553.getPsValue(); read_als_value = CoreS3.Ltr553.getAlsValue(); CoreS3.Display.drawString( "PS:" + String(read_ps_value) + " / " + "ALS:" + String(read_als_value), CoreS3.Display.width() / 2, CoreS3.Display.height() / 2); Serial.printf("ps value = %d\r\n", read_ps_value); Serial.printf("als value = %d\r\n", read_als_value); delay(100);}