Skip to content

Commit 4e8fc62

Browse files
tschundlervidplace7
authored andcommitted
Nodelist with Playa addresses for burningmesh (#7321)
* Move BRC address code to a .cpp file since it will be used from multiple places. * Nodelist with addresses * Burning Man icon for BRC page * Draw last-seen time instead of compass This is likely more important - don't want to wander to a device that is off. * Add the bearing list back to the cycled pages on oled devices * Add bearings screen into the carousel of rotated screens * trunk fmt * fix build errors caused by trunk fmt * correct swapped screen positions for BRC vs bearings display * don't show playa position if unknown
1 parent 1d926ce commit 4e8fc62

File tree

7 files changed

+284
-149
lines changed

7 files changed

+284
-149
lines changed

src/graphics/BRC.cpp

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#include "BRC.h"
2+
#include "GPSStatus.h"
3+
#include "gps/GeoCoord.h"
4+
#include "graphics/Screen.h"
5+
6+
using namespace meshtastic;
7+
8+
const int32_t BRC_LATI = (40.786958 * 1e7);
9+
const int32_t BRC_LONI = (-119.202994 * 1e7);
10+
const double BRC_LATF = 40.786958;
11+
const double BRC_LONF = -119.202994;
12+
const double BRC_NOON = 1.5;
13+
const double RAD_TO_HOUR = (6.0 / 3.14159);
14+
const double METER_TO_FEET = 3.28084;
15+
const double FEET_TO_METER = 1.0 / METER_TO_FEET;
16+
17+
// Pre-calculated street data for performance
18+
struct StreetInfo {
19+
float center;
20+
float width;
21+
const char *name;
22+
};
23+
24+
/*
25+
# python code to generate the StreetInfo
26+
27+
esp_center = 2500
28+
street_info = [
29+
# name, width, preceeding block depth
30+
('Esp', 40, 60), # block size is fake
31+
('A', 30, 400),
32+
('B', 30, 250),
33+
('C', 30, 250),
34+
('D', 30, 250),
35+
('E', 40, 250),
36+
('F', 30, 450), # E-F block is exra deep
37+
('G', 30, 250),
38+
('H', 30, 250),
39+
('I', 30, 250),
40+
('J', 30, 150),
41+
('K', 50, 150),
42+
]
43+
44+
street_center = esp_center - street_info[0][1] //2 - street_info[0][2]
45+
last_center = esp_center
46+
for (name, street_width, block_width) in street_info:
47+
offset = (street_width + block_width) // 2
48+
street_center += street_width //2 + block_width
49+
50+
dia = street_center * 2
51+
dist = street_center - last_center
52+
53+
print(f"{{{street_center}, {offset}, \"{name}\"}},\t// +{dist}ft\tdia: {dia:,}ft")
54+
55+
last_center = street_center
56+
street_center += street_width //2
57+
58+
street_center += 50 # extra buffer after the edge of k to include walk-in camping parking
59+
print(f"{{{street_center}, 0, nullptr}},\t// +{street_center-last_center}ft")
60+
*/
61+
62+
static const StreetInfo streets[] = {
63+
{2500, 50, "Esp"}, // +0ft dia: 5,000ft
64+
{2935, 215, "A"}, // +435ft dia: 5,870ft
65+
{3215, 140, "B"}, // +280ft dia: 6,430ft
66+
{3495, 140, "C"}, // +280ft dia: 6,990ft
67+
{3775, 140, "D"}, // +280ft dia: 7,550ft
68+
{4060, 145, "E"}, // +285ft dia: 8,120ft
69+
{4545, 240, "F"}, // +485ft dia: 9,090ft
70+
{4825, 140, "G"}, // +280ft dia: 9,650ft
71+
{5105, 140, "H"}, // +280ft dia: 10,210ft
72+
{5385, 140, "I"}, // +280ft dia: 10,770ft
73+
{5565, 90, "J"}, // +180ft dia: 11,130ft
74+
{5755, 100, "K"}, // +190ft dia: 11,510ft
75+
{5830, 0, nullptr}, // +75ft
76+
};
77+
78+
BRCAddress::BRCAddress(int32_t lat, int32_t lon)
79+
{
80+
bearing = GeoCoord::bearing(BRC_LATF, BRC_LONF, DegD(lat), DegD(lon)) * RAD_TO_HOUR;
81+
bearing += 12.0 - BRC_NOON;
82+
while (bearing > 12.0) {
83+
bearing -= 12.0;
84+
}
85+
86+
// In imperial units because that is how golden spike data is provided.
87+
distance = GeoCoord::latLongToMeter(BRC_LATF, BRC_LONF, DegD(lat), DegD(lon)) * METER_TO_FEET;
88+
};
89+
90+
int BRCAddress::radial(char *buf, size_t len)
91+
{
92+
uint8_t hour = (uint8_t)(bearing);
93+
uint8_t minute = (uint8_t)((bearing - hour) * 60.0);
94+
hour %= 12;
95+
if (hour == 0) {
96+
hour = 12;
97+
}
98+
return snprintf(buf, len, "%d:%02d", hour, minute);
99+
};
100+
101+
int BRCAddress::annular(char *buf, size_t len, bool noUnit)
102+
{
103+
const char *unit = "m";
104+
float unitMultiplier = FEET_TO_METER;
105+
if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) {
106+
unitMultiplier = 1.0;
107+
unit = "ft";
108+
}
109+
if (noUnit)
110+
unit = "";
111+
112+
if (bearing > 1.75 && bearing < 10.25) {
113+
const char *street = nullptr;
114+
float dist = 0;
115+
// Find the appropriate street based on distance
116+
for (const auto &s : streets) {
117+
if (distance > s.center - s.width) {
118+
street = s.name;
119+
dist = distance - s.center;
120+
} else {
121+
break;
122+
}
123+
}
124+
if (street) {
125+
return snprintf(buf, len, "%s %d%s", street, int(dist * unitMultiplier), unit);
126+
}
127+
}
128+
129+
return snprintf(buf, len, "%d%s", int(distance * unitMultiplier), unit);
130+
};
131+
132+
int BRCAddress::full(char *buf, size_t len)
133+
{
134+
auto l = radial(buf, len - 4);
135+
buf += l;
136+
*(buf++) = ' ';
137+
*(buf++) = '&';
138+
*(buf++) = ' ';
139+
buf += annular(buf, len - l - 4, false);
140+
buf[l] = 0; // always null terminated
141+
return l;
142+
};
143+
144+
int BRCAddress::compact(char *buf, size_t len)
145+
{
146+
auto l = radial(buf, len - 2);
147+
buf += l;
148+
*(buf++) = '&';
149+
buf += annular(buf, len - l - 2, true);
150+
buf[l] = 0; // always null terminated
151+
return l;
152+
};

