1
0
Fork 0

Fixup mixed tabs/spaces

This commit is contained in:
Fred Sundvik 2017-07-09 13:50:18 +03:00 committed by Jack Humbert
parent 630f065376
commit 011ee29441
5 changed files with 153 additions and 153 deletions

View file

@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if GFX_USE_GDISP #if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK #define GDISP_DRIVER_VMT GDISPVMT_IS31FL3731C_QMK
#include "gdisp_lld_config.h" #include "gdisp_lld_config.h"
#include "src/gdisp/gdisp_driver.h" #include "src/gdisp/gdisp_driver.h"
@ -34,26 +34,26 @@ extern const uint8_t CIE1931_CURVE[];
/*===========================================================================*/ /*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT #ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 9 #define GDISP_SCREEN_HEIGHT 9
#endif #endif
#ifndef GDISP_SCREEN_WIDTH #ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 16 #define GDISP_SCREEN_WIDTH 16
#endif #endif
#ifndef GDISP_INITIAL_CONTRAST #ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 0 #define GDISP_INITIAL_CONTRAST 0
#endif #endif
#ifndef GDISP_INITIAL_BACKLIGHT #ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 0 #define GDISP_INITIAL_BACKLIGHT 0
#endif #endif
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
#define IS31_ADDR_DEFAULT 0x74 #define IS31_ADDR_DEFAULT 0x74
#define IS31_REG_CONFIG 0x00 #define IS31_REG_CONFIG 0x00
// bits in reg // bits in reg
#define IS31_REG_CONFIG_PICTUREMODE 0x00 #define IS31_REG_CONFIG_PICTUREMODE 0x00
#define IS31_REG_CONFIG_AUTOPLAYMODE 0x08 #define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
#define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18 #define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
// D2:D0 bits are starting frame for autoplay mode // D2:D0 bits are starting frame for autoplay mode
@ -144,14 +144,14 @@ static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint
} }
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// The private area is the display surface. // The private area is the display surface.
g->priv = gfxAlloc(sizeof(PrivData)); g->priv = gfxAlloc(sizeof(PrivData));
__builtin_memset(PRIV(g), 0, sizeof(PrivData)); __builtin_memset(PRIV(g), 0, sizeof(PrivData));
PRIV(g)->page = 0; PRIV(g)->page = 0;
// Initialise the board interface // Initialise the board interface
init_board(g); init_board(g);
gfxSleepMilliseconds(10); gfxSleepMilliseconds(10);
// zero function page, all registers (assuming full_page is all zeroes) // zero function page, all registers (assuming full_page is all zeroes)
write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE); write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
@ -179,134 +179,134 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// Finish Init // Finish Init
post_init_board(g); post_init_board(g);
/* Initialise the GDISP structure */ /* Initialise the GDISP structure */
g->g.Width = GDISP_SCREEN_WIDTH; g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT; g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Orientation = GDISP_ROTATE_0; g->g.Orientation = GDISP_ROTATE_0;
g->g.Powermode = powerOff; g->g.Powermode = powerOff;
g->g.Backlight = GDISP_INITIAL_BACKLIGHT; g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
g->g.Contrast = GDISP_INITIAL_CONTRAST; g->g.Contrast = GDISP_INITIAL_CONTRAST;
return TRUE; return TRUE;
} }
#if GDISP_HARDWARE_FLUSH #if GDISP_HARDWARE_FLUSH
LLDSPEC void gdisp_lld_flush(GDisplay *g) { LLDSPEC void gdisp_lld_flush(GDisplay *g) {
// Don't flush if we don't need it. // Don't flush if we don't need it.
if (!(g->flags & GDISP_FLG_NEEDFLUSH)) if (!(g->flags & GDISP_FLG_NEEDFLUSH))
return; return;
PRIV(g)->page++; PRIV(g)->page++;
PRIV(g)->page %= 2; PRIV(g)->page %= 2;
// TODO: some smarter algorithm for this // TODO: some smarter algorithm for this
// We should run only one physical page at a time // We should run only one physical page at a time
// This way we don't need to send so much data, and // This way we don't need to send so much data, and
// we could use slightly less memory // we could use slightly less memory
uint8_t* src = PRIV(g)->frame_buffer; uint8_t* src = PRIV(g)->frame_buffer;
for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) { for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
for (int x=0;x<GDISP_SCREEN_WIDTH;x++) { for (int x=0;x<GDISP_SCREEN_WIDTH;x++) {
uint8_t val = (uint16_t)*src * g->g.Backlight / 100; uint8_t val = (uint16_t)*src * g->g.Backlight / 100;
PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val]; PRIV(g)->write_buffer[get_led_address(g, x, y)]=CIE1931_CURVE[val];
++src; ++src;
} }
} }
write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE); write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
gfxSleepMilliseconds(1); gfxSleepMilliseconds(1);
write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page); write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
g->flags &= ~GDISP_FLG_NEEDFLUSH; g->flags &= ~GDISP_FLG_NEEDFLUSH;
} }
#endif #endif
#if GDISP_HARDWARE_DRAWPIXEL #if GDISP_HARDWARE_DRAWPIXEL
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
coord_t x, y; coord_t x, y;
switch(g->g.Orientation) { switch(g->g.Orientation) {
default: default:
case GDISP_ROTATE_0: case GDISP_ROTATE_0:
x = g->p.x; x = g->p.x;
y = g->p.y; y = g->p.y;
break; break;
case GDISP_ROTATE_180: case GDISP_ROTATE_180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x; x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = g->p.y; y = g->p.y;
break; break;
} }
PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color); PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
g->flags |= GDISP_FLG_NEEDFLUSH; g->flags |= GDISP_FLG_NEEDFLUSH;
} }
#endif #endif
#if GDISP_HARDWARE_PIXELREAD #if GDISP_HARDWARE_PIXELREAD
LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
coord_t x, y; coord_t x, y;
switch(g->g.Orientation) { switch(g->g.Orientation) {
default: default:
case GDISP_ROTATE_0: case GDISP_ROTATE_0:
x = g->p.x; x = g->p.x;
y = g->p.y; y = g->p.y;
break; break;
case GDISP_ROTATE_180: case GDISP_ROTATE_180:
x = GDISP_SCREEN_WIDTH-1 - g->p.x; x = GDISP_SCREEN_WIDTH-1 - g->p.x;
y = g->p.y; y = g->p.y;
break; break;
} }
return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]); return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
} }
#endif #endif
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL #if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g) { LLDSPEC void gdisp_lld_control(GDisplay *g) {
switch(g->p.x) { switch(g->p.x) {
case GDISP_CONTROL_POWER: case GDISP_CONTROL_POWER:
if (g->g.Powermode == (powermode_t)g->p.ptr) if (g->g.Powermode == (powermode_t)g->p.ptr)
return;
switch((powermode_t)g->p.ptr) {
case powerOff:
case powerSleep:
case powerDeepSleep:
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
break;
case powerOn:
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
break;
default:
return;
}
g->g.Powermode = (powermode_t)g->p.ptr;
return;
case GDISP_CONTROL_ORIENTATION:
if (g->g.Orientation == (orientation_t)g->p.ptr)
return;
switch((orientation_t)g->p.ptr) {
/* Rotation is handled by the drawing routines */
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
case GDISP_ROTATE_270:
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
default:
return;
}
g->g.Orientation = (orientation_t)g->p.ptr;
return;
case GDISP_CONTROL_BACKLIGHT:
if (g->g.Backlight == (unsigned)g->p.ptr)
return; return;
unsigned val = (unsigned)g->p.ptr; switch((powermode_t)g->p.ptr) {
g->g.Backlight = val > 100 ? 100 : val; case powerOff:
case powerSleep:
case powerDeepSleep:
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
break;
case powerOn:
write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
break;
default:
return;
}
g->g.Powermode = (powermode_t)g->p.ptr;
return;
case GDISP_CONTROL_ORIENTATION:
if (g->g.Orientation == (orientation_t)g->p.ptr)
return;
switch((orientation_t)g->p.ptr) {
/* Rotation is handled by the drawing routines */
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
g->g.Height = GDISP_SCREEN_HEIGHT;
g->g.Width = GDISP_SCREEN_WIDTH;
break;
case GDISP_ROTATE_90:
case GDISP_ROTATE_270:
g->g.Height = GDISP_SCREEN_WIDTH;
g->g.Width = GDISP_SCREEN_HEIGHT;
break;
default:
return;
}
g->g.Orientation = (orientation_t)g->p.ptr;
return;
case GDISP_CONTROL_BACKLIGHT:
if (g->g.Backlight == (unsigned)g->p.ptr)
return;
unsigned val = (unsigned)g->p.ptr;
g->g.Backlight = val > 100 ? 100 : val;
g->flags |= GDISP_FLG_NEEDFLUSH; g->flags |= GDISP_FLG_NEEDFLUSH;
return; return;
} }
} }
#endif // GDISP_NEED_CONTROL #endif // GDISP_NEED_CONTROL
#endif // GFX_USE_GDISP #endif // GFX_USE_GDISP

