mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 14:55:46 +00:00
DisplayDriver: introduce drawTextRightAlign and drawTextLeftAlign
This commit is contained in:
committed by
Florent
parent
db7635102d
commit
18bfc2d81a
@@ -257,40 +257,27 @@ public:
|
||||
} else if (_page == HomePage::GPS) {
|
||||
LocationProvider* nmea = sensors.getLocationProvider();
|
||||
int y = 18;
|
||||
display.setCursor(0, y);
|
||||
display.print(_task->getGPSState() ? "gps on" : "gps off");
|
||||
display.drawTextLeftAlign(0, y, _task->getGPSState() ? "gps on" : "gps off");
|
||||
if (nmea == NULL) {
|
||||
y = y + 12;
|
||||
display.setCursor(0, y);
|
||||
display.print("Can't access GPS");
|
||||
display.drawTextLeftAlign(0, y, "Can't access GPS");
|
||||
} else {
|
||||
char buf[50];
|
||||
strcpy(buf, nmea->isValid()?"fix":"no fix");
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||
y = y + 12;
|
||||
display.setCursor(0,y);
|
||||
display.print("sat");
|
||||
display.drawTextLeftAlign(0, y, "sat");
|
||||
sprintf(buf, "%d", nmea->satellitesCount());
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||
y = y + 12;
|
||||
display.setCursor(0,y);
|
||||
display.print("pos");
|
||||
display.drawTextLeftAlign(0, y, "pos");
|
||||
sprintf(buf, "%.4f %.4f",
|
||||
nmea->getLatitude()/1000000., nmea->getLongitude()/1000000.);
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||
y = y + 12;
|
||||
display.setCursor(0,y);
|
||||
display.print("alt");
|
||||
display.drawTextLeftAlign(0, y, "alt");
|
||||
sprintf(buf, "%.2f", nmea->getAltitude()/1000.);
|
||||
display.setCursor(
|
||||
display.width()-display.getTextWidth(buf)-1, y);
|
||||
display.print(buf);
|
||||
display.drawTextRightAlign(display.width()-1, y, buf);
|
||||
y = y + 12;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -32,6 +32,15 @@ public:
|
||||
setCursor(mid_x - w/2, y);
|
||||
print(str);
|
||||
}
|
||||
virtual void drawTextRightAlign(int x_anch, int y, const char* str) {
|
||||
int w = getTextWidth(str);
|
||||
setCursor(x_anch - w, y);
|
||||
print(str);
|
||||
}
|
||||
virtual void drawTextLeftAlign(int x_anch, int y, const char* str) {
|
||||
setCursor(x_anch, y);
|
||||
print(str);
|
||||
}
|
||||
|
||||
// convert UTF-8 characters to displayable block characters for compatibility
|
||||
virtual void translateUTF8ToBlocks(char* dest, const char* src, size_t dest_size) {
|
||||
|
||||
Reference in New Issue
Block a user