More features for uLisp on M5Stack (ESP32):
flash support, muting of the speaker and backlight control
Last edited on February 23, 2021
I finished the IoT sensor device prototype and shipped it last Thursday. It just has a stub bootstrap system in the flash via uLisp's Lisp Library and downloads the actual application in a second boot phase via HTTPS. More on that later.
To make it happen I've added a bunch of things to ulisp-esp-m5stack: flash support, fixes for some quirks of the M5Stack, time via NTP, an HTTP function supporting methods PUT, POST, GET, Auth, HTTP and HTTP, temperature sensors via one wire, and more. I plan to publish all these features in the next days.
Today you get: flash support, muting of the builtin speaker and control of the LED backlight of the builtin display.
Flash support
My M5Stacks all have got 4 MB of flash memory attached via SPI. Newer version seem to come with 16 MB. The original ESP32 version of uLisp already uses flash to store workspace images with SAVE-IMAGE but it uses Arduino's EEPROM emulation that is limited to only use 4 kB (of the whole 4 MB). Now you can increase your workspace size and still store images without having to insert an SD card. If you want it, just activate the line #define flashsupport.To add this was simple as the interface to use SD cards is the same as for flash. Most of the code to support flash is shared between both. The flash memory will be formatted with SPIFFS (SPI flash file system). When I decode the binary partition table that the Arduino software creates when compiling uLisp with the command:
python gen_esp32part.py ulisp-esp.ino.partitions.bin ulisp-esp.ino.partitions.csv
# Espressif ESP32 Partition Table # Name, Type, SubType, Offset, Size, Flags nvs,data,nvs,0x9000,20K, otadata,data,ota,0xe000,8K, app0,app,ota_0,0x10000,1280K, app1,app,ota_1,0x150000,1280K, spiffs,data,spiffs,0x290000,1472K,
Muting of the builtin speaker
The M5Stack / M5Core Basic comes with a little 1W speaker connected to analog PIN 25. If you don't configure the PIN and set it to zero, the speaker gives a little chirping sound when you send data to other devices and it clicks when you blank the display. This can be quite annoying.The function MUTE-SPEAKER does this little configuration task and the nuisance stops. There is also the define flag #define m5stack_boot_mute which mutes the speaker on startup.
Brightness of the backlight
The builtin screen of the M5Stack / M5Core Basic has an LED backlight connected to pin 32 and the intensity can be controlled via PWM channel 7. You can change the birghtness with the new function SETUP-BACKLIGHT-PWM:Brightness between 0-255: 0 is off, 255 brightest, 80 (the default) offers a good compromise: good readability for inside rooms. Set to small value to conserve power.
M5Display::begin already does such a setup with a default brightness value of 80.
See also uLisp on M5Stack (ESP32).