src/graphics/BRC.h

Lines changed: 9 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,19 @@
11
#pragma once
22

3-
#include "GPSStatus.h"
4-
#include "gps/GeoCoord.h"
5-
#include "graphics/Screen.h"
6-
7-
using namespace meshtastic;
8-
9-
const int32_t BRC_LATI = (40.786958 * 1e7);
10-
const int32_t BRC_LONI = (-119.202994 * 1e7);
11-
const double BRC_LATF = 40.786958;
12-
const double BRC_LONF = -119.202994;
13-
const double BRC_NOON = 1.5;
14-
const double RAD_TO_HOUR = (6.0 / 3.14159);
15-
const double METER_TO_FEET = 3.28084;
16-
const double FEET_TO_METER = 1.0 / METER_TO_FEET;
17-
18-
// Pre-calculated street data for performance
19-
struct StreetInfo {
20-
float center;
21-
float width;
22-
const char *name;
23-
};
24-
25-
/*
26-
# python code to generate the StreetInfo
27-
28-
esp_center = 2500
29-
street_info = [
30-
# name, width, preceeding block depth
31-
('Esp', 40, 60), # block size is fake
32-
('A', 30, 400),
33-
('B', 30, 250),
34-
('C', 30, 250),
35-
('D', 30, 250),
36-
('E', 40, 250),
37-
('F', 30, 450), # E-F block is exra deep
38-
('G', 30, 250),
39-
('H', 30, 250),
40-
('I', 30, 250),
41-
('J', 30, 150),
42-
('K', 50, 150),
43-
]
44-
45-
street_center = esp_center - street_info[0][1] //2 - street_info[0][2]
46-
last_center = esp_center
47-
for (name, street_width, block_width) in street_info:
48-
offset = (street_width + block_width) // 2
49-
street_center += street_width //2 + block_width
50-
51-
dia = street_center * 2
52-
dist = street_center - last_center
53-
54-
print(f"{{{street_center}, {offset}, \"{name}\"}},\t// +{dist}ft\tdia: {dia:,}ft")
55-
56-
last_center = street_center
57-
street_center += street_width //2
58-
59-
street_center += 50 # extra buffer after the edge of k to include walk-in camping parking
60-
print(f"{{{street_center}, 0, nullptr}},\t// +{street_center-last_center}ft")
61-
*/
62-
63-
static const StreetInfo streets[] = {
64-
{2500, 50, "Esp"}, // +0ft dia: 5,000ft
65-
{2935, 215, "A"}, // +435ft dia: 5,870ft
66-
{3215, 140, "B"}, // +280ft dia: 6,430ft
67-
{3495, 140, "C"}, // +280ft dia: 6,990ft
68-
{3775, 140, "D"}, // +280ft dia: 7,550ft
69-
{4060, 145, "E"}, // +285ft dia: 8,120ft
70-
{4545, 240, "F"}, // +485ft dia: 9,090ft
71-
{4825, 140, "G"}, // +280ft dia: 9,650ft
72-
{5105, 140, "H"}, // +280ft dia: 10,210ft
73-
{5385, 140, "I"}, // +280ft dia: 10,770ft
74-
{5565, 90, "J"}, // +180ft dia: 11,130ft
75-
{5755, 100, "K"}, // +190ft dia: 11,510ft
76-
{5830, 0, nullptr}, // +75ft
77-
};
3+
// For size_t/int32_t types on some platforms.
4+
#include <cstdint>
5+
// For size_t
6+
#include <cstddef>
787

