Skip to content

Meck-P4 v0.7.1: Keyboard Support

Pre-release
Pre-release

Choose a tag to compare

@pelgraine pelgraine released this 03 Aug 13:38

⚠️ Flashing this release will delete your existing channel message history. ⚠️

Channel history is now filed by channel identity rather than by slot number, which is what fixes history following the wrong channel after a delete or a companion-app rewrite. The old files cannot be trusted to belong to the channel now in their slot, so the first boot after upgrading removes them rather than migrating them. This happens once.

Not affected: your identity, contacts, channels themselves, radio and device settings, notes, and direct message history. Only stored channel messages are cleared. New messages accumulate normally from first boot.

This release brings full support for the *LilyGo T-Display-P4-Keyboard (K270)* -- physical typing across the whole UI, a brightness-controlled key backlight, and a second battery gauge column for the keyboard's 21700 pack -- together with a markdown Notes app, and a set of fixes to channel message history, WiFi companion recovery, and idle power draw.

It supersedes v0.7, which was never published. If you are coming from v0.6.5, everything below is new to you.

Meck_P4_README_v0.7.1.pdf is included in this release. It documents the keyboard end to end -- how to connect it safely, the battery model, the backlight, every key mapping -- plus the rewritten Notes section and the full settings reference.


First-Time Flashing: Read This First

Meck-P4 ships as a single merged binary (bootloader + partition table + application combined). One file, flash at offset 0x0.

An SD card is recommended. With a FAT32-formatted card inserted, every saved setting, channel message, DM, room post, and note is mirrored or stored on the card, notification tones have somewhere to live, and the device recovers gracefully from a wiped NVS. Without an SD card the device still works but loses message history on reboot, and the Reader, Notes, and notification sounds have no storage.

Keyboard support is a build-time board type, not a runtime setting. A build made for the plain T-Display P4 ignores an attached K270 keyboard entirely, and a keyboard build runs correctly on a bare board -- it probes for the keyboard at boot and falls back to the on-screen keyboard when none answers. Download the image that matches your hardware.

Ensure you use the right-side USB-C port (the data port), not the high-speed charger port, to flash.

correct port usage for flashing

Flashing with the MeshCore Web Flasher (recommended)

  1. Go to https://flasher.meshcore.io/
  2. Scroll to the bottom and select Custom Firmware
  3. Select the .bin file you downloaded
  4. Click OK on the merged-binary warning
  5. Click Flash, pick your device in the popup, and click Connect

Flashing with esptool.py

pip install esptool
esptool.py --chip esp32p4 -p PORT write_flash 0x0 meck-p4-0.7.1.bin

(Replace PORT with /dev/cu.usbmodemXXXX on macOS, /dev/ttyACM0 on Linux, or COM3 on Windows.)

Upgrading from v0.6.5 does not require erase_flash. Your existing settings carry over -- the one new preference (keyboard backlight level) is appended to the end of the prefs blob, and older blobs come up short and fall back to the 25% default. Channel message history is the exception: the old slot-keyed history files are purged once on first boot, for the reason described under Fixes below.


What's New Since v0.6.5

T-Display-P4-Keyboard (K270) support

The K270 keyboard is now fully supported. Meck talks to it directly -- an XL9555 I/O expander at 0x20 and a TCA8418 keypad scanner at 0x34, on a bit-banged I2C bus off the 1x4 P2 connector -- and polls the key FIFO from a 30 ms timer rather than the interrupt line, which keeps the driver clear of GPIO 47/48 and avoids a second GPIO ISR service alongside the radio's.

Keystrokes go to whatever text field is focused on the current screen. Meck walks the active screen for a focused text area rather than consulting a fixed list, so every field in the firmware is covered: message composers, settings, channel and region editors, WiFi, trace and path editors, repeater admin, the web reader's URL and search bars, and the Notes editor.

  • Enter commits a field (the same action as the on-screen keyboard's OK button, so each screen's existing save/send handler runs), Esc cancels, Backspace deletes, and Left / Right move the cursor.
  • Type-to-compose: on the channel and room message screens, any printable key opens the composer and starts typing into it. Arrows, Enter and Esc are left alone so you can still move around the message list.
  • Left / Right on the home screen page the tile grid, the same movement a swipe produces.
  • Shift is a one-shot upper case, Caps is a lock, and the two cancel each other as on a normal keyboard. Fn is a one-shot symbol layer.
  • Fn+H types a comma. LilyGo's vendor key map carried no comma anywhere and duplicated the apostrophe instead; H sits directly above B, which is the full stop.

Important: always power both halves down before joining or separating them -- P4 off, keyboard off, cells in, attach, keyboard on. See the README for the full procedure.

Keyboard backlight, with brightness control

The LilyGo key toggles the key backlight. It sits between Fn and Shift and produces no character.

Settings -> Keyboard Backlight is a new slider, 5% to 100%, defaulting to 25%. Dragging applies the level live and the value is saved when you release. The setting appears on keyboard builds only.

The backlight is driven with 20 kHz LEDC PWM rather than a plain high level: full drive measured about +1 A of extra pack draw, against roughly 398 mA at the 25% default.

The backlight also no longer comes up lit. LilyGo's boot code ran a PWM ramp that made it look like a hardware default; it was firmware, and it was a standing current draw on a battery device. It is now off after every boot until you press the LilyGo key.

Keyboard battery gauge

The Battery tile gains a second column, headed KBD, for the keyboard's 21700 pack.

