File: MD8800.c

package info (click to toggle)
lcdproc 0.5.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,064 kB
  • sloc: ansic: 59,645; sh: 1,740; perl: 681; makefile: 417
file content (933 lines) | stat: -rw-r--r-- 26,377 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
/** \file server/drivers/MD8800.c
 * LCDd \c MD8800 driver for the CFD used in Medion MD8800 PCs.
 */

/*
    Copyright (C) 2006 Stefan Herdler in collaboration with Martin M�ller.

    This source Code is based on the NoritakeVFD, the serialVFD and the
    CFontzPacket Driver of this package.

    2006-05-07 Version 0.1: mostly everything should work

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301


    ==============================================================================

    Known hardware-commands of the MD8800 display
    discovered by Martin M�ller (listed in octal notation):

    \33\0abcdef (abcdef can be anything, it seems) - set clock, I think.
	   	The mapping is: bb:aa dd.cc.eeff
	   	Date values are entered in hex, e.g. :
    		0x18 0x08 0x05 0x04 0x20 0x06 for 8:18 04.05.2006

    \33\1 - 24 hour clock
    \33\2 - 12 hour clock (AM/PM)
    \33\3 - Stop clock from moving around
    \33\4 - Moving clock
    \33\5 - Show clock

    \33\40 - 2-line mode, clearing at end of last line.
    \33\41 - Only write to line1, no clearing,
             automatic scroll to the left when display is full.
    \33\42 - Only write to line2, no clearing,
             automatic scroll to the left when display is full.

      (d is in the range 0-4. Anything above 4 is full brightness, b = 0/1):
    ==============================================================================
    \33\60\00\d - brightness of 'hdd'   icon. \33\60\00\0 clears the 'hdd'   icon.
    \33\60\01\d - brightness of '1394'  icon. \33\60\01\0 clears the '1394'  icon.
    \33\60\02\d - brightness of 'cdrom' icon. \33\60\02\0 clears the 'cdrom' icon.
    \33\60\03\d - brightness of 'usb'   icon. \33\60\03\0 clears the 'usb'   icon.
    \33\60\04\d - brightness of 'movie' icon. \33\60\04\0 clears the 'movie' icon.
    \33\60\05\d - brightness of 'tv'    icon. \33\60\05\0 clears the 'tv'    icon.
    \33\60\06\d - brightness of 'music' icon. \33\60\06\0 clears the 'music' icon.
    \33\60\07\d - brightness of 'photo' icon. \33\60\07\0 clears the 'photo' icon.
    \33\60\10\d - recording light on/off.
    \33\60\11\b - email icon on/off.
    \33\60\12\b - email icon red on/off.
    \33\60\13\b - volume bar (least) on/off.
    \33\60\14\b - volume bar on/off.
    \33\60\15\b - volume bar on/off.
    \33\60\16\b - volume bar on/off.
    \33\60\17\b - volume bar on/off.
    \33\60\20\b - volume bar on/off.
    \33\60\21\b - volume bar (most) on/off.
    \33\60\22\b - red light beneath volume bars on/off (ie max volume)
    \33\60\23\b - speaker icon on/off
    \33\60\24\b - muted speaker icon on/off (they are adjacent, not overlapping)
    \33\60\25\b - red wifi/sound bar (least) on/off.
    \33\60\26\b - red wifi/sound bar on/off.
    \33\60\27\b - red wifi/sound bar (most) on/off.
    \33\60\30\b - (de)activate bounding box around first 4 icons (hdd,1394,cd,usb)
    \33\60\31\b - (de)activate bounding box around second 4 icons (movie,tv,music,photos)
    \33\60\32\b - (de)activate bounding box around record and 'play/pause/whatever' icon.
    \33\60\33\b - (de)activate bounding box around email icon.
    \33\60\34\b - (de)activate bounding box around volume icons.

    \33\62x - Don't know yet.
    \33\63x - Don't know yet.
    \33\61abcdefghi - Show graphics in 'multimedia' icon based on bitmap represented by 'abcdefghi'.
                      Graphics are 9 7-bit bitmaps. Values are given from the right-up, moving towards the left.
                      See examples in MD8800.c.

    \33\100\d - Brightness. d=0-5, i.e. 6 levels, from black to 'shiny'.  :)
    \33\120   - reset again (soft?). Acts as a 'clear' command. Doesn't unset some things.
    \33\121   - pos1.
    \33\122   - turn on display.
    \33\123   - turn off display (you can still write to it and '\33\122' will show the result.
    \33\124   - demo condition. The display is 'raining' and the icons are dancing  :) . \33\120 cannot reset it. \37 can.
    \33\360   - vertical bars in each character slot.
    \33\361   - horizontal bars in each character slot.
    \33\365   - Product and version! : SG-1788 ver 1.0

    \37 - Reset display (yay!)




    Commands availible to the client via output command:

    Commandnumber off+0 on+50 (50 that should be enough space for unknown commands ;-))
    |(decimal notation)
    |
    v      (d is in the range 0-4. Anything above 4 is full brightness, b = 0/1):
    ==============================================================================
    1	(de)activate 'hdd'   icon.
    2	(de)activate '1394'  icon.
    3	(de)activate 'cdrom' icon.
    4	(de)activate 'usb'   icon.
    5	(de)activate 'movie' icon.
    6	(de)activate 'tv'    icon.
    7	(de)activate 'music' icon.
    8	(de)activate 'photo' icon.
    9	recording light on/off.
    10 	(de)activate bounding box around first 4 icons (hdd,1394,cd,usb)
    11 	(de)activate bounding box around second 4 icons (movie,tv,music,photos)
    12 	(de)activate bounding box around record and 'play/pause/whatever' icon.
    13 	(de)activate bounding box around email icon.
    14 	(de)activate bounding box around volume icons.
    15	(de)activate all bounding boxes

    Commandnumber(decimal notation):
    |
    v
    110 off
    111 email icon on
    112 email icon and red icon on

    120 off
    121 volume bar least on
    122 volume bar least 2 on
    123 volume bar least 3 on
    124 volume bar least 4 on
    125 volume bar least 5 on
    126 volume bar least 6 on
    127 volume bar all 7 on
    128 volume bar all 7 and red light beneath  on
	That should make it easy for the client:
	Just calculate a volumelevel between 0 and 8 then add 120.

    130 off
    131 muted speaker icon on
    132 speaker icon on

    140 off
    141 red wifi/sound bar least on
    142 red wifi/sound bar least 2 on
    143 red wifi/sound bar all 3 on
    144 red wifi/sound bar "scanning"
	See volume bar.

	Predefined 'multimedia' icons:
    150 clear mm-icon
    151 play
    152 stop
    153 pause
    154 ffwd
    155 rwnd
    156 heart
    157 heart outline



    The display is running at:
    9600 baud 8n*2* no flow control

*/


