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:

FacesCalculator3Module

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:

example.png

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: _FacesModule

Create a Faces Calculator3 Module object.

Parameters:

address (int) – I2C address. Default is 0x08.

UiFlow2 Code Block:

init.png

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 None to 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:

tick.png

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:

int

UiFlow2 Code Block:

get_device_id.png

MicroPython Code Block:

device.get_device_id()
get_firmware_version()

Get the firmware version.

Returns:

The firmware version.

Return type:

int

UiFlow2 Code Block:

get_firmware_version.png

MicroPython Code Block:

device.get_firmware_version()
get_i2c_address()

Get the current 7-bit I2C address.

Returns:

The current I2C address.

Return type:

int

UiFlow2 Code Block:

get_i2c_address.png

MicroPython Code Block:

device.get_i2c_address()
get_uid()

Get the 96-bit MCU unique identifier.

Returns:

The 12-byte unique identifier.

Return type:

bytes

UiFlow2 Code Block:

get_uid.png

MicroPython Code Block:

device.get_uid()
set_i2c_address(address)

Set and persist a new 7-bit I2C address.

Parameters:

address (int) – New address in the range 0x08 to 0x77.

Return type:

None

UiFlow2 Code Block:

set_i2c_address.png

MicroPython Code Block:

device.set_i2c_address(0x08)

Calculator key constants:

Constant

Value

Key

KEY_BACKSPACE

0x08

Backspace

KEY_ENTER

0x0D

Enter

KEY_AC

0x41

All clear

KEY_MEMORY

0x4D

Memory

KEY_PERCENT

0x25

Percent

KEY_DIVIDE

0x2F

Divide

KEY_MULTIPLY

0x2A

Multiply

KEY_MINUS

0x2D

Minus

KEY_PLUS

0x2B

Plus

KEY_SIGN

0x60

Sign

KEY_EQUAL

0x3D

Equal