mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Change the buffers to byte buffers and update most of the drawing code to use
it accordingly. Large fonts broken.
This commit is contained in:
parent
fef6567cff
commit
b3150500d5
@ -24,8 +24,8 @@ int32_t osdgenInitialize(void);
|
|||||||
|
|
||||||
// Macros for computing addresses and bit positions.
|
// Macros for computing addresses and bit positions.
|
||||||
// NOTE: /16 in y is because we are addressing by word not byte.
|
// NOTE: /16 in y is because we are addressing by word not byte.
|
||||||
#define CALC_BUFF_ADDR(x, y) (((x) / 16) + ((y) * (DISP_WIDTH / 16)))
|
#define CALC_BUFF_ADDR(x, y) (((x) / 8) + ((y) * (DISP_WIDTH / 8)))
|
||||||
#define CALC_BIT_IN_WORD(x) ((x) & 15)
|
#define CALC_BIT_IN_WORD(x) ((x) & 7)
|
||||||
#define DEBUG_DELAY
|
#define DEBUG_DELAY
|
||||||
// Macro for writing a word with a mode (NAND = clear, OR = set, XOR = toggle)
|
// Macro for writing a word with a mode (NAND = clear, OR = set, XOR = toggle)
|
||||||
// at a given position
|
// at a given position
|
||||||
@ -41,8 +41,8 @@ int32_t osdgenInitialize(void);
|
|||||||
|
|
||||||
// Horizontal line calculations.
|
// Horizontal line calculations.
|
||||||
// Edge cases.
|
// Edge cases.
|
||||||
#define COMPUTE_HLINE_EDGE_L_MASK(b) ((1 << (16 - (b))) - 1)
|
#define COMPUTE_HLINE_EDGE_L_MASK(b) ((1 << (8 - (b))) - 1)
|
||||||
#define COMPUTE_HLINE_EDGE_R_MASK(b) (~((1 << (15 - (b))) - 1))
|
#define COMPUTE_HLINE_EDGE_R_MASK(b) (~((1 << (7 - (b))) - 1))
|
||||||
// This computes an island mask.
|
// This computes an island mask.
|
||||||
#define COMPUTE_HLINE_ISLAND_MASK(b0, b1) (COMPUTE_HLINE_EDGE_L_MASK(b0) ^ COMPUTE_HLINE_EDGE_L_MASK(b1));
|
#define COMPUTE_HLINE_ISLAND_MASK(b0, b1) (COMPUTE_HLINE_EDGE_L_MASK(b0) ^ COMPUTE_HLINE_EDGE_L_MASK(b1));
|
||||||
|
|
||||||
@ -159,26 +159,26 @@ void updateGraphics();
|
|||||||
void drawGraphicsLine();
|
void drawGraphicsLine();
|
||||||
|
|
||||||
void write_char16(char ch, unsigned int x, unsigned int y, int font);
|
void write_char16(char ch, unsigned int x, unsigned int y, int font);
|
||||||
void write_pixel(uint16_t *buff, unsigned int x, unsigned int y, int mode);
|
void write_pixel(uint8_t *buff, unsigned int x, unsigned int y, int mode);
|
||||||
void write_pixel_lm(unsigned int x, unsigned int y, int mmode, int lmode);
|
void write_pixel_lm(unsigned int x, unsigned int y, int mmode, int lmode);
|
||||||
void write_hline(uint16_t *buff, unsigned int x0, unsigned int x1, unsigned int y, int mode);
|
void write_hline(uint8_t *buff, unsigned int x0, unsigned int x1, unsigned int y, int mode);
|
||||||
void write_hline_lm(unsigned int x0, unsigned int x1, unsigned int y, int lmode, int mmode);
|
void write_hline_lm(unsigned int x0, unsigned int x1, unsigned int y, int lmode, int mmode);
|
||||||
void write_hline_outlined(unsigned int x0, unsigned int x1, unsigned int y, int endcap0, int endcap1, int mode, int mmode);
|
void write_hline_outlined(unsigned int x0, unsigned int x1, unsigned int y, int endcap0, int endcap1, int mode, int mmode);
|
||||||
void write_vline(uint16_t *buff, unsigned int x, unsigned int y0, unsigned int y1, int mode);
|
void write_vline(uint8_t *buff, unsigned int x, unsigned int y0, unsigned int y1, int mode);
|
||||||
void write_vline_lm(unsigned int x, unsigned int y0, unsigned int y1, int lmode, int mmode);
|
void write_vline_lm(unsigned int x, unsigned int y0, unsigned int y1, int lmode, int mmode);
|
||||||
void write_vline_outlined(unsigned int x, unsigned int y0, unsigned int y1, int endcap0, int endcap1, int mode, int mmode);
|
void write_vline_outlined(unsigned int x, unsigned int y0, unsigned int y1, int endcap0, int endcap1, int mode, int mmode);
|
||||||
void write_filled_rectangle(uint16_t *buff, unsigned int x, unsigned int y, unsigned int width, unsigned int height, int mode);
|
void write_filled_rectangle(uint8_t *buff, unsigned int x, unsigned int y, unsigned int width, unsigned int height, int mode);
|
||||||
void write_filled_rectangle_lm(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int lmode, int mmode);
|
void write_filled_rectangle_lm(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int lmode, int mmode);
|
||||||
void write_rectangle_outlined(unsigned int x, unsigned int y, int width, int height, int mode, int mmode);
|
void write_rectangle_outlined(unsigned int x, unsigned int y, int width, int height, int mode, int mmode);
|
||||||
void write_circle(uint16_t *buff, unsigned int cx, unsigned int cy, unsigned int r, unsigned int dashp, int mode);
|
void write_circle(uint8_t *buff, unsigned int cx, unsigned int cy, unsigned int r, unsigned int dashp, int mode);
|
||||||
void write_circle_outlined(unsigned int cx, unsigned int cy, unsigned int r, unsigned int dashp, int bmode, int mode, int mmode);
|
void write_circle_outlined(unsigned int cx, unsigned int cy, unsigned int r, unsigned int dashp, int bmode, int mode, int mmode);
|
||||||
void write_circle_filled(uint16_t *buff, unsigned int cx, unsigned int cy, unsigned int r, int mode);
|
void write_circle_filled(uint8_t *buff, unsigned int cx, unsigned int cy, unsigned int r, int mode);
|
||||||
void write_line(uint16_t *buff, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int mode);
|
void write_line(uint8_t *buff, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int mode);
|
||||||
void write_line_lm(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int mmode, int lmode);
|
void write_line_lm(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int mmode, int lmode);
|
||||||
void write_line_outlined(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int endcap0, int endcap1, int mode, int mmode);
|
void write_line_outlined(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int endcap0, int endcap1, int mode, int mmode);
|
||||||
void write_word_misaligned(uint16_t *buff, uint16_t word, unsigned int addr, unsigned int xoff, int mode);
|
void write_word_misaligned(uint8_t *buff, uint16_t word, unsigned int addr, unsigned int xoff, int mode);
|
||||||
void write_word_misaligned_NAND(uint16_t *buff, uint16_t word, unsigned int addr, unsigned int xoff);
|
void write_word_misaligned_NAND(uint8_t *buff, uint16_t word, unsigned int addr, unsigned int xoff);
|
||||||
void write_word_misaligned_OR(uint16_t *buff, uint16_t word, unsigned int addr, unsigned int xoff);
|
void write_word_misaligned_OR(uint8_t *buff, uint16_t word, unsigned int addr, unsigned int xoff);
|
||||||
void write_word_misaligned_lm(uint16_t wordl, uint16_t wordm, unsigned int addr, unsigned int xoff, int lmode, int mmode);
|
void write_word_misaligned_lm(uint16_t wordl, uint16_t wordm, unsigned int addr, unsigned int xoff, int lmode, int mmode);
|
||||||
//int fetch_font_info(char ch, int font, struct FontEntry *font_info, char *lookup);
|
//int fetch_font_info(char ch, int font, struct FontEntry *font_info, char *lookup);
|
||||||
void write_char(char ch, unsigned int x, unsigned int y, int flags, int font);
|
void write_char(char ch, unsigned int x, unsigned int y, int flags, int font);
|
||||||
|
@ -63,10 +63,10 @@ static int32_t m_gpsLon=0;
|
|||||||
static float m_gpsAlt=0;
|
static float m_gpsAlt=0;
|
||||||
static float m_gpsSpd=0;
|
static float m_gpsSpd=0;
|
||||||
|
|
||||||
extern uint16_t *draw_buffer_level;
|
extern uint8_t *draw_buffer_level;
|
||||||
extern uint16_t *draw_buffer_mask;
|
extern uint8_t *draw_buffer_mask;
|
||||||
extern uint16_t *disp_buffer_level;
|
extern uint8_t *disp_buffer_level;
|
||||||
extern uint16_t *disp_buffer_mask;
|
extern uint8_t *disp_buffer_mask;
|
||||||
|
|
||||||
|
|
||||||
TTime time;
|
TTime time;
|
||||||
@ -94,8 +94,8 @@ static xTaskHandle osdgenTaskHandle;
|
|||||||
struct splashEntry
|
struct splashEntry
|
||||||
{
|
{
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
unsigned short *level;
|
uint8_t *level;
|
||||||
unsigned short *mask;
|
uint8_t *mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct splashEntry splash[3] = {
|
struct splashEntry splash[3] = {
|
||||||
@ -177,33 +177,31 @@ uint8_t printCharFB(uint16_t ch, uint16_t x, uint16_t y) {
|
|||||||
|
|
||||||
uint16_t mirror(uint16_t source)
|
uint16_t mirror(uint16_t source)
|
||||||
{
|
{
|
||||||
int result = ((source & 0x8000) >> 15) | ((source & 0x4000) >> 13) |
|
int result = ((source & 0x8000) >> 7) | ((source & 0x4000) >> 5) |
|
||||||
((source & 0x2000) >> 11) | ((source & 0x1000) >> 9) |
|
((source & 0x2000) >> 3) | ((source & 0x1000) >> 1) |
|
||||||
((source & 0x0800) >> 7) | ((source & 0x0400) >> 5) |
|
((source & 0x0800) << 1) | ((source & 0x0400) << 3) |
|
||||||
((source & 0x0200) >> 3) | ((source & 0x0100) >> 1) |
|
((source & 0x0200) << 5) | ((source & 0x0100) << 7) |
|
||||||
((source & 0x0080) << 1) | ((source & 0x0040) << 3) |
|
((source & 0x0080) >> 7) | ((source & 0x0040) >> 5) |
|
||||||
((source & 0x0020) << 5) | ((source & 0x0010) << 7) |
|
((source & 0x0020) >> 3) | ((source & 0x0010) >> 1) |
|
||||||
((source & 0x0008) << 9) | ((source & 0x0004) << 11) |
|
((source & 0x0008) << 1) | ((source & 0x0004) << 3) |
|
||||||
((source & 0x0002) << 13) | ((source & 0x0001) << 15);
|
((source & 0x0002) << 5) | ((source & 0x0001) << 7);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearGraphics() {
|
void clearGraphics() {
|
||||||
memset((uint8_t *) draw_buffer_mask, 0, GRAPHICS_WIDTH * GRAPHICS_HEIGHT * 2);
|
memset((uint8_t *) draw_buffer_mask, 0, GRAPHICS_WIDTH * GRAPHICS_HEIGHT);
|
||||||
memset((uint8_t *) draw_buffer_level, 0, GRAPHICS_WIDTH * GRAPHICS_HEIGHT * 2);
|
memset((uint8_t *) draw_buffer_level, 0, GRAPHICS_WIDTH * GRAPHICS_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyimage(uint16_t offsetx, uint16_t offsety, int image) {
|
void copyimage(uint16_t offsetx, uint16_t offsety, int image) {
|
||||||
struct splashEntry splash_info;
|
struct splashEntry splash_info;
|
||||||
splash_info = splash[image];
|
splash_info = splash[image];
|
||||||
offsetx=offsetx/16;
|
offsetx=offsetx/8;
|
||||||
int i=0;
|
|
||||||
for (uint16_t y = offsety; y < ((splash_info.height)+offsety); y++) {
|
for (uint16_t y = offsety; y < ((splash_info.height)+offsety); y++) {
|
||||||
for (uint16_t x = offsetx; x < (((splash_info.width)/16)+offsetx); x++) {
|
for (uint16_t x = offsetx; x < (((splash_info.width)/8)+offsetx); x++) {
|
||||||
draw_buffer_level[y*GRAPHICS_WIDTH+x] = mirror(splash_info.level[(y-offsety)*((splash_info.width)/16)+(x-offsetx)]);
|
draw_buffer_level[y*GRAPHICS_WIDTH+x] = mirror(splash_info.level[(y-offsety)*((splash_info.width)/8)+(x-offsetx)]);
|
||||||
draw_buffer_mask[y*GRAPHICS_WIDTH+x] = mirror(splash_info.mask[(y-offsety)*((splash_info.width)/16)+(x-offsetx)]);
|
draw_buffer_mask[y*GRAPHICS_WIDTH+x] = mirror(splash_info.mask[(y-offsety)*((splash_info.width)/8)+(x-offsetx)]);
|
||||||
i+=2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,9 +217,9 @@ void setPixel(uint16_t x, uint16_t y, uint8_t state) {
|
|||||||
if (!validPos(x, y)) {
|
if (!validPos(x, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t bitPos = 15-(x%16);
|
uint8_t bitPos = 7-(x%8);
|
||||||
uint16_t tempf = draw_buffer_level[y*GRAPHICS_WIDTH+x/16];
|
uint16_t tempf = draw_buffer_level[y*GRAPHICS_WIDTH+x/8];
|
||||||
uint16_t tempm = draw_buffer_mask[y*GRAPHICS_WIDTH+x/16];
|
uint16_t tempm = draw_buffer_mask[y*GRAPHICS_WIDTH+x/8];
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
tempf &= ~(1<<bitPos);
|
tempf &= ~(1<<bitPos);
|
||||||
tempm &= ~(1<<bitPos);
|
tempm &= ~(1<<bitPos);
|
||||||
@ -234,8 +232,8 @@ void setPixel(uint16_t x, uint16_t y, uint8_t state) {
|
|||||||
tempf ^= (1<<bitPos);
|
tempf ^= (1<<bitPos);
|
||||||
tempm ^= (1<<bitPos);
|
tempm ^= (1<<bitPos);
|
||||||
}
|
}
|
||||||
draw_buffer_level[y*GRAPHICS_WIDTH+x/16] = tempf;
|
draw_buffer_level[y*GRAPHICS_WIDTH+x/8] = tempf;
|
||||||
draw_buffer_mask[y*GRAPHICS_WIDTH+x/16] = tempm;
|
draw_buffer_mask[y*GRAPHICS_WIDTH+x/8] = tempm;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Credit for this one goes to wikipedia! :-)
|
// Credit for this one goes to wikipedia! :-)
|
||||||
@ -480,15 +478,16 @@ void drawBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
|||||||
* @param y y coordinate
|
* @param y y coordinate
|
||||||
* @param mode 0 = clear bit, 1 = set bit, 2 = toggle bit
|
* @param mode 0 = clear bit, 1 = set bit, 2 = toggle bit
|
||||||
*/
|
*/
|
||||||
void write_pixel(uint16_t *buff, unsigned int x, unsigned int y, int mode)
|
void write_pixel(uint8_t *buff, unsigned int x, unsigned int y, int mode)
|
||||||
{
|
{
|
||||||
|
APPLY_DEADBAND(x, y);
|
||||||
CHECK_COORDS(x, y);
|
CHECK_COORDS(x, y);
|
||||||
// Determine the bit in the word to be set and the word
|
// Determine the bit in the word to be set and the word
|
||||||
// index to set it in.
|
// index to set it in.
|
||||||
int bitnum = CALC_BIT_IN_WORD(x);
|
int bitnum = CALC_BIT_IN_WORD(x);
|
||||||
int wordnum = CALC_BUFF_ADDR(x, y);
|
int wordnum = CALC_BUFF_ADDR(x, y);
|
||||||
// Apply a mask.
|
// Apply a mask.
|
||||||
uint16_t mask = 1 << (15 - bitnum);
|
uint16_t mask = 1 << (7 - bitnum);
|
||||||
WRITE_WORD_MODE(buff, wordnum, mask, mode);
|
WRITE_WORD_MODE(buff, wordnum, mask, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +508,7 @@ void write_pixel_lm(unsigned int x, unsigned int y, int mmode, int lmode)
|
|||||||
int bitnum = CALC_BIT_IN_WORD(x);
|
int bitnum = CALC_BIT_IN_WORD(x);
|
||||||
int wordnum = CALC_BUFF_ADDR(x, y);
|
int wordnum = CALC_BUFF_ADDR(x, y);
|
||||||
// Apply the masks.
|
// Apply the masks.
|
||||||
uint16_t mask = 1 << (15 - bitnum);
|
uint16_t mask = 1 << (7 - bitnum);
|
||||||
WRITE_WORD_MODE(draw_buffer_mask, wordnum, mask, mmode);
|
WRITE_WORD_MODE(draw_buffer_mask, wordnum, mask, mmode);
|
||||||
WRITE_WORD_MODE(draw_buffer_level, wordnum, mask, lmode);
|
WRITE_WORD_MODE(draw_buffer_level, wordnum, mask, lmode);
|
||||||
}
|
}
|
||||||
@ -524,7 +523,7 @@ void write_pixel_lm(unsigned int x, unsigned int y, int mmode, int lmode)
|
|||||||
* @param y y coordinate
|
* @param y y coordinate
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_hline(uint16_t *buff, unsigned int x0, unsigned int x1, unsigned int y, int mode)
|
void write_hline(uint8_t *buff, unsigned int x0, unsigned int x1, unsigned int y, int mode)
|
||||||
{
|
{
|
||||||
CLIP_COORDS(x0, y);
|
CLIP_COORDS(x0, y);
|
||||||
CLIP_COORDS(x1, y);
|
CLIP_COORDS(x1, y);
|
||||||
@ -557,7 +556,7 @@ void write_hline(uint16_t *buff, unsigned int x0, unsigned int x1, unsigned int
|
|||||||
// Now write 0xffff words from start+1 to end-1.
|
// Now write 0xffff words from start+1 to end-1.
|
||||||
for(i = addr0 + 1; i <= addr1 - 1; i++)
|
for(i = addr0 + 1; i <= addr1 - 1; i++)
|
||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, i, 0xffff, mode);
|
WRITE_WORD_MODE(buff, i, 0xff, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -617,7 +616,7 @@ void write_hline_outlined(unsigned int x0, unsigned int x1, unsigned int y, int
|
|||||||
* @param y1 y1 coordinate
|
* @param y1 y1 coordinate
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_vline(uint16_t *buff, unsigned int x, unsigned int y0, unsigned int y1, int mode)
|
void write_vline(uint8_t *buff, unsigned int x, unsigned int y0, unsigned int y1, int mode)
|
||||||
{
|
{
|
||||||
unsigned int a;
|
unsigned int a;
|
||||||
CLIP_COORDS(x, y0);
|
CLIP_COORDS(x, y0);
|
||||||
@ -633,10 +632,10 @@ void write_vline(uint16_t *buff, unsigned int x, unsigned int y0, unsigned int y
|
|||||||
int addr1 = CALC_BUFF_ADDR(x, y1);
|
int addr1 = CALC_BUFF_ADDR(x, y1);
|
||||||
/* Then we calculate the pixel data to be written. */
|
/* Then we calculate the pixel data to be written. */
|
||||||
int bitnum = CALC_BIT_IN_WORD(x);
|
int bitnum = CALC_BIT_IN_WORD(x);
|
||||||
uint16_t mask = 1 << (15 - bitnum);
|
uint16_t mask = 1 << (7 - bitnum);
|
||||||
/* Run from addr0 to addr1 placing pixels. Increment by the number
|
/* Run from addr0 to addr1 placing pixels. Increment by the number
|
||||||
* of words n each graphics line. */
|
* of words n each graphics line. */
|
||||||
for(a = addr0; a <= addr1; a += DISP_WIDTH / 16)
|
for(a = addr0; a <= addr1; a += DISP_WIDTH / 8)
|
||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, a, mask, mode);
|
WRITE_WORD_MODE(buff, a, mask, mode);
|
||||||
}
|
}
|
||||||
@ -702,7 +701,7 @@ void write_vline_outlined(unsigned int x, unsigned int y0, unsigned int y1, int
|
|||||||
* @param height rectangle height
|
* @param height rectangle height
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_filled_rectangle(uint16_t *buff, unsigned int x, unsigned int y, unsigned int width, unsigned int height, int mode)
|
void write_filled_rectangle(uint8_t *buff, unsigned int x, unsigned int y, unsigned int width, unsigned int height, int mode)
|
||||||
{
|
{
|
||||||
int yy, addr0_old, addr1_old;
|
int yy, addr0_old, addr1_old;
|
||||||
CHECK_COORDS(x, y);
|
CHECK_COORDS(x, y);
|
||||||
@ -723,7 +722,7 @@ void write_filled_rectangle(uint16_t *buff, unsigned int x, unsigned int y, unsi
|
|||||||
while(height--)
|
while(height--)
|
||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, addr0, mask, mode);
|
WRITE_WORD_MODE(buff, addr0, mask, mode);
|
||||||
addr0 += DISP_WIDTH / 16;
|
addr0 += DISP_WIDTH / 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise we need to write the edges and then the middle repeatedly.
|
// Otherwise we need to write the edges and then the middle repeatedly.
|
||||||
@ -739,8 +738,8 @@ void write_filled_rectangle(uint16_t *buff, unsigned int x, unsigned int y, unsi
|
|||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, addr0, mask_l, mode);
|
WRITE_WORD_MODE(buff, addr0, mask_l, mode);
|
||||||
WRITE_WORD_MODE(buff, addr1, mask_r, mode);
|
WRITE_WORD_MODE(buff, addr1, mask_r, mode);
|
||||||
addr0 += DISP_WIDTH / 16;
|
addr0 += DISP_WIDTH / 8;
|
||||||
addr1 += DISP_WIDTH / 16;
|
addr1 += DISP_WIDTH / 8;
|
||||||
yy++;
|
yy++;
|
||||||
}
|
}
|
||||||
// Now write 0xffff words from start+1 to end-1 for each row.
|
// Now write 0xffff words from start+1 to end-1 for each row.
|
||||||
@ -751,10 +750,10 @@ void write_filled_rectangle(uint16_t *buff, unsigned int x, unsigned int y, unsi
|
|||||||
{
|
{
|
||||||
for(i = addr0 + 1; i <= addr1 - 1; i++)
|
for(i = addr0 + 1; i <= addr1 - 1; i++)
|
||||||
{
|
{
|
||||||
WRITE_WORD_MODE(buff, i, 0xffff, mode);
|
WRITE_WORD_MODE(buff, i, 0xff, mode);
|
||||||
}
|
}
|
||||||
addr0 += DISP_WIDTH / 16;
|
addr0 += DISP_WIDTH / 8;
|
||||||
addr1 += DISP_WIDTH / 16;
|
addr1 += DISP_WIDTH / 8;
|
||||||
yy++;
|
yy++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -810,7 +809,7 @@ void write_rectangle_outlined(unsigned int x, unsigned int y, int width, int hei
|
|||||||
* @param dashp dash period (pixels) - zero for no dash
|
* @param dashp dash period (pixels) - zero for no dash
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_circle(uint16_t *buff, unsigned int cx, unsigned int cy, unsigned int r, unsigned int dashp, int mode)
|
void write_circle(uint8_t *buff, unsigned int cx, unsigned int cy, unsigned int r, unsigned int dashp, int mode)
|
||||||
{
|
{
|
||||||
CHECK_COORDS(cx, cy);
|
CHECK_COORDS(cx, cy);
|
||||||
int error = -r, x = r, y = 0;
|
int error = -r, x = r, y = 0;
|
||||||
@ -906,7 +905,7 @@ void write_circle_outlined(unsigned int cx, unsigned int cy, unsigned int r, uns
|
|||||||
* @param r radius
|
* @param r radius
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_circle_filled(uint16_t *buff, unsigned int cx, unsigned int cy, unsigned int r, int mode)
|
void write_circle_filled(uint8_t *buff, unsigned int cx, unsigned int cy, unsigned int r, int mode)
|
||||||
{
|
{
|
||||||
CHECK_COORDS(cx, cy);
|
CHECK_COORDS(cx, cy);
|
||||||
int error = -r, x = r, y = 0, xch = 0;
|
int error = -r, x = r, y = 0, xch = 0;
|
||||||
@ -956,7 +955,7 @@ void write_circle_filled(uint16_t *buff, unsigned int cx, unsigned int cy, unsig
|
|||||||
* @param y1 second y coordinate
|
* @param y1 second y coordinate
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_line(uint16_t *buff, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int mode)
|
void write_line(uint8_t *buff, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, int mode)
|
||||||
{
|
{
|
||||||
// Based on http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
|
// Based on http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
|
||||||
int steep = abs(y1 - y0) > abs(x1 - x0);
|
int steep = abs(y1 - y0) > abs(x1 - x0);
|
||||||
@ -1141,10 +1140,10 @@ void write_line_outlined(unsigned int x0, unsigned int y0, unsigned int x1, unsi
|
|||||||
* @param xoff x offset (0-15)
|
* @param xoff x offset (0-15)
|
||||||
* @param mode 0 = clear, 1 = set, 2 = toggle
|
* @param mode 0 = clear, 1 = set, 2 = toggle
|
||||||
*/
|
*/
|
||||||
void write_word_misaligned(uint16_t *buff, uint16_t word, unsigned int addr, unsigned int xoff, int mode)
|
void write_word_misaligned(uint8_t *buff, uint16_t word, unsigned int addr, unsigned int xoff, int mode)
|
||||||
{
|
{
|
||||||
uint16_t firstmask = word >> xoff;
|
uint16_t firstmask = word >> xoff;
|
||||||
uint16_t lastmask = word << (16 - xoff);
|
uint16_t lastmask = word << (8 - xoff);
|
||||||
WRITE_WORD_MODE(buff, addr, firstmask, mode);
|
WRITE_WORD_MODE(buff, addr, firstmask, mode);
|
||||||
if(xoff > 0)
|
if(xoff > 0)
|
||||||
{
|
{
|
||||||
@ -1167,10 +1166,10 @@ void write_word_misaligned(uint16_t *buff, uint16_t word, unsigned int addr, uns
|
|||||||
* it doesn't go through a lot of switch logic which slows down text writing
|
* it doesn't go through a lot of switch logic which slows down text writing
|
||||||
* a lot.
|
* a lot.
|
||||||
*/
|
*/
|
||||||
void write_word_misaligned_NAND(uint16_t *buff, uint16_t word, unsigned int addr, unsigned int xoff)
|
void write_word_misaligned_NAND(uint8_t *buff, uint16_t word, unsigned int addr, unsigned int xoff)
|
||||||
{
|
{
|
||||||
uint16_t firstmask = word >> xoff;
|
uint16_t firstmask = word >> xoff;
|
||||||
uint16_t lastmask = word << (16 - xoff);
|
uint16_t lastmask = word << (8 - xoff);
|
||||||
WRITE_WORD_NAND(buff, addr, firstmask);
|
WRITE_WORD_NAND(buff, addr, firstmask);
|
||||||
if(xoff > 0)
|
if(xoff > 0)
|
||||||
{
|
{
|
||||||
@ -1193,10 +1192,10 @@ void write_word_misaligned_NAND(uint16_t *buff, uint16_t word, unsigned int addr
|
|||||||
* it doesn't go through a lot of switch logic which slows down text writing
|
* it doesn't go through a lot of switch logic which slows down text writing
|
||||||
* a lot.
|
* a lot.
|
||||||
*/
|
*/
|
||||||
void write_word_misaligned_OR(uint16_t *buff, uint16_t word, unsigned int addr, unsigned int xoff)
|
void write_word_misaligned_OR(uint8_t *buff, uint16_t word, unsigned int addr, unsigned int xoff)
|
||||||
{
|
{
|
||||||
uint16_t firstmask = word >> xoff;
|
uint16_t firstmask = word >> xoff;
|
||||||
uint16_t lastmask = word << (16 - xoff);
|
uint16_t lastmask = word << (8 - xoff);
|
||||||
WRITE_WORD_OR(buff, addr, firstmask);
|
WRITE_WORD_OR(buff, addr, firstmask);
|
||||||
if(xoff > 0)
|
if(xoff > 0)
|
||||||
{
|
{
|
||||||
@ -1280,7 +1279,7 @@ void write_char16(char ch, unsigned int x, unsigned int y, int font)
|
|||||||
row = ch * font_info.height;
|
row = ch * font_info.height;
|
||||||
row_temp = row;
|
row_temp = row;
|
||||||
addr_temp = addr;
|
addr_temp = addr;
|
||||||
xshift = 16 - font_info.width;
|
xshift = 8 - font_info.width;
|
||||||
// We can write mask words easily.
|
// We can write mask words easily.
|
||||||
for(yy = y; yy < y + font_info.height; yy++)
|
for(yy = y; yy < y + font_info.height; yy++)
|
||||||
{
|
{
|
||||||
@ -1288,7 +1287,7 @@ void write_char16(char ch, unsigned int x, unsigned int y, int font)
|
|||||||
write_word_misaligned_OR(draw_buffer_mask, font_mask12x18[row] << xshift, addr, wbit);
|
write_word_misaligned_OR(draw_buffer_mask, font_mask12x18[row] << xshift, addr, wbit);
|
||||||
else
|
else
|
||||||
write_word_misaligned_OR(draw_buffer_mask, font_mask8x10[row] << xshift, addr, wbit);
|
write_word_misaligned_OR(draw_buffer_mask, font_mask8x10[row] << xshift, addr, wbit);
|
||||||
addr += DISP_WIDTH / 16;
|
addr += DISP_WIDTH / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
// Level bits are more complicated. We need to set or clear
|
// Level bits are more complicated. We need to set or clear
|
||||||
@ -1317,7 +1316,7 @@ void write_char16(char ch, unsigned int x, unsigned int y, int font)
|
|||||||
// If we're not bold write the AND mask.
|
// If we're not bold write the AND mask.
|
||||||
//if(!(flags & FONT_BOLD))
|
//if(!(flags & FONT_BOLD))
|
||||||
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
||||||
addr += DISP_WIDTH / 16;
|
addr += DISP_WIDTH / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1364,12 +1363,12 @@ void write_char(char ch, unsigned int x, unsigned int y, int flags, int font)
|
|||||||
row = lookup * font_info.height * 2;
|
row = lookup * font_info.height * 2;
|
||||||
row_temp = row;
|
row_temp = row;
|
||||||
addr_temp = addr;
|
addr_temp = addr;
|
||||||
xshift = 16 - font_info.width;
|
xshift = 8 - font_info.width;
|
||||||
// We can write mask words easily.
|
// We can write mask words easily.
|
||||||
for(yy = y; yy < y + font_info.height; yy++)
|
for(yy = y; yy < y + font_info.height; yy++)
|
||||||
{
|
{
|
||||||
write_word_misaligned_OR(draw_buffer_mask, font_info.data[row] << xshift, addr, wbit);
|
write_word_misaligned_OR(draw_buffer_mask, font_info.data[row] << xshift, addr, wbit);
|
||||||
addr += DISP_WIDTH / 16;
|
addr += DISP_WIDTH / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
// Level bits are more complicated. We need to set or clear
|
// Level bits are more complicated. We need to set or clear
|
||||||
@ -1389,7 +1388,7 @@ void write_char(char ch, unsigned int x, unsigned int y, int flags, int font)
|
|||||||
// If we're not bold write the AND mask.
|
// If we're not bold write the AND mask.
|
||||||
//if(!(flags & FONT_BOLD))
|
//if(!(flags & FONT_BOLD))
|
||||||
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
write_word_misaligned_NAND(draw_buffer_level, and_mask, addr, wbit);
|
||||||
addr += DISP_WIDTH / 16;
|
addr += DISP_WIDTH / 8;
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ static const struct pios_video_cfg * dev_cfg;
|
|||||||
// Must be allocated in one block, so it is in a struct.
|
// Must be allocated in one block, so it is in a struct.
|
||||||
struct _buffers
|
struct _buffers
|
||||||
{
|
{
|
||||||
uint16_t buffer0_level[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
uint8_t buffer0_level[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
||||||
uint16_t buffer0_mask[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
uint8_t buffer0_mask[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
||||||
uint16_t buffer1_level[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
uint8_t buffer1_level[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
||||||
uint16_t buffer1_mask[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
uint8_t buffer1_mask[GRAPHICS_HEIGHT*GRAPHICS_WIDTH];
|
||||||
} buffers;
|
} buffers;
|
||||||
|
|
||||||
// Remove the struct definition (makes it easier to write for.)
|
// Remove the struct definition (makes it easier to write for.)
|
||||||
@ -58,10 +58,10 @@ struct _buffers
|
|||||||
#define buffer1_mask (buffers.buffer1_mask)
|
#define buffer1_mask (buffers.buffer1_mask)
|
||||||
|
|
||||||
// We define pointers to each of these buffers.
|
// We define pointers to each of these buffers.
|
||||||
uint16_t *draw_buffer_level;
|
uint8_t *draw_buffer_level;
|
||||||
uint16_t *draw_buffer_mask;
|
uint8_t *draw_buffer_mask;
|
||||||
uint16_t *disp_buffer_level;
|
uint8_t *disp_buffer_level;
|
||||||
uint16_t *disp_buffer_mask;
|
uint8_t *disp_buffer_mask;
|
||||||
|
|
||||||
volatile uint8_t gLineType = LINE_TYPE_UNKNOWN;
|
volatile uint8_t gLineType = LINE_TYPE_UNKNOWN;
|
||||||
volatile uint16_t gActiveLine = 0;
|
volatile uint16_t gActiveLine = 0;
|
||||||
|
@ -76,11 +76,11 @@ extern void PIOS_Vsync_ISR();
|
|||||||
#define GRAPHICS_WIDTH_REAL 336
|
#define GRAPHICS_WIDTH_REAL 336
|
||||||
#define GRAPHICS_HEIGHT_REAL 270
|
#define GRAPHICS_HEIGHT_REAL 270
|
||||||
|
|
||||||
#define GRAPHICS_WIDTH (GRAPHICS_WIDTH_REAL/16)
|
#define GRAPHICS_WIDTH (GRAPHICS_WIDTH_REAL/8)
|
||||||
#define GRAPHICS_HEIGHT GRAPHICS_HEIGHT_REAL
|
#define GRAPHICS_HEIGHT GRAPHICS_HEIGHT_REAL
|
||||||
|
|
||||||
// dma lenght
|
// dma lenght
|
||||||
#define BUFFER_LINE_LENGTH (GRAPHICS_WIDTH*2) //Yes, in 16 bit halfwords.
|
#define BUFFER_LINE_LENGTH (GRAPHICS_WIDTH) //Yes, in bytes.
|
||||||
|
|
||||||
// line types
|
// line types
|
||||||
#define LINE_TYPE_UNKNOWN 0
|
#define LINE_TYPE_UNKNOWN 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user