Skip to content

Commit f86a2e4

Browse files
committed
Improve lcd handling for ETC
1 parent 45c0cd8 commit f86a2e4

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Inc/orblcd_protocol.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,24 @@
1414
#define ORBLCD_CMD_CLEAR (3)
1515
#define ORBLCD_CMD_GOTOXY (4)
1616

17+
#define LCD_BE (0)
18+
#define LCD_LE (1)
19+
1720
#define ORBLCD_ENCODE_X(x) ((x&0xfff)<<0)
1821
#define ORBLCD_ENCODE_Y(x) ((x&0xfff)<<12)
1922
#define ORBLCD_ENCODE_D(x) ((x&0x03)<<24)
2023
#define ORBLCD_ENCODE_C(x) ((x&0x3f)<<26)
24+
#define ORBLCD_ENCODE_L(x) ((x&0x01)<<31)
2125
#define ORBLCD_DECODE_X(x) ((x>>0)&0xfff)
2226
#define ORBLCD_DECODE_Y(x) ((x>>12)&0xfff)
2327
#define ORBLCD_DECODE_D(x) ((x>>24)&0x03)
24-
#define ORBLCD_DECODE_C(x) ((x>>26)&0x3f)
28+
#define ORBLCD_DECODE_C(x) ((x>>26)&0x1f)
29+
#define ORBLCD_DECODE_L(x) ((x>>31)&0x01)
2530

2631
#define ORBLCD_GET_DEPTH(x) (((int[]){1,8,16,24})[ORBLCD_DECODE_D(x)])
2732
#define ORBLCD_PIXELS_PER_WORD(x) (((int[]){32,4,2,1})[ORBLCD_DECODE_D(x)])
2833

29-
#define ORBLCD_OPEN_SCREEN(x,y,d) (ORBLCD_ENCODE_C(ORBLCD_CMD_INIT_LCD)|ORBLCD_ENCODE_D(d)|ORBLCD_ENCODE_X(x)|ORBLCD_ENCODE_Y(y))
34+
#define ORBLCD_OPEN_SCREEN(x,y,d,l) (ORBLCD_ENCODE_L(l)|ORBLCD_ENCODE_C(ORBLCD_CMD_INIT_LCD)|ORBLCD_ENCODE_D(d)|ORBLCD_ENCODE_X(x)|ORBLCD_ENCODE_Y(y))
3035
#define ORBLCD_CLOSE_SCREEN (ORBLCD_ENCODE_C(ORBLCD_CMD_CLOSE_SCREEN))
3136
#define ORBLCD_CLEAR (ORBLCD_ENCODE_C(ORBLCD_CMD_CLEAR))
3237

Src/orblcd.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,14 @@ static void _paintPixels( struct swMsg *m, struct RunTime *r )
127127
switch ( ORBLCD_DECODE_D( r->app->modeDescriptor ) )
128128
{
129129
case ORBLCD_DEPTH_1:
130-
y = ( d & ( 1 << ( b % 8 ) ) ) ? r->app->sbcolour : 0;
130+
if ( ORBLCD_DECODE_L( r->app->modeDescriptor ) )
131+
{
132+
y = ( d & ( 128 >> ( b % 8 ) ) ) ? r->app->sbcolour : 0;
133+
}
134+
else
135+
{
136+
y = ( d & ( 1 << ( b % 8 ) ) ) ? r->app->sbcolour : 0;
137+
}
131138

132139
if ( !( b % 8 ) )
133140
{

0 commit comments

Comments
 (0)