Faces Calculator3 Module
Faces Calculator3 is a calculator keypad module. It reports released key
codes through a callback and uses I2C address 0x08 by default.
Support the following products:
UiFlow2 Example
Key event display
This example reports the key released on the CoreS3 display. The callback receives the released key code, converts it to a character, and displays it.
Open the faces_calculator3_cores3_example.m5f2 project in UiFlow2.
UiFlow2 Code Block:
MicroPython Example
Key event display
Call FacesCalculator3Module.tick() regularly from the main loop to poll
for new key events.
1# SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
2#
3# SPDX-License-Identifier: MIT
4
5import os, sys, io
6import M5
7from M5 import *
8from module import FacesCalculator3Module
9
10
11title0 = None
12label0 = None
13faces_calculator3_0 = None
14
15
16event_args = None
17
18
19def faces_calculator3_0_key_event(args):
20 global title0, label0, faces_calculator3_0, event_args
21 event_args = chr(args)
22 label0.setText(str((str("Key: ") + str(event_args))))
23
24
25def setup():
26 global title0, label0, faces_calculator3_0, event_args
27
28 M5.begin()
29 Widgets.setRotation(1)
30 Widgets.fillScreen(0x222222)
31 title0 = Widgets.Title(
32 "Faces Calculator3 CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.Montserrat18
33 )
34 label0 = Widgets.Label("label0", 1, 112, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.Montserrat18)
35
36 faces_calculator3_0 = FacesCalculator3Module(address=0x08)
37 faces_calculator3_0.set_callback(faces_calculator3_0_key_event)
38
39
40def loop():
41 global title0, label0, faces_calculator3_0, event_args
42 M5.update()
43 faces_calculator3_0.tick()
44
45
46if __name__ == "__main__":
47 try:
48 setup()
49 while True:
50 loop()
51 except (Exception, KeyboardInterrupt) as e:
52 try:
53 from utility import print_error_msg
54
55 print_error_msg(e)
56 except ImportError:
57 print("please update to latest firmware")
API
- class module.faces.FacesCalculator3Module(address=8)
Bases:
_FacesModuleCreate a Faces Calculator3 Module object.
- Parameters:
address (int) – I2C address. Default is
0x08.
UiFlow2 Code Block:

MicroPython Code Block:
from module import FacesCalculator3Module faces_calculator3 = FacesCalculator3Module()
- set_callback(handler)
Set the callback for key events.
The callback receives the released key code. Pass
Noneto disable it.- Parameters:
handler – Callable accepting one key code, or
None.- Return type:
None
- tick()
Poll once and invoke the callback when a key event is available.
UiFlow2 Code Block:

MicroPython Code Block:
faces_calculator3.tick()
- Return type:
None
- get_device_id()
Get the Faces module device type ID.
- Returns:
The device type ID.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
device.get_device_id()
- get_firmware_version()
Get the firmware version.
- Returns:
The firmware version.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
device.get_firmware_version()
- get_i2c_address()
Get the current 7-bit I2C address.
- Returns:
The current I2C address.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
device.get_i2c_address()
- get_uid()
Get the 96-bit MCU unique identifier.
- Returns:
The 12-byte unique identifier.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
device.get_uid()
Calculator key constants:
Constant |
Value |
Key |
|---|---|---|
|
|
Backspace |
|
|
Enter |
|
|
All clear |
|
|
Memory |
|
|
Percent |
|
|
Divide |
|
|
Multiply |
|
|
Minus |
|
|
Plus |
|
|
Sign |
|
|
Equal |


