e-paper whereabouts board program

Dependencies:   SDFileSystem mbed

Committer:
kohacraft
Date:
Sun May 01 03:12:28 2016 +0000
Revision:
0:e4c67c26ba3f
Child:
1:cb28911c7ba5
ver1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 0:e4c67c26ba3f 1 #include "mbed.h"
kohacraft 0:e4c67c26ba3f 2 #include "extdio.h"
kohacraft 0:e4c67c26ba3f 3 #include "eink.h"
kohacraft 0:e4c67c26ba3f 4
kohacraft 0:e4c67c26ba3f 5
kohacraft 0:e4c67c26ba3f 6 //initialize port
kohacraft 0:e4c67c26ba3f 7 void initPort()
kohacraft 0:e4c67c26ba3f 8 {
kohacraft 0:e4c67c26ba3f 9 setCL( 0 );
kohacraft 0:e4c67c26ba3f 10 setContBas( LE , 0);
kohacraft 0:e4c67c26ba3f 11 setContBas( OE , 0);
kohacraft 0:e4c67c26ba3f 12 setContBas( NC10 , 1);
kohacraft 0:e4c67c26ba3f 13 setContBas( SPH , 1);
kohacraft 0:e4c67c26ba3f 14
kohacraft 0:e4c67c26ba3f 15 setContBas( GMODE , 0);
kohacraft 0:e4c67c26ba3f 16 setContBas( SPV , 1);
kohacraft 0:e4c67c26ba3f 17 setContBas( CKV , 0);
kohacraft 0:e4c67c26ba3f 18 setContBas( EN , 0);
kohacraft 0:e4c67c26ba3f 19
kohacraft 0:e4c67c26ba3f 20 setDataBas( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
kohacraft 0:e4c67c26ba3f 21 }
kohacraft 0:e4c67c26ba3f 22
kohacraft 0:e4c67c26ba3f 23 //pageStart
kohacraft 0:e4c67c26ba3f 24 void pageStart()
kohacraft 0:e4c67c26ba3f 25 {
kohacraft 0:e4c67c26ba3f 26
kohacraft 0:e4c67c26ba3f 27 setContBas( GMODE , 1 );
kohacraft 0:e4c67c26ba3f 28 setContBas( CKV , 1 );
kohacraft 0:e4c67c26ba3f 29 wait_us(11);
kohacraft 0:e4c67c26ba3f 30 setContBas( SPV , 0 );
kohacraft 0:e4c67c26ba3f 31 wait_us(11);
kohacraft 0:e4c67c26ba3f 32 setContBas( CKV , 0 );
kohacraft 0:e4c67c26ba3f 33 wait_us(10);
kohacraft 0:e4c67c26ba3f 34 setContBas( CKV , 1 );
kohacraft 0:e4c67c26ba3f 35 wait_us(10);
kohacraft 0:e4c67c26ba3f 36 setContBas( SPV , 1 );
kohacraft 0:e4c67c26ba3f 37 wait_us(12);
kohacraft 0:e4c67c26ba3f 38
kohacraft 0:e4c67c26ba3f 39 setContBas( CKV , 0 );
kohacraft 0:e4c67c26ba3f 40 wait_us(10);
kohacraft 0:e4c67c26ba3f 41 setContBas( CKV , 1 );
kohacraft 0:e4c67c26ba3f 42 wait_us(22);
kohacraft 0:e4c67c26ba3f 43 setContBas( CKV , 0 );
kohacraft 0:e4c67c26ba3f 44 wait_us(10);
kohacraft 0:e4c67c26ba3f 45 setContBas( CKV , 1 );
kohacraft 0:e4c67c26ba3f 46 wait_us(22);
kohacraft 0:e4c67c26ba3f 47 setContBas( CKV , 0 );
kohacraft 0:e4c67c26ba3f 48 wait_us(10);
kohacraft 0:e4c67c26ba3f 49 setContBas( CKV , 1 );
kohacraft 0:e4c67c26ba3f 50 wait_us(1);
kohacraft 0:e4c67c26ba3f 51 }
kohacraft 0:e4c67c26ba3f 52
kohacraft 0:e4c67c26ba3f 53 //lineStart
kohacraft 0:e4c67c26ba3f 54 void lineStart()
kohacraft 0:e4c67c26ba3f 55 {
kohacraft 0:e4c67c26ba3f 56
kohacraft 0:e4c67c26ba3f 57 setCL( 1 );
kohacraft 0:e4c67c26ba3f 58 setCL( 0 );
kohacraft 0:e4c67c26ba3f 59 setContBas( LE , 0 );
kohacraft 0:e4c67c26ba3f 60 wait_us(1);
kohacraft 0:e4c67c26ba3f 61
kohacraft 0:e4c67c26ba3f 62 setCL( 1 );
kohacraft 0:e4c67c26ba3f 63 setCL( 0 );
kohacraft 0:e4c67c26ba3f 64 wait_us(1);
kohacraft 0:e4c67c26ba3f 65
kohacraft 0:e4c67c26ba3f 66 setCL( 1 );
kohacraft 0:e4c67c26ba3f 67 setCL( 0 );
kohacraft 0:e4c67c26ba3f 68 wait_us(1);
kohacraft 0:e4c67c26ba3f 69
kohacraft 0:e4c67c26ba3f 70 setCL( 1 );
kohacraft 0:e4c67c26ba3f 71 setCL( 0 );
kohacraft 0:e4c67c26ba3f 72 setContBas( OE , 1 );
kohacraft 0:e4c67c26ba3f 73 wait_us(1);
kohacraft 0:e4c67c26ba3f 74
kohacraft 0:e4c67c26ba3f 75 setCL( 1 );
kohacraft 0:e4c67c26ba3f 76 setCL( 0 );
kohacraft 0:e4c67c26ba3f 77 setContBas( SPH , 0 );
kohacraft 0:e4c67c26ba3f 78 }
kohacraft 0:e4c67c26ba3f 79
kohacraft 0:e4c67c26ba3f 80 //drow pixels
kohacraft 0:e4c67c26ba3f 81 void drowPixelsRaw( bool d7 , bool d6 , bool d5 , bool d4 , bool d3 , bool d2 , bool d1 , bool d0 )
kohacraft 0:e4c67c26ba3f 82 {
kohacraft 0:e4c67c26ba3f 83 setDataBas( d7 , d6 , d5 , d4 , d3 , d2 , d1 , d0 );
kohacraft 0:e4c67c26ba3f 84 setCL( 1 );
kohacraft 0:e4c67c26ba3f 85 setCL( 0 );
kohacraft 0:e4c67c26ba3f 86 }
kohacraft 0:e4c67c26ba3f 87
kohacraft 0:e4c67c26ba3f 88 //lineEnd
kohacraft 0:e4c67c26ba3f 89 void lineEnd()
kohacraft 0:e4c67c26ba3f 90 {
kohacraft 0:e4c67c26ba3f 91 setContBas( NC10 , 1 );
kohacraft 0:e4c67c26ba3f 92 setContBas( CKV , 0 );
kohacraft 0:e4c67c26ba3f 93
kohacraft 0:e4c67c26ba3f 94 setCL( 1 );
kohacraft 0:e4c67c26ba3f 95 setCL( 0 );
kohacraft 0:e4c67c26ba3f 96 wait_us(10);
kohacraft 0:e4c67c26ba3f 97
kohacraft 0:e4c67c26ba3f 98 setContBas( OE , 0 );
kohacraft 0:e4c67c26ba3f 99 setContBas( LE , 1 );
kohacraft 0:e4c67c26ba3f 100 setContBas( CKV , 1 );
kohacraft 0:e4c67c26ba3f 101 wait_us(1);
kohacraft 0:e4c67c26ba3f 102 }
kohacraft 0:e4c67c26ba3f 103
kohacraft 0:e4c67c26ba3f 104 //pageEnd
kohacraft 0:e4c67c26ba3f 105 void pageEnd()
kohacraft 0:e4c67c26ba3f 106 {
kohacraft 0:e4c67c26ba3f 107 setCL( 1 );
kohacraft 0:e4c67c26ba3f 108 setCL( 0 );
kohacraft 0:e4c67c26ba3f 109 setContBas( LE , 0 );
kohacraft 0:e4c67c26ba3f 110
kohacraft 0:e4c67c26ba3f 111 setCL( 1 );
kohacraft 0:e4c67c26ba3f 112 setCL( 0 );
kohacraft 0:e4c67c26ba3f 113
kohacraft 0:e4c67c26ba3f 114 setCL( 1 );
kohacraft 0:e4c67c26ba3f 115 setCL( 0 );
kohacraft 0:e4c67c26ba3f 116
kohacraft 0:e4c67c26ba3f 117 setCL( 1 );
kohacraft 0:e4c67c26ba3f 118 setCL( 0 );
kohacraft 0:e4c67c26ba3f 119 setContBas( OE , 1 );
kohacraft 0:e4c67c26ba3f 120
kohacraft 0:e4c67c26ba3f 121 setCL( 1 );
kohacraft 0:e4c67c26ba3f 122 setCL( 0 );
kohacraft 0:e4c67c26ba3f 123
kohacraft 0:e4c67c26ba3f 124 for( int i=0 ; i<200 ; i++ )
kohacraft 0:e4c67c26ba3f 125 {
kohacraft 0:e4c67c26ba3f 126 setCL( 1 );
kohacraft 0:e4c67c26ba3f 127 setCL( 0 );
kohacraft 0:e4c67c26ba3f 128 }
kohacraft 0:e4c67c26ba3f 129 setContBas( CKV , 0 );
kohacraft 0:e4c67c26ba3f 130
kohacraft 0:e4c67c26ba3f 131 setCL( 1 );
kohacraft 0:e4c67c26ba3f 132 setCL( 0 );
kohacraft 0:e4c67c26ba3f 133
kohacraft 0:e4c67c26ba3f 134 wait_us(10);
kohacraft 0:e4c67c26ba3f 135 setContBas( OE , 0 );
kohacraft 0:e4c67c26ba3f 136
kohacraft 0:e4c67c26ba3f 137 wait_us(330);
kohacraft 0:e4c67c26ba3f 138
kohacraft 0:e4c67c26ba3f 139 setContBas( GMODE , 0 );
kohacraft 0:e4c67c26ba3f 140 wait_us(130);
kohacraft 0:e4c67c26ba3f 141
kohacraft 0:e4c67c26ba3f 142 }
kohacraft 0:e4c67c26ba3f 143
kohacraft 0:e4c67c26ba3f 144 //change SPH signals
kohacraft 0:e4c67c26ba3f 145 void changeSPH()
kohacraft 0:e4c67c26ba3f 146 {
kohacraft 0:e4c67c26ba3f 147 setContBas( SPH , 1 );
kohacraft 0:e4c67c26ba3f 148 setContBas( NC10 , 0 );
kohacraft 0:e4c67c26ba3f 149 }
kohacraft 0:e4c67c26ba3f 150
kohacraft 0:e4c67c26ba3f 151 //turn off the power
kohacraft 0:e4c67c26ba3f 152 void powerOff()
kohacraft 0:e4c67c26ba3f 153 {
kohacraft 0:e4c67c26ba3f 154 setDataBas( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
kohacraft 0:e4c67c26ba3f 155
kohacraft 0:e4c67c26ba3f 156 setCL( 0 );
kohacraft 0:e4c67c26ba3f 157 setContBas( LE , 0);
kohacraft 0:e4c67c26ba3f 158 setContBas( OE , 0);
kohacraft 0:e4c67c26ba3f 159 setContBas( NC10 , 0);
kohacraft 0:e4c67c26ba3f 160 setContBas( SPH , 0);
kohacraft 0:e4c67c26ba3f 161
kohacraft 0:e4c67c26ba3f 162 setContBas( GMODE , 0);
kohacraft 0:e4c67c26ba3f 163 setContBas( SPV , 0);
kohacraft 0:e4c67c26ba3f 164 setContBas( CKV , 0);
kohacraft 0:e4c67c26ba3f 165
kohacraft 0:e4c67c26ba3f 166 setContBas( EN , 1);
kohacraft 0:e4c67c26ba3f 167
kohacraft 0:e4c67c26ba3f 168 }
kohacraft 0:e4c67c26ba3f 169
kohacraft 0:e4c67c26ba3f 170 //turn on the power
kohacraft 0:e4c67c26ba3f 171 void powerOn()
kohacraft 0:e4c67c26ba3f 172 {
kohacraft 0:e4c67c26ba3f 173 setContBas( EN , 0);
kohacraft 0:e4c67c26ba3f 174 }
kohacraft 0:e4c67c26ba3f 175
kohacraft 0:e4c67c26ba3f 176 //clear screen 0:Black 1:White
kohacraft 0:e4c67c26ba3f 177 void clrdisp( bool color )
kohacraft 0:e4c67c26ba3f 178 {
kohacraft 0:e4c67c26ba3f 179 pageStart();
kohacraft 0:e4c67c26ba3f 180 for( int j=0 ; j<600 ; j++)
kohacraft 0:e4c67c26ba3f 181 {
kohacraft 0:e4c67c26ba3f 182 lineStart();
kohacraft 0:e4c67c26ba3f 183 for( int i=0 ; i<100 ; i++ )
kohacraft 0:e4c67c26ba3f 184 {
kohacraft 0:e4c67c26ba3f 185 if( color == 1)
kohacraft 0:e4c67c26ba3f 186 drowPixelsRaw( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //Draw white
kohacraft 0:e4c67c26ba3f 187 else
kohacraft 0:e4c67c26ba3f 188 drowPixelsRaw( 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ); //Draw black
kohacraft 0:e4c67c26ba3f 189 }
kohacraft 0:e4c67c26ba3f 190 changeSPH();
kohacraft 0:e4c67c26ba3f 191 for( int i=100 ; i<200 ; i++ )
kohacraft 0:e4c67c26ba3f 192 {
kohacraft 0:e4c67c26ba3f 193 if( color == 1)
kohacraft 0:e4c67c26ba3f 194 drowPixelsRaw( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //Draw white
kohacraft 0:e4c67c26ba3f 195 else
kohacraft 0:e4c67c26ba3f 196 drowPixelsRaw( 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ); //Draw black
kohacraft 0:e4c67c26ba3f 197 }
kohacraft 0:e4c67c26ba3f 198 lineEnd();
kohacraft 0:e4c67c26ba3f 199
kohacraft 0:e4c67c26ba3f 200 }
kohacraft 0:e4c67c26ba3f 201 pageEnd();
kohacraft 0:e4c67c26ba3f 202 }
kohacraft 0:e4c67c26ba3f 203
kohacraft 0:e4c67c26ba3f 204
kohacraft 0:e4c67c26ba3f 205
kohacraft 0:e4c67c26ba3f 206 //Drow 8pixels paletteWhite: 0:draw white at 0 of a data bit, 1:draw white at 1 of a data bit
kohacraft 0:e4c67c26ba3f 207 void drowPixels( char data , bool paletteWhite )
kohacraft 0:e4c67c26ba3f 208 {
kohacraft 0:e4c67c26ba3f 209 if( paletteWhite == 0 )
kohacraft 0:e4c67c26ba3f 210 {
kohacraft 0:e4c67c26ba3f 211 drowPixelsRaw( (data&0x10)!=0 , 1 , (data&0x20)!=0 , 1 , (data&0x40)!=0 , 1 , (data&0x80)!=0 , 1 );
kohacraft 0:e4c67c26ba3f 212 drowPixelsRaw( (data&0x01)!=0 , 1 , (data&0x02)!=0 , 1 , (data&0x04)!=0 , 1 , (data&0x08)!=0 , 1 );
kohacraft 0:e4c67c26ba3f 213 //drowPixelsRaw( (data&0x10)!=0 , (data&0x10)==0 , (data&0x20)!=0 , (data&0x20)==0 , (data&0x40)!=0 , (data&0x40)==0 , (data&0x80)!=0 , (data&0x80)==0 );
kohacraft 0:e4c67c26ba3f 214 //drowPixelsRaw( (data&0x01)!=0 , (data&0x01)==0 , (data&0x02)!=0 , (data&0x02)==0 , (data&0x04)!=0 , (data&0x04)==0 , (data&0x08)!=0 , (data&0x08)==0 );
kohacraft 0:e4c67c26ba3f 215 }
kohacraft 0:e4c67c26ba3f 216 else
kohacraft 0:e4c67c26ba3f 217 {
kohacraft 0:e4c67c26ba3f 218 drowPixelsRaw( (data&0x10)==0 , 1 , (data&0x20)==0 , 1 , (data&0x40)==0 , 1 , (data&0x80)==0 , 1 );
kohacraft 0:e4c67c26ba3f 219 drowPixelsRaw( (data&0x01)==0 , 1 , (data&0x02)==0 , 1 , (data&0x04)==0 , 1 , (data&0x08)==0 , 1 );
kohacraft 0:e4c67c26ba3f 220 //drowPixelsRaw( (data&0x10)==0 , (data&0x10)!=0 , (data&0x20)==0 , (data&0x20)!=0 , (data&0x40)==0 , (data&0x40)!=0 , (data&0x80)==0 , (data&0x80)!=0 );
kohacraft 0:e4c67c26ba3f 221 //drowPixelsRaw( (data&0x01)==0 , (data&0x01)!=0 , (data&0x02)==0 , (data&0x02)!=0 , (data&0x04)==0 , (data&0x04)!=0 , (data&0x08)==0 , (data&0x08)!=0 );
kohacraft 0:e4c67c26ba3f 222 }
kohacraft 0:e4c67c26ba3f 223 }
kohacraft 0:e4c67c26ba3f 224
kohacraft 0:e4c67c26ba3f 225 //draw BMP file of fp(File Pointer) at locate(0,0)
kohacraft 0:e4c67c26ba3f 226 //BMP width and hight size is multiples of 8pixel
kohacraft 0:e4c67c26ba3f 227 void dispbmp(FILE *fp )
kohacraft 0:e4c67c26ba3f 228 {
kohacraft 0:e4c67c26ba3f 229 dispbmp( fp , 0 , 0 );
kohacraft 0:e4c67c26ba3f 230 }
kohacraft 0:e4c67c26ba3f 231
kohacraft 0:e4c67c26ba3f 232 //draw BMP file of fp(File Pointer) at locate(xpos,ypos)
kohacraft 0:e4c67c26ba3f 233 //BMP width and hight size is multiples of 8pixel
kohacraft 0:e4c67c26ba3f 234 //locate parametors are multiples of 8pixel
kohacraft 0:e4c67c26ba3f 235 void dispbmp(FILE *fp , int xpos , int ypos)
kohacraft 0:e4c67c26ba3f 236 {
kohacraft 0:e4c67c26ba3f 237 char bmpdata;
kohacraft 0:e4c67c26ba3f 238 int size;
kohacraft 0:e4c67c26ba3f 239
kohacraft 0:e4c67c26ba3f 240 //check file pointer is avalable.
kohacraft 0:e4c67c26ba3f 241 if( fp == NULL )
kohacraft 0:e4c67c26ba3f 242 {
kohacraft 0:e4c67c26ba3f 243 fclose(fp);
kohacraft 0:e4c67c26ba3f 244 free(fp);
kohacraft 0:e4c67c26ba3f 245
kohacraft 0:e4c67c26ba3f 246 //not avalable
kohacraft 0:e4c67c26ba3f 247 clrdisp(1); //clear White
kohacraft 0:e4c67c26ba3f 248 clrdisp(0); //clear Black
kohacraft 0:e4c67c26ba3f 249 clrdisp(1); //clear White
kohacraft 0:e4c67c26ba3f 250 clrdisp(0); //clear Black
kohacraft 0:e4c67c26ba3f 251
kohacraft 0:e4c67c26ba3f 252 return;
kohacraft 0:e4c67c26ba3f 253 }
kohacraft 0:e4c67c26ba3f 254
kohacraft 0:e4c67c26ba3f 255
kohacraft 0:e4c67c26ba3f 256
kohacraft 0:e4c67c26ba3f 257 //get Image Width and hight pixels
kohacraft 0:e4c67c26ba3f 258 unsigned int xsize , ysize;
kohacraft 0:e4c67c26ba3f 259 fseek(fp, 18 , SEEK_SET);//to xsize
kohacraft 0:e4c67c26ba3f 260 size = fread( &xsize , sizeof(unsigned int) , 1 , fp);
kohacraft 0:e4c67c26ba3f 261 size = fread( &ysize , sizeof(unsigned int) , 1 , fp);
kohacraft 0:e4c67c26ba3f 262
kohacraft 0:e4c67c26ba3f 263
kohacraft 0:e4c67c26ba3f 264 //decide witch value(0 or 1 of the image data bit) is writing in white dot
kohacraft 0:e4c67c26ba3f 265 unsigned char palettetemp[8];
kohacraft 0:e4c67c26ba3f 266 fseek(fp, 54 , SEEK_SET);//bitmap headder throw
kohacraft 0:e4c67c26ba3f 267 size = fread( palettetemp , sizeof(char) , 8 , fp);
kohacraft 0:e4c67c26ba3f 268 int palette0 = (int)palettetemp[0]+(int)palettetemp[1]+(int)palettetemp[2]; //sum of palette0 RGBvaue
kohacraft 0:e4c67c26ba3f 269 int palette1 = (int)palettetemp[4]+(int)palettetemp[5]+(int)palettetemp[6]; //sum of palette1 RGBvaue
kohacraft 0:e4c67c26ba3f 270 bool paletteWhite = 0;
kohacraft 0:e4c67c26ba3f 271 if( palette0 > palette1 )
kohacraft 0:e4c67c26ba3f 272 {
kohacraft 0:e4c67c26ba3f 273 paletteWhite = 0; //draw white in the bit value 0 of BMP data
kohacraft 0:e4c67c26ba3f 274 }
kohacraft 0:e4c67c26ba3f 275 else
kohacraft 0:e4c67c26ba3f 276 {
kohacraft 0:e4c67c26ba3f 277 paletteWhite = 1; //draw white in the bit value 1 of BMP data
kohacraft 0:e4c67c26ba3f 278 }
kohacraft 0:e4c67c26ba3f 279
kohacraft 0:e4c67c26ba3f 280 //go to bmp image data
kohacraft 0:e4c67c26ba3f 281 unsigned int dataOffset;
kohacraft 0:e4c67c26ba3f 282 fseek(fp, 10 , SEEK_SET);
kohacraft 0:e4c67c26ba3f 283 size = fread( &dataOffset , sizeof(unsigned int) , 1 , fp);
kohacraft 0:e4c67c26ba3f 284 fseek(fp, dataOffset , SEEK_SET);
kohacraft 0:e4c67c26ba3f 285
kohacraft 0:e4c67c26ba3f 286 pageStart();
kohacraft 0:e4c67c26ba3f 287
kohacraft 0:e4c67c26ba3f 288 //pass line until drow y position
kohacraft 0:e4c67c26ba3f 289 for( int j=0 ; j<ypos ; j++)
kohacraft 0:e4c67c26ba3f 290 {
kohacraft 0:e4c67c26ba3f 291 lineStart();
kohacraft 0:e4c67c26ba3f 292 for( int i=0 ; i<100 ; i++ )
kohacraft 0:e4c67c26ba3f 293 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );
kohacraft 0:e4c67c26ba3f 294 changeSPH();
kohacraft 0:e4c67c26ba3f 295 for( int i=0 ; i<100 ; i++ )
kohacraft 0:e4c67c26ba3f 296 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );
kohacraft 0:e4c67c26ba3f 297 lineEnd();
kohacraft 0:e4c67c26ba3f 298 }
kohacraft 0:e4c67c26ba3f 299
kohacraft 0:e4c67c26ba3f 300 for( int j=ypos ; j<ysize+ypos ; j++)
kohacraft 0:e4c67c26ba3f 301 {
kohacraft 0:e4c67c26ba3f 302 lineStart();
kohacraft 0:e4c67c26ba3f 303
kohacraft 0:e4c67c26ba3f 304 for( int i=0 ; i<100 ; i+=2 )
kohacraft 0:e4c67c26ba3f 305 {
kohacraft 0:e4c67c26ba3f 306 if( i>=(xpos/4) && i<((xsize+xpos)/4) )
kohacraft 0:e4c67c26ba3f 307 {
kohacraft 0:e4c67c26ba3f 308 size = fread( &bmpdata , sizeof(char) , 1 , fp);
kohacraft 0:e4c67c26ba3f 309 if( size != 1 )
kohacraft 0:e4c67c26ba3f 310 {
kohacraft 0:e4c67c26ba3f 311 drowPixelsRaw( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //if it can not read , draw in white
kohacraft 0:e4c67c26ba3f 312 drowPixelsRaw( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 );
kohacraft 0:e4c67c26ba3f 313 }
kohacraft 0:e4c67c26ba3f 314 else
kohacraft 0:e4c67c26ba3f 315 {
kohacraft 0:e4c67c26ba3f 316 drowPixels(bmpdata,paletteWhite); //draw
kohacraft 0:e4c67c26ba3f 317 }
kohacraft 0:e4c67c26ba3f 318 }
kohacraft 0:e4c67c26ba3f 319 else
kohacraft 0:e4c67c26ba3f 320 {
kohacraft 0:e4c67c26ba3f 321 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); //not draw at out of image
kohacraft 0:e4c67c26ba3f 322 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );
kohacraft 0:e4c67c26ba3f 323 }
kohacraft 0:e4c67c26ba3f 324 }
kohacraft 0:e4c67c26ba3f 325 changeSPH();
kohacraft 0:e4c67c26ba3f 326 for( int i=100 ; i<200 ; i+=2 )
kohacraft 0:e4c67c26ba3f 327 {
kohacraft 0:e4c67c26ba3f 328 if( i>=(xpos/4) && i<((xsize+xpos)/4) ) //
kohacraft 0:e4c67c26ba3f 329 {
kohacraft 0:e4c67c26ba3f 330 size = fread( &bmpdata , sizeof(char) , 1 , fp);
kohacraft 0:e4c67c26ba3f 331 if( size != 1 )
kohacraft 0:e4c67c26ba3f 332 {
kohacraft 0:e4c67c26ba3f 333 drowPixelsRaw( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //if it can not read , draw in white
kohacraft 0:e4c67c26ba3f 334 drowPixelsRaw( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 );
kohacraft 0:e4c67c26ba3f 335 }
kohacraft 0:e4c67c26ba3f 336 else
kohacraft 0:e4c67c26ba3f 337 {
kohacraft 0:e4c67c26ba3f 338 drowPixels(bmpdata,paletteWhite);
kohacraft 0:e4c67c26ba3f 339 }
kohacraft 0:e4c67c26ba3f 340 }
kohacraft 0:e4c67c26ba3f 341 else
kohacraft 0:e4c67c26ba3f 342 {
kohacraft 0:e4c67c26ba3f 343 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); //not draw at out of image
kohacraft 0:e4c67c26ba3f 344 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );
kohacraft 0:e4c67c26ba3f 345 }
kohacraft 0:e4c67c26ba3f 346
kohacraft 0:e4c67c26ba3f 347 }
kohacraft 0:e4c67c26ba3f 348
kohacraft 0:e4c67c26ba3f 349 //pass the data over 800pixels
kohacraft 0:e4c67c26ba3f 350 if( (xsize+xpos)>800 )
kohacraft 0:e4c67c26ba3f 351 {
kohacraft 0:e4c67c26ba3f 352 int dataPass = ((xsize+xpos)-800)/8;
kohacraft 0:e4c67c26ba3f 353 fseek(fp, dataPass , SEEK_CUR);
kohacraft 0:e4c67c26ba3f 354 }
kohacraft 0:e4c67c26ba3f 355
kohacraft 0:e4c67c26ba3f 356 lineEnd();
kohacraft 0:e4c67c26ba3f 357 }
kohacraft 0:e4c67c26ba3f 358
kohacraft 0:e4c67c26ba3f 359 //pass remain lines
kohacraft 0:e4c67c26ba3f 360 for( int j=ypos+ysize ; j<600 ; j++)
kohacraft 0:e4c67c26ba3f 361 {
kohacraft 0:e4c67c26ba3f 362 lineStart();
kohacraft 0:e4c67c26ba3f 363 for( int i=0 ; i<100 ; i++ )
kohacraft 0:e4c67c26ba3f 364 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); //not draw
kohacraft 0:e4c67c26ba3f 365 changeSPH();
kohacraft 0:e4c67c26ba3f 366 for( int i=0 ; i<100 ; i++ )
kohacraft 0:e4c67c26ba3f 367 drowPixelsRaw( 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); //not draw
kohacraft 0:e4c67c26ba3f 368 lineEnd();
kohacraft 0:e4c67c26ba3f 369 }
kohacraft 0:e4c67c26ba3f 370
kohacraft 0:e4c67c26ba3f 371 pageEnd();
kohacraft 0:e4c67c26ba3f 372 }
kohacraft 0:e4c67c26ba3f 373
kohacraft 0:e4c67c26ba3f 374