Skip to content

Commit

Permalink
Update API and add How To Use example
Browse files Browse the repository at this point in the history
Also update README to point to documentation.
  • Loading branch information
pguyot committed Jul 4, 2023
1 parent a35c21c commit 39b4e43
Show file tree
Hide file tree
Showing 20 changed files with 47,546 additions and 125 deletions.
23 changes: 16 additions & 7 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
---
BasedOnStyle: WebKit
StatementMacros:
- M5_NIF_v_v
- M5_NIF_v_i
- M5_NIF_b_v
- M5_NIF_f_f2_v
- M5_NIF_i_v
- M5_NIF_i2_i2u_v
- M5_NIF_i2_v
- M5_NIF_i3_i3u_v
- M5_NIF_i3_v
- M5_NIF_i2_i3_v
- M5_NIF_i3_i4_v
- M5_NIF_i4_i5_v
- M5_NIF_i5_i6_v
- M5_NIF_i6_i7_v
- M5_NIF_i4_i4u_v
- M5_NIF_i4_v
- M5_NIF_i5_i5u_v
- M5_NIF_i6_i6u_v
- M5_NIF_si2_i
- M5_NIF_u_v
- M5_NIF_v_3b
- M5_NIF_v_b
- M5_NIF_v_i
- M5_NIF_v_i4
- M5_NIF_v_u_v
- M5_NIF_v_v
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

set(ATOMVM_M5_COMPONENT_SRCS
"nifs/atomvm_m5.cc"
"nifs/atomvm_m5_btn.cc"
"nifs/atomvm_m5_display.cc"
"nifs/atomvm_m5_i2c.cc"
"nifs/atomvm_m5_imu.cc"
"nifs/atomvm_m5_power.cc"
"nifs/atomvm_m5_power_axp192.cc"
"nifs/atomvm_m5_rtc.cc"
Expand Down
12 changes: 12 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ config AVM_M5_ENABLE
help
Use this parameter to enable or disable the AtomVM M5 driver.

config AVM_M5_BTN_ENABLE
bool "Enable AtomVM M5 driver button API"
default y
help
Use this parameter to enable or disable the AtomVM M5 driver button API.

config AVM_M5_DISPLAY_ENABLE
bool "Enable AtomVM M5 driver display API"
default y
Expand All @@ -30,6 +36,12 @@ config AVM_M5_I2C_ENABLE
help
Use this parameter to enable or disable the AtomVM M5 driver I2C API.

config AVM_M5_IMU_ENABLE
bool "Enable AtomVM M5 driver IMU API"
default y
help
Use this parameter to enable or disable the AtomVM M5 driver IMU API.

config AVM_M5_RTC_ENABLE
bool "Enable AtomVM M5 driver RTC API"
default y
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,4 @@ This project is a port of M5Unified for the AtomVM platform.

## Usage

The following modules are currently defined:

```
m5
m5_display
m5_i2c
m5_power
m5_power_axp192
m5_rtc
m5_speaker
```
Please refer to [examples](examples/) and [API documentation](https://pguyot.github.io/atomvm_m5/).
19 changes: 19 additions & 0 deletions examples/basic/how_to_use/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.rebar3
_*
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
_build
.idea
*.iml
rebar3.crashdump
*~
19 changes: 19 additions & 0 deletions examples/basic/how_to_use/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
How to use
==========

![Sample code running on M5 Stick C Plus and M5GO](./how_to_use.jpg)

This sample code is a port of the following example:
https://github.com/m5stack/M5Unified/blob/master/examples/Basic/HowToUse/HowToUse.ino

Installation
------------

- Compile and install AtomVM with `atomvm_m5` as explained [here](../../../README.md)
- Install rebar3
- Connect a M5 device with AtomVM (VM and library) preinstalled.
- Compile and flash with:

```
rebar3 esp32_flash -p /dev/tty.usbserial-*
```
Binary file added examples/basic/how_to_use/how_to_use.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/basic/how_to_use/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{erl_opts, [debug_info]}.
{deps, [
{atomvm_m5, {path, "../../../"}}
]}.
{plugins, [
rebar3_path_deps,
{atomvm_rebar3_plugin, {git, "https://github.com/atomvm/atomvm_rebar3_plugin.git", {branch, "master"}}}
]}.
14 changes: 14 additions & 0 deletions examples/basic/how_to_use/src/how_to_use.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{application, how_to_use,
[{description, "How to use M5 sample code"},
{vsn, "0.1.0"},
{registered, []},
{applications,
[kernel,
stdlib
]},
{env,[]},
{modules, []},

{licenses, ["MIT"]},
{links, []}
]}.
Loading

0 comments on commit 39b4e43

Please sign in to comment.