LED Display

The M5Atom library will initialize the LED Display in the M5.begin function (disabled by default). Refer to the example below to enable or disable it.


#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() {
}

drawpix

Functionality:

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

Function Prototype:

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

Usage 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(){
}

Note:
1. RGB Conversion Tool Download

fillpix

Functionality:

Fills the entire LED matrix with a specified RGB color

Function Prototype:

void fillpix(CRGB Color)

Usage 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
}

clear

Functionality:

Turns off all lit LEDs

Function Prototype:

void clear()

Usage 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
  }
}

setBrightness

Functionality:

Sets the brightness of the lit LEDs

Function Prototype:

void setBrightness(uint8_t brightness)

Usage 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);
}

setWidthHeight

Functionality:

Sets the width and height of the pattern

Function Prototype:

void setWidthHeight(uint16_t xColumns, uint16_t yRows)

run()

Functionality:

Starts the LED display

Function Prototype:

void run()

Note:
1.If you do not want to use M5.begin() to initialize the LED and want to use animation(), please call this function before using

animation()

Usage Example:

#include <M5Atom.h>

void setup() {
  M5.Lcd.begin();  // Initialize Atom LED matrix
  M5.Lcd.run();
}

void loop() {
}

animation

Functionality:

Moves a pattern at a specified speed in a specified direction

Function Prototype:

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

Usage 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);
}

Note:
1. Image.c Picture Download

animationrunning

Functionality:

Gets whether the pattern is moving

Function Prototype:

boolean animationrunning()

Return Value:

Value Function
true Moving
false Still

displaybuff

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

Note:
1.x>0 moves right, y>0 moves down

Usage 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);
}
On This Page