Create new module for flipper and update UI flipper zero
This commit is contained in:
@@ -1,27 +1,104 @@
|
||||
# CAN Monitor for Flipper Zero
|
||||
|
||||
Flipper Zero application for monitoring CAN sniffer statistics from Raspberry Pi 5 via UART.
|
||||
Dynamic multi-page monitor application for Raspberry Pi 5 via UART.
|
||||
|
||||
## Features
|
||||
|
||||
- Real-time display of CAN sniffer statistics
|
||||
- Shows: IP address, total frames, pending frames, processed frames
|
||||
- Connection status indicator
|
||||
- Compatible with Unleashed firmware (0.84e and later)
|
||||
- **Dynamic Page System** - Pages are fully controlled by RPi5
|
||||
- **Multiple Page Types**:
|
||||
- **Info** - Read-only status display
|
||||
- **Menu** - Selectable action items
|
||||
- **Confirm** - Yes/No confirmation dialogs
|
||||
- **Real-time Updates** - Content refreshes every second
|
||||
- **Bidirectional Communication** - Send commands back to RPi5
|
||||
- **Result Notifications** - Action results displayed as overlay
|
||||
|
||||
## Default Pages
|
||||
|
||||
When connected to the CAN Sniffer system:
|
||||
|
||||
| Page | Type | Description |
|
||||
|------|------|-------------|
|
||||
| CAN Statistics | Info | Frame counts, queue status, per-interface stats |
|
||||
| UPS Status | Info | Battery level, voltage, charging state (X120x) |
|
||||
| System Info | Info | CPU temperature, power consumption, fan RPM |
|
||||
| Actions | Menu | Shutdown, Reboot, Cancel shutdown |
|
||||
|
||||
## Screen Layout
|
||||
|
||||
```
|
||||
128x64 pixels (Flipper Zero display)
|
||||
|
||||
+----------------------------------+
|
||||
| [1/4] Page Title (*) | <- Header: page indicator, title, connection dot
|
||||
+----------------------------------+
|
||||
| |
|
||||
| Content Line 1 | <- Content area: 4-5 lines
|
||||
| Content Line 2 |
|
||||
| Content Line 3 |
|
||||
| Content Line 4 |
|
||||
| |
|
||||
+----------------------------------+
|
||||
| < Hint Text > | <- Footer: nav arrows, action hint
|
||||
+----------------------------------+
|
||||
```
|
||||
|
||||
## Controls
|
||||
|
||||
| Key | Info Page | Menu Page | Confirm Page |
|
||||
|-----|-----------|-----------|--------------|
|
||||
| **Left/Right** | Navigate pages | Navigate pages | Navigate pages |
|
||||
| **Up/Down** | - | Select item | Switch Yes/No |
|
||||
| **OK** | - | Execute action | Confirm selection |
|
||||
| **Back** | Disconnect (pg 0) / Prev page | Same | Cancel dialog |
|
||||
|
||||
## Protocol
|
||||
|
||||
### RPi5 -> Flipper
|
||||
|
||||
```
|
||||
PAGE:<idx>/<total>|<type>|<title>|<lines>|<actions>|<selected>
|
||||
ACK:<device>,ip=<ip>
|
||||
RESULT:<OK|ERROR>|<message>
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
```
|
||||
PAGE:0/4|info|CAN Statistics|Total: 12.3K;Processed: 12.1K;Queue: 142||0
|
||||
PAGE:1/4|info|UPS Status|Bat: 85.2% [====];Voltage: 4.12V;Status: Charging||0
|
||||
PAGE:2/4|info|System Info|CPU Temp: 52.1C;Power: 4.2W;Fan: 3200 RPM||0
|
||||
PAGE:3/4|menu|Actions|Shutdown;Reboot;Cancel Shutdown||0
|
||||
PAGE:3/4|confirm|Confirm Shutdown?|Are you sure?|Yes;No|1
|
||||
ACK:rpi5,ip=192.168.1.100
|
||||
RESULT:OK|Shutdown in 1 min
|
||||
```
|
||||
|
||||
### Flipper -> RPi5
|
||||
|
||||
```
|
||||
INIT:flipper - Start handshake
|
||||
STOP:flipper - Disconnect
|
||||
CMD:NAV:next - Next page
|
||||
CMD:NAV:prev - Previous page
|
||||
CMD:SELECT:<index> - Select menu item
|
||||
CMD:CONFIRM - Confirm action
|
||||
CMD:CANCEL - Cancel action
|
||||
CMD:REFRESH - Request page update
|
||||
```
|
||||
|
||||
## Hardware Connection
|
||||
|
||||
### Wiring (RPI5 <-> Flipper Zero)
|
||||
### Wiring Diagram
|
||||
|
||||
```
|
||||
RPI5 GPIO Flipper Zero GPIO
|
||||
----------- -----------------
|
||||
TX (GPIO 14) --> RX (Pin 14)
|
||||
RX (GPIO 15) <-- TX (Pin 13)
|
||||
GND --> GND
|
||||
Flipper Zero Raspberry Pi 5
|
||||
----------- ---------------
|
||||
Pin 13 (TX) ----> GPIO 15 (RX) - Pin 10
|
||||
Pin 14 (RX) <---- GPIO 14 (TX) - Pin 8
|
||||
Pin 8/11/18 (GND) ---- GND - Pin 6
|
||||
```
|
||||
|
||||
**Note:** Cross TX/RX connections (RPI TX -> Flipper RX, RPI RX -> Flipper TX)
|
||||
**Note:** Cross TX/RX connections (Flipper TX -> RPi RX)
|
||||
|
||||
### Flipper Zero GPIO Pinout
|
||||
|
||||
@@ -54,12 +131,6 @@ cd unleashed-firmware
|
||||
cp -r /path/to/carpibord/flip_monitor applications_user/can_monitor
|
||||
```
|
||||
|
||||
3. Create icon (10x10 PNG, 1-bit):
|
||||
```bash
|
||||
# Create icons/can_monitor.png (10x10 pixels, black & white)
|
||||
# You can use any image editor or online tool
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
@@ -83,23 +154,29 @@ SD Card/apps/GPIO/can_monitor.fap
|
||||
|
||||
### 1. Enable UART
|
||||
|
||||
Add to `/boot/config.txt`:
|
||||
Add to `/boot/firmware/config.txt`:
|
||||
```
|
||||
enable_uart=1
|
||||
dtoverlay=uart0
|
||||
```
|
||||
|
||||
Disable serial console:
|
||||
```bash
|
||||
sudo raspi-config
|
||||
# Interface Options -> Serial Port -> No (login shell) -> Yes (hardware)
|
||||
```
|
||||
|
||||
Reboot after changes.
|
||||
|
||||
### 2. Install pyserial
|
||||
### 2. Install Dependencies
|
||||
|
||||
```bash
|
||||
pip install pyserial
|
||||
pip install pyserial smbus2 gpiozero
|
||||
```
|
||||
|
||||
### 3. Configure CAN Sniffer
|
||||
|
||||
Add to `can_sniffer/config.json`:
|
||||
Add to `can_sniffer/src/config.json`:
|
||||
```json
|
||||
{
|
||||
"flipper": {
|
||||
@@ -124,19 +201,38 @@ cd can_sniffer/src
|
||||
python main.py
|
||||
```
|
||||
|
||||
## Protocol
|
||||
## Adding Custom Pages
|
||||
|
||||
The RPI5 sends text-based statistics over UART:
|
||||
On RPi5 side, create a new page class:
|
||||
|
||||
```
|
||||
STATS:ip=192.168.1.100,total=12345,pending=100,processed=12245\n
|
||||
```python
|
||||
from flipper.pages.base import InfoPage
|
||||
|
||||
class MyCustomPage(InfoPage):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
name="my_page",
|
||||
title="My Page",
|
||||
icon="custom"
|
||||
)
|
||||
|
||||
def get_lines(self) -> list[str]:
|
||||
return [
|
||||
"Custom line 1",
|
||||
"Custom line 2",
|
||||
f"Value: {self.get_value()}"
|
||||
]
|
||||
```
|
||||
|
||||
Fields:
|
||||
- `ip` - RPI5 IP address
|
||||
- `total` - Total CAN frames received
|
||||
- `pending` - Frames in processing queue
|
||||
- `processed` - Successfully processed frames
|
||||
Register in FlipperHandler:
|
||||
|
||||
```python
|
||||
# In flipper_handler.py
|
||||
from flipper.pages.my_custom import MyCustomPage
|
||||
|
||||
# In _setup_pages():
|
||||
self._page_manager.register_page(MyCustomPage())
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -148,7 +244,7 @@ Fields:
|
||||
4. Test UART manually:
|
||||
```bash
|
||||
# On RPI5
|
||||
echo "STATS:ip=test,total=1,pending=0,processed=1" > /dev/ttyAMA0
|
||||
echo "ACK:rpi5,ip=test" > /dev/ttyAMA0
|
||||
```
|
||||
|
||||
### Permission denied on /dev/ttyAMA0
|
||||
@@ -159,11 +255,23 @@ sudo usermod -a -G dialout $USER
|
||||
# Then logout and login again
|
||||
```
|
||||
|
||||
### Flipper shows "Waiting..."
|
||||
### Flipper shows "Waiting for data..."
|
||||
|
||||
- Stats are sent every 1 second (configurable)
|
||||
- Data is sent every 1 second (configurable)
|
||||
- Connection timeout is 5 seconds
|
||||
- Check if CAN sniffer is running
|
||||
- Check UART logs: `CAN_SNIFFER_LOGGING__LEVEL=DEBUG python main.py`
|
||||
|
||||
### UPS page shows "not available"
|
||||
|
||||
- X120x UPS must be connected via I2C
|
||||
- Install smbus2: `pip install smbus2`
|
||||
- Check I2C: `i2cdetect -y 1` (should show device at 0x36)
|
||||
|
||||
## Version History
|
||||
|
||||
- **v2.0** - Dynamic page system, bidirectional commands, UPS/System pages
|
||||
- **v1.0** - Basic CAN statistics display
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in New Issue
Block a user