#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "lcd.h"
#include "MD8800.h"

#include "shared/report.h"

/* Constants for userdefchar_mode */
#define NUM_CCs		0 /* max. number of custom characters */
#define DEFAULT_OFF_BRIGHTNESS	300
#define DEFAULT_ON_BRIGHTNESS	1000

/** private data for the \c MD8800 driver */
typedef struct MD8800_private_data {
	char device[200];
	int fd;
	int speed;
	/* dimensions */
	int width, height;
	int cellwidth, cellheight;
	/* framebuffer and buffer for old LCD contents */
	unsigned char *framebuf;
	unsigned char *backingstore;
	/* definable characters */
	int on_brightness;
	int off_brightness;
	int hw_brightness;
	int last_command;
	int wifi_scan;
	char info[255];
} PrivateData;

/* Vars for the server core */
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 0;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "MD8800_";



// Opens com port and sets baud correctly...
//
MODULE_EXPORT int
MD8800_init (Driver *drvthis)
{
	struct termios portset;
	int tmp, w, h;
	char size[200] = DEFAULT_SIZE;

	PrivateData *p;

	/* Allocate and store private data */
	p = (PrivateData *) calloc(1, sizeof(PrivateData));
	if (p == NULL)
		return -1;
	if (drvthis->store_private_ptr(drvthis, p))
		return -1;

	/* Initialize the PrivateData structure */
	p->fd = -1;
	p->cellwidth = DEFAULT_CELL_WIDTH;
	p->cellheight = DEFAULT_CELL_HEIGHT;
        p->wifi_scan = 1;
	p->hw_brightness = 6;

	debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis);

	/* Read config file */
	/* Which device should be used */
	strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
	p->device[sizeof(p->device)-1] = '\0';
	report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);

	/* Which size */
	strncpy(size, drvthis->config_get_string(drvthis->name, "Size", 0, DEFAULT_SIZE), sizeof(size));
	size[sizeof(size)-1] = '\0';
	if ((sscanf(size, "%dx%d", &w, &h) != 2)
	    || (w <= 0) || (w > LCD_MAX_WIDTH)
	    || (h <= 0) || (h > LCD_MAX_HEIGHT)) {
		report(RPT_WARNING, "%s: cannot parse Size: %s; using default %s",
			drvthis->name, size, DEFAULT_SIZE);
		sscanf(DEFAULT_SIZE, "%dx%d", &w, &h);
	}
	p->width = w;
	p->height = h;

	/* Which backlight brightness */
	tmp = drvthis->config_get_int(drvthis->name, "Brightness", 0, DEFAULT_ON_BRIGHTNESS);
	debug(RPT_INFO, "%s: Brightness (in config) is '%d'", __FUNCTION__, tmp);
	if ((tmp < 0) || (tmp > 1000)) {
		report(RPT_WARNING, "%s: Brightness must be between 0 and 1000; using default %d",
			drvthis->name, DEFAULT_ON_BRIGHTNESS);
		tmp = DEFAULT_ON_BRIGHTNESS;
	}
	p->on_brightness = tmp;

	/* Which backlight-off "brightness" */
	tmp = drvthis->config_get_int(drvthis->name, "OffBrightness", 0, DEFAULT_OFF_BRIGHTNESS);
	debug(RPT_INFO, "%s: OffBrightness (in config) is '%d'", __FUNCTION__, tmp);
	if ((tmp < 0) || (tmp > 1000)) {
		report(RPT_WARNING, "%s: OffBrightness must be between 0 and 1000; using default %d",
			drvthis->name, DEFAULT_OFF_BRIGHTNESS);
		tmp = DEFAULT_OFF_BRIGHTNESS;
	}
	p->off_brightness = tmp;


	/* Which speed */
	tmp = drvthis->config_get_int(drvthis->name, "Speed", 0, DEFAULT_SPEED);
	if ((tmp != 1200) && (tmp != 2400) && (tmp != 9600) && (tmp != 19200) && (tmp != 115200)) {
		report(RPT_WARNING, "%s: Speed must be 1200, 2400, 9600, 19200 or 115200; using default %d",
			drvthis->name, DEFAULT_SPEED);
		tmp = DEFAULT_SPEED;
	}
	if (tmp == 1200) p->speed = B1200;
	else if (tmp == 2400) p->speed = B2400;
	else if (tmp == 9600) p->speed = B9600;
	else if (tmp == 19200) p->speed = B19200;
	else if (tmp == 115200) p->speed = B115200;




	/* Set up io port correctly, and open it...*/
	debug(RPT_DEBUG, "%s: Opening device: %s", __FUNCTION__, p->device);
	p->fd = open (p->device, O_RDWR | O_NOCTTY | O_NDELAY);

	if (p->fd == -1) {
		report(RPT_ERR, "%s: open() of %s failed (%s)", drvthis->name, p->device, strerror(errno));
		return -1;
	}

	tcgetattr(p->fd, &portset);

	// We use RAW mode
