Skip to content

Commit 6ec32b2

Browse files
committed
Merge branch 'main' into native-file-browser-options-init
2 parents 6804d1e + 4f76105 commit 6ec32b2

File tree

15 files changed

+9383
-5726
lines changed

15 files changed

+9383
-5726
lines changed

.github/workflows/_build_and_test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run:
1616
working-directory: ${{ inputs.target }}
1717
steps:
18-
- uses: actions/[email protected].0
18+
- uses: actions/[email protected].1
1919
- run: rustup component add llvm-tools
2020
- run: sudo apt install libudev-dev
2121
- name: Build

.github/workflows/_lints.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
run:
1616
working-directory: ${{ inputs.target }}
1717
steps:
18-
- uses: actions/[email protected].0
18+
- uses: actions/[email protected].1
1919
- name: Install build dependencies
2020
run: sudo apt install libudev-dev
2121
- name: Run Clippy
22-
uses: auguwu/clippy-action@1.2.2
22+
uses: auguwu/clippy-action@1.3.0
2323
with:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
working-directory: ${{ inputs.target }}
@@ -36,7 +36,7 @@ jobs:
3636
run:
3737
working-directory: ${{ inputs.target }}
3838
steps:
39-
- uses: actions/[email protected].0
39+
- uses: actions/[email protected].1
4040
- name: Install build dependencies
4141
run: sudo apt install libudev-dev
4242
- uses: dtolnay/rust-toolchain@beta
@@ -45,7 +45,7 @@ jobs:
4545
components: clippy
4646
- run: rustup override set ${{ steps.toolchain.outputs.name }}
4747
- name: Run Clippy (beta)
48-
uses: auguwu/clippy-action@1.2.2
48+
uses: auguwu/clippy-action@1.3.0
4949
continue-on-error: true
5050
with:
5151
token: ${{ secrets.GITHUB_TOKEN }}
@@ -62,7 +62,7 @@ jobs:
6262
run:
6363
working-directory: ${{ inputs.target }}
6464
steps:
65-
- uses: actions/[email protected].0
65+
- uses: actions/[email protected].1
6666
- name: Install build dependencies
6767
run: sudo apt install libudev-dev
6868
# Use nightly Rust (as docs.rs does), because some of our dependencies enable the
@@ -86,5 +86,5 @@ jobs:
8686
run:
8787
working-directory: ${{ inputs.target }}
8888
steps:
89-
- uses: actions/[email protected].0
89+
- uses: actions/[email protected].1
9090
- run: cargo fmt --all --check

CHANGELOG.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
77

88
## Unreleased
99

10-
- Migrated to SDK 39.1 (firmware 0.92.2).
10+
### Added
1111

12-
## [0.12.0]
12+
- `flipperzero::gpio::i2c`, providing a Rust interface to the external 3.3V I2C
13+
bus over GPIO pins C0 and C1, as well as the internal (power) I2C bus.
1314

1415
### Changed
1516

16-
- `flipperzero::dialogs::DialogFileBrowserOptions` now uses native initialization function
17+
- Migrated to SDK 46.0 (firmware 0.95.0).
18+
- `flipperzero::dialogs::DialogFileBrowserOptions` now uses native initialization function.
1719
- Bumped pinned nightly Rust version to `nightly-2023-12-03`.
1820

19-
### Removed
20-
21-
- `impl Default for flipperzero::dialogs::DialogFileBrowserOptions`
22-
2321
## [0.11.0]
2422

2523
### Added

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rust for Flipper Zero 🐬❤️🦀
22