798
class BRCAddress
809
{
8110
public:
82-
BRCAddress(int32_t lat, int32_t lon)
83-
{
84-
bearing = GeoCoord::bearing(BRC_LATF, BRC_LONF, DegD(lat), DegD(lon)) * RAD_TO_HOUR;
85-
bearing += 12.0 - BRC_NOON;
86-
while (bearing > 12.0) {
87-
bearing -= 12.0;
88-
}
89-
90-
// In imperial units because that is how golden spike data is provided.
91-
distance = GeoCoord::latLongToMeter(BRC_LATF, BRC_LONF, DegD(lat), DegD(lon)) * METER_TO_FEET;
92-
};
93-
94-
int radial(char *buf, size_t len)
95-
{
96-
uint8_t hour = (uint8_t)(bearing);
97-
uint8_t minute = (uint8_t)((bearing - hour) * 60.0);
98-
hour %= 12;
99-
if (hour == 0) {
100-
hour = 12;
101-
}
102-
return snprintf(buf, len, "%d:%02d", hour, minute);
103-
};
104-
105-
int annular(char *buf, size_t len)
106-
{
107-
const char *unit = "m";
108-
float unitMultiplier = FEET_TO_METER;
109-
if (config.display.units == meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL) {
110-
unitMultiplier = 1.0;
111-
unit = "ft";
112-
}
113-
114-
if (bearing > 1.75 && bearing < 10.25) {
115-
const char *street = nullptr;
116-
float dist = 0;
117-
// Find the appropriate street based on distance
118-
for (const auto &s : streets) {
119-
if (distance > s.center - s.width) {
120-
street = s.name;
121-
dist = distance - s.center;
122-
} else {
123-
break;
124-
}
125-
}
126-
if (street) {
127-
return snprintf(buf, len, "%s %d%s", street, int(dist * unitMultiplier), unit);
128-
}
129-
}
130-
131-
return snprintf(buf, len, "%d%s", int(distance * unitMultiplier), unit);
132-
};
11+
BRCAddress(int32_t lat, int32_t lon);
13312

134-
int full(char *buf, size_t len)
135-
{
136-
auto l = radial(buf, len - 4);
137-
buf += l;
138-
*(buf++) = ' ';
139-
*(buf++) = '&';
140-
*(buf++) = ' ';
141-
buf += annular(buf, len - l - 4);
142-
buf[l] = 0; // always null terminated
143-
return l;
144-
};
13+
int radial(char *buf, size_t len);
14+
int annular(char *buf, size_t len, bool noUnit);
15+
int full(char *buf, size_t len);
16+
int compact(char *buf, size_t len);
14517

14618
private:
14719
float bearing;

src/graphics/Screen.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void Screen::setFrames(FrameFocus focus)
907907

908908
// Show detailed node views only on E-Ink builds
909909
#ifdef USE_EINK
910-
fsi.positions.nodelist_lastheard = numframes;
910+
fsi.positions.nodelist_bearings = numframes;
911911
normalFrames[numframes++] = graphics::NodeListRenderer::drawLastHeardScreen;
912912
indicatorIcons.push_back(icon_nodes);
913913

@@ -918,11 +918,15 @@ void Screen::setFrames(FrameFocus focus)
918918
fsi.positions.nodelist_distance = numframes;
919919
normalFrames[numframes++] = graphics::NodeListRenderer::drawDistanceScreen;
920920
indicatorIcons.push_back(icon_distance);
921-
#endif
922-
#if HAS_GPS
921+
923922
fsi.positions.nodelist_bearings = numframes;
924923
normalFrames[numframes++] = graphics::NodeListRenderer::drawNodeListWithCompasses;
925924
indicatorIcons.push_back(icon_list);
925+
#endif
926+
#if HAS_GPS
927+
fsi.positions.nodelist_brc = numframes;
928+
normalFrames[numframes++] = graphics::NodeListRenderer::drawBRCList;
929+
indicatorIcons.push_back(icon_bm);
926930

927931
fsi.positions.gps = numframes;
928932
normalFrames[numframes++] = graphics::UIRenderer::drawCompassAndLocationScreen;
@@ -1391,7 +1395,8 @@ int Screen::handleInputEvent(const InputEvent *event)
13911395
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_hopsignal ||
13921396
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_distance ||
13931397
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_hopsignal ||
1394-
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_bearings) {
1398+
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_bearings ||
1399+
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_brc) {
13951400
menuHandler::nodeListMenu();
13961401
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.wifi) {
13971402
menuHandler::wifiBaseMenu();

src/graphics/Screen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ class Screen : public concurrency::OSThread
662662
uint8_t nodelist_hopsignal = 255;
663663
uint8_t nodelist_distance = 255;
664664
uint8_t nodelist_bearings = 255;
665+
uint8_t nodelist_brc = 255;
665666
uint8_t clock = 255;
666667
uint8_t firstFavorite = 255;
667668
uint8_t lastFavorite = 255;

0 commit comments

Comments
 (0)