There is only one fuel gauge in the system -- the P4's BQ27220 -- and the keyboard's selector switch puts exactly one battery on the rail at a time, with no way for firmware to tell which. So Meck asks you to declare the switch position instead of pretending to sense it:

  • Tap the blue KBD header to switch which column is live. The declared side is drawn in white and carries the readings; the other is grey and inert. The header stays tappable in both states, so it is always the way back.
  • Tap the capacity line to declare the pack size -- 5,000 mAh for one 21700 cell or 10,000 mAh for two.
  • Both choices persist across reboots, and the battery percentage in the top-right of the home screen follows the declared source.

While the pack is selected, the chip's own state-of-charge is ignored -- its coulomb counter is referenced against the internal cell's 1000 mAh design capacity and is meaningless for a 21700. Percentage comes from the voltage curve instead, and Rem is declared-capacity arithmetic, so both are marked ~ est. on screen. Time-to-empty is estimated from present discharge current and shown only while actually discharging. Voltage and current remain direct gauge readings.

Also new on the Battery tile for every build: a Gauge temp row showing the BQ27220's raw Temperature() register -- the value the chip is actually using for its CEDV maths, which is not always what the die-temperature row reports.

Notes: markdown

The Notes app now reads and writes markdown.

  • New notes are created as .md. Both .md and .txt are listed, and the files stay plain text, so they open correctly in any editor off-device.
  • .md notes render whole-file into a single scrolling markdown view. .txt notes keep the original paged reader, tap zones and progress percentage, unchanged.
  • A seven-button formatting toolbar in the editor: bold, italic, a heading cycle (none -> # -> ## -> ###), bullet toggle, indent and outdent by two spaces, and a live preview toggle.
  • Bold and italic insert one marker per tap -- tap to open, type the word, tap again to close.
  • Focus stays in the note across a toolbar tap, so you can format and keep typing without tapping back into the field. The insertion point is a blinking white I-beam.
  • Rename preserves the extension, so renaming a .md note cannot turn it into a .txt.

The renderer is a deliberate subset -- #/##/### headings, - bullets, preserved indentation, and inline **bold** / *italic* -- so anything it does not know renders literally and the file stays readable as plain text.

Six new font faces ship for this: Montserrat bold and italic at 22, 24 and 28. Heading and body sizes follow your Settings -> Font Size preference (Classic / Larger / Extra Large), chosen fresh each time the view is drawn.

Fixes

Channel message history is now keyed by channel identity, not slot index. History files were named ch_<slot>.bin, so any reshuffle of the channel table -- delete-and-compact, a companion-app rewrite, a config import -- could leave a channel showing the previous occupant's messages. Files are now keyed by a hash of the channel secret, so history follows the channel through any reshuffle.

Because the old layout gives no way to tell whether a legacy file's contents actually belong to the channel now at that slot, the old ch_<N>.bin files are purged once on upgrade rather than migrated. Existing channel history is cleared by this release; new messages accumulate normally from first boot.

Deleting a channel now deletes its history, instead of leaving a file the next channel in that slot could inherit.

Companion channel writes reload correctly. When the app writes a different channel into an occupied slot, the message ring is reloaded for the new occupant instead of inheriting the previous one's messages.

WiFi companion recovers from a wedged C6 link. Bulk companion traffic -- contact import or delete storms -- could wedge the ESP32-C6's SDIO transmit path: receive kept working, but every AT command afterwards died the same way, including the disable and enable that toggling WiFi issues. Only a reboot cleared it. Meck now detects the signature, tears down interface state without attempting AT traffic, pulses the C6 enable line and re-initialises SDIO and AT, then reconnects with your stored credentials. Three attempts, and toggling WiFi in Settings re-arms the counter.

Keystrokes no longer go missing on the keyboard build. LilyGo's boot code registered an LVGL keypad input device reading the same TCA8418 event FIFO that Meck's own driver reads. Whichever ran first in a given cycle popped the event and the other saw nothing. There is now a single reader.

Smaller changes

  • The Web home tile border is now deep purple, which stacked badly as amber directly under Notes' yellow in the landscape grid.
  • The README has been substantially expanded -- a full keyboard section, a rewritten Notes section, the keyboard-battery model, and a Font Size row in the settings table that was previously undocumented.

Known Limitations

  • The keyboard's CC1101 and nRF24L01+ radios are not available in Meck. There is no driver for either in the firmware; they are reachable only through LilyGo's own standalone example builds. Meck's mesh traffic goes over the P4's SX1262 and nothing else.
  • Keyboard pack readings are estimates. Percentage tracks voltage correctly, but the mAh and time-to-empty figures scale off the capacity you declared, and 5,000 mAh is a nominal figure for a typical 21700 rather than anything read from the cells.
  • Existing channel message history is cleared on upgrade, as described above under Fixes.
  • CardKB support no longer compiles in. The MECK_CARDKB build definition was removed when the K270 driver landed, so the M5Stack CardKB path is currently compiled out of both board types.
  • BLE companion is still not available; WiFi companion remains the way to connect the MeshCore app.
  • The keyboard cannot yet drive the whole UI. Its arrow keys move the cursor inside a text field and page the home grid, but everything else -- scrolling lists, cycling contact filters, opening a message -- is still touch only. Mapping the existing swipe gestures onto the arrow keys is planned for a future release.

For the full feature list see the README.

Reporting Issues

The Meck-P4 channel on the MeshCore Discord is the fastest path. GitHub Issues on the Meck-P4 repo also work for anything reproducible. Include the serial log if you can: Settings > Debug Logs > Start captures it to SD if a serial monitor isn't practical.

License

MIT for Meck-specific code. The combined firmware binary links libraries with mixed licensing including GPL-3.0 and LGPL-2.1 (Codec2) and is effectively GPL-3.0 when distributed.