Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions apps/v-maps/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# V-maps

## 1.1.0

- A menu with two big rounded buttons, Home and Work. It is the screen you get when there is no drive ("Waiting for
Vela…" over it while the phone is out of reach, "Start a destination" once it is there), and during a drive you
swipe right to open it ("Go to", with a hint) and swipe left to close it.
- Pressing Home or Work sends `n1H` / `n1W` to the phone, which ends the drive that is on, if any, and starts one to
the place saved as Home or Work in Vela (needs the new phone patch). The watch shows "Getting the route…" until the
route arrives, and "Open Vela on the phone" if nothing comes within 12 seconds.
- Holding the screen still switches the map between turning with you and held, as before; a slow swipe is not a hold.
- No map is drawn while the menu is up, and the map drawing and rotation code are as they were.
- The big font has an H and a W now.

## 1.0.0

First release as its own app, from Vela Nav 1.27.1: a live heading-up or north-up map with the route as blue dots,
the streets around you, a black dome at the bottom with the next turn, its distance and the time left, a light disc
as your position, and a smooth rotation. New: its own name, icon and listing; the title on the waiting screens;
rounded bends in the streets while the map moves.
13 changes: 13 additions & 0 deletions apps/v-maps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "v-maps"
edition.workspace = true
license.workspace = true
version.workspace = true

[dependencies]
cmf-wp2-app.workspace = true
cmf-wp2-ui.workspace = true

[[bin]]
name = "v-maps"
bench = false
9 changes: 9 additions & 0 deletions apps/v-maps/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Notice

- **V-maps began as Vela Nav**, the watch app by arunk140 in the CMF Tech Community apps repository (MIT). It has
since been rewritten and extended by Abdalrahman (a new screen, map, marker, route dots, animation and icon) and
is a separate app, `v-maps`, so it installs next to Vela Nav and never replaces it.
- **Fonts**: the glyph tables in `src/fonts.rs` are rendered from Noto Sans (SIL Open Font License 1.1), see
`fonts/OFL.txt`.
- **Vela for Android** (arunk140/esp32-vela, GPL-3.0) is a separate program that V-maps talks to over Bluetooth. No
code from it is in this app.
93 changes: 93 additions & 0 deletions apps/v-maps/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
80 changes: 80 additions & 0 deletions apps/v-maps/fonts/mkfont.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"""Renders Noto Sans into the antialiased glyph tables in ../src/fonts.rs.

uv run --with pillow python fonts/mkfont.py [dir with NotoSans-*.ttf]

The output is committed, so a build needs neither Python nor the font files. Noto Sans is under the SIL Open
Font License 1.1 (OFL.txt next to this script); the tables are a converted copy of it.
"""
import sys
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont

SRC = Path(sys.argv[1] if len(sys.argv) > 1 else "/usr/share/fonts/google-noto")
OUT = Path(__file__).resolve().parent.parent / "src" / "fonts.rs"
ASCII = "".join(chr(c) for c in range(32, 127))

# (Rust name, file, px, characters)
FONTS = [
("XL", "NotoSans-Bold.ttf", 84, "0123456789. "),
# units, the clock, the limit, titles
("L", "NotoSans-SemiBold.ttf", 40, "0123456789:. abcdefghijklmnopqrstuvwxyzAVNROHW"),
("S", "NotoSans-Medium.ttf", 26, ASCII + "…·"),
]


def glyphs(file, px, chars):
font = ImageFont.truetype(str(SRC / file), px)
ascent, descent = font.getmetrics()
rows, data = [], bytearray()
for ch in chars:
adv = round(font.getlength(ch))
# draw on a roomy canvas, then crop to the ink (Pillow's bbox includes the side bearings)
big = Image.new("L", (px * 3, px * 3), 0)
ImageDraw.Draw(big).text((px, px * 2), ch, font=font, fill=255, anchor="ls")
q = big.point(lambda v: (v * 15 + 127) // 255 * 17) # 4-bit, so a faint edge pixel counts as nothing
box = q.getbbox()
x0, y0, w, h, off = 0, 0, 0, 0, len(data)
if box:
x0, y0 = box[0] - px, box[1] - px * 2
w, h = box[2] - box[0], box[3] - box[1]
px4 = [v // 17 for v in q.crop(box).get_flattened_data()]
if len(px4) % 2:
px4.append(0)
data += bytes(px4[i] << 4 | px4[i + 1] for i in range(0, len(px4), 2))
rows.append((ch, adv, x0, y0, w, h, off))
cap = font.getbbox("H", anchor="ls")[1] # its top edge, so ink-exact
return ascent, descent, -cap, rows, data


def rust_char(c):
return {"'": "\\'", "\\": "\\\\"}.get(c, c)


out = [
"//! Generated by `fonts/mkfont.py` from Noto Sans (SIL Open Font License 1.1, `fonts/OFL.txt`). Do not edit.",
"",
"use crate::font::{Font, Glyph};",
"",
]
total = 0
for name, file, px, chars in FONTS:
ascent, descent, cap, rows, data = glyphs(file, px, chars)
total += len(data) + len(rows) * 12
print(name, len(data))
out.append(f"/// {file[:-4]} at {px} px: {len(rows)} glyphs, {len(data)} B of 4-bit coverage.")
out.append(f"pub static {name}: Font = Font {{")
out.append(f" ascent: {ascent},")
out.append(f" descent: {descent},")
out.append(f" cap: {cap},")
out.append(" glyphs: &[")
for ch, adv, x, y, w, h, off in rows:
out.append(f" Glyph {{ c: '{rust_char(ch)}', adv: {adv}, x: {x}, y: {y}, w: {w}, h: {h}, off: {off} }},")
out.append(" ],")
out.append(" bits: &[")
for i in range(0, len(data), 24):
out.append(" " + " ".join(f"{b},"for b in data[i:i + 24]))
out.append(" ],")
out.append("};")
out.append("")
OUT.write_text("\n".join(out))
print(f"{OUT}: {total} B")
Binary file added apps/v-maps/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/v-maps/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/v-maps/shots/driving.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/v-maps/shots/off-route.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/v-maps/shots/zoomed-out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading