rad1o: apply Linux kernel style clang-format

This commit is contained in:
schneider
2022-01-10 23:42:52 +01:00
parent 7bf55dc983
commit 8a013172b2
14 changed files with 3994 additions and 3989 deletions

View File

@ -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];
@ -14,110 +14,114 @@ static uint8_t charBuf[MAXCHR];
// Get next nibble // Get next nibble
static uint8_t gnn() static uint8_t gnn()
{ {
static uint8_t byte; static uint8_t byte;
uint8_t val; uint8_t val;
if (hilo == 1) if (hilo == 1)
ctr++; ctr++;
hilo = 1 - hilo; hilo = 1 - hilo;
if (hilo == 1) { if (hilo == 1) {
byte = data[ctr]; byte = data[ctr];
val = byte >> 4; val = byte >> 4;
} else { } else {
val = byte & 0x0f; val = byte & 0x0f;
}; };
return val; return val;
} }
// Local function: Unpack "long run". // Local function: Unpack "long run".
static int upl(int off) static int upl(int off)
{ {
int retval; int retval;
while ((retval = gnn()) == 0) { while ((retval = gnn()) == 0) {
off++; off++;
}; };
while (off-- > 0) { while (off-- > 0) {
retval = retval << 4; retval = retval << 4;
retval += gnn(); retval += gnn();
}; };
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;
data = ldata; data = ldata;
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;
#define DYN (12) // Decoder parameter: Fixed value for now. #define DYN (12) // Decoder parameter: Fixed value for now.
int repeat = 0; // Decoder internal: repeat colum? int repeat = 0; // Decoder internal: repeat colum?
int curbit = 0; // Decoder internal: current bit (1 or 0) int curbit = 0; // Decoder internal: current bit (1 or 0)
int pos = 0; // Decoder internal: current bit position (0..7) int pos = 0; // Decoder internal: current bit position (0..7)
int nyb; // Decoder internal: current nibble / value int nyb; // Decoder internal: current nibble / value
if (data[ctr] >> 4 == 14) { // Char starts with 1-bits. if (data[ctr] >> 4 == 14) { // Char starts with 1-bits.
gnn(); gnn();
curbit = 1; curbit = 1;
}; };
while (ctr < length) { /* Iterate the whole input stream */ while (ctr < length) { /* Iterate the whole input stream */
/* Get next encoded nibble and decode */ /* Get next encoded nibble and decode */
nyb = gnn(); nyb = gnn();
if (nyb == 15) { if (nyb == 15) {
repeat++; repeat++;
continue; continue;
} else if (nyb == 14) { } else if (nyb == 14) {
nyb = upl(0); nyb = upl(0);
nyb += 1; nyb += 1;
repeat += nyb; repeat += nyb;
continue; continue;
} else if (nyb > DYN) { } else if (nyb > DYN) {
nyb = (16 * (nyb - DYN - 1)) + gnn() + DYN + 1; nyb = (16 * (nyb - DYN - 1)) + gnn() + DYN + 1;
} else if (nyb == 0) { } else if (nyb == 0) {
nyb = upl(1); nyb = upl(1);
nyb += (16 * (13 - DYN) + DYN) - 16; nyb += (16 * (13 - DYN) + DYN) - 16;
}; };
/* Generate & output bits */ /* Generate & output bits */
while (nyb-- > 0) { while (nyb-- > 0) {
if (pos == 0) // Clear each byte before we start. if (pos == 0) // Clear each byte before we start.
*bufptr = 0; *bufptr = 0;
if (curbit == 1) { if (curbit == 1) {
*bufptr |= 1 << (7 - pos); *bufptr |= 1 << (7 - pos);
}; };
pos++; pos++;
if (((bufptr - charBuf) % height) == (height - 1) && (pos == hoff)) { if (((bufptr - charBuf) % height) == (height - 1) &&
// Finish incomplete last byte per column (pos == hoff)) {
pos = 8; // Finish incomplete last byte per column
}; pos = 8;
};
if (pos == 8) { if (pos == 8) {
bufptr++; bufptr++;
if ((bufptr - charBuf) % height == 0) { // End of column? if ((bufptr - charBuf) % height ==
while (repeat > 0) { 0) { // End of column?
for (int y = 0; y < height; y++) { while (repeat > 0) {
bufptr[0] = bufptr[-height]; for (int y = 0; y < height;
bufptr++; y++) {
}; bufptr[0] =
repeat--; bufptr[-height];
}; bufptr++;
}; };
pos = 0; repeat--;
}; };
}; };
curbit = 1 - curbit; pos = 0;
}; };
};
curbit = 1 - curbit;
};
*len = (bufptr - charBuf) / height; // return size of output buffer. *len = (bufptr - charBuf) / height; // return size of output buffer.
return charBuf; return charBuf;
} }

View File

@ -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

View File

@ -12,8 +12,8 @@
static void delayms(const uint32_t milliseconds) static void delayms(const uint32_t milliseconds)
{ {
/* NOTE: Naively assumes 204 MHz instruction cycle clock and five instructions per count */ /* NOTE: Naively assumes 204 MHz instruction cycle clock and five instructions per count */
delay(milliseconds * 40800); delay(milliseconds * 40800);
} }
static struct gpio_t gpio_lcd_cs = GPIO(4, 12); /* P9_0 */ static struct gpio_t gpio_lcd_cs = GPIO(4, 12); /* P9_0 */
@ -32,7 +32,7 @@ static bool isTurned;
static void select() static void select()
{ {
/* /*
* The LCD requires 9-Bit frames * The LCD requires 9-Bit frames
* Freq = PCLK / (CPSDVSR * [SCR+1]) * Freq = PCLK / (CPSDVSR * [SCR+1])
* We want 120ns / bit -> 8.3 MHz. * We want 120ns / bit -> 8.3 MHz.
@ -41,144 +41,140 @@ static void select()
* *
* Set CPSDVSR = 12 * Set CPSDVSR = 12
*/ */
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);
} }
static void deselect() static void deselect()
{ {
gpio_set(&gpio_lcd_cs); gpio_set(&gpio_lcd_cs);
} }
static void write(uint8_t cd, uint8_t data) static void write(uint8_t cd, uint8_t data)
{ {
uint16_t frame = 0x0; uint16_t frame = 0x0;
frame = cd << 8; frame = cd << 8;
frame |= data; frame |= data;
ssp_transfer(LCD_SSP, frame); ssp_transfer(LCD_SSP, frame);
} }
void rad1o_lcdInit(void) void rad1o_lcdInit(void)
{ {
gpio_output(&gpio_lcd_bl_en); gpio_output(&gpio_lcd_bl_en);
gpio_output(&gpio_lcd_reset); gpio_output(&gpio_lcd_reset);
gpio_output(&gpio_lcd_cs); gpio_output(&gpio_lcd_cs);
/* prepare SPI */ /* prepare SPI */
SETUPpin(LCD_DI); SETUPpin(LCD_DI);
SETUPpin(LCD_SCK); SETUPpin(LCD_SCK);
// Reset the display // Reset the display
gpio_clear(&gpio_lcd_reset); gpio_clear(&gpio_lcd_reset);
delayms(100); delayms(100);
gpio_set(&gpio_lcd_reset); gpio_set(&gpio_lcd_reset);
delayms(100); delayms(100);
select(); select();
/* The controller is a PCF8833 - documentation can be found online. */ /* The controller is a PCF8833 - documentation can be found online. */
static uint8_t initseq_d[] = { static uint8_t initseq_d[] = {
0x11, // SLEEP_OUT (wake up) 0x11, // SLEEP_OUT (wake up)
0x3A, 2, // mode 8bpp (2= 8bpp, 3= 12bpp, 5= 16bpp) 0x3A, 2, // mode 8bpp (2= 8bpp, 3= 12bpp, 5= 16bpp)
0x36, 0b11000000, // my,mx,v,lao,rgb,x,x,x 0x36, 0b11000000, // my,mx,v,lao,rgb,x,x,x
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) |
(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); (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);
size_t i = 0; size_t i = 0;
while (i < sizeof(initseq_d)) { while (i < sizeof(initseq_d)) {
write(initseq_c & 1, initseq_d[i++]); write(initseq_c & 1, initseq_d[i++]);
initseq_c = initseq_c >> 1; initseq_c = initseq_c >> 1;
} }
deselect(); deselect();
rad1o_lcdFill(0xff); /* Clear display buffer */ rad1o_lcdFill(0xff); /* Clear display buffer */
rotate(); rotate();
gpio_set(&gpio_lcd_bl_en); gpio_set(&gpio_lcd_bl_en);
} }
void rad1o_lcdDeInit(void) void rad1o_lcdDeInit(void)
{ {
gpio_clear(&gpio_lcd_bl_en); gpio_clear(&gpio_lcd_bl_en);
rad1o_lcdFill(0xff); rad1o_lcdFill(0xff);
rad1o_lcdDisplay(); rad1o_lcdDisplay();
} }
void rad1o_lcdFill(uint8_t f) void rad1o_lcdFill(uint8_t f)
{ {
memset(lcdBuffer, f, RESX * RESY); memset(lcdBuffer, f, RESX * RESY);
} }
void rad1o_lcdSetPixel(uint8_t x, uint8_t y, uint8_t f) void rad1o_lcdSetPixel(uint8_t x, uint8_t y, uint8_t f)
{ {
if (x > RESX || y > RESY) if (x > RESX || y > RESY)
return; return;
lcdBuffer[y * RESX + x] = f; lcdBuffer[y * RESX + x] = f;
} }
static uint8_t getPixel(uint8_t x, uint8_t y) 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;
} }
void rad1o_lcdDisplay(void) void rad1o_lcdDisplay(void)
{ {
select(); select();
uint16_t x, y; uint16_t x, y;
/* set (back) to 8 bpp mode */ /* set (back) to 8 bpp mode */
write(TYPE_CMD, 0x3a); write(TYPE_CMD, 0x3a);
write(TYPE_DATA, 2); write(TYPE_DATA, 2);
write(TYPE_CMD, 0x2C); // memory write (RAMWR) write(TYPE_CMD, 0x2C); // memory write (RAMWR)
for (y = 0; y < RESY; y++) { for (y = 0; y < RESY; y++) {
for (x = 0; x < RESX; x++) { for (x = 0; x < RESX; x++) {
write(TYPE_DATA, getPixel(x, y)); write(TYPE_DATA, getPixel(x, y));
}; };
} }
deselect(); deselect();
} }
static void rotate(void) static void rotate(void)
{ {
select(); select();
write(TYPE_CMD, 0x36); // MDAC-Command write(TYPE_CMD, 0x36); // MDAC-Command
if (isTurned) { if (isTurned) {
write(TYPE_DATA, 0b01100000); // my,mx,v,lao,rgb,x,x,x write(TYPE_DATA, 0b01100000); // my,mx,v,lao,rgb,x,x,x
isTurned = true; isTurned = true;
} else { } else {
write(TYPE_DATA, 0b11000000); // my,mx,v,lao,rgb,x,x,x write(TYPE_DATA, 0b11000000); // my,mx,v,lao,rgb,x,x,x
isTurned = false; isTurned = false;
} }
deselect(); deselect();
rad1o_lcdDisplay(); rad1o_lcdDisplay();
} }

View File

@ -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

View File

@ -2,29 +2,29 @@
#include <stdint.h> #include <stdint.h>
#define SWAP(p1, p2) \ #define SWAP(p1, p2) \
do { \ do { \
uint8_t SWAP = p1; \ uint8_t SWAP = p1; \
p1 = p2; \ p1 = p2; \
p2 = SWAP; \ p2 = SWAP; \
} while (0) } while (0)
void rad1o_drawHLine(uint8_t y, uint8_t x1, uint8_t x2, uint8_t color) void rad1o_drawHLine(uint8_t y, uint8_t x1, uint8_t x2, uint8_t color)
{ {
if (x1 > x2) { if (x1 > x2) {
SWAP(x1, x2); SWAP(x1, x2);
} }
for (uint8_t i = x1; i <= x2; ++i) { for (uint8_t i = x1; i <= x2; ++i) {
rad1o_lcdSetPixel(i, y, color); rad1o_lcdSetPixel(i, y, color);
} }
} }
void rad1o_drawVLine(uint8_t x, uint8_t y1, uint8_t y2, uint8_t color) void rad1o_drawVLine(uint8_t x, uint8_t y1, uint8_t y2, uint8_t color)
{ {
if (y1 > y2) { if (y1 > y2) {
SWAP(y1, y2); SWAP(y1, y2);
} }
for (uint8_t i = y1; i <= y2; ++i) { for (uint8_t i = y1; i <= y2; ++i) {
rad1o_lcdSetPixel(x, i, color); rad1o_lcdSetPixel(x, i, color);
} }
} }

View File

@ -7,26 +7,26 @@
/* Based on code code by Kevin Townsend */ /* Based on code code by Kevin Townsend */
typedef struct { typedef struct {
const uint8_t widthBits; // width, in bits (or pixels), of the character const uint8_t widthBits; // width, in bits (or pixels), of the character
} FONT_CHAR_INFO; } FONT_CHAR_INFO;
struct FONT_DEF { struct FONT_DEF {
uint8_t u8Width; /* Character width for storage */ uint8_t u8Width; /* Character width for storage */
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 {
uint8_t type; // 0: none, 1: static, 2: loaded uint8_t type; // 0: none, 1: static, 2: loaded
char name[13]; char name[13];
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

View File

@ -7,37 +7,37 @@
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);
} }
void rad1o_lcdNl(void) void rad1o_lcdNl(void)
{ {
x = 0; x = 0;
y += rad1o_getFontHeight(); y += rad1o_getFontHeight();
} }
void rad1o_lcdClear(void) void rad1o_lcdClear(void)
{ {
x = 0; x = 0;
y = 0; y = 0;
rad1o_lcdFill(0xff); rad1o_lcdFill(0xff);
} }
void rad1o_lcdMoveCrsr(int32_t dx, int32_t dy) void rad1o_lcdMoveCrsr(int32_t dx, int32_t dy)
{ {
x += dx; x += dx;
y += dy; y += dy;
} }
void rad1o_lcdSetCrsr(int32_t dx, int32_t dy) void rad1o_lcdSetCrsr(int32_t dx, int32_t dy)
{ {
x = dx; x = dx;
y = dy; y = dy;
} }
void rad1o_setSystemFont(void) void rad1o_setSystemFont(void)
{ {
rad1o_setIntFont(&Font_7x8); rad1o_setIntFont(&Font_7x8);
} }

View File

@ -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);

View File