View file

@ -24,13 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Driver hardware support. */ /* Driver hardware support. */
/*===========================================================================*/ /*===========================================================================*/
#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
#define GDISP_HARDWARE_DRAWPIXEL TRUE #define GDISP_HARDWARE_DRAWPIXEL TRUE
#define GDISP_HARDWARE_PIXELREAD TRUE #define GDISP_HARDWARE_PIXELREAD TRUE
#define GDISP_HARDWARE_CONTROL TRUE #define GDISP_HARDWARE_CONTROL TRUE
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256 #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY256
#endif /* GFX_USE_GDISP */ #endif /* GFX_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */ #endif /* _GDISP_LLD_CONFIG_H */

View file

@ -9,7 +9,7 @@
#if GFX_USE_GDISP #if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK #define GDISP_DRIVER_VMT GDISPVMT_ST7565_QMK
#include "gdisp_lld_config.h" #include "gdisp_lld_config.h"
#include "src/gdisp/gdisp_driver.h" #include "src/gdisp/gdisp_driver.h"
@ -20,24 +20,24 @@
/*===========================================================================*/ /*===========================================================================*/
#ifndef GDISP_SCREEN_HEIGHT #ifndef GDISP_SCREEN_HEIGHT
#define GDISP_SCREEN_HEIGHT 32 #define GDISP_SCREEN_HEIGHT 32
#endif #endif
#ifndef GDISP_SCREEN_WIDTH #ifndef GDISP_SCREEN_WIDTH
#define GDISP_SCREEN_WIDTH 128 #define GDISP_SCREEN_WIDTH 128
#endif #endif
#ifndef GDISP_INITIAL_CONTRAST #ifndef GDISP_INITIAL_CONTRAST
#define GDISP_INITIAL_CONTRAST 35 #define GDISP_INITIAL_CONTRAST 35
#endif #endif
#ifndef GDISP_INITIAL_BACKLIGHT #ifndef GDISP_INITIAL_BACKLIGHT
#define GDISP_INITIAL_BACKLIGHT 100 #define GDISP_INITIAL_BACKLIGHT 100
#endif #endif
#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0) #define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)
#include "st7565.h" #include "st7565.h"
/*===========================================================================*/ /*===========================================================================*/
/* Driver config defaults for backward compatibility. */ /* Driver config defaults for backward compatibility. */
/*===========================================================================*/ /*===========================================================================*/
#ifndef ST7565_LCD_BIAS #ifndef ST7565_LCD_BIAS
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_7 #define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
@ -65,7 +65,7 @@ typedef struct{
// Some common routines and macros // Some common routines and macros
#define PRIV(g) ((PrivData*)g->priv) #define PRIV(g) ((PrivData*)g->priv)
#define RAM(g) (PRIV(g)->ram) #define RAM(g) (PRIV(g)->ram)
static GFXINLINE void write_cmd(GDisplay* g, uint8_t cmd) { static GFXINLINE void write_cmd(GDisplay* g, uint8_t cmd) {
PRIV(g)->data[PRIV(g)->data_pos++] = cmd; PRIV(g)->data[PRIV(g)->data_pos++] = cmd;
@ -76,15 +76,15 @@ static GFXINLINE void flush_cmd(GDisplay* g) {
PRIV(g)->data_pos = 0; PRIV(g)->data_pos = 0;
} }
#define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); } #define write_cmd2(g, cmd1, cmd2) { write_cmd(g, cmd1); write_cmd(g, cmd2); }
#define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); } #define write_cmd3(g, cmd1, cmd2, cmd3) { write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); }
// Some common routines and macros // Some common routines and macros
#define delay(us) gfxSleepMicroseconds(us) #define delay(us) gfxSleepMicroseconds(us)
#define delay_ms(ms) gfxSleepMilliseconds(ms) #define delay_ms(ms) gfxSleepMilliseconds(ms)
#define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH) #define xyaddr(x, y) ((x) + ((y)>>3)*GDISP_SCREEN_WIDTH)
#define xybit(y) (1<<((y)&7)) #define xybit(y) (1<<((y)&7))
/*===========================================================================*/ /*===========================================================================*/
/* Driver exported functions. */ /* Driver exported functions. */
@ -150,7 +150,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
#if GDISP_HARDWARE_FLUSH #if GDISP_HARDWARE_FLUSH
LLDSPEC void gdisp_lld_flush(GDisplay *g) { LLDSPEC void gdisp_lld_flush(GDisplay *g) {
unsigned p; unsigned p;
// Don't flush if we don't need it. // Don't flush if we don't need it.
if (!(g->flags & GDISP_FLG_NEEDFLUSH)) if (!(g->flags & GDISP_FLG_NEEDFLUSH))
@ -181,7 +181,7 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
#if GDISP_HARDWARE_DRAWPIXEL #if GDISP_HARDWARE_DRAWPIXEL
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
coord_t x, y; coord_t x, y;
switch(g->g.Orientation) { switch(g->g.Orientation) {
default: default:
@ -212,7 +212,7 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
#if GDISP_HARDWARE_PIXELREAD #if GDISP_HARDWARE_PIXELREAD
LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) { LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
coord_t x, y; coord_t x, y;
switch(g->g.Orientation) { switch(g->g.Orientation) {
default: default:
@ -257,7 +257,7 @@ LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
else { else {
*dst &= ~xybit(dsty); *dst &= ~xybit(dsty);
} }
dstx++; dstx++;
srcbit++; srcbit++;
} }
} }

View file

@ -14,7 +14,7 @@
/* Driver hardware support. */ /* Driver hardware support. */
/*===========================================================================*/ /*===========================================================================*/
#define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing
#define GDISP_HARDWARE_DRAWPIXEL TRUE #define GDISP_HARDWARE_DRAWPIXEL TRUE
#define GDISP_HARDWARE_PIXELREAD TRUE #define GDISP_HARDWARE_PIXELREAD TRUE
#define GDISP_HARDWARE_CONTROL TRUE #define GDISP_HARDWARE_CONTROL TRUE
@ -22,6 +22,6 @@
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_MONO
#endif /* GFX_USE_GDISP */ #endif /* GFX_USE_GDISP */
#endif /* _GDISP_LLD_CONFIG_H */ #endif /* _GDISP_LLD_CONFIG_H */

View file

@ -83,7 +83,7 @@ static GFXINLINE void init_board(GDisplay *g) {
} }
static GFXINLINE void post_init_board(GDisplay *g) { static GFXINLINE void post_init_board(GDisplay *g) {
(void) g; (void) g;
} }
static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
@ -106,8 +106,8 @@ static GFXINLINE void enter_cmd_mode(GDisplay *g) {
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) { static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
(void) g; (void) g;
spiSend(&SPID1, length, data); spiSend(&SPID1, length, data);
} }
#endif /* _GDISP_LLD_BOARD_H */ #endif /* _GDISP_LLD_BOARD_H */