Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions examples/Hat_DLight_M5StickC/Hat_DLight_M5StickC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@
* 获取更多资料请访问: http://docs.m5stack.com/zh_CN/hat/hat_dlight
*
* Product: Hat DLight.
* Date: 2023/05/29
* Date: 2026/7/17
*******************************************************************************
Measure and output light intensity on screen and serial port
测量并在屏幕和串口输出光照强度
*/

#include <M5StickC.h>
#include <M5GFX.h>
#include <M5Unified.h>
#include <M5_DLight.h>

M5GFX display;
M5Canvas canvas(&display);
M5Canvas canvas(&M5.Display);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin();
display.begin();
M5.Display.setRotation(3);
canvas.setTextDatum(MC_DATUM);
canvas.setColorDepth(1);
canvas.setFont(&fonts::Orbitron_Light_24);
canvas.setTextSize(1);
canvas.setRotation(3);
canvas.createSprite(display.width(), display.height());
canvas.createSprite(M5.Display.width(), M5.Display.height());
canvas.setPaletteColor(1, ORANGE);
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin(&Wire, 0, 26); // HAT DLight

Expand Down
14 changes: 6 additions & 8 deletions examples/Hat_DLight_M5StickCPlus/Hat_DLight_M5StickCPlus.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@
* 获取更多资料请访问: http://docs.m5stack.com/zh_CN/hat/hat_dlight
*
* Product: Hat DLight.
* Date: 2022/07/27
* Date: 2026/7/17
*******************************************************************************
Measure and output light intensity on screen and serial port
测量并在屏幕和串口输出光照强度
*/

#include <M5GFX.h>
#include <M5StickCPlus.h>
#include <M5Unified.h>
#include <M5_DLight.h>

M5GFX display;
M5Canvas canvas(&display);
M5Canvas canvas(&M5.Display);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin();
display.begin();
M5.Display.setRotation(3);
canvas.setTextDatum(MC_DATUM);
canvas.setColorDepth(1);
canvas.setFont(&fonts::Orbitron_Light_24);
canvas.setTextSize(1);
canvas.setRotation(3);
canvas.createSprite(display.width(), display.height());
canvas.createSprite(M5.Display.width(), M5.Display.height());
canvas.setPaletteColor(1, ORANGE);
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin(&Wire, 0, 26); // HAT DLight

Expand Down
30 changes: 23 additions & 7 deletions examples/Unit_DLight_M5Atom/Unit_DLight_M5Atom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,34 @@
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/dlight
*
* Product: Unit DLight
* Date: 2023/05/29
* Date: 2026/7/17
*******************************************************************************
Please connect the sensor to port, the Lux value will be output
on the serial after successful initialization
请将传感器连接至端口, 成功初始化后串口上将输出Lux数值
*/

#include <M5Atom.h>
#include <M5Unified.h>
#include <M5_DLight.h>
// Install the Adafruit NeoPixel library:
// https://github.com/adafruit/Adafruit_NeoPixel
#include <Adafruit_NeoPixel.h>

