blob: e1d1953d540194f92db75007fea507535e053049 [file] [log] [blame]
Daniel Stenbergd20e6ee2002-03-26 10:06:28 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
Daniel Stenberg319d1f32002-03-26 10:59:39 +000020#include <stdio.h>
21#include <string.h>
22#include <stdarg.h>
23#include <stdlib.h>
24#include <ctype.h>
25#include <sys/types.h>
26#include <sys/stat.h>
27#include <fcntl.h>
28
29#include <errno.h>
30#include <ctype.h>
31#include <time.h>
32
33#include "screenhack.h"
34
Daniel Stenbergd20e6ee2002-03-26 10:06:28 +000035/*
Daniel Stenberg319d1f32002-03-26 10:59:39 +000036 * Specific implementations for X11, using the generic LCD API and data.
Daniel Stenbergd20e6ee2002-03-26 10:06:28 +000037 */
38
Daniel Stenberga1fd2552002-03-26 14:27:03 +000039#include "lcd-x11.h"
Daniel Stenberg319d1f32002-03-26 10:59:39 +000040
Markus Braunde8fbf02002-08-07 10:35:26 +000041extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8];
Björn Stenbergf9429cc2002-04-19 12:55:12 +000042extern void screen_resized(int width, int height);
43extern Display *dpy;
Daniel Stenberg319d1f32002-03-26 10:59:39 +000044
Markus Braunde8fbf02002-08-07 10:35:26 +000045unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8];
Daniel Stenbergc1543512002-04-27 23:41:41 +000046
Daniel Stenberged6c7e42002-06-14 11:00:13 +000047/* this is in uibasic.c */
48extern void drawdots(int color, XPoint *points, int count);
49
Daniel Stenberg319d1f32002-03-26 10:59:39 +000050void lcd_update (void)
51{
Björn Stenbergf9429cc2002-04-19 12:55:12 +000052 int x, y;
53 int p=0;
54 int bit;
55 XPoint points[LCD_WIDTH * LCD_HEIGHT];
Daniel Stenbergc1543512002-04-27 23:41:41 +000056 int cp=0;
57 XPoint clearpoints[LCD_WIDTH * LCD_HEIGHT];
Daniel Stenberg319d1f32002-03-26 10:59:39 +000058
Daniel Stenbergc1543512002-04-27 23:41:41 +000059#if 0
Björn Stenbergf9429cc2002-04-19 12:55:12 +000060 screen_resized(LCD_WIDTH, LCD_HEIGHT);
61
62 for(y=0; y<LCD_HEIGHT; y+=8) {
63 for(x=0; x<LCD_WIDTH; x++) {
Markus Braunde8fbf02002-08-07 10:35:26 +000064 if(lcd_framebuffer[x][y/8]) {
Björn Stenbergf9429cc2002-04-19 12:55:12 +000065 /* one or more bits/pixels are set */
66 for(bit=0; bit<8; bit++) {
Markus Braunde8fbf02002-08-07 10:35:26 +000067 if(lcd_framebuffer[x][y/8]&(1<<bit)) {
Björn Stenbergf9429cc2002-04-19 12:55:12 +000068 points[p].x = x + MARGIN_X;
69 points[p].y = y+bit + MARGIN_Y;
70 p++; /* increase the point counter */
71 }
72 }
73 }
Daniel Stenberg319d1f32002-03-26 10:59:39 +000074 }
Daniel Stenberg319d1f32002-03-26 10:59:39 +000075 }
Daniel Stenbergc1543512002-04-27 23:41:41 +000076#else
77 for(y=0; y<LCD_HEIGHT; y+=8) {
78 for(x=0; x<LCD_WIDTH; x++) {
Markus Braunde8fbf02002-08-07 10:35:26 +000079 if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) {
Daniel Stenbergc1543512002-04-27 23:41:41 +000080 /* one or more bits/pixels are changed */
81 unsigned char diff =
Markus Braunde8fbf02002-08-07 10:35:26 +000082 lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8];
Daniel Stenbergc1543512002-04-27 23:41:41 +000083
84 for(bit=0; bit<8; bit++) {
Markus Braunde8fbf02002-08-07 10:35:26 +000085 if(lcd_framebuffer[x][y/8]&(1<<bit)) {
Daniel Stenbergc1543512002-04-27 23:41:41 +000086 /* set a dot */
87 points[p].x = x + MARGIN_X;
88 points[p].y = y+bit + MARGIN_Y;
89 p++; /* increase the point counter */
90 }
91 else if(diff &(1<<bit)) {
92 /* clear a dot */
93 clearpoints[cp].x = x + MARGIN_X;
94 clearpoints[cp].y = y+bit + MARGIN_Y;
95 cp++; /* increase the point counter */
96 }
97 }
98 }
99 }
100 }
101
102 /* copy a huge block */
Markus Braunde8fbf02002-08-07 10:35:26 +0000103 memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer));
Daniel Stenbergc1543512002-04-27 23:41:41 +0000104
105#endif
106
Daniel Stenbergc1543512002-04-27 23:41:41 +0000107 drawdots(0, &clearpoints[0], cp);
Daniel Stenberg5ab87aa2002-04-30 13:29:08 +0000108 drawdots(1, &points[0], p);
Robert Hak38cb0402002-05-03 06:54:41 +0000109/* Logf("lcd_update: Draws %d pixels, clears %d pixels", p, cp);*/
Björn Stenbergf9429cc2002-04-19 12:55:12 +0000110 XSync(dpy,False);
Daniel Stenberg319d1f32002-03-26 10:59:39 +0000111}