Espruino software for the ESP32 based M5StickC.
The Espruino Code relies on the use of the
lcd_spi_unbuf component that does not form part of the standard ESP32 build. Consequently, you need to install the firmware build from this repository contained in the compressed tar archive-
espruino_2v06.144_m5stickc.tgz. Instructions for flashing this are in the README contained in this
.tgz archive. There is a tutorial on how to create your own firmware on the Espruino website, however, the firmware here contains a version of
lcd_spi_unbufwith performance optimisations - see
this thread on the Espruino Forum.
When the firmware has been flashed, use the Espruino Web IDE to upload
boot0.js, lcd.js, & rtc.js to Storage on your M5StickC by clicking on the Storage icon in the IDE. When uploading,
boot0.js use the IDE prompt to name this file
.boot0 in Storage.
The final operation is to set the time by typing or copy/paste-ing the command
rtc.setRTC() into the righthand edit window of the IDE - then the press the
Send to Espriuno icon. This will reset your device, and by default set the time. The
rtc.setRTC() command sets the M5StickC real time clock from the system clock so that when you power down your device it will maintain the current time.
After installation as above, you should see:-
Although it should be reading a positive battery charging current as the M5StickC is plugged into your computer.
Running an app
cube.js to the M5StickC to a Storage file named
app.js. Then, simply press and hold Button B - the small button on the bottom side of the device - until your app starts running.
M5C.BTNA - Large top button
M5C.BTNB - Small side button - bottom
M5C.LED - Digital output pin for red LED
M5C.IR - Digital output pin for IR LED
state set to true/false i.e. on/off
M5C.brightness(b) - screen brightness range 0 to 1 default is 0.8.
M5C.batV() - returns battery voltage.
M5C.batA() - returns battery charge/discharge current in milliamps.
M5C.deepSleep(usec,pin) - turns off backlight etc and sets the processor to sleep for
usec microseconds. If
usec is set to zero, then the sleep period is indefinite. The optional
pin parameter can be used to set a button to wake up the device again. Note: this uses a non-standard version of ESP32.deepSleep that has not yet reached standard Espruino.
Screen LCD device
lcd - this global variable is an Espruino Graphics object representing the M5StickC's LCD screen.
With no rotation, coordinate (0,0) is at the top right of the screen with the device oriented as in the pictures above. Optimum performance for image buffer rendering is achieved with no rotation of
lcd, however rotation within an image buffer has no effect on graphics performance. The LCD driver does use some buffering, so call
lcd.flip() after graphics operations to ensure your entire image is displayed.
The M5StickC contains an RTC chip which maintains the current time and date when the device is shutdown. However, you should access time as usual in Espruino using the standard
Date class. For reference:-
rtc.setSYS() - sets system time from the RTC. Called by
rtc.setRTC() - sets RTC time from the system time.