@ -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;
@ -17,143 +17,146 @@ static uint8_t color_fg = 0x00; /* foreground color */
/* Exported Functions */ /* Exported Functions */
void rad1o_setTextColor(uint8_t bg, uint8_t fg) void rad1o_setTextColor(uint8_t bg, uint8_t fg)
{ {
color_bg = bg; color_bg = bg;
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;
font = &efont.def; font = &efont.def;
} }
int rad1o_getFontHeight(void) int rad1o_getFontHeight(void)
{ {
if (font) if (font)
return font->u8Height; return font->u8Height;
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 &&
c = ERRCHR; font->charExtra == NULL)
c = ERRCHR;
if (c > font->u8LastChar && (efont.type == FONT_EXTERNAL || font->charExtra != NULL)) { if (c > font->u8LastChar &&
int cc = 0; (efont.type == FONT_EXTERNAL || font->charExtra != NULL)) {
while (font->charExtra[cc] < c) int cc = 0;
cc++; while (font->charExtra[cc] < c)
if (font->charExtra[cc] > c) cc++;
c = ERRCHR; if (font->charExtra[cc] > c)
else c = ERRCHR;
c = font->u8LastChar + cc + 1; else
}; c = font->u8LastChar + cc + 1;
c -= font->u8FirstChar; };
return c; c -= font->u8FirstChar;
return c;
} }
int rad1o_DoChar(int sx, int sy, int c) int rad1o_DoChar(int sx, int sy, int c)
{ {
if (font == NULL) { if (font == NULL) {
font = &Font_7x8; font = &Font_7x8;
}; };
/* how many bytes is it high? */ /* how many bytes is it high? */
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 */
c = _getIndex(c); c = _getIndex(c);
/* starting offset into character source data */ /* starting offset into character source data */
int toff = 0; int toff = 0;
if (font->u8Width == 0) { if (font->u8Width == 0) {
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;
toff *= height; toff *= height;
data = &font->au8FontTable[toff]; data = &font->au8FontTable[toff];
postblank = 1; postblank = 1;
} else if (font->u8Width == 1) { // NEW CODE } else if (font->u8Width == 1) { // NEW CODE
// Find offset and length for our character // Find offset and length for our character
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 ==
preblank = font->au8FontTable[toff + 1]; 15) { // It's a raw character!
postblank = font->au8FontTable[toff + 2]; preblank = font->au8FontTable[toff + 1];
data = &font->au8FontTable[toff + 3]; postblank = font->au8FontTable[toff + 2];
width = (width - 3 / height); data = &font->au8FontTable[toff + 3];
} else { width = (width - 3 / height);
data = rad1o_pk_decode(&font->au8FontTable[toff], &width); } else {
} data = rad1o_pk_decode(
} else { &font->au8FontTable[toff], &width);
toff = (c)*font->u8Width * 1; }
width = font->u8Width; } else {
data = &font->au8FontTable[toff]; toff = (c)*font->u8Width * 1;
}; width = font->u8Width;
data = &font->au8FontTable[toff];
};
} while (0); } while (0);
#define xy_(x, y) \ #define xy_(x, y) \
((x < 0 || y < 0 || x >= RESX || y >= RESY) ? 0 : (y)*RESX + (x)) ((x < 0 || y < 0 || x >= RESX || y >= RESY) ? 0 : (y)*RESX + (x))
#define gPx(x, y) (data[x * height + (height - y / 8 - 1)] & (1 << (y % 8))) #define gPx(x, y) (data[x * height + (height - y / 8 - 1)] & (1 << (y % 8)))
int x = 0; int x = 0;
/* Fonts may not be byte-aligned, shift up so the top matches */ /* Fonts may not be byte-aligned, shift up so the top matches */
sy -= hoff; sy -= hoff;
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)
continue; continue;
/* Optional: empty space to the left */ /* Optional: empty space to the left */
for (int b = 1; b <= preblank; b++) { for (int b = 1; b <= preblank; b++) {
if (sx >= RESX) if (sx >= RESX)
continue; continue;
lcdBuffer[xy_(sx - b, sy + y)] = color_bg; lcdBuffer[xy_(sx - b, sy + y)] = color_bg;
}; };
/* Render character */ /* Render character */
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
if (sx + x >= RESX) if (sx + x >= RESX)
continue; continue;
if (gPx(x, y)) { if (gPx(x, y)) {
lcdBuffer[xy_(sx + x, sy + y)] = color_fg; lcdBuffer[xy_(sx + x, sy + y)] = color_fg;
} else { } else {
lcdBuffer[xy_(sx + x, sy + y)] = color_bg; lcdBuffer[xy_(sx + x, sy + y)] = color_bg;
}; };
}; };
/* Optional: empty space to the right */ /* Optional: empty space to the right */
for (int m = 0; m < postblank; m++) { for (int m = 0; m < postblank; m++) {
if (sx + x + m >= RESX) if (sx + x + m >= RESX)
continue; continue;
lcdBuffer[xy_(sx + x + m, sy + y)] = color_bg; lcdBuffer[xy_(sx + x + m, sy + y)] = color_bg;
}; };
}; };
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);
}; };
return sx; return sx;
} }

View File

@ -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

View File