#ifdef HAVE_CFMAKERAW
	// The easy way
	cfmakeraw(&portset);
#else
	// The hard way
	portset.c_iflag &= ~( IGNBRK | BRKINT | PARMRK | ISTRIP
   	                   | INLCR | IGNCR | ICRNL | IXON );
	portset.c_oflag &= ~OPOST;
	portset.c_lflag &= ~( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
	portset.c_cflag &= ~( CSIZE | PARENB | CRTSCTS );
	portset.c_cflag |= CS8 | CREAD | CLOCAL;
#endif
	portset.c_cflag |= CSTOPB;
	// Set port speed
	cfsetospeed(&portset, p->speed);
	cfsetispeed(&portset, B0);

	// Do it...
	tcsetattr(p->fd, TCSANOW, &portset);

	/* make sure the frame buffer is there... */
	p->framebuf = (unsigned char *) malloc(p->width * p->height);
	if (p->framebuf == NULL) {
		report(RPT_ERR, "%s: unable to create framebuffer", drvthis->name);
		return -1;
	}
	memset(p->framebuf, ' ', p->width * p->height);

	/* make sure the framebuffer backing store is there... */
	p->backingstore = (unsigned char *) malloc(p->width * p->height);
	if (p->backingstore == NULL) {
		report(RPT_ERR, "%s: unable to create framebuffer backing store", drvthis->name);
		return -1;
	}
	memset(p->backingstore, ' ', p->width * p->height);

	MD8800_backlight(drvthis, 1);

	//init
	write(p->fd, "\x1F", 1);
	write(p->fd, "\x1B", 1);
	write(p->fd, "\x20", 1);

	//boot screen
	write(p->fd, "\x1B\x51", 2);// medion \33\121 oct
	write(p->fd, "MD8800driver forlcdproc  (C) by:", 32);
	sleep(1);
	write(p->fd, " Stefan Herdler & Martin M\xF6ller ", 32);
	sleep(1);

	report(RPT_DEBUG, "%s: init() done", drvthis->name);

	return 0;

}

