kopia lustrzana https://github.com/OpenRTX/OpenRTX
Reorganised graphics module and moved graphics.h from interfaces to core folder
rodzic
e29994f396
commit
1bb574c4fa
|
@ -22,7 +22,7 @@ def = {}
|
|||
openrtx_src = ['openrtx/src/core/state.c',
|
||||
'openrtx/src/core/threads.c',
|
||||
'openrtx/src/core/battery.c',
|
||||
'openrtx/src/core/graphics.cpp',
|
||||
'openrtx/src/core/graphics.c',
|
||||
'openrtx/src/core/input.c',
|
||||
'openrtx/src/core/utils.c',
|
||||
'openrtx/src/core/queue.c',
|
||||
|
|
|
@ -20,24 +20,12 @@
|
|||
#ifndef GRAPHICS_H
|
||||
#define GRAPHICS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <interfaces/display.h>
|
||||
#include <state.h>
|
||||
#include <gfxfont.h>
|
||||
#include <TomThumb.h>
|
||||
#include <FreeSans6pt7b.h>
|
||||
#include <FreeSans8pt7b.h>
|
||||
#include <FreeSans9pt7b.h>
|
||||
#include <FreeSans10pt7b.h>
|
||||
#include <FreeSans12pt7b.h>
|
||||
#include <FreeSans16pt7b.h>
|
||||
#include <FreeSans18pt7b.h>
|
||||
#include <FreeSans24pt7b.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <gps.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <deque>
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
@ -108,18 +96,6 @@ typedef enum
|
|||
TEXT_ALIGN_RIGHT
|
||||
} textAlign_t;
|
||||
|
||||
/**
|
||||
* Selection of the fonts, ordered by the fontSize_t enum.
|
||||
*/
|
||||
static GFXfont const fonts[] = { TomThumb, // 5pt
|
||||
FreeSans6pt7b, // 6pt
|
||||
FreeSans8pt7b, // 8pt
|
||||
FreeSans9pt7b, // 9pt
|
||||
FreeSans10pt7b, // 10pt
|
||||
FreeSans12pt7b, // 12pt
|
||||
FreeSans16pt7b, // 16pt
|
||||
FreeSans18pt7b, // 16pt
|
||||
FreeSans24pt7b }; // 24pt
|
||||
|
||||
/**
|
||||
* This function calls the correspondent method of the low level interface display.h
|
||||
|
@ -219,7 +195,8 @@ void gfx_drawVLine(int16_t x, uint16_t width, color_t color);
|
|||
* @param color: border and fill color, in color_t format.
|
||||
* @param fill: if true the rectangle will be solid, otherwise it will be empty with a 1-pixel border
|
||||
*/
|
||||
void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color, bool fill);
|
||||
void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color,
|
||||
bool fill);
|
||||
|
||||
/**
|
||||
* Draw the outline of a circle of specified radius and color.
|
||||
|
@ -294,7 +271,8 @@ void gfx_printError(const char *text, fontSize_t size);
|
|||
* @param height: battery icon height
|
||||
* @param percentage: battery charge percentage
|
||||
*/
|
||||
void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, uint8_t percentage);
|
||||
void gfx_drawBattery(point_t start, uint16_t width, uint16_t height,
|
||||
uint8_t percentage);
|
||||
|
||||
/**
|
||||
* Function to draw Smeter of arbitrary size.
|
||||
|
@ -306,7 +284,8 @@ void gfx_drawBattery(point_t start, uint16_t width, uint16_t height, uint8_t per
|
|||
* @param squelch: squelch level in percentage
|
||||
* @param color: color of the squelch bar
|
||||
*/
|
||||
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi, float squelch, color_t color);
|
||||
void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
|
||||
float squelch, color_t color);
|
||||
|
||||
/**
|
||||
* Function to draw Smeter + level meter of arbitrary size.
|
||||
|
@ -318,7 +297,8 @@ void gfx_drawSmeter(point_t start, uint16_t width, uint16_t height, float rssi,
|
|||
* @param rssi: rssi level in dBm
|
||||
* @param level: level in range {0, 255}
|
||||
*/
|
||||
void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height, float rssi, uint8_t level);
|
||||
void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height,
|
||||
float rssi, uint8_t level);
|
||||
|
||||
/**
|
||||
* Function to draw GPS SNR bar graph of arbitrary size.
|
||||
|
@ -329,7 +309,8 @@ void gfx_drawSmeterLevel(point_t start, uint16_t width, uint16_t height, float r
|
|||
* @param sats: pointer to the array of satellites data
|
||||
* @param active_sats: bitset representing which sats are part of the fix
|
||||
*/
|
||||
void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height, gpssat_t *sats, uint32_t active_sats);
|
||||
void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height,
|
||||
gpssat_t *sats, uint32_t active_sats);
|
||||
|
||||
/**
|
||||
* Function to draw a compass of arbitrary size.
|
||||
|
@ -341,18 +322,20 @@ void gfx_drawGPSgraph(point_t start, uint16_t width, uint16_t height, gpssat_t *
|
|||
*/
|
||||
void gfx_drawGPScompass(point_t start, uint16_t radius, float deg, bool active);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to plot a collection of data on the screen.
|
||||
* Starting coordinates are relative to the top left point.
|
||||
* @param start: Plot start point, in pixel coordinates.
|
||||
* @param width: Plot width
|
||||
* @param height: Plot height
|
||||
* @param data: pointer to the deque containing data
|
||||
* @param data: pointer to data buffer
|
||||
* @param len: data length, in elements
|
||||
*/
|
||||
void gfx_plotData(point_t start, uint16_t width, uint16_t height, std::deque<int16_t> data);
|
||||
void gfx_plotData(point_t start, uint16_t width, uint16_t height,
|
||||
const int16_t *data, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GRAPHICS_H */
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <state.h>
|
||||
#include <interfaces/graphics.h>
|
||||
#include <graphics.h>
|
||||
#include <interfaces/keyboard.h>
|
||||
#include <stdint.h>
|
||||
#include <event.h>
|
||||
|
|
|
@ -22,22 +22,48 @@
|
|||
* It is suitable for both color, grayscale and B/W display
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <interfaces/display.h>
|
||||
#include <hwconfig.h>
|
||||
#include <graphics.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <hwconfig.h>
|
||||
#include <stdarg.h>
|
||||
#include <interfaces/display.h>
|
||||
#include <interfaces/graphics.h>
|
||||
#include <climits>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gfxfont.h>
|
||||
#include <TomThumb.h>
|
||||
#include <FreeSans6pt7b.h>
|
||||
#include <FreeSans8pt7b.h>
|
||||
#include <FreeSans9pt7b.h>
|
||||
#include <FreeSans10pt7b.h>
|
||||
#include <FreeSans12pt7b.h>
|
||||
#include <FreeSans16pt7b.h>
|
||||
#include <FreeSans18pt7b.h>
|
||||
#include <FreeSans24pt7b.h>
|
||||
|
||||
// Variable swap macro
|
||||
#define DEG_RAD 0.017453292519943295769236907684886
|
||||
#define SIN(x) sinf((x) * DEG_RAD)
|
||||
#define COS(x) cosf((x) * DEG_RAD)
|
||||
|
||||
/**
|
||||
* Fonts, ordered by the fontSize_t enum.
|
||||
*/
|
||||
static const GFXfont fonts[] = { TomThumb, // 5pt
|
||||
FreeSans6pt7b, // 6pt
|
||||
FreeSans8pt7b, // 8pt
|
||||
FreeSans9pt7b, // 9pt
|
||||
FreeSans10pt7b, // 10pt
|
||||
FreeSans12pt7b, // 12pt
|
||||
FreeSans16pt7b, // 16pt
|
||||
FreeSans18pt7b, // 16pt
|
||||
FreeSans24pt7b // 24pt
|
||||
};
|
||||
|
||||
#ifdef PIX_FMT_RGB565
|
||||
|
||||
/* This specialization is meant for an RGB565 little endian pixel format.
|
||||
* Thus, to accomodate for the endianness, the fields in struct rgb565_t have to
|
||||
* be written in reversed order.
|
||||
|
@ -46,14 +72,17 @@
|
|||
* page: http://mjfrazer.org/mjfrazer/bitfields/
|
||||
*/
|
||||
|
||||
#define PIXEL_T rgb565_t
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t b : 5;
|
||||
uint16_t g : 6;
|
||||
uint16_t r : 5;
|
||||
} rgb565_t;
|
||||
}
|
||||
rgb565_t;
|
||||
|
||||
rgb565_t _true2highColor(color_t true_color)
|
||||
static rgb565_t _true2highColor(color_t true_color)
|
||||
{
|
||||
rgb565_t high_color;
|
||||
high_color.r = true_color.r >> 3;
|
||||
|
@ -63,21 +92,24 @@ rgb565_t _true2highColor(color_t true_color)
|
|||
return high_color;
|
||||
}
|
||||
|
||||
#define PIXEL_T rgb565_t
|
||||
#elif defined PIX_FMT_BW
|
||||
|
||||
/**
|
||||
* This specialization is meant for black and white pixel format.
|
||||
* It is suitable for monochromatic displays with 1 bit per pixel,
|
||||
* it will have RGB and grayscale counterparts
|
||||
*/
|
||||
|
||||
#define PIXEL_T uint8_t
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WHITE = 0,
|
||||
BLACK = 1,
|
||||
} bw_t;
|
||||
}
|
||||
bw_t;
|
||||
|
||||
bw_t _color2bw(color_t true_color)
|
||||
static bw_t _color2bw(color_t true_color)
|
||||
{
|
||||
if(true_color.r == 0 &&
|
||||
true_color.g == 0 &&
|
||||
|
@ -87,15 +119,14 @@ bw_t _color2bw(color_t true_color)
|
|||
return BLACK;
|
||||
}
|
||||
|
||||
#define PIXEL_T uint8_t
|
||||
#else
|
||||
#error Please define a pixel format type into hwconfig.h or meson.build
|
||||
#endif
|
||||
|
||||
bool initialized = 0;
|
||||
PIXEL_T *buf;
|
||||
uint16_t fbSize;
|
||||
char text[32];
|
||||
static bool initialized = 0;
|
||||
static PIXEL_T *buf;
|
||||
static uint16_t fbSize;
|
||||
static char text[32];
|
||||
|
||||
void gfx_init()
|
||||
{
|
||||
|
@ -894,23 +925,22 @@ void gfx_drawGPScompass(point_t start,
|
|||
gfx_print(n_pos, FONT_SIZE_6PT, TEXT_ALIGN_LEFT, white, "N");
|
||||
}
|
||||
|
||||
void gfx_plotData(point_t start,
|
||||
uint16_t width,
|
||||
uint16_t height,
|
||||
std::deque<int16_t> data)
|
||||
void gfx_plotData(point_t start, uint16_t width, uint16_t height,
|
||||
const int16_t *data, size_t len)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
uint16_t horizontal_pos = start.x;
|
||||
color_t white = {255, 255, 255, 255};
|
||||
point_t prev_pos {0, 0}, pos{0, 0};
|
||||
point_t prev_pos = {0, 0};
|
||||
point_t pos = {0, 0};
|
||||
bool first_iteration = true;
|
||||
for (auto d : data)
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
horizontal_pos++;
|
||||
if (horizontal_pos > start.x + width)
|
||||
if (horizontal_pos > (start.x + width))
|
||||
break;
|
||||
pos.x = horizontal_pos;
|
||||
pos.y = start.y + height / 2 + (float) d * 4 / (2 * SHRT_MAX) * height;
|
||||
pos.y = start.y + (height / 2)
|
||||
+ ((data[i] * 4) / (2 * SHRT_MAX) * height);
|
||||
if (pos.y > SCREEN_HEIGHT)
|
||||
pos.y = SCREEN_HEIGHT;
|
||||
if (!first_iteration)
|
||||
|
@ -919,5 +949,4 @@ void gfx_plotData(point_t start,
|
|||
if (first_iteration)
|
||||
first_iteration = false;
|
||||
}
|
||||
gfx_render();
|
||||
}
|
|
@ -19,12 +19,13 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/graphics.h>
|
||||
#include <interfaces/display.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <interfaces/cps_io.h>
|
||||
#include <interfaces/gps.h>
|
||||
#include <threads.h>
|
||||
#include <graphics.h>
|
||||
#include <openrtx.h>
|
||||
#include <threads.h>
|
||||
#include <ui.h>
|
||||
|
||||
extern void *dev_task(void *arg);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <ui.h>
|
||||
#include <state.h>
|
||||
#include <threads.h>
|
||||
#include <interfaces/graphics.h>
|
||||
#include <graphics.h>
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <interfaces/radio.h>
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/graphics.h>
|
||||
#include <interfaces/gpio.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <stdio.h>
|
||||
|
|
Ładowanie…
Reference in New Issue