@ -41,103 +41,103 @@
/* System 7x8 */ /* System 7x8 */
const uint8_t au8Font7x8[] = { const uint8_t au8Font7x8[] = {
0, 0, 0, 0, 0, 0, 0, //' ' 0, 0, 0, 0, 0, 0, 0, //' '
0, 6, 95, 95, 6, 0, 0, //'!' 0, 6, 95, 95, 6, 0, 0, //'!'
0, 7, 7, 0, 7, 7, 0, //'"' 0, 7, 7, 0, 7, 7, 0, //'"'
20, 127, 127, 20, 127, 127, 20, //'#' 20, 127, 127, 20, 127, 127, 20, //'#'
36, 46, 107, 107, 58, 18, 0, //'$' 36, 46, 107, 107, 58, 18, 0, //'$'
70, 102, 48, 24, 12, 102, 98, //'%' 70, 102, 48, 24, 12, 102, 98, //'%'
48, 122, 79, 93, 55, 122, 72, //'&' 48, 122, 79, 93, 55, 122, 72, //'&'
4, 7, 3, 0, 0, 0, 0, //''' 4, 7, 3, 0, 0, 0, 0, //'''
0, 28, 62, 99, 65, 0, 0, //'(' 0, 28, 62, 99, 65, 0, 0, //'('
0, 65, 99, 62, 28, 0, 0, //')' 0, 65, 99, 62, 28, 0, 0, //')'
8, 42, 62, 28, 28, 62, 42, //'*' 8, 42, 62, 28, 28, 62, 42, //'*'
8, 8, 62, 62, 8, 8, 0, //'+' 8, 8, 62, 62, 8, 8, 0, //'+'
0, 128, 224, 96, 0, 0, 0, //',' 0, 128, 224, 96, 0, 0, 0, //','
8, 8, 8, 8, 8, 8, 0, //'-' 8, 8, 8, 8, 8, 8, 0, //'-'
0, 0, 96, 96, 0, 0, 0, //'.' 0, 0, 96, 96, 0, 0, 0, //'.'
96, 48, 24, 12, 6, 3, 1, //'/' 96, 48, 24, 12, 6, 3, 1, //'/'
62, 127, 113, 89, 77, 127, 62, //'0' 62, 127, 113, 89, 77, 127, 62, //'0'
64, 66, 127, 127, 64, 64, 0, //'1' 64, 66, 127, 127, 64, 64, 0, //'1'
98, 115, 89, 73, 111, 102, 0, //'2' 98, 115, 89, 73, 111, 102, 0, //'2'
34, 99, 73, 73, 127, 54, 0, //'3' 34, 99, 73, 73, 127, 54, 0, //'3'
24, 28, 22, 83, 127, 127, 80, //'4' 24, 28, 22, 83, 127, 127, 80, //'4'
39, 103, 69, 69, 125, 57, 0, //'5' 39, 103, 69, 69, 125, 57, 0, //'5'
60, 126, 75, 73, 121, 48, 0, //'6' 60, 126, 75, 73, 121, 48, 0, //'6'
3, 3, 113, 121, 15, 7, 0, //'7' 3, 3, 113, 121, 15, 7, 0, //'7'
54, 127, 73, 73, 127, 54, 0, //'8' 54, 127, 73, 73, 127, 54, 0, //'8'
6, 79, 73, 105, 63, 30, 0, //'9' 6, 79, 73, 105, 63, 30, 0, //'9'
0, 0, 102, 102, 0, 0, 0, //':' 0, 0, 102, 102, 0, 0, 0, //':'
0, 128, 230, 102, 0, 0, 0, //';' 0, 128, 230, 102, 0, 0, 0, //';'
8, 28, 54, 99, 65, 0, 0, //'<' 8, 28, 54, 99, 65, 0, 0, //'<'
36, 36, 36, 36, 36, 36, 0, //'=' 36, 36, 36, 36, 36, 36, 0, //'='
0, 65, 99, 54, 28, 8, 0, //'>' 0, 65, 99, 54, 28, 8, 0, //'>'
2, 3, 81, 89, 15, 6, 0, //'?' 2, 3, 81, 89, 15, 6, 0, //'?'
62, 127, 65, 93, 93, 31, 30, //'@' 62, 127, 65, 93, 93, 31, 30, //'@'
124, 126, 19, 19, 126, 124, 0, //'A' 124, 126, 19, 19, 126, 124, 0, //'A'
65, 127, 127, 73, 73, 127, 54, //'B' 65, 127, 127, 73, 73, 127, 54, //'B'
28, 62, 99, 65, 65, 99, 34, //'C' 28, 62, 99, 65, 65, 99, 34, //'C'
65, 127, 127, 65, 99, 62, 28, //'D' 65, 127, 127, 65, 99, 62, 28, //'D'
65, 127, 127, 73, 93, 65, 99, //'E' 65, 127, 127, 73, 93, 65, 99, //'E'
65, 127, 127, 73, 29, 1, 3, //'F' 65, 127, 127, 73, 29, 1, 3, //'F'
28, 62, 99, 65, 81, 115, 114, //'G' 28, 62, 99, 65, 81, 115, 114, //'G'
127, 127, 8, 8, 127, 127, 0, //'H' 127, 127, 8, 8, 127, 127, 0, //'H'
0, 65, 127, 127, 65, 0, 0, //'I' 0, 65, 127, 127, 65, 0, 0, //'I'
48, 112, 64, 65, 127, 63, 1, //'J' 48, 112, 64, 65, 127, 63, 1, //'J'
65, 127, 127, 8, 28, 119, 99, //'K' 65, 127, 127, 8, 28, 119, 99, //'K'
65, 127, 127, 65, 64, 96, 112, //'L' 65, 127, 127, 65, 64, 96, 112, //'L'
127, 127, 14, 28, 14, 127, 127, //'M' 127, 127, 14, 28, 14, 127, 127, //'M'
127, 127, 6, 12, 24, 127, 127, //'N' 127, 127, 6, 12, 24, 127, 127, //'N'
28, 62, 99, 65, 99, 62, 28, //'O' 28, 62, 99, 65, 99, 62, 28, //'O'
65, 127, 127, 73, 9, 15, 6, //'P' 65, 127, 127, 73, 9, 15, 6, //'P'
30, 63, 33, 113, 127, 94, 0, //'Q' 30, 63, 33, 113, 127, 94, 0, //'Q'
65, 127, 127, 9, 25, 127, 102, //'R' 65, 127, 127, 9, 25, 127, 102, //'R'
38, 111, 77, 89, 115, 50, 0, //'S' 38, 111, 77, 89, 115, 50, 0, //'S'
3, 65, 127, 127, 65, 3, 0, //'T' 3, 65, 127, 127, 65, 3, 0, //'T'
127, 127, 64, 64, 127, 127, 0, //'U' 127, 127, 64, 64, 127, 127, 0, //'U'
31, 63, 96, 96, 63, 31, 0, //'V' 31, 63, 96, 96, 63, 31, 0, //'V'
127, 127, 48, 24, 48, 127, 127, //'W' 127, 127, 48, 24, 48, 127, 127, //'W'
67, 103, 60, 24, 60, 103, 67, //'X' 67, 103, 60, 24, 60, 103, 67, //'X'
7, 79, 120, 120, 79, 7, 0, //'Y' 7, 79, 120, 120, 79, 7, 0, //'Y'
71, 99, 113, 89, 77, 103, 115, //'Z' 71, 99, 113, 89, 77, 103, 115, //'Z'
0, 127, 127, 65, 65, 0, 0, //'[' 0, 127, 127, 65, 65, 0, 0, //'['
1, 3, 6, 12, 24, 48, 96, //'\' 1, 3, 6, 12, 24, 48, 96, //'\'
0, 65, 65, 127, 127, 0, 0, //']' 0, 65, 65, 127, 127, 0, 0, //']'
8, 12, 6, 3, 6, 12, 8, //'^' 8, 12, 6, 3, 6, 12, 8, //'^'
128, 128, 128, 128, 128, 128, 128, //'_' 128, 128, 128, 128, 128, 128, 128, //'_'
0, 0, 3, 7, 4, 0, 0, //'`' 0, 0, 3, 7, 4, 0, 0, //'`'
32, 116, 84, 84, 60, 120, 64, //'a' 32, 116, 84, 84, 60, 120, 64, //'a'
65, 127, 63, 72, 72, 120, 48, //'b' 65, 127, 63, 72, 72, 120, 48, //'b'
56, 124, 68, 68, 108, 40, 0, //'c' 56, 124, 68, 68, 108, 40, 0, //'c'
48, 120, 72, 73, 63, 127, 64, //'d' 48, 120, 72, 73, 63, 127, 64, //'d'
56, 124, 84, 84, 92, 24, 0, //'e' 56, 124, 84, 84, 92, 24, 0, //'e'
72, 126, 127, 73, 3, 2, 0, //'f' 72, 126, 127, 73, 3, 2, 0, //'f'
56, 188, 164, 164, 252, 120, 0, //'g' 56, 188, 164, 164, 252, 120, 0, //'g'
65, 127, 127, 8, 4, 124, 120, //'h' 65, 127, 127, 8, 4, 124, 120, //'h'
0, 68, 125, 125, 64, 0, 0, //'i' 0, 68, 125, 125, 64, 0, 0, //'i'
96, 224, 128, 128, 253, 125, 0, //'j' 96, 224, 128, 128, 253, 125, 0, //'j'
65, 127, 127, 16, 56, 108, 68, //'k' 65, 127, 127, 16, 56, 108, 68, //'k'
0, 65, 127, 127, 64, 0, 0, //'l' 0, 65, 127, 127, 64, 0, 0, //'l'
120, 124, 28, 56, 28, 124, 120, //'m' 120, 124, 28, 56, 28, 124, 120, //'m'
124, 124, 4, 4, 124, 120, 0, //'n' 124, 124, 4, 4, 124, 120, 0, //'n'
56, 124, 68, 68, 124, 56, 0, //'o' 56, 124, 68, 68, 124, 56, 0, //'o'
0, 252, 252, 164, 36, 60, 24, //'p' 0, 252, 252, 164, 36, 60, 24, //'p'
24, 60, 36, 164, 248, 252, 132, //'q' 24, 60, 36, 164, 248, 252, 132, //'q'
68, 124, 120, 76, 4, 28, 24, //'r' 68, 124, 120, 76, 4, 28, 24, //'r'
72, 92, 84, 84, 116, 36, 0, //'s' 72, 92, 84, 84, 116, 36, 0, //'s'
0, 4, 62, 127, 68, 36, 0, //'t' 0, 4, 62, 127, 68, 36, 0, //'t'
60, 124, 64, 64, 60, 124, 64, //'u' 60, 124, 64, 64, 60, 124, 64, //'u'
28, 60, 96, 96, 60, 28, 0, //'v' 28, 60, 96, 96, 60, 28, 0, //'v'
60, 124, 112, 56, 112, 124, 60, //'w' 60, 124, 112, 56, 112, 124, 60, //'w'
68, 108, 56, 16, 56, 108, 68, //'x' 68, 108, 56, 16, 56, 108, 68, //'x'
60, 188, 160, 160, 252, 124, 0, //'y' 60, 188, 160, 160, 252, 124, 0, //'y'
76, 100, 116, 92, 76, 100, 0, //'z' 76, 100, 116, 92, 76, 100, 0, //'z'
8, 8, 62, 119, 65, 65, 0, //'{' 8, 8, 62, 119, 65, 65, 0, //'{'
0, 0, 0, 119, 119, 0, 0, //'|' 0, 0, 0, 119, 119, 0, 0, //'|'
65, 65, 119, 62, 8, 8, 0, //'}' 65, 65, 119, 62, 8, 8, 0, //'}'
2, 3, 1, 3, 2, 3, 1, //'~' 2, 3, 1, 3, 2, 3, 1, //'~'
255, 129, 129, 129, 129, 129, 255, //'^?' 255, 129, 129, 129, 129, 129, 255, //'^?'
14, 159, 145, 177, 251, 74, 0 //'?' 14, 159, 145, 177, 251, 74, 0 //'?'
}; };
/* Global variables */ /* Global variables */