/////////////////////////////////////////////////////////////////
// Clean-up
//
MODULE_EXPORT void
MD8800_close (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;
	if (p != NULL) {
		if (p->fd >= 0)
			close(p->fd);

		if (p->framebuf)
			free(p->framebuf);

		if (p->backingstore)
			free(p->backingstore);
		free(p);
	}
	drvthis->store_private_ptr(drvthis, NULL);
//        MD8800_set_brightness (drvthis, 0, p->off_brightness);
}

/*
 * Returns the display width in characters
 */
MODULE_EXPORT int
MD8800_width (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	return p->width;
}


/*
 * Returns the display height in characters
 */
MODULE_EXPORT int
MD8800_height (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	return p->height;
}


/*
 * Returns the width of a character in pixels
 */
MODULE_EXPORT int
MD8800_cellwidth (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	return p->cellwidth;
}


/*
 * Returns the height of a character in pixels
 */
MODULE_EXPORT int
MD8800_cellheight (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	return p->cellheight;
}

/*
 * Retrieves brightness (in promille)
 */
MODULE_EXPORT int
MD8800_get_brightness(Driver *drvthis, int state)
{
	PrivateData *p = drvthis->private_data;

	return (state == BACKLIGHT_ON) ? p->on_brightness : p->off_brightness;
}


/*
 * Sets on/off brightness (in promille)
 */
MODULE_EXPORT void
MD8800_set_brightness(Driver *drvthis, int state, int promille)
{
	PrivateData *p = drvthis->private_data;

	/* Check it */
	if (promille < 0 || promille > 1000)
		return;

	/* store the software value since there is not get */
	if (state == BACKLIGHT_ON) {
		p->on_brightness = promille;
	}
	else {
		p->off_brightness = promille;
	}
	 //MD8800_backlight(drvthis,state);
}


/*
 * Sets the backlight on or off.
 * The hardware support any value between 0 and 100.
 */
MODULE_EXPORT void
MD8800_backlight (Driver *drvthis, int on)
{
	PrivateData *p = drvthis->private_data;
	int hardware_value = (on == BACKLIGHT_ON)
			     ? p->on_brightness
			     : p->off_brightness;

	/* map range [0, 1000] -> [0, 6] that the hardware understands */
	hardware_value /= 167;
	if (hardware_value != p->hw_brightness) {
		p->hw_brightness = hardware_value;
		write(p->fd, "\x1B\x40", 2);
		write(p->fd, &p->hw_brightness, 1);
	}
}

/////////////////////////////////////////////////////////////////
// Prints a character on the lcd display, at position (x,y).  The
// upper-left is (1,1), and the lower right should be (16,2).
//
MODULE_EXPORT void
MD8800_chr (Driver *drvthis, int x, int y, char c)
{
	PrivateData *p = drvthis->private_data;

	y--;
	x--;
	if ((x > p->width) || (y > p->height))
		return;

	p->framebuf[(y * p->width) + x ] = c;
}




/////////////////////////////////////////////////////////////
// Blasts a single frame onscreen, to the lcd...
//
// Input is a character array, sized MD8800->width*MD8800->height
//



MODULE_EXPORT void
MD8800_flush (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	if (memcmp(p->backingstore, p->framebuf, p->width*p->height) == 0)
		return;

	/* Backing-store implementation.  If it's already
	 * on the screen, don't put it there again
	 */

       	/* else, write out the entire row */
	memcpy(p->backingstore, p->framebuf, p->width*p->height);

	write(p->fd, "\x1B\x51", 2);// medion \33\121 oct
//	usleep(300);
//	write(p->fd, "\x51", 1);// medion \33\121 oct
//	usleep(300);

//	write(p->fd, "\x0D", 1); // nec
	write(p->fd, p->framebuf, p->width*p->height);


}

