Update ATtiny84 firmware to use Volume Up for shutdown, configure KeyMapper, and document automatic boot hotspot

This commit is contained in:
2026-05-25 17:49:30 +02:00
parent 8d101b3162
commit 7d669b4a91
3 changed files with 58 additions and 24 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ uint32_t get_mce_code(uint8_t button) {
case 4: return 0x800f0421; // RIGHT case 4: return 0x800f0421; // RIGHT
case 5: return 0x800f0422; // ENTER / OK case 5: return 0x800f0422; // ENTER / OK
case 6: return 0x800f0423; // BACK case 6: return 0x800f0423; // BACK
case 7: return 0x800f046f; // F12 (Shutdown) case 7: return 0x800f0410; // Volume Up (Shutdown)
default: return 0; default: return 0;
} }
} }
@@ -210,7 +210,7 @@ void loop() {
current_button = 0; current_button = 0;
} }
// Car off detection: if no LIN activity for 5 seconds, send F12 to trigger shutdown // Car off detection: if no LIN activity for 5 seconds, send Volume Up to trigger shutdown
if (is_car_on && (millis() - last_lin_activity_time > 5000)) { if (is_car_on && (millis() - last_lin_activity_time > 5000)) {
is_car_on = false; is_car_on = false;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
+47 -17
View File
@@ -27,7 +27,7 @@ The Steering Wheel Module (SWM) sends frames on LIN ID `0x20` with the navigatio
| **RIGHT** | `d0 & 0x08` | `4` | `0x800f0421` | Navigate Right | | **RIGHT** | `d0 & 0x08` | `4` | `0x800f0421` | Navigate Right |
| **ENTER** | `d1 & 0x08` | `5` | `0x800f0422` | Select / OK | | **ENTER** | `d1 & 0x08` | `5` | `0x800f0422` | Select / OK |
| **BACK** | `d1 & 0x01` | `6` | `0x800f0423` | Back / Exit | | **BACK** | `d1 & 0x01` | `6` | `0x800f0423` | Back / Exit |
| **F12 (Shutdown)** | LIN Silent > 5s | `7` | `0x800f046f` | Trigger Shutdown (via MacroDroid) | | **Volume Up (Shutdown)** | LIN Silent > 5s | `7` | `0x800f0410` | Trigger Shutdown (via KeyMapper) |
*Note: In previous revisions, `ENTER` and `BACK` were reversed. This has been corrected so that pressing `ENTER` maps to `0x800f0422` and `BACK` maps to `0x800f0423`.* *Note: In previous revisions, `ENTER` and `BACK` were reversed. This has been corrected so that pressing `ENTER` maps to `0x800f0422` and `BACK` maps to `0x800f0423`.*
@@ -36,35 +36,65 @@ The Steering Wheel Module (SWM) sends frames on LIN ID `0x20` with the navigatio
To automatically power off the Raspberry Pi when the car is turned off: To automatically power off the Raspberry Pi when the car is turned off:
1. **Activity Monitor**: The ATtiny monitors LIN bus activity. The Central Electronic Module (CEM) continuously polls the LIN bus when the ignition is on. 1. **Activity Monitor**: The ATtiny monitors LIN bus activity. The Central Electronic Module (CEM) continuously polls the LIN bus when the ignition is on.
2. **Timeout**: If no LIN serial data is received for 5 seconds, the ATtiny assumes the car is off. 2. **Timeout**: If no LIN serial data is received for 5 seconds, the ATtiny assumes the car is off.
3. **Shutdown Signal**: It transitions the car status to "off" and sends the MCE code `0x800f046f` (mapped to `KEY_F12`) 3 times to ensure transmission reliability. 3. **Shutdown Signal**: It transitions the car status to "off" and sends the MCE code `0x800f0410` (mapped to `KEY_VOLUMEUP`) 3 times to ensure transmission reliability.
4. **State Protection**: It will not send the shutdown command again until the car is turned back on and LIN traffic resumes (which sets `is_car_on` back to `true`). 4. **State Protection**: It will not send the shutdown command again until the car is turned back on and LIN traffic resumes (which sets `is_car_on` back to `true`).
## Raspberry Pi Configuration ## Raspberry Pi Configuration
### 1. Keymap Setup ### 1. Keymap Setup
Remap scancode `0x800f046f` to `KEY_F12` on the Raspberry Pi: Remap the MCE remote codes on the Raspberry Pi:
- The custom TOML configuration is saved at `/data/rc-rc6-mce.toml` on the Pi. - The custom TOML configuration is saved at `/data/rc-rc6-mce.toml` on the Pi.
- To apply it dynamically: - To apply it dynamically:
```bash ```bash
/vendor/bin/ir-keytable -w /data/rc-rc6-mce.toml /vendor/bin/ir-keytable -w /data/rc-rc6-mce.toml
``` ```
### 2. MacroDroid Persistence & Trigger ### 2. KeyMapper Setup
Configure two macros in **MacroDroid** to manage keymap loading and shutdown: Instead of MacroDroid, **KeyMapper** is used to intercept the `KEY_VOLUMEUP` trigger from the direct-wired IR receiver and execute the shutdown command.
- **Macro 1: Load Keymap on Boot** To configure KeyMapper completely via command-line:
- **Trigger**: *Device Boot* - **Enable Accessibility Service**:
- **Action**: *Run Shell Command* (Check **Run as Root**) ```bash
```bash adb shell settings put secure accessibility_enabled 1
/vendor/bin/ir-keytable -w /data/rc-rc6-mce.toml adb shell settings put secure enabled_accessibility_services io.github.sds100.keymapper/.system.accessibility.MyAccessibilityService
``` ```
- **Grant Do Not Disturb Access** (to prevent warnings on volume key mapping):
```bash
adb shell settings put secure enabled_notification_policy_access_packages io.github.sds100.keymapper
```
- **Map Trigger and Action**:
The preconfigured KeyMapper SQLite database is pushed directly to the device. The Volume Up key is mapped to run the command:
```bash
reboot -p
```
- **Macro 2: Shutdown on F12** ### 3. Wi-Fi Hotspot Auto-start Setup
- **Trigger**: *Media / Key Pressed* -> Select **F12** To enable the Wi-Fi hotspot (`VolvoC70_AndroidAuto` with passphrase `123456789`) automatically at startup:
- **Action**: *Run Shell Command* (Check **Run as Root**) - A boot shell script `/system/bin/start_hotspot.sh` is defined to wait for boot completion and start the SoftAP.
```bash - A custom Android init service configuration `/system/etc/init/start_hotspot.rc` starts it when `sys.boot_completed` transitions to `1`.
reboot -p
``` **Script (`/system/bin/start_hotspot.sh`):**
```sh
#!/system/bin/sh
while [ "$(getprop sys.boot_completed)" != "1" ]; do
sleep 1
done
sleep 5
cmd wifi start-softap VolvoC70_AndroidAuto wpa2 123456789
```
**Init Service (`/system/etc/init/start_hotspot.rc`):**
```rc
service start_hotspot /system/bin/sh /system/bin/start_hotspot.sh
class main
user root
group root system wifi
oneshot
disabled
on property:sys.boot_completed=1
start start_hotspot
```
## Protocol and Timing ## Protocol and Timing
+9 -5
View File
@@ -514,7 +514,6 @@
"priority": 2147483647, "priority": 2147483647,
"schematic_color": "rgba(0, 0, 0, 0.000)", "schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.2, "track_width": 0.2,
"tuning_profile": "",
"via_diameter": 0.6, "via_diameter": 0.6,
"via_drill": 0.3, "via_drill": 0.3,
"wire_width": 6 "wire_width": 6
@@ -533,7 +532,6 @@
"priority": 0, "priority": 0,
"schematic_color": "rgba(0, 0, 0, 0.000)", "schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 1.37, "track_width": 1.37,
"tuning_profile": "",
"via_diameter": 0.6, "via_diameter": 0.6,
"via_drill": 0.3, "via_drill": 0.3,
"wire_width": 6 "wire_width": 6
@@ -552,7 +550,6 @@
"priority": 1, "priority": 1,
"schematic_color": "rgba(0, 0, 0, 0.000)", "schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.5, "track_width": 0.5,
"tuning_profile": "",
"via_diameter": 0.8, "via_diameter": 0.8,
"via_drill": 0.4, "via_drill": 0.4,
"wire_width": 6 "wire_width": 6
@@ -571,14 +568,13 @@
"priority": 2, "priority": 2,
"schematic_color": "rgba(0, 0, 0, 0.000)", "schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.15, "track_width": 0.15,
"tuning_profile": "",
"via_diameter": 0.5, "via_diameter": 0.5,
"via_drill": 0.4, "via_drill": 0.4,
"wire_width": 6 "wire_width": 6
} }
], ],
"meta": { "meta": {
"version": 5 "version": 4
}, },
"net_colors": null, "net_colors": null,
"netclass_assignments": null, "netclass_assignments": null,
@@ -599,8 +595,10 @@
"idf": "", "idf": "",
"netlist": "", "netlist": "",
"plot": "", "plot": "",
"pos_files": "",
"specctra_dsn": "", "specctra_dsn": "",
"step": "3D/PCB_AndroidAuto.stp", "step": "3D/PCB_AndroidAuto.stp",
"svg": "",
"vrml": "" "vrml": ""
}, },
"page_layout_descr_file": "" "page_layout_descr_file": ""
@@ -724,8 +722,14 @@
"page_layout_descr_file": "", "page_layout_descr_file": "",
"plot_directory": "", "plot_directory": "",
"reuse_designators": true, "reuse_designators": true,
"space_save_all_events": true,
"spice_adjust_passive_values": false, "spice_adjust_passive_values": false,
"spice_current_sheet_as_root": false,
"spice_external_command": "spice \"%I\"", "spice_external_command": "spice \"%I\"",
"spice_model_current_sheet_as_root": true,
"spice_save_all_currents": false,
"spice_save_all_dissipations": false,
"spice_save_all_voltages": false,
"subpart_first_id": 65, "subpart_first_id": 65,
"subpart_id_separator": 0, "subpart_id_separator": 0,
"top_level_sheets": [ "top_level_sheets": [