#include "M5Atom.h"
void setup() {
// SerialEnable: true, I2CEnable: false, DisplayEnable: true
M5.begin(true, false, true);
delay(50);
M5.dis.drawpix(0, 0x00ff00);
}
void loop() {
}
Description:
Lights up an LED at a specified location with a specified RGB color (Number: 0~24) (Atom-Lite has only one light)
Lights up the LED at the (x,y) coordinates with a specified RGB color
Syntax:
void drawpix(uint8_t xpos, uint8_t ypos, CRGB Color)
void drawpix(uint8_t Number, CRGB Color)
Parameter | Type | Description |
---|---|---|
xpos | uint8_t | x-coordinate (0~5) |
ypos | uint8_t | y-coordinate (0~5) |
Number | uint8_t | Light up the *th light (0~24) |
Color | CRGB | Color of the light |
Example:
#include "M5Atom.h"
void setup(){
M5.begin(true, false, true); // Initialize M5Atom
delay(50); // Delay 50ms
M5.dis.drawpix(0, 0xBBFFFF); // Light up the first LED with RGB color 0xBBFFFF
//M5.dis.drawpix(0,0, 0xBBFFFF); // Light up the LED at (0,0) with RGB color 0xBBFFFF
}
void loop(){
}
Description:
Fills the entire LED matrix with a specified RGB color
Syntax:
void fillpix(CRGB Color)
Example:
#include "M5Atom.h"
void setup(){
M5.begin(true, false, true); // Initialize M5Atom
}
void loop(){
M5.dis.fillpix(0xffffff); // Light up the entire LED matrix with RGB color 0xffffff
}
Description:
Turns off all lit LEDs
Syntax:
void clear()
Example:
#include "M5Atom.h"
void setup(){
M5.begin(true, false, true); // Initialize M5Stack
delay(50); // Delay 50ms
M5.dis.drawpix(0, 0xBBFFFF);
//M5.dis.drawpix(0,0, 0xBBFFFF);
}
void loop(){
M5.update(); // Read the button press state
if (M5.Btn.wasPressed()){
M5.dis.clear(); // Turn off all lit LEDs
}
}
Description:
Sets the brightness of the lit LEDs
Syntax:
void setBrightness(uint8_t brightness)
Example:
#include "M5Atom.h"
void setup(){
M5.begin(true, false, true); // Initialize M5Atom
}
void loop(){
M5.dis.fillpix(0xffffff); // Light up the entire LED matrix with RGB color 0xffffff
M5.dis.setBrightness(10); // Set the brightness of the lit LEDs
delay(1000);
M5.dis.fillpix(0xFFFF00);
M5.dis.setBrightness(100);
delay(1000);
}
Description:
Sets the width and height of the pattern
Syntax:
void setWidthHeight(uint16_t xColumns, uint16_t yRows)
Description:
Starts the LED display
Syntax:
void run()
animation()
Example:
#include <M5Atom.h>
void setup() {
M5.Lcd.begin(); // Initialize Atom LED matrix
M5.Lcd.run();
}
void loop() {
}
Description:
Moves a pattern at a specified speed in a specified direction
Syntax:
void animation(uint8_t *buffptr, uint8_t amspeed, uint8_t ammode, int64_t amcount)
Parameter | Type | Description |
---|---|---|
buffptr | uint8_t * | The pattern |
amspeed | uint8_t | Moving speed (0~255) |
ammode | uint8_t | Moving direction |
amcount | int64_t | Number of steps |
Moving Directions:
Constant | Value | Description |
---|---|---|
kMoveRight | 0x01 | Move the image right |
kMoveLeft | 0x02 | Move the image left |
kMoveTop | 0x04 | Move the image up |
kMoveButtom | 0x08 | Move the image down |
Example:
#include "M5Atom.h"
extern const unsigned char AtomImageData[375 + 2]; // External reference to an array storing the image (click below on image.c to download and store in the same directory as .ino)
void setup(){
M5.begin(true, false, true); // Clear the serial buffer, set the serial baud rate to 115200; initialize the LED matrix
delay(50);
}
void loop(){
// Move a pattern AtomImageData at a specified speed 200 in the direction kMoveLeft for 25 steps
M5.dis.animation((uint8_t *)AtomImageData, 200, LED_DisPlay::kMoveLeft, 25);
delay(5250);
}
Description:
Gets whether the pattern is moving
Syntax:
boolean animationrunning()
Return Value:
Value | Function |
---|---|
true | Moving |
false | Still |
Functionality:
Moves the displayed content in a certain direction
Function Prototype:
void displaybuff(uint8_t *buffptr, int8_t offsetx = 0, int8_t offsety = 0)
Parameter | Type | Description |
---|---|---|
buffptr | uint8_t * | The array storing the pattern |
offsetx | int8_t | Number of cells to move in the x direction |
offsety | int8_t | Number of cells to move in the y direction |
Example:
#include "M5Atom.h"
extern const unsigned char AtomImageData[375 + 2];//For the array, click above on image.c to download
void setup(){
M5.begin(true, false, true);
delay(50);
}
void loop(){
M5.dis.displaybuff((uint8_t *)AtomImageData,-2, 0); // Move the pattern 2 cells to the left
delay(100);
}