33
[![crates.io](https://img.shields.io/crates/v/flipperzero)](https://crates.io/crates/flipperzero)
4-
[![Flipper Zero API](https://img.shields.io/badge/Flipper%20Zero%20API-39.1-orange)](https://github.com/flipperdevices/flipperzero-firmware/blob/0.92.2/firmware/targets/f7/api_symbols.csv)
4+
[![Flipper Zero API](https://img.shields.io/badge/Flipper%20Zero%20API-46.0-orange)](https://github.com/flipperdevices/flipperzero-firmware/blob/0.95.0/targets/f7/api_symbols.csv)
55
[![docs.rs](https://img.shields.io/docsrs/flipperzero)](https://docs.rs/flipperzero)
66
[![MIT license](https://img.shields.io/crates/l/flipperzero)](LICENSE)
77

@@ -17,13 +17,13 @@ This means it's not possible to use anything in the [`std`](https://doc.rust-lan
1717

1818
## SDK version
1919

20-
Currently supports SDK 39.1 ([flipperzero-firmware@0.92.2](https://github.com/flipperdevices/flipperzero-firmware/tree/0.92.2)).
20+
Currently supports SDK 46.0 ([flipperzero-firmware@0.95.0](https://github.com/flipperdevices/flipperzero-firmware/tree/0.95.0)).
2121

22-
The crate major version number will be updated after a bump in [API version](https://github.com/flipperdevices/flipperzero-firmware/blob/release/firmware/targets/f7/api_symbols.csv) in the Flipper Zero firmware.
22+
The crate major version number will be updated after a bump in [API version](https://github.com/flipperdevices/flipperzero-firmware/blob/release/targets/f7/api_symbols.csv) in the Flipper Zero firmware.
2323

2424
| Crate version | API version |
2525
|---------------|-------------|
26-
| Unreleased | 39.1 |
26+
| Unreleased | 46.0 |
2727
| 0.11.x | 35.0 |
2828
| 0.10.x | 28.2 |
2929
| 0.9.x | 23.0 |

crates/flipperzero/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ lock_api = "0.4"
3535
digest = "0.10"
3636
bitflags = "1.0"
3737

38+
# Embedded-hal
39+
embedded-hal = { version = "1.0.0-rc.1", optional = true }
40+
embedded-hal-0 = { package = "embedded-hal", version = "0.2.7", features = ["unproven"], optional = true }
41+
3842
# Docs
3943
document-features = { workspace = true, optional = true }
4044

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//! Example of communicating with a [DS3231] Real-Time Clock.
2+
//!
3+
//! [DS3231]: https://www.analog.com/media/en/technical-documentation/data-sheets/DS3231.pdf
4+
5+
#![no_main]
6+
#![no_std]
7+
8+
// Required for panic handler
9+
extern crate flipperzero_rt;
10+
11+
// Required for allocator
12+
#[cfg(feature = "alloc")]
13+
extern crate flipperzero_alloc;
14+
15+
use flipperzero::{error, furi::time::Duration, gpio::i2c, println};
16+
use flipperzero_rt::{entry, manifest};
17+
use ufmt::derive::uDebug;
18+
19+
manifest!(name = "I2C DS3231 Example");
20+
entry!(main);
21+
22+
#[derive(Debug, uDebug)]
23+
enum Hour {
24+
F12 { hour: u8, pm: bool },
25+
F24(u8),
26+
}
27+
28+
#[derive(Debug, uDebug)]
29+
struct RtcTime {
30+
year: u8,
31+
month: u8,
32+
date: u8,
33+
day: u8,
34+
hour: Hour,
35+
minutes: u8,
36+
seconds: u8,
37+
}
38+
39+
impl RtcTime {
40+
fn parse(data: [u8; 7]) -> Self {
41+
let unbcd = |b: u8| 10 * (b >> 4) + (b & 0x0F);
42+
43+
const FORMAT_12HR: u8 = 0b0100_0000;
44+
45+
Self {
46+
year: unbcd(data[6]),
47+
month: unbcd(data[5] & 0x1F),
48+
date: unbcd(data[4] & 0x3F),
49+
day: data[3] & 0x07,
50+
hour: if data[2] & FORMAT_12HR != 0 {
51+
Hour::F12 {
52+
hour: unbcd(data[2] & 0x1F),
53+
pm: data[2] & 0b0010_0000 != 0,
54+
}
55+
} else {
56+
Hour::F24(unbcd(data[2] & 0x3F))
57+
},
58+
minutes: unbcd(data[1] & 0x7F),
59+
seconds: unbcd(data[0] & 0x7F),
60+
}
61+
}
62+
}
63+
64+
fn main(_args: *mut u8) -> i32 {
65+
let mut bus = i2c::Bus::EXTERNAL.acquire();
66+
let rtc = i2c::DeviceAddress::new(0x68);
67+
let timeout = Duration::from_millis(50);
68+
69+
if bus.is_device_ready(rtc, timeout) {
70+
let mut data = [0; 7];
71+
if bus.read_exact(rtc, 0x00, &mut data, timeout).is_ok() {
72+
println!("Time: {:?}", RtcTime::parse(data));
73+
} else {
74+
error!("Could not read from DS3231");
75+
}
76+
} else {
77+
error!("DS3231 is not connected and ready");
78+
}
79+
80+
0
81+
}

crates/flipperzero/examples/storage.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ fn main(_args: *mut u8) -> i32 {
4242

4343
// Next, we'll open a file browser dialog and let the user select the file.
4444
let mut dialogs_app = DialogsApp::open();
45-
4645
let file_browser_options = DialogFileBrowserOptions::new().set_hide_ext(false);
4746
let mut start_path = FuriString::from(path);
4847
let result_path =

0 commit comments

Comments
 (0)