Skip to content

Commit e7ab18e

Browse files
authored
Merge pull request #1 from cycle-uber-space/master
add support for atom matrix led array Extend LED support for the single LED of the M5Atom Lite to support the 25 LEDs of the M5Atom Matrix. The single LED has just the same interface as the LED matrix, as expected.
2 parents a608e79 + a805afb commit e7ab18e

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

ulisp-esp.ino

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define enable_http_keywords // keywords used for http but might be used more general
3333
#define enable_dallastemp
3434
//#define enable_m5atom_led // need to disable gfx_m5stack (and gfxsupport) for enable_m5atom_led!
35+
#define enable_m5atom_led_matrix
3536

3637
// Includes
3738

@@ -4614,27 +4615,41 @@ object *fn_gettempdevicescount(object *args, object *env) {
46144615

46154616
#include <Adafruit_NeoPixel.h>
46164617

4618+
#ifdef enable_m5atom_led_matrix
4619+
#define ATOM_NUM_LEDS 25
4620+
#else
46174621
#define ATOM_NUM_LEDS 1
4622+
#endif
46184623
#define ATOM_LED_DATA_PIN 27
46194624

46204625
Adafruit_NeoPixel atom_leds(ATOM_NUM_LEDS, ATOM_LED_DATA_PIN, NEO_GRB);
46214626

46224627
void init_atomled () {
46234628
atom_leds.begin(); // INITIALIZE NeoPixel
4629+
#ifdef enable_m5atom_led_matrix
4630+
// prevent device from overheating, see M5 atom matrix docs
4631+
atom_leds.setBrightness(20);
4632+
#endif
46244633
atom_leds.clear();
46254634
// atom_leds.setPixelColor(0, atom_leds.Color(150, 150, 0));
46264635
atom_leds.show();
46274636
}
46284637

4629-
void atomled(uint32_t color) {
4630-
atom_leds.setPixelColor(0, color);
4638+
void atomled(uint32_t color, uint16_t index) {
4639+
atom_leds.setPixelColor(index, color);
46314640
atom_leds.show();
46324641
}
46334642

46344643
object *fn_atomled(object *args, object *env) {
46354644
uint32_t color = 0xff0000;
4636-
if (args != NULL) color = checkinteger(ATOMLED, first(args));
4637-
atomled(color);
4645+
uint16_t index = 0;
4646+
if (args != NULL) {
4647+
color = checkinteger(ATOMLED, first(args));
4648+
if (cdr(args) != NULL) {
4649+
index = checkinteger(ATOMLED, second(args));
4650+
}
4651+
}
4652+
atomled(color, index);
46384653
return nil;
46394654
}
46404655

@@ -5187,7 +5202,7 @@ const tbl_entry_t lookup_table[] PROGMEM = {
51875202
{ user46625f7d60ca8651d4a2b9150c7d, fn_gettempdevicescount, 0x00 },
51885203
#endif # enable_dallastemp
51895204
#if defined(enable_m5atom_led)
5190-
{ user160acae49c44508fee79466e2136, fn_atomled, 0x01 },
5205+
{ user160acae49c44508fee79466e2136, fn_atomled, 0x02 },
51915206
#endif # enable_m5atom_led
51925207
{ user48fb449eec8a7ce84c164201c1b6, fn_reboot, 0x00 },
51935208
// functions of m-g-r/ulisp-esp-m5stack - end

0 commit comments

Comments
 (0)