rad1o: apply Linux kernel style clang-format
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
// Local function: Get next nibble.
|
// Local function: Get next nibble.
|
||||||
static int ctr = 0; // offset for next nibble
|
static int ctr = 0; // offset for next nibble
|
||||||
static int hilo = 0; // 0= high nibble next, 1=low nibble next
|
static int hilo = 0; // 0= high nibble next, 1=low nibble next
|
||||||
static const uint8_t* data;
|
static const uint8_t *data;
|
||||||
|
|
||||||
#define MAXCHR (30 * 20)
|
#define MAXCHR (30 * 20)
|
||||||
static uint8_t charBuf[MAXCHR];
|
static uint8_t charBuf[MAXCHR];
|
||||||
@ -43,7 +43,7 @@ static int upl(int off)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* rad1o_pk_decode(const uint8_t* ldata, int* len)
|
uint8_t *rad1o_pk_decode(const uint8_t *ldata, int *len)
|
||||||
{
|
{
|
||||||
ctr = 0;
|
ctr = 0;
|
||||||
hilo = 0;
|
hilo = 0;
|
||||||
@ -51,7 +51,7 @@ uint8_t* rad1o_pk_decode(const uint8_t* ldata, int* len)
|
|||||||
int length = *len; // Length of character bytestream
|
int length = *len; // Length of character bytestream
|
||||||
int height; // Height of character in bytes
|
int height; // Height of character in bytes
|
||||||
int hoff; // bit position for non-integer heights
|
int hoff; // bit position for non-integer heights
|
||||||
uint8_t* bufptr = charBuf; // Output buffer for decoded character
|
uint8_t *bufptr = charBuf; // Output buffer for decoded character
|
||||||
|
|
||||||
height = (rad1o_getFontHeight() - 1) / 8 + 1;
|
height = (rad1o_getFontHeight() - 1) / 8 + 1;
|
||||||
hoff = rad1o_getFontHeight() % 8;
|
hoff = rad1o_getFontHeight() % 8;
|
||||||
@ -96,17 +96,21 @@ uint8_t* rad1o_pk_decode(const uint8_t* ldata, int* len)
|
|||||||
*bufptr |= 1 << (7 - pos);
|
*bufptr |= 1 << (7 - pos);
|
||||||
};
|
};
|
||||||
pos++;
|
pos++;
|
||||||
if (((bufptr - charBuf) % height) == (height - 1) && (pos == hoff)) {
|
if (((bufptr - charBuf) % height) == (height - 1) &&
|
||||||
|
(pos == hoff)) {
|
||||||
// Finish incomplete last byte per column
|
// Finish incomplete last byte per column
|
||||||
pos = 8;
|
pos = 8;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pos == 8) {
|
if (pos == 8) {
|
||||||
bufptr++;
|
bufptr++;
|
||||||
if ((bufptr - charBuf) % height == 0) { // End of column?
|
if ((bufptr - charBuf) % height ==
|
||||||
|
0) { // End of column?
|
||||||
while (repeat > 0) {
|
while (repeat > 0) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height;
|
||||||
bufptr[0] = bufptr[-height];
|
y++) {
|
||||||
|
bufptr[0] =
|
||||||
|
bufptr[-height];
|
||||||
bufptr++;
|
bufptr++;
|
||||||
};
|
};
|
||||||
repeat--;
|
repeat--;
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
uint8_t* rad1o_pk_decode(const uint8_t* data, int* len);
|
uint8_t *rad1o_pk_decode(const uint8_t *data, int *len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,15 +44,9 @@ static void select()
|
|||||||
uint8_t serial_clock_rate = 1;
|
uint8_t serial_clock_rate = 1;
|
||||||
uint8_t clock_prescale_rate = 12;
|
uint8_t clock_prescale_rate = 12;
|
||||||
|
|
||||||
ssp_init(LCD_SSP,
|
ssp_init(LCD_SSP, SSP_DATA_9BITS, SSP_FRAME_SPI, SSP_CPOL_0_CPHA_0,
|
||||||
SSP_DATA_9BITS,
|
serial_clock_rate, clock_prescale_rate, SSP_MODE_NORMAL,
|
||||||
SSP_FRAME_SPI,
|
SSP_MASTER, SSP_SLAVE_OUT_ENABLE);
|
||||||
SSP_CPOL_0_CPHA_0,
|
|
||||||
serial_clock_rate,
|
|
||||||
clock_prescale_rate,
|
|
||||||
SSP_MODE_NORMAL,
|
|
||||||
SSP_MASTER,
|
|
||||||
SSP_SLAVE_OUT_ENABLE);
|
|
||||||
|
|
||||||
gpio_clear(&gpio_lcd_cs);
|
gpio_clear(&gpio_lcd_cs);
|
||||||
}
|
}
|
||||||
@ -98,11 +92,13 @@ void rad1o_lcdInit(void)
|
|||||||
0x25, 0x3a, // set contrast
|
0x25, 0x3a, // set contrast
|
||||||
0x29, // display on
|
0x29, // display on
|
||||||
0x03, // BSTRON (booster voltage)
|
0x03, // BSTRON (booster voltage)
|
||||||
0x2A, 1, RESX,
|
0x2A, 1, RESX, 0x2B, 1, RESY
|
||||||
0x2B, 1, RESY
|
|
||||||
};
|
};
|
||||||
uint16_t initseq_c = ~(/* commands: 1, data: 0 */
|
uint16_t initseq_c = ~(/* commands: 1, data: 0 */
|
||||||
(1 << 0) | (1 << 1) | (0 << 2) | (1 << 3) | (0 << 4) | (1 << 5) | (0 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (0 << 10) | (0 << 11) | (1 << 12) | (0 << 13) | (0 << 14) | 0);
|
(1 << 0) | (1 << 1) | (0 << 2) | (1 << 3) |
|
||||||
|
(0 << 4) | (1 << 5) | (0 << 6) | (1 << 7) |
|
||||||
|
(1 << 8) | (1 << 9) | (0 << 10) | (0 << 11) |
|
||||||
|
(1 << 12) | (0 << 13) | (0 << 14) | 0);
|
||||||
|
|
||||||
write(0, 0x01); /* most color displays need the pause */
|
write(0, 0x01); /* most color displays need the pause */
|
||||||
delayms(10);
|
delayms(10);
|
||||||
@ -143,7 +139,7 @@ static uint8_t getPixel(uint8_t x, uint8_t y)
|
|||||||
return lcdBuffer[y * RESX + x];
|
return lcdBuffer[y * RESX + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* rad1o_lcdGetBuffer(void)
|
uint8_t *rad1o_lcdGetBuffer(void)
|
||||||
{
|
{
|
||||||
return lcdBuffer;
|
return lcdBuffer;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ void rad1o_lcdDeInit(void);
|
|||||||
void rad1o_lcdFill(uint8_t f);
|
void rad1o_lcdFill(uint8_t f);
|
||||||
void rad1o_lcdDisplay(void);
|
void rad1o_lcdDisplay(void);
|
||||||
void rad1o_lcdSetPixel(uint8_t x, uint8_t y, uint8_t f);
|
void rad1o_lcdSetPixel(uint8_t x, uint8_t y, uint8_t f);
|
||||||
uint8_t* rad1o_lcdGetBuffer(void);
|
uint8_t *rad1o_lcdGetBuffer(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,9 +15,9 @@ struct FONT_DEF {
|
|||||||
uint8_t u8Height; /* Character height for storage */
|
uint8_t u8Height; /* Character height for storage */
|
||||||
uint8_t u8FirstChar; /* The first character available */
|
uint8_t u8FirstChar; /* The first character available */
|
||||||
uint8_t u8LastChar; /* The last character available */
|
uint8_t u8LastChar; /* The last character available */
|
||||||
const uint8_t* au8FontTable; /* Font table start address in memory */
|
const uint8_t *au8FontTable; /* Font table start address in memory */
|
||||||
const FONT_CHAR_INFO* charInfo; /* Pointer to array of char information */
|
const FONT_CHAR_INFO *charInfo; /* Pointer to array of char information */
|
||||||
const uint16_t* charExtra; /* Pointer to array of extra char info */
|
const uint16_t *charExtra; /* Pointer to array of extra char info */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EXTFONT {
|
struct EXTFONT {
|
||||||
@ -26,7 +26,7 @@ struct EXTFONT {
|
|||||||
struct FONT_DEF def;
|
struct FONT_DEF def;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef const struct FONT_DEF* FONT;
|
typedef const struct FONT_DEF *FONT;
|
||||||
|
|
||||||
#define FONT_DEFAULT 0
|
#define FONT_DEFAULT 0
|
||||||
#define FONT_INTERNAL 1
|
#define FONT_INTERNAL 1
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
static int32_t x = 0;
|
static int32_t x = 0;
|
||||||
static int32_t y = 0;
|
static int32_t y = 0;
|
||||||
|
|
||||||
void rad1o_lcdPrint(const char* string)
|
void rad1o_lcdPrint(const char *string)
|
||||||
{
|
{
|
||||||
x = rad1o_DoString(x, y, string);
|
x = rad1o_DoString(x, y, string);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void rad1o_lcdPrint(const char* string);
|
void rad1o_lcdPrint(const char *string);
|
||||||
void rad1o_lcdNl(void);
|
void rad1o_lcdNl(void);
|
||||||
void rad1o_lcdClear(void);
|
void rad1o_lcdClear(void);
|
||||||
void rad1o_lcdMoveCrsr(int32_t dx, int32_t dy);
|
void rad1o_lcdMoveCrsr(int32_t dx, int32_t dy);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* Global Variables */
|
/* Global Variables */
|
||||||
static const struct FONT_DEF* font = NULL;
|
static const struct FONT_DEF *font = NULL;
|
||||||
|
|
||||||
static struct EXTFONT efont;
|
static struct EXTFONT efont;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ void rad1o_setTextColor(uint8_t bg, uint8_t fg)
|
|||||||
color_fg = fg;
|
color_fg = fg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rad1o_setIntFont(const struct FONT_DEF* newfont)
|
void rad1o_setIntFont(const struct FONT_DEF *newfont)
|
||||||
{
|
{
|
||||||
memcpy(&efont.def, newfont, sizeof(struct FONT_DEF));
|
memcpy(&efont.def, newfont, sizeof(struct FONT_DEF));
|
||||||
efont.type = FONT_INTERNAL;
|
efont.type = FONT_INTERNAL;
|
||||||
@ -35,17 +35,18 @@ int rad1o_getFontHeight(void)
|
|||||||
return 8; // XXX: Should be done right.
|
return 8; // XXX: Should be done right.
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int _getIndex(int c)
|
||||||
_getIndex(int c)
|
|
||||||
{
|
{
|
||||||
#define ERRCHR (font->u8FirstChar + 1)
|
#define ERRCHR (font->u8FirstChar + 1)
|
||||||
/* Does this font provide this character? */
|
/* Does this font provide this character? */
|
||||||
if (c < font->u8FirstChar)
|
if (c < font->u8FirstChar)
|
||||||
c = ERRCHR;
|
c = ERRCHR;
|
||||||
if (c > font->u8LastChar && efont.type != FONT_EXTERNAL && font->charExtra == NULL)
|
if (c > font->u8LastChar && efont.type != FONT_EXTERNAL &&
|
||||||
|
font->charExtra == NULL)
|
||||||
c = ERRCHR;
|
c = ERRCHR;
|
||||||
|
|
||||||
if (c > font->u8LastChar && (efont.type == FONT_EXTERNAL || font->charExtra != NULL)) {
|
if (c > font->u8LastChar &&
|
||||||
|
(efont.type == FONT_EXTERNAL || font->charExtra != NULL)) {
|
||||||
int cc = 0;
|
int cc = 0;
|
||||||
while (font->charExtra[cc] < c)
|
while (font->charExtra[cc] < c)
|
||||||
cc++;
|
cc++;
|
||||||
@ -68,7 +69,7 @@ int rad1o_DoChar(int sx, int sy, int c)
|
|||||||
char height = (font->u8Height - 1) / 8 + 1;
|
char height = (font->u8Height - 1) / 8 + 1;
|
||||||
char hoff = (8 - (font->u8Height % 8)) % 8;
|
char hoff = (8 - (font->u8Height % 8)) % 8;
|
||||||
|
|
||||||
const uint8_t* data;
|
const uint8_t *data;
|
||||||
int width, preblank = 0, postblank = 0;
|
int width, preblank = 0, postblank = 0;
|
||||||
do { /* Get Character data */
|
do { /* Get Character data */
|
||||||
/* Get intex into character list */
|
/* Get intex into character list */
|
||||||
@ -90,13 +91,15 @@ int rad1o_DoChar(int sx, int sy, int c)
|
|||||||
for (int y = 0; y < c; y++)
|
for (int y = 0; y < c; y++)
|
||||||
toff += font->charInfo[y].widthBits;
|
toff += font->charInfo[y].widthBits;
|
||||||
width = font->charInfo[c].widthBits;
|
width = font->charInfo[c].widthBits;
|
||||||
if (font->au8FontTable[toff] >> 4 == 15) { // It's a raw character!
|
if (font->au8FontTable[toff] >> 4 ==
|
||||||
|
15) { // It's a raw character!
|
||||||
preblank = font->au8FontTable[toff + 1];
|
preblank = font->au8FontTable[toff + 1];
|
||||||
postblank = font->au8FontTable[toff + 2];
|
postblank = font->au8FontTable[toff + 2];
|
||||||
data = &font->au8FontTable[toff + 3];
|
data = &font->au8FontTable[toff + 3];
|
||||||
width = (width - 3 / height);
|
width = (width - 3 / height);
|
||||||
} else {
|
} else {
|
||||||
data = rad1o_pk_decode(&font->au8FontTable[toff], &width);
|
data = rad1o_pk_decode(
|
||||||
|
&font->au8FontTable[toff], &width);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toff = (c)*font->u8Width * 1;
|
toff = (c)*font->u8Width * 1;
|
||||||
@ -117,7 +120,7 @@ int rad1o_DoChar(int sx, int sy, int c)
|
|||||||
|
|
||||||
sx += preblank;
|
sx += preblank;
|
||||||
|
|
||||||
uint8_t* lcdBuffer = rad1o_lcdGetBuffer();
|
uint8_t *lcdBuffer = rad1o_lcdGetBuffer();
|
||||||
/* per line */
|
/* per line */
|
||||||
for (int y = hoff; y < height * 8; y++) {
|
for (int y = hoff; y < height * 8; y++) {
|
||||||
if (sy + y >= RESY)
|
if (sy + y >= RESY)
|
||||||
@ -149,9 +152,9 @@ int rad1o_DoChar(int sx, int sy, int c)
|
|||||||
return sx + (width + postblank);
|
return sx + (width + postblank);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rad1o_DoString(int sx, int sy, const char* s)
|
int rad1o_DoString(int sx, int sy, const char *s)
|
||||||
{
|
{
|
||||||
const char* c;
|
const char *c;
|
||||||
for (c = s; *c != 0; c++) {
|
for (c = s; *c != 0; c++) {
|
||||||
sx = rad1o_DoChar(sx, sy, *c);
|
sx = rad1o_DoChar(sx, sy, *c);
|
||||||
};
|
};
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
|
|
||||||
void rad1o_setTextColor(uint8_t bg, uint8_t fg);
|
void rad1o_setTextColor(uint8_t bg, uint8_t fg);
|
||||||
void rad1o_setIntFont(const struct FONT_DEF* font);
|
void rad1o_setIntFont(const struct FONT_DEF *font);
|
||||||
int rad1o_getFontHeight(void);
|
int rad1o_getFontHeight(void);
|
||||||
int rad1o_DoString(int sx, int sy, const char* s);
|
int rad1o_DoString(int sx, int sy, const char *s);
|
||||||
int rad1o_DoChar(int sx, int sy, int c);
|
int rad1o_DoChar(int sx, int sy, int c);
|
||||||
#endif
|
#endif
|
||||||
|
@ -3399,18 +3399,17 @@ const FONT_CHAR_INFO Ubuntu18ptLengths[] = {
|
|||||||
{ 30 }, /* € */
|
{ 30 }, /* € */
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint16_t Ubuntu18ptExtra[] = {
|
const uint16_t Ubuntu18ptExtra[] = { 196, 214, 220, 223, 228,
|
||||||
196, 214, 220, 223, 228, 246, 252, 8364, 65535
|
246, 252, 8364, 65535 };
|
||||||
};
|
|
||||||
|
|
||||||
/* Font info */
|
/* Font info */
|
||||||
const struct FONT_DEF Font_Ubuntu18pt = {
|
const struct FONT_DEF Font_Ubuntu18pt = { 1, /* width (1 == comressed) */
|
||||||
1, /* width (1 == comressed) */
|
|
||||||
26, /* character height */
|
26, /* character height */
|
||||||
32, /* first char */
|
32, /* first char */
|
||||||
126, /* last char */
|
126, /* last char */
|
||||||
Ubuntu18ptBitmaps, Ubuntu18ptLengths, Ubuntu18ptExtra
|
Ubuntu18ptBitmaps,
|
||||||
};
|
Ubuntu18ptLengths,
|
||||||
|
Ubuntu18ptExtra };
|
||||||
|
|
||||||
/* Font metadata:
|
/* Font metadata:
|
||||||
* Name: Ubuntu Regular 18pt
|
* Name: Ubuntu Regular 18pt
|
||||||
|
@ -130,7 +130,7 @@ static void ui_update(void)
|
|||||||
rad1o_drawHLine(11, 0, RESX - 1, WHITE);
|
rad1o_drawHLine(11, 0, RESX - 1, WHITE);
|
||||||
|
|
||||||
rad1o_lcdSetCrsr(2, 12);
|
rad1o_lcdSetCrsr(2, 12);
|
||||||
if(trx_mode == TRANSCEIVER_MODE_RX_SWEEP) {
|
if (trx_mode == TRANSCEIVER_MODE_RX_SWEEP) {
|
||||||
rad1o_setIntFont(&Font_Ubuntu18pt);
|
rad1o_setIntFont(&Font_Ubuntu18pt);
|
||||||
rad1o_lcdPrint("SWEEP");
|
rad1o_lcdPrint("SWEEP");
|
||||||
} else {
|
} else {
|
||||||
@ -223,7 +223,7 @@ static void rad1o_ui_set_frequency(uint64_t frequency)
|
|||||||
{
|
{
|
||||||
freq = frequency;
|
freq = frequency;
|
||||||
|
|
||||||
if(TRANSCEIVER_MODE_RX_SWEEP == trx_mode) {
|
if (TRANSCEIVER_MODE_RX_SWEEP == trx_mode) {
|
||||||
} else {
|
} else {
|
||||||
ui_update();
|
ui_update();
|
||||||
}
|
}
|
||||||
@ -271,12 +271,14 @@ static void rad1o_ui_set_bb_tx_vga_gain(const uint32_t gain_db)
|
|||||||
ui_update();
|
ui_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rad1o_ui_set_first_if_frequency(const uint64_t frequency __attribute__((unused)))
|
static void rad1o_ui_set_first_if_frequency(const uint64_t frequency
|
||||||
|
__attribute__((unused)))
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rad1o_ui_set_filter(const rf_path_filter_t filter __attribute__((unused)))
|
static void rad1o_ui_set_filter(const rf_path_filter_t filter
|
||||||
|
__attribute__((unused)))
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
}
|
}
|
||||||
@ -286,7 +288,8 @@ static void rad1o_ui_set_antenna_bias(bool antenna_bias __attribute__((unused)))
|
|||||||
// Not implemented
|
// Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rad1o_ui_set_clock_source(clock_source_t source __attribute__((unused)))
|
static void rad1o_ui_set_clock_source(clock_source_t source
|
||||||
|
__attribute__((unused)))
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
}
|
}
|
||||||
@ -321,7 +324,7 @@ static const hackrf_ui_t rad1o_ui = {
|
|||||||
&rad1o_ui_operacake_gpio_compatible,
|
&rad1o_ui_operacake_gpio_compatible,
|
||||||
};
|
};
|
||||||
|
|
||||||
const hackrf_ui_t* rad1o_ui_setup(void)
|
const hackrf_ui_t *rad1o_ui_setup(void)
|
||||||
{
|
{
|
||||||
return &rad1o_ui;
|
return &rad1o_ui;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,6 @@
|
|||||||
|
|
||||||
#include "hackrf_ui.h"
|
#include "hackrf_ui.h"
|
||||||
|
|
||||||
const hackrf_ui_t* rad1o_ui_setup(void) __attribute__((weak));
|
const hackrf_ui_t *rad1o_ui_setup(void) __attribute__((weak));
|
||||||
|
|
||||||
#endif/*__UI_RAD1O_H__*/
|
#endif /*__UI_RAD1O_H__*/
|
||||||
|
Reference in New Issue
Block a user