/////////////////////////////////////////////////////////////////
// Clears the LCD screen
//
MODULE_EXPORT void
MD8800_clear (Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	memset(p->framebuf, ' ', p->width * p->height);
}


/////////////////////////////////////////////////////////////////
// Prints a string on the lcd display, at position (x,y).  The
// upper-left is (1,1), and the lower right should be (20,4).
//
MODULE_EXPORT void
MD8800_string (Driver *drvthis, int x, int y, const char string[])
{
	PrivateData *p = drvthis->private_data;
	int i;

	x--;
	y--;
	for (i = 0; string[i] != '\0'; i++) {
		// Check for buffer overflows...
		if ((y * p->width) + x + i > (p->width * p->height))
			break;
		p->framebuf[(y * p->width) + x + i] = string[i];
	}
}

MODULE_EXPORT int
MD8800_icon (Driver *drvthis, int x, int y, int icon)
{
	switch (icon) {
		case ICON_BLOCK_FILLED:
			MD8800_chr(drvthis, x, y, 127);
			break;
		default:
			return -1; // Let the core do other icons
	}
	return 0;
}

////////////////////////////////////////////////////////////////////
// Controls the custom icons.
//
//
MODULE_EXPORT void
MD8800_output (Driver *drvthis, int on)
{
	PrivateData *p = drvthis->private_data;

	if (on == 144) {
		switch (p->wifi_scan){
			case 1:
				write(p->fd, "\x1B\x30\x15\x01", 4);
			//	write(p->fd, "\x1B\x30\x16\x00", 4);
				write(p->fd, "\x1B\x30\x17\x00", 4);
			break;
			case 4:
				write(p->fd, "\x1B\x30\x15\x00", 4);
				write(p->fd, "\x1B\x30\x16\x01", 4);
			//	write(p->fd, "\x1B\x30\x17\x00", 4);
			break;
			case 7:
			//	write(p->fd, "\x1B\x30\x15\x00", 4);
				write(p->fd, "\x1B\x30\x16\x00", 4);
				write(p->fd, "\x1B\x30\x17\x01", 4);
			break;
			case 10:
				p->wifi_scan=0;
			break;
			}
		p->wifi_scan++;
	}

	if (on == p->last_command)
		return;
	p->last_command = on;

	report(RPT_ERR, "command send is: %i", on);
	switch (on) {
	// +0 -> off
		case 1: // 'hdd'
			write(p->fd, "\x1B\x30\x00\x00", 4);
		break;
		case 2: // '1394'
			write(p->fd, "\x1B\x30\x01\x00", 4);
		break;
		case 3: // 'cdrom'
			write(p->fd, "\x1B\x30\x02\x00", 4);
		break;
		case 4: // 'usb'
			write(p->fd, "\x1B\x30\x03\x00", 4);
		break;
		case 5: // 'movie'
			write(p->fd, "\x1B\x30\x04\x00", 4);
		break;
		case 6: // 'tv'
			write(p->fd, "\x1B\x30\x05\x00", 4);
		break;
		case 7: // 'music'
			write(p->fd, "\x1B\x30\x06\x00", 4);
		break;
		case 8: // 'photo'
			write(p->fd, "\x1B\x30\x07\x00", 4);
		break;
		case 9: // 'recording light'
			write(p->fd, "\x1B\x30\x08\x00", 4);
		break;
		case 10: // bounding box (hdd,1394,cd,usb)
			write(p->fd, "\x1B\x30\x18\x00", 4);
		break;
		case 11: // bounding box (movie,tv,music,photos)
			write(p->fd, "\x1B\x30\x19\x00", 4);
		break;
		case 12: // bounding box (play/pause/whatever)
			write(p->fd, "\x1B\x30\x1A\x00", 4);
		break;
		case 13: // bounding box (email)
			write(p->fd, "\x1B\x30\x1B\x00", 4);
		break;
		case 14: // bounding box (volume)
			write(p->fd, "\x1B\x30\x1C\x00", 4);
		break;
		case 15: // all bounding boxes
			write(p->fd, "\x1B\x30\x18\x00", 4);
			write(p->fd, "\x1B\x30\x19\x00", 4);
			write(p->fd, "\x1B\x30\x1A\x00", 4);
			write(p->fd, "\x1B\x30\x1B\x00", 4);
			write(p->fd, "\x1B\x30\x1C\x00", 4);
		break;

	// +50 -> on
		case 51: // 'hdd'
			write(p->fd, "\x1B\x30\x00", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 52: // '1394'
			write(p->fd, "\x1B\x30\x01", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 53: // 'cdrom'
			write(p->fd, "\x1B\x30\x02", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 54: // 'usb'
			write(p->fd, "\x1B\x30\x03", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 55: // 'movie'
			write(p->fd, "\x1B\x30\x04", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 56: // 'tv'
			write(p->fd, "\x1B\x30\x05", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 57: // 'music'
			write(p->fd, "\x1B\x30\x06", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 58: // 'photo'
			write(p->fd, "\x1B\x30\x07", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 59: // 'recording light'
			write(p->fd, "\x1B\x30\x08", 3);
			write(p->fd, &p->hw_brightness, 1);
		break;
		case 60: // bounding box (hdd,1394,cd,usb)
			write(p->fd, "\x1B\x30\x18\x01", 4);
		break;
		case 61: // bounding box (movie,tv,music,photos)
			write(p->fd, "\x1B\x30\x19\x01", 4);
		break;
		case 62: // bounding box (play/pause/whatever)
			write(p->fd, "\x1B\x30\x1A\x01", 4);
		break;
		case 63: // bounding box (email)
			write(p->fd, "\x1B\x30\x1B\x01", 4);
		break;
		case 64: // bounding box (volume)
			write(p->fd, "\x1B\x30\x1C\x01", 4);
		break;
		case 65: // all bounding boxes
			write(p->fd, "\x1B\x30\x18\x01", 4);
			write(p->fd, "\x1B\x30\x19\x01", 4);
			write(p->fd, "\x1B\x30\x1A\x01", 4);
			write(p->fd, "\x1B\x30\x1B\x01", 4);
			write(p->fd, "\x1B\x30\x1C\x01", 4);
		break;
			//email icons
		case 100:
			write(p->fd, "\x1B\x30\x09\x00", 4);
			write(p->fd, "\x1B\x30\x0A\x00", 4);
		break;
		case 101:

			write(p->fd, "\x1B\x30\x09\x01", 4);
			write(p->fd, "\x1B\x30\x0A\x00", 4);
		break;
		case 102:

			write(p->fd, "\x1B\x30\x09\x01", 4);
			write(p->fd, "\x1B\x30\x0A\x01", 4);
		break;
			// volume bar
		case 120:
			write(p->fd, "\x1B\x30\x0B\x00", 4);
			write(p->fd, "\x1B\x30\x0C\x00", 4);
			write(p->fd, "\x1B\x30\x0D\x00", 4);
			write(p->fd, "\x1B\x30\x0E\x00", 4);
			write(p->fd, "\x1B\x30\x0F\x00", 4);
			write(p->fd, "\x1B\x30\x10\x00", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 121:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x00", 4);
			write(p->fd, "\x1B\x30\x0D\x00", 4);
			write(p->fd, "\x1B\x30\x0E\x00", 4);
			write(p->fd, "\x1B\x30\x0F\x00", 4);
			write(p->fd, "\x1B\x30\x10\x00", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 122:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x00", 4);
			write(p->fd, "\x1B\x30\x0E\x00", 4);
			write(p->fd, "\x1B\x30\x0F\x00", 4);
			write(p->fd, "\x1B\x30\x10\x00", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 123:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x01", 4);
			write(p->fd, "\x1B\x30\x0E\x00", 4);
			write(p->fd, "\x1B\x30\x0F\x00", 4);
			write(p->fd, "\x1B\x30\x10\x00", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 124:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x01", 4);
			write(p->fd, "\x1B\x30\x0E\x01", 4);
			write(p->fd, "\x1B\x30\x0F\x00", 4);
			write(p->fd, "\x1B\x30\x10\x00", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 125:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x01", 4);
			write(p->fd, "\x1B\x30\x0E\x01", 4);
			write(p->fd, "\x1B\x30\x0F\x01", 4);
			write(p->fd, "\x1B\x30\x10\x00", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 126:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x01", 4);
			write(p->fd, "\x1B\x30\x0E\x01", 4);
			write(p->fd, "\x1B\x30\x0F\x01", 4);
			write(p->fd, "\x1B\x30\x10\x01", 4);
			write(p->fd, "\x1B\x30\x11\x00", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 127:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x01", 4);
			write(p->fd, "\x1B\x30\x0E\x01", 4);
			write(p->fd, "\x1B\x30\x0F\x01", 4);
			write(p->fd, "\x1B\x30\x10\x01", 4);
			write(p->fd, "\x1B\x30\x11\x01", 4);
			write(p->fd, "\x1B\x30\x12\x00", 4);
		break;
		case 128:
			write(p->fd, "\x1B\x30\x0B\x01", 4);
			write(p->fd, "\x1B\x30\x0C\x01", 4);
			write(p->fd, "\x1B\x30\x0D\x01", 4);
			write(p->fd, "\x1B\x30\x0E\x01", 4);
			write(p->fd, "\x1B\x30\x0F\x01", 4);
			write(p->fd, "\x1B\x30\x10\x01", 4);
			write(p->fd, "\x1B\x30\x11\x01", 4);
			write(p->fd, "\x1B\x30\x12\x01", 4);
		break;
		case 130:
			write(p->fd, "\x1B\x30\x13\x00", 4);
			write(p->fd, "\x1B\x30\x14\x00", 4);
		break;
		case 131:
			write(p->fd, "\x1B\x30\x13\x00", 4);
			write(p->fd, "\x1B\x30\x14\x01", 4);
		break;
		case 132:
			write(p->fd, "\x1B\x30\x13\x01", 4);
			write(p->fd, "\x1B\x30\x14\x00", 4);
		break;


			// red wifi/sound bar
		case 140:
			write(p->fd, "\x1B\x30\x15\x00", 4);
			write(p->fd, "\x1B\x30\x16\x00", 4);
			write(p->fd, "\x1B\x30\x17\x00", 4);
		break;
		case 141:
			write(p->fd, "\x1B\x30\x15\x01", 4);
			write(p->fd, "\x1B\x30\x16\x00", 4);
			write(p->fd, "\x1B\x30\x17\x00", 4);
		break;
		case 142:
			write(p->fd, "\x1B\x30\x15\x01", 4);
			write(p->fd, "\x1B\x30\x16\x01", 4);
			write(p->fd, "\x1B\x30\x17\x00", 4);
		break;
		case 143:
			write(p->fd, "\x1B\x30\x15\x01", 4);
			write(p->fd, "\x1B\x30\x16\x01", 4);
			write(p->fd, "\x1B\x30\x17\x01", 4);
		break;
			// multimedia icon
		case 150: // clear
			write(p->fd, "\x1B\x31\x00\x00\x00\x00\x00\x00\x00\x00\x00", 11);
		break;
		case 151: // play
			write(p->fd, "\x1B\x31\x00\x00\x08\x1C\x3E\x7F\x00\x00\x00", 11);
		break;
		case 152: // stop
			write(p->fd, "\x1B\x31\x00\x3E\x3E\x3E\x3E\x3E\x00\x00\x00", 11);
		break;
		case 153: // pause
			write(p->fd, "\x1B\x31\x00\x3E\x3E\x00\x3E\x3E\x00\x00\x00", 11);
		break;
		case 154: // ffwd
			write(p->fd, "\x1B\x31\x00\x08\x1C\x3E\x08\x1C\x3E\x00\x00", 11);
		break;
		case 155: // rwnd
			write(p->fd, "\x1B\x31\x00\x3E\x1C\x08\x3E\x1C\x08\x00\x00", 11);
		break;
		case 156: // heart
			write(p->fd, "\x1B\x31\x00\x0C\x1E\x3E\x7C\x3E\x1E\x0C\x00", 11);
		break;
		case 157: // heart outline
			write(p->fd, "\x1B\x31\x0C\x12\x21\x41\x02\x41\x21\x12\x0C", 11);
		break;

		default:
			return;
	}

}

/*
 * Provide some info about this driver
 */
MODULE_EXPORT const char *
MD8800_get_info(Driver *drvthis)
{
	PrivateData *p = drvthis->private_data;

	snprintf(p->info, sizeof(p->info)-1, "Medion MD8800 Driver");
	return p->info;
}

/* EOF */