62 #include "physical_constants.h"
64 #include "airspeedactual.h"
65 #include "flightstatus.h"
66 #include "systemalarms.h"
67 #include "modulesettings.h"
69 static inline float pythag(
float a,
float b) {
70 return sqrtf(a * a + b * b);
80 const uint8_t _rect_thin [] = {0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7};
81 const uint8_t _rect_fill [] = {0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf};
83 if (w < 2 || h < 2)
return;
88 const uint8_t *rect = filled ? _rect_fill : _rect_thin;
92 for (uint8_t
i = 0;
i < h;
i ++) {
95 buffer [0] = rect [0];
96 buffer [r] = rect [2];
99 buffer [0] = rect [4];
100 buffer [r] = rect [6];
103 buffer [0] = rect [3];
104 buffer [r] = rect [7];
109 memset(buffer + 1, spacer, w - 2);
117 #define ERR_STR "---"
119 #define terminate_buffer() do { buffer [sizeof(buffer) - 1] = 0; } while (0)
121 #define STD_UPDATE(__name, n, fmt, ...) static void __name ## _update(charosd_state_t state, uint8_t x, uint8_t y) \
124 snprintf(buffer, sizeof (buffer), fmt, __VA_ARGS__); \
125 terminate_buffer(); \
126 PIOS_MAX7456_puts(state->dev, x, y, buffer, 0); \
129 #define STD_PANEL(__name, bs, fmt, ...) \
130 STD_UPDATE(__name, bs, fmt, __VA_ARGS__);
134 STD_PANEL(ALTITUDE, 8,
"\x85%d\x8d", (int16_t)round(-
state->telemetry.position_actual.Down));
137 #define _PAN_CLIMB_SYMB 0x03
151 snprintf(buffer,
sizeof (buffer),
"%c%.1f\x8c", s,
161 const char *
mode =
"INIT";
164 case FLIGHTSTATUS_FLIGHTMODE_MANUAL:
167 case FLIGHTSTATUS_FLIGHTMODE_ACRO:
170 case FLIGHTSTATUS_FLIGHTMODE_ACROPLUS:
173 case FLIGHTSTATUS_FLIGHTMODE_LEVELING:
176 case FLIGHTSTATUS_FLIGHTMODE_HORIZON:
179 case FLIGHTSTATUS_FLIGHTMODE_AXISLOCK:
182 case FLIGHTSTATUS_FLIGHTMODE_VIRTUALBAR:
185 case FLIGHTSTATUS_FLIGHTMODE_STABILIZED1:
188 case FLIGHTSTATUS_FLIGHTMODE_STABILIZED2:
191 case FLIGHTSTATUS_FLIGHTMODE_STABILIZED3:
194 case FLIGHTSTATUS_FLIGHTMODE_AUTOTUNE:
197 case FLIGHTSTATUS_FLIGHTMODE_ALTITUDEHOLD:
200 case FLIGHTSTATUS_FLIGHTMODE_POSITIONHOLD:
203 case FLIGHTSTATUS_FLIGHTMODE_RETURNTOHOME:
206 case FLIGHTSTATUS_FLIGHTMODE_PATHPLANNER:
209 case FLIGHTSTATUS_FLIGHTMODE_ACRODYNE:
212 case FLIGHTSTATUS_FLIGHTMODE_FAILSAFE:
215 case FLIGHTSTATUS_FLIGHTMODE_TABLETCONTROL:
219 case FLIGHTSTATUS_FLIGHTMODE_LQG:
222 case FLIGHTSTATUS_FLIGHTMODE_LQGLEVELING:
225 case FLIGHTSTATUS_FLIGHTMODE_FLIPREVERSED:
238 draw_rect(state, x, y, 3, 3,
true, attr);
247 uint16_t hours = (time / 3600000);
250 sec = (time / 1000) - 60 * min;
251 sprintf(buffer,
"%02d:%02d", (
int)min, (
int)sec);
253 min = time / 60000 - 60 * hours;
254 sec = (time / 1000) - 60 * min - 3600 * hours;
255 sprintf(buffer,
"%02d:%02d:%02d", (
int)hours, (
int)min, (
int)sec);
271 #define _PAN_GPS_2D 0x01
272 #define _PAN_GPS_3D 0x02
291 STD_PANEL(LATITUDE, 11,
"\x83%02.6f", (
double)
state->telemetry.gps_position.Latitude / 10000000.0);
294 STD_PANEL(LONGITUDE, 11,
"\x84%02.6f", (
double)
state->telemetry.gps_position.Longitude / 10000000.0);
296 #define PANEL_HORIZON_WIDTH 14
297 #define PANEL_HORIZON_HEIGHT 5
299 #define _PAN_HORZ_LINE 0x16
300 #define _PAN_HORZ_TOP 0x0e
302 #define _PAN_HORZ_CHAR_LINES 18
303 #define _PAN_HORZ_VRES 9
304 #define _PAN_HORZ_INT_WIDTH (PANEL_HORIZON_WIDTH - 2)
305 #define _PAN_HORZ_LINES (PANEL_HORIZON_HEIGHT * _PAN_HORZ_VRES)
306 #define _PAN_HORZ_TOTAL_LINES (PANEL_HORIZON_HEIGHT * _PAN_HORZ_CHAR_LINES)
316 memcpy(buffer[
i], i == PANEL_HORIZON_HEIGHT / 2 ? _horz_center : _horz_line,
PANEL_HORIZON_WIDTH);
343 STD_PANEL(THROTTLE, 7,
"\x87%d%%", (
int)
MAX(-99,
state->telemetry.manual.thrust*100));
347 (
int)roundf(
pythag(
state->telemetry.velocity_actual.North,
348 state->telemetry.velocity_actual.East) * 3.6f));
351 STD_PANEL(BATTERYVOLT, 8,
"%.2f\x8e", (
double)
state->telemetry.battery.Voltage);
354 STD_PANEL(BATTERYCURRENT, 8,
"%.2f\x8f", (
double)
state->telemetry.battery.Current);
357 STD_PANEL(BATTERYCONSUMED, 8,
"%u\x82", (uint16_t)
state->telemetry.battery.ConsumedEnergy);
373 snprintf(buffer,
sizeof(buffer),
"%.2f%c",
376 snprintf(buffer,
sizeof(buffer),
"%d%c",
384 #define _ARROWS CHAROSD_CHAR_ARROW_NL
394 uint8_t chr =
_ARROWS + (0xf & (((uint8_t) (home_dir / 360.0
f * 16.0
f)) * 2));
406 STD_PANEL(TEMPERATURE, 9,
"\xfd%.1f\x8a", 0.0);
411 const char _l0 [] =
"\xe5\xe8\xe8";
412 const char _l1 [] =
"\xe2\xe8\xe8";
413 const char _l2 [] =
"\xe2\xe6\xe8";
414 const char _l3 [] =
"\xe2\xe3\xe8";
415 const char _l4 [] =
"\xe2\xe3\xe7";
416 const char _l5 [] =
"\xe2\xe3\xe4";
418 const char *
const levels [] = { _l0, _l1, _l2, _l3, _l4, _l5 };
423 if (level > 5) level = 5;
431 const uint8_t ruler [] = {
432 0xc2, 0xc0, 0xc1, 0xc0,
433 0xc4, 0xc0, 0xc1, 0xc0,
434 0xc3, 0xc0, 0xc1, 0xc0,
435 0xc5, 0xc0, 0xc1, 0xc0,
438 const int8_t ruler_size =
sizeof(ruler);
441 / 360.0f) - (
sizeof(buffer) - 1) / 2;
442 if (offset < 0) offset += ruler_size;
443 for (uint8_t
i = 0;
i <
sizeof (buffer) - 1;
i ++) {
445 if (++offset >= ruler_size) offset = 0;
459 AirspeedActualTrueAirspeedGet(&airspeed);
460 snprintf(buffer,
sizeof(buffer),
"\x88%d\x81", (
int)(airspeed * 3.6
f));
468 #define MAX_ALARM_LEN MAX7456_COLUMNS
472 SystemAlarmsData alarm;
473 SystemAlarmsGet(&alarm);
477 AlarmString(&alarm, buffer,
sizeof(buffer),
false, &alarm_state);
481 #define declare_panel(__name, __req) [CHARONSCREENDISPLAYSETTINGS_PANELTYPE_ ## __name] = { \
485 const panel_t panels [CHARONSCREENDISPLAYSETTINGS_PANELTYPE_MAXOPTVAL+1] = {
static void ARMEDFLAG_update(charosd_state_t state, uint8_t x, uint8_t y)
const panel_t panels[CHARONSCREENDISPLAYSETTINGS_PANELTYPE_MAXOPTVAL+1]
#define PANEL_HORIZON_WIDTH
static void ALARMS_update(charosd_state_t state, uint8_t x, uint8_t y)
struct telemetry_t::@9 system
static void RSSI_update(charosd_state_t state, uint8_t x, uint8_t y)
int sprintf(char *out, const char *format,...)
static void RSSIFLAG_update(charosd_state_t state, uint8_t x, uint8_t y)
struct telemetry_t::@7 manual
VelocityActualData velocity_actual
AttitudeActualData attitude_actual
struct _msp_pid_item roll
GPSPositionData gps_position
static void AIRSPEED_update(charosd_state_t state, uint8_t x, uint8_t y)
static void draw_rect(charosd_state_t state, uint8_t l, uint8_t t, uint8_t w, uint8_t h, bool filled, uint8_t attr)
static void HOMEDIRECTION_update(charosd_state_t state, uint8_t x, uint8_t y)
FlightStatusArmedOptions arm_status
static void FLIGHTTIME_update(charosd_state_t state, uint8_t x, uint8_t y)
#define MAX7456_ATTR_INVERT
void PIOS_MAX7456_put(max7456_dev_t dev, uint8_t col, uint8_t row, uint8_t chr, uint8_t attr)
Sets a position of character memory.
PositionActualData position_actual
static void HOMEDISTANCE_update(charosd_state_t state, uint8_t x, uint8_t y)
const char _horz_center[PANEL_HORIZON_WIDTH+1]
void PIOS_MAX7456_puts(max7456_dev_t dev, uint8_t col, uint8_t row, const char *s, uint8_t attr)
Sets a string into character memory.
#define PANEL_HORIZON_HEIGHT
const char _horz_line[PANEL_HORIZON_WIDTH+1]
struct telemetry_t::@8 flight_status
static void CLIMB_update(charosd_state_t state, uint8_t x, uint8_t y)
struct _msp_pid_item level
#define _PAN_HORZ_TOTAL_LINES
#define _PAN_HORZ_INT_WIDTH
#define terminate_buffer()
static void FLIGHTMODE_update(charosd_state_t state, uint8_t x, uint8_t y)
#define HAS_SENSOR(available, required)
void HORIZON_update(charosd_state_t state, uint8_t x, uint8_t y)
static void GPS_update(charosd_state_t state, uint8_t x, uint8_t y)
#define declare_panel(__name, __req)
Includes PiOS and core architecture components.
static void COMPASS_update(charosd_state_t state, uint8_t x, uint8_t y)
int snprintf(char *buf, size_t count, const char *format,...)
static float pythag(float a, float b)
int32_t AlarmString(SystemAlarmsData *alarm, char *buf, size_t buflen, bool blink, uint8_t *state)
SharedDefsFlightModeOptions mode
#define STD_PANEL(__name, bs, fmt,...)
#define MAX7456_ATTR_BLINK
#define CHAROSD_CHAR_COMPASS_INTERNAL
#define _PAN_HORZ_CHAR_LINES