File diff suppressed because it is too large Load Diff

View File

@ -52,276 +52,279 @@ static bool enabled = false;
static void draw_frequency(void) static void draw_frequency(void)
{ {
char tmp[100]; char tmp[100];
uint32_t mhz; uint32_t mhz;
uint32_t khz; uint32_t khz;
mhz = freq / 1000000; mhz = freq / 1000000;
khz = (freq - mhz * 1000000) / 1000; khz = (freq - mhz * 1000000) / 1000;
rad1o_setTextColor(BLACK, GREEN); rad1o_setTextColor(BLACK, GREEN);
rad1o_setIntFont(&Font_Ubuntu18pt); rad1o_setIntFont(&Font_Ubuntu18pt);
sprintf(tmp, "%4u.%03u", (unsigned int)mhz, (unsigned int)khz); sprintf(tmp, "%4u.%03u", (unsigned int)mhz, (unsigned int)khz);
rad1o_lcdPrint(tmp); rad1o_lcdPrint(tmp);
rad1o_setIntFont(&Font_7x8); rad1o_setIntFont(&Font_7x8);
rad1o_lcdMoveCrsr(1, 18 - 7); rad1o_lcdMoveCrsr(1, 18 - 7);
rad1o_lcdPrint("MHz"); rad1o_lcdPrint("MHz");
} }
static void draw_tx_rx(void) static void draw_tx_rx(void)
{ {
uint8_t bg, fg; uint8_t bg, fg;
rad1o_setIntFont(&Font_Ubuntu18pt); rad1o_setIntFont(&Font_Ubuntu18pt);
bg = BLACK; bg = BLACK;
fg = GREY; fg = GREY;
if (direction == RF_PATH_DIRECTION_OFF) { if (direction == RF_PATH_DIRECTION_OFF) {
fg = WHITE; fg = WHITE;
} }
rad1o_setTextColor(bg, fg); rad1o_setTextColor(bg, fg);
rad1o_lcdPrint("OFF "); rad1o_lcdPrint("OFF ");
fg = GREY; fg = GREY;
if (direction == RF_PATH_DIRECTION_RX) { if (direction == RF_PATH_DIRECTION_RX) {
fg = GREEN; fg = GREEN;
} }
rad1o_setTextColor(bg, fg); rad1o_setTextColor(bg, fg);
rad1o_lcdPrint("RX "); rad1o_lcdPrint("RX ");
fg = GREY; fg = GREY;
if (direction == RF_PATH_DIRECTION_TX) { if (direction == RF_PATH_DIRECTION_TX) {
fg = RED; fg = RED;
} }
rad1o_setTextColor(bg, fg); rad1o_setTextColor(bg, fg);
rad1o_lcdPrint("TX"); rad1o_lcdPrint("TX");
rad1o_setIntFont(&Font_7x8); rad1o_setIntFont(&Font_7x8);
} }
static void ui_update(void) static void ui_update(void)
{ {
char tmp[100]; char tmp[100];
uint32_t mhz; uint32_t mhz;
uint32_t khz; uint32_t khz;
if (!enabled) { if (!enabled) {
return; return;
} }
rad1o_lcdClear(); rad1o_lcdClear();
rad1o_lcdFill(0x00); rad1o_lcdFill(0x00);
rad1o_drawHLine(0, 0, RESX - 1, WHITE); rad1o_drawHLine(0, 0, RESX - 1, WHITE);
rad1o_drawVLine(0, 0, RESY - 1, WHITE); rad1o_drawVLine(0, 0, RESY - 1, WHITE);
rad1o_drawHLine(RESY - 1, 0, RESX - 1, WHITE); rad1o_drawHLine(RESY - 1, 0, RESX - 1, WHITE);
rad1o_drawVLine(RESX - 1, 0, RESY - 1, WHITE); rad1o_drawVLine(RESX - 1, 0, RESY - 1, WHITE);
rad1o_lcdSetCrsr(25, 2); rad1o_lcdSetCrsr(25, 2);
rad1o_setTextColor(BLACK, GREEN); rad1o_setTextColor(BLACK, GREEN);
rad1o_lcdPrint("HackRF Mode"); rad1o_lcdPrint("HackRF Mode");
rad1o_lcdNl(); rad1o_lcdNl();
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 {
draw_frequency(); draw_frequency();
} }
rad1o_drawHLine(40, 0, RESX - 1, WHITE); rad1o_drawHLine(40, 0, RESX - 1, WHITE);
rad1o_lcdSetCrsr(6, 41); rad1o_lcdSetCrsr(6, 41);
draw_tx_rx(); draw_tx_rx();
rad1o_drawHLine(69, 0, RESX - 1, WHITE); rad1o_drawHLine(69, 0, RESX - 1, WHITE);
rad1o_setTextColor(BLACK, WHITE); rad1o_setTextColor(BLACK, WHITE);
rad1o_lcdSetCrsr(2, 71); rad1o_lcdSetCrsr(2, 71);
rad1o_lcdPrint("Rate: "); rad1o_lcdPrint("Rate: ");
mhz = sample_rate / 1000000; mhz = sample_rate / 1000000;
khz = (sample_rate - mhz * 1000000) / 1000; khz = (sample_rate - mhz * 1000000) / 1000;
sprintf(tmp, "%2u.%03u MHz", (unsigned int)mhz, (unsigned int)khz); sprintf(tmp, "%2u.%03u MHz", (unsigned int)mhz, (unsigned int)khz);
rad1o_lcdPrint(tmp); rad1o_lcdPrint(tmp);
rad1o_lcdNl(); rad1o_lcdNl();
rad1o_lcdMoveCrsr(2, 0); rad1o_lcdMoveCrsr(2, 0);
rad1o_lcdPrint("Filter: "); rad1o_lcdPrint("Filter: ");
mhz = filter_bw / 1000000; mhz = filter_bw / 1000000;
khz = (filter_bw - mhz * 1000000) / 1000; khz = (filter_bw - mhz * 1000000) / 1000;
sprintf(tmp, "%2u.%03u MHz", (unsigned int)mhz, (unsigned int)khz); sprintf(tmp, "%2u.%03u MHz", (unsigned int)mhz, (unsigned int)khz);
rad1o_lcdPrint(tmp); rad1o_lcdPrint(tmp);
rad1o_lcdNl(); rad1o_lcdNl();
rad1o_drawHLine(88, 0, RESX - 1, WHITE); rad1o_drawHLine(88, 0, RESX - 1, WHITE);
rad1o_setTextColor(BLACK, WHITE); rad1o_setTextColor(BLACK, WHITE);
rad1o_lcdSetCrsr(2, 90); rad1o_lcdSetCrsr(2, 90);
rad1o_lcdPrint(" Gains"); rad1o_lcdPrint(" Gains");
rad1o_lcdNl(); rad1o_lcdNl();
rad1o_setTextColor(BLACK, GREEN); rad1o_setTextColor(BLACK, GREEN);
rad1o_lcdMoveCrsr(2, 2); rad1o_lcdMoveCrsr(2, 2);
rad1o_lcdPrint("AMP: "); rad1o_lcdPrint("AMP: ");
if (lna_on) { if (lna_on) {
rad1o_setTextColor(BLACK, RED); rad1o_setTextColor(BLACK, RED);
rad1o_lcdPrint("ON "); rad1o_lcdPrint("ON ");
} else { } else {
rad1o_lcdPrint("OFF"); rad1o_lcdPrint("OFF");
} }
rad1o_setTextColor(BLACK, RED_DARK); rad1o_setTextColor(BLACK, RED_DARK);
if (direction == RF_PATH_DIRECTION_TX) { if (direction == RF_PATH_DIRECTION_TX) {
rad1o_setTextColor(BLACK, RED); rad1o_setTextColor(BLACK, RED);
} }
sprintf(tmp, " TX: %u dB", (unsigned int)bbtxvga_gain); sprintf(tmp, " TX: %u dB", (unsigned int)bbtxvga_gain);
rad1o_lcdPrint(tmp); rad1o_lcdPrint(tmp);
rad1o_lcdNl(); rad1o_lcdNl();
rad1o_lcdMoveCrsr(2, 0); rad1o_lcdMoveCrsr(2, 0);
rad1o_setTextColor(BLACK, GREEN_DARK); rad1o_setTextColor(BLACK, GREEN_DARK);
if (direction == RF_PATH_DIRECTION_RX) { if (direction == RF_PATH_DIRECTION_RX) {
rad1o_setTextColor(BLACK, GREEN); rad1o_setTextColor(BLACK, GREEN);
} }
sprintf(tmp, "LNA: %2u dB", (unsigned int)bblna_gain); sprintf(tmp, "LNA: %2u dB", (unsigned int)bblna_gain);
rad1o_lcdPrint(tmp); rad1o_lcdPrint(tmp);
rad1o_lcdNl(); rad1o_lcdNl();
rad1o_lcdMoveCrsr(2, 0); rad1o_lcdMoveCrsr(2, 0);
sprintf(tmp, "VGA: %2u dB", (unsigned int)bbvga_gain); sprintf(tmp, "VGA: %2u dB", (unsigned int)bbvga_gain);
rad1o_lcdPrint(tmp); rad1o_lcdPrint(tmp);
rad1o_lcdNl(); rad1o_lcdNl();
rad1o_lcdDisplay(); rad1o_lcdDisplay();
// Don't ask... // Don't ask...
ssp1_set_mode_max2837(); ssp1_set_mode_max2837();
} }
static void rad1o_ui_init(void) static void rad1o_ui_init(void)
{ {
rad1o_lcdInit(); rad1o_lcdInit();
enabled = true; enabled = true;
ui_update(); ui_update();
} }
static void rad1o_ui_deinit(void) static void rad1o_ui_deinit(void)
{ {
rad1o_lcdDeInit(); rad1o_lcdDeInit();
enabled = false; enabled = false;
// Don't ask... // Don't ask...
ssp1_set_mode_max2837(); ssp1_set_mode_max2837();
} }
static void rad1o_ui_set_frequency(uint64_t frequency) 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();
} }
} }
static void rad1o_ui_set_sample_rate(uint32_t _sample_rate) static void rad1o_ui_set_sample_rate(uint32_t _sample_rate)
{ {
sample_rate = _sample_rate; sample_rate = _sample_rate;
ui_update(); ui_update();
} }
static void rad1o_ui_set_direction(const rf_path_direction_t _direction) static void rad1o_ui_set_direction(const rf_path_direction_t _direction)
{ {
direction = _direction; direction = _direction;
ui_update(); ui_update();
} }
static void rad1o_ui_set_filter_bw(uint32_t bandwidth) static void rad1o_ui_set_filter_bw(uint32_t bandwidth)
{ {
filter_bw = bandwidth; filter_bw = bandwidth;
ui_update(); ui_update();
} }
static void rad1o_ui_set_lna_power(bool _lna_on) static void rad1o_ui_set_lna_power(bool _lna_on)
{ {
lna_on = _lna_on; lna_on = _lna_on;
ui_update(); ui_update();
} }
static void rad1o_ui_set_bb_lna_gain(const uint32_t gain_db) static void rad1o_ui_set_bb_lna_gain(const uint32_t gain_db)
{ {
bblna_gain = gain_db; bblna_gain = gain_db;
ui_update(); ui_update();
} }
static void rad1o_ui_set_bb_vga_gain(const uint32_t gain_db) static void rad1o_ui_set_bb_vga_gain(const uint32_t gain_db)
{ {
bbvga_gain = gain_db; bbvga_gain = gain_db;
ui_update(); ui_update();
} }
static void rad1o_ui_set_bb_tx_vga_gain(const uint32_t gain_db) static void rad1o_ui_set_bb_tx_vga_gain(const uint32_t gain_db)
{ {
bbtxvga_gain = gain_db; bbtxvga_gain = 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
} }
static void rad1o_ui_set_antenna_bias(bool antenna_bias __attribute__((unused))) 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
} }
static void rad1o_ui_set_transceiver_mode(transceiver_mode_t mode) static void rad1o_ui_set_transceiver_mode(transceiver_mode_t mode)
{ {
trx_mode = mode; trx_mode = mode;
ui_update(); ui_update();
} }
static bool rad1o_ui_operacake_gpio_compatible(void) static bool rad1o_ui_operacake_gpio_compatible(void)
{ {
return true; return true;
} }
static const hackrf_ui_t rad1o_ui = { static const hackrf_ui_t rad1o_ui = {
&rad1o_ui_init, &rad1o_ui_init,
&rad1o_ui_deinit, &rad1o_ui_deinit,
&rad1o_ui_set_frequency, &rad1o_ui_set_frequency,
&rad1o_ui_set_sample_rate, &rad1o_ui_set_sample_rate,
&rad1o_ui_set_direction, &rad1o_ui_set_direction,
&rad1o_ui_set_filter_bw, &rad1o_ui_set_filter_bw,
&rad1o_ui_set_lna_power, &rad1o_ui_set_lna_power,
&rad1o_ui_set_bb_lna_gain, &rad1o_ui_set_bb_lna_gain,
&rad1o_ui_set_bb_vga_gain, &rad1o_ui_set_bb_vga_gain,
&rad1o_ui_set_bb_tx_vga_gain, &rad1o_ui_set_bb_tx_vga_gain,
&rad1o_ui_set_first_if_frequency, &rad1o_ui_set_first_if_frequency,
&rad1o_ui_set_filter, &rad1o_ui_set_filter,
&rad1o_ui_set_antenna_bias, &rad1o_ui_set_antenna_bias,
&rad1o_ui_set_clock_source, &rad1o_ui_set_clock_source,
&rad1o_ui_set_transceiver_mode, &rad1o_ui_set_transceiver_mode,
&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;
} }

View File

@ -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__*/