#define LED_PIN 27
#define NUM_LEDS 25

Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin(true, true, true);
void setup()
{
M5.begin();
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin();
sensor.begin(&Wire, 26, 32);
strip.begin();

// CONTINUOUSLY_H_RESOLUTION_MODE
// CONTINUOUSLY_H_RESOLUTION_MODE2
Expand All @@ -34,8 +45,13 @@ void setup() {
sensor.setMode(CONTINUOUSLY_H_RESOLUTION_MODE);
}

void loop() {
M5.dis.fillpix(0x00ff00);
void loop()
{
for (char i = 0; i <= NUM_LEDS; i++)
{
strip.setPixelColor(i, strip.Color(0, 255, 0));
}
strip.show();
lux = sensor.getLUX();
Serial.printf("lux: %d\n", lux);
delay(200);
Expand Down
12 changes: 5 additions & 7 deletions examples/Unit_DLight_M5Core/Unit_DLight_M5Core.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/dlight
*
* Describe: Unit DLight
* Date: 2023/5/29
* Date: 2026/7/17
*******************************************************************************
Please connect the sensor to port A (22, 21), the Lux value will be displayed
on the display after successful initialization
请将传感器连接至端口A(22、21),成功初始化后显示屏上将显示Lux数值
*/

#include <M5Stack.h>
#include <M5GFX.h>
#include <M5Unified.h>
#include <M5_DLight.h>

M5GFX display;
M5Canvas canvas(&display);
M5Canvas canvas(&M5.Display);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin();
display.begin();
canvas.setTextDatum(MC_DATUM);
canvas.setColorDepth(1);
canvas.setFont(&fonts::Orbitron_Light_24);
canvas.setTextSize(2);
canvas.createSprite(display.width(), display.height());
canvas.createSprite(M5.Display.width(), M5.Display.height());
canvas.setPaletteColor(1, ORANGE);
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin();

Expand Down
12 changes: 5 additions & 7 deletions examples/Unit_DLight_M5Core2/Unit_DLight_M5Core2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/dlight
*
* Product: Unit DLight
* Date: 2022/7/27
* Date: 2026/7/17
*******************************************************************************
Please connect the sensor to port A (32,33), the Lux value will be displayed
on the display after successful initialization 请将传感器连接至端口A(32,33),
成功初始化后显示屏上将显示Lux数值
*/

#include <M5Core2.h>
#include <M5GFX.h>
#include <M5Unified.h>
#include <M5_DLight.h>

M5GFX display;
M5Canvas canvas(&display);
M5Canvas canvas(&M5.Display);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin();
display.begin();
canvas.setTextDatum(MC_DATUM);
canvas.setColorDepth(1);
canvas.setFont(&fonts::Orbitron_Light_24);
canvas.setTextSize(2);
canvas.createSprite(display.width(), display.height());
canvas.createSprite(M5.Display.width(), M5.Display.height());
canvas.setPaletteColor(1, ORANGE);
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin();

Expand Down
14 changes: 6 additions & 8 deletions examples/Unit_DLight_M5StickC/Unit_DLight_M5StickC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,31 @@
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/dlight
*
* Product: Unit DLight
* Date: 2022/7/27
* Date: 2026/7/17
*******************************************************************************
Please connect the sensor to port, the Lux value will be displayed
on the display after successful initialization 请将传感器连接至端口,
成功初始化后显示屏上将显示Lux数值
*/

#include <M5StickC.h>
#include <M5GFX.h>
#include <M5Unified.h>
#include <M5_DLight.h>

M5GFX display;
M5Canvas canvas(&display);
M5Canvas canvas(&M5.Display);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin();
display.begin();
M5.Display.setRotation(3);
canvas.setTextDatum(MC_DATUM);
canvas.setColorDepth(1);
canvas.setFont(&fonts::Orbitron_Light_24);
canvas.setTextSize(1);
canvas.setRotation(3);
canvas.createSprite(display.width(), display.height());
canvas.createSprite(M5.Display.width(), M5.Display.height());
canvas.setPaletteColor(1, ORANGE);
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin();

Expand Down
14 changes: 6 additions & 8 deletions examples/Unit_DLight_M5StickCPlus/Unit_DLight_M5StickCPlus.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,31 @@
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/dlight
*
* Product: Unit DLight
* Date: 2022/7/27
* Date: 2026/7/17
*******************************************************************************
Please connect the sensor to port, the Lux value will be displayed
on the display after successful initialization 请将传感器连接至端口,
成功初始化后显示屏上将显示Lux数值
*/

#include <M5GFX.h>
#include <M5StickCPlus.h>
#include <M5Unified.h>
#include <M5_DLight.h>

M5GFX display;
M5Canvas canvas(&display);
M5Canvas canvas(&M5.Display);

M5_DLight sensor;
uint16_t lux;

void setup() {
M5.begin();
display.begin();
M5.Display.setRotation(3);
canvas.setTextDatum(MC_DATUM);
canvas.setColorDepth(1);
canvas.setFont(&fonts::Orbitron_Light_24);
canvas.setTextSize(1);
canvas.setRotation(3);
canvas.createSprite(display.width(), display.height());
canvas.createSprite(M5.Display.width(), M5.Display.height());
canvas.setPaletteColor(1, ORANGE);
Serial.begin(115200);
Serial.println("Sensor begin.....");
sensor.begin();

Expand Down