eink paper ED060SC4(LF) にSD内の01.bmpを表示させます

Dependencies:   SDFileSystem mbed

Committer:
kohacraft
Date:
Sun Feb 14 09:02:57 2016 +0000
Revision:
1:8c9178c52155
Parent:
0:97881c3945b1
?????????OFF???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kohacraft 0:97881c3945b1 1 #include "mbed.h"
kohacraft 0:97881c3945b1 2 #include "extdio.h"
kohacraft 0:97881c3945b1 3 #include "eink.h"
kohacraft 0:97881c3945b1 4
kohacraft 0:97881c3945b1 5 //ポートの初期化
kohacraft 0:97881c3945b1 6 void initPort()
kohacraft 0:97881c3945b1 7 {
kohacraft 0:97881c3945b1 8 setCL( 0 );
kohacraft 0:97881c3945b1 9 setContBas( LE , 0);
kohacraft 0:97881c3945b1 10 setContBas( OE , 0);
kohacraft 0:97881c3945b1 11 setContBas( NC10 , 1);
kohacraft 0:97881c3945b1 12 setContBas( SPH , 1);
kohacraft 0:97881c3945b1 13
kohacraft 0:97881c3945b1 14 setContBas( GMODE , 0);
kohacraft 0:97881c3945b1 15 setContBas( SPV , 1);
kohacraft 0:97881c3945b1 16 setContBas( CKV , 0);
kohacraft 0:97881c3945b1 17 setContBas( EN , 0);
kohacraft 0:97881c3945b1 18
kohacraft 0:97881c3945b1 19 setDataBas( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
kohacraft 0:97881c3945b1 20 }
kohacraft 0:97881c3945b1 21
kohacraft 0:97881c3945b1 22 //pageStart
kohacraft 0:97881c3945b1 23 void pageStart()
kohacraft 0:97881c3945b1 24 {
kohacraft 0:97881c3945b1 25
kohacraft 0:97881c3945b1 26 setContBas( GMODE , 1 );
kohacraft 0:97881c3945b1 27 setContBas( CKV , 1 );
kohacraft 0:97881c3945b1 28 wait_us(11);
kohacraft 0:97881c3945b1 29 setContBas( SPV , 0 );
kohacraft 0:97881c3945b1 30 wait_us(11);
kohacraft 0:97881c3945b1 31 setContBas( CKV , 0 );
kohacraft 0:97881c3945b1 32 wait_us(10);
kohacraft 0:97881c3945b1 33 setContBas( CKV , 1 );
kohacraft 0:97881c3945b1 34 wait_us(10);
kohacraft 0:97881c3945b1 35 setContBas( SPV , 1 );
kohacraft 0:97881c3945b1 36 wait_us(12);
kohacraft 0:97881c3945b1 37
kohacraft 0:97881c3945b1 38 setContBas( CKV , 0 );
kohacraft 0:97881c3945b1 39 wait_us(10);
kohacraft 0:97881c3945b1 40 setContBas( CKV , 1 );
kohacraft 0:97881c3945b1 41 wait_us(22);
kohacraft 0:97881c3945b1 42 setContBas( CKV , 0 );
kohacraft 0:97881c3945b1 43 wait_us(10);
kohacraft 0:97881c3945b1 44 setContBas( CKV , 1 );
kohacraft 0:97881c3945b1 45 wait_us(22);
kohacraft 0:97881c3945b1 46 setContBas( CKV , 0 );
kohacraft 0:97881c3945b1 47 wait_us(10);
kohacraft 0:97881c3945b1 48 setContBas( CKV , 1 );
kohacraft 0:97881c3945b1 49 wait_us(1);
kohacraft 0:97881c3945b1 50 }
kohacraft 0:97881c3945b1 51
kohacraft 0:97881c3945b1 52 //lineStart
kohacraft 0:97881c3945b1 53 void lineStart()
kohacraft 0:97881c3945b1 54 {
kohacraft 0:97881c3945b1 55
kohacraft 0:97881c3945b1 56 setCL( 1 );
kohacraft 0:97881c3945b1 57 setCL( 0 );
kohacraft 0:97881c3945b1 58 setContBas( LE , 0 );
kohacraft 0:97881c3945b1 59 wait_us(1);
kohacraft 0:97881c3945b1 60
kohacraft 0:97881c3945b1 61 setCL( 1 );
kohacraft 0:97881c3945b1 62 setCL( 0 );
kohacraft 0:97881c3945b1 63 wait_us(1);
kohacraft 0:97881c3945b1 64
kohacraft 0:97881c3945b1 65 setCL( 1 );
kohacraft 0:97881c3945b1 66 setCL( 0 );
kohacraft 0:97881c3945b1 67 wait_us(1);
kohacraft 0:97881c3945b1 68
kohacraft 0:97881c3945b1 69 setCL( 1 );
kohacraft 0:97881c3945b1 70 setCL( 0 );
kohacraft 0:97881c3945b1 71 setContBas( OE , 1 );
kohacraft 0:97881c3945b1 72 wait_us(1);
kohacraft 0:97881c3945b1 73
kohacraft 0:97881c3945b1 74 setCL( 1 );
kohacraft 0:97881c3945b1 75 setCL( 0 );
kohacraft 0:97881c3945b1 76 setContBas( SPH , 0 );
kohacraft 0:97881c3945b1 77 }
kohacraft 0:97881c3945b1 78
kohacraft 0:97881c3945b1 79 //点を描画
kohacraft 0:97881c3945b1 80 void drowPixels( bool d7 , bool d6 , bool d5 , bool d4 , bool d3 , bool d2 , bool d1 , bool d0 )
kohacraft 0:97881c3945b1 81 {
kohacraft 0:97881c3945b1 82 setDataBas( d7 , d6 , d5 , d4 , d3 , d2 , d1 , d0 );
kohacraft 0:97881c3945b1 83 setCL( 1 );
kohacraft 0:97881c3945b1 84 setCL( 0 );
kohacraft 0:97881c3945b1 85 }
kohacraft 0:97881c3945b1 86
kohacraft 0:97881c3945b1 87 //lineEnd
kohacraft 0:97881c3945b1 88 void lineEnd()
kohacraft 0:97881c3945b1 89 {
kohacraft 0:97881c3945b1 90 setContBas( NC10 , 1 );
kohacraft 0:97881c3945b1 91 setContBas( CKV , 0 );
kohacraft 0:97881c3945b1 92
kohacraft 0:97881c3945b1 93 setCL( 1 );
kohacraft 0:97881c3945b1 94 setCL( 0 );
kohacraft 0:97881c3945b1 95 wait_us(10);
kohacraft 0:97881c3945b1 96
kohacraft 0:97881c3945b1 97 setContBas( OE , 0 );
kohacraft 0:97881c3945b1 98 setContBas( LE , 1 );
kohacraft 0:97881c3945b1 99 setContBas( CKV , 1 );
kohacraft 0:97881c3945b1 100 wait_us(1);
kohacraft 0:97881c3945b1 101 }
kohacraft 0:97881c3945b1 102
kohacraft 0:97881c3945b1 103 //pageEnd
kohacraft 0:97881c3945b1 104 void pageEnd()
kohacraft 0:97881c3945b1 105 {
kohacraft 0:97881c3945b1 106 setCL( 1 );
kohacraft 0:97881c3945b1 107 setCL( 0 );
kohacraft 0:97881c3945b1 108 setContBas( LE , 0 );
kohacraft 0:97881c3945b1 109
kohacraft 0:97881c3945b1 110 setCL( 1 );
kohacraft 0:97881c3945b1 111 setCL( 0 );
kohacraft 0:97881c3945b1 112
kohacraft 0:97881c3945b1 113 setCL( 1 );
kohacraft 0:97881c3945b1 114 setCL( 0 );
kohacraft 0:97881c3945b1 115
kohacraft 0:97881c3945b1 116 setCL( 1 );
kohacraft 0:97881c3945b1 117 setCL( 0 );
kohacraft 0:97881c3945b1 118 setContBas( OE , 1 );
kohacraft 0:97881c3945b1 119
kohacraft 0:97881c3945b1 120 setCL( 1 );
kohacraft 0:97881c3945b1 121 setCL( 0 );
kohacraft 0:97881c3945b1 122
kohacraft 0:97881c3945b1 123 for( int i=0 ; i<200 ; i++ )
kohacraft 0:97881c3945b1 124 {
kohacraft 0:97881c3945b1 125 setCL( 1 );
kohacraft 0:97881c3945b1 126 setCL( 0 );
kohacraft 0:97881c3945b1 127 }
kohacraft 0:97881c3945b1 128 setContBas( CKV , 0 );
kohacraft 0:97881c3945b1 129
kohacraft 0:97881c3945b1 130 setCL( 1 );
kohacraft 0:97881c3945b1 131 setCL( 0 );
kohacraft 0:97881c3945b1 132
kohacraft 0:97881c3945b1 133 wait_us(10);
kohacraft 0:97881c3945b1 134 setContBas( OE , 0 );
kohacraft 0:97881c3945b1 135
kohacraft 0:97881c3945b1 136 wait_us(330);
kohacraft 0:97881c3945b1 137
kohacraft 0:97881c3945b1 138 setContBas( GMODE , 0 );
kohacraft 0:97881c3945b1 139 wait_us(130);
kohacraft 0:97881c3945b1 140
kohacraft 0:97881c3945b1 141 }
kohacraft 0:97881c3945b1 142
kohacraft 0:97881c3945b1 143 //SPHを交代する
kohacraft 0:97881c3945b1 144 void changeSPH()
kohacraft 0:97881c3945b1 145 {
kohacraft 0:97881c3945b1 146 setContBas( SPH , 1 );
kohacraft 0:97881c3945b1 147 setContBas( NC10 , 0 );
kohacraft 0:97881c3945b1 148 }
kohacraft 0:97881c3945b1 149
kohacraft 0:97881c3945b1 150 //画面をクリアする 0:黒 1:白
kohacraft 0:97881c3945b1 151 void clrdisp( bool color )
kohacraft 0:97881c3945b1 152 {
kohacraft 0:97881c3945b1 153 pageStart();
kohacraft 0:97881c3945b1 154 for( int j=0 ; j<600 ; j++)
kohacraft 0:97881c3945b1 155 {
kohacraft 0:97881c3945b1 156 lineStart();
kohacraft 0:97881c3945b1 157 for( int i=0 ; i<100 ; i++ )
kohacraft 0:97881c3945b1 158 {
kohacraft 0:97881c3945b1 159 if( color == 1)
kohacraft 0:97881c3945b1 160 drowPixels( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //白でクリアする
kohacraft 0:97881c3945b1 161 else
kohacraft 0:97881c3945b1 162 drowPixels( 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ); //黒でクリアする
kohacraft 0:97881c3945b1 163 }
kohacraft 0:97881c3945b1 164 changeSPH();
kohacraft 0:97881c3945b1 165 for( int i=100 ; i<200 ; i++ )
kohacraft 0:97881c3945b1 166 {
kohacraft 0:97881c3945b1 167 if( color == 1)
kohacraft 0:97881c3945b1 168 drowPixels( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //白でクリアする
kohacraft 0:97881c3945b1 169 else
kohacraft 0:97881c3945b1 170 drowPixels( 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 ); //黒でクリアする
kohacraft 0:97881c3945b1 171 }
kohacraft 0:97881c3945b1 172 lineEnd();
kohacraft 0:97881c3945b1 173
kohacraft 0:97881c3945b1 174 }
kohacraft 0:97881c3945b1 175 pageEnd();
kohacraft 0:97881c3945b1 176 }
kohacraft 0:97881c3945b1 177
kohacraft 0:97881c3945b1 178 void dispbmp(FILE *fp , bool mode )
kohacraft 0:97881c3945b1 179 {
kohacraft 0:97881c3945b1 180 char bmpdata[12];
kohacraft 0:97881c3945b1 181 int size;
kohacraft 0:97881c3945b1 182 fseek(fp, 54 , SEEK_SET);//bitmap headder throw
kohacraft 0:97881c3945b1 183
kohacraft 0:97881c3945b1 184 pageStart();
kohacraft 0:97881c3945b1 185 for( int j=0 ; j<600 ; j++)
kohacraft 0:97881c3945b1 186 {
kohacraft 0:97881c3945b1 187 lineStart();
kohacraft 0:97881c3945b1 188
kohacraft 0:97881c3945b1 189 for( int i=0 ; i<100 ; i++ )
kohacraft 0:97881c3945b1 190 {
kohacraft 0:97881c3945b1 191 size = fread( bmpdata , sizeof(char) , 12 , fp);
kohacraft 0:97881c3945b1 192 if( size < 12 )
kohacraft 0:97881c3945b1 193 {
kohacraft 0:97881c3945b1 194 drowPixels( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //読み込めない場合は白にする
kohacraft 0:97881c3945b1 195 }
kohacraft 0:97881c3945b1 196 else
kohacraft 0:97881c3945b1 197 {
kohacraft 0:97881c3945b1 198 if( mode == 0 )
kohacraft 0:97881c3945b1 199 drowPixels( bmpdata[9]==0 , bmpdata[9]>0 , bmpdata[6]==0 , bmpdata[6]>0 , bmpdata[3]==0 , bmpdata[3]>0 , bmpdata[0]==0 , bmpdata[0]>0 );
kohacraft 0:97881c3945b1 200 else
kohacraft 0:97881c3945b1 201 drowPixels( bmpdata[9]==0 , 1 , bmpdata[6]==0 , 1 , bmpdata[3]==0 , 1 , bmpdata[0]==0 , 1 );
kohacraft 0:97881c3945b1 202 }
kohacraft 0:97881c3945b1 203 }
kohacraft 0:97881c3945b1 204 changeSPH();
kohacraft 0:97881c3945b1 205 for( int i=100 ; i<200 ; i++ )
kohacraft 0:97881c3945b1 206 {
kohacraft 0:97881c3945b1 207 size = fread( bmpdata , sizeof(char) , 12 , fp);
kohacraft 0:97881c3945b1 208 if( size < 12 )
kohacraft 0:97881c3945b1 209 {
kohacraft 0:97881c3945b1 210 drowPixels( 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ); //読み込めない場合は白にする
kohacraft 0:97881c3945b1 211 }
kohacraft 0:97881c3945b1 212 else
kohacraft 0:97881c3945b1 213 {
kohacraft 0:97881c3945b1 214 if( mode == 0 )
kohacraft 0:97881c3945b1 215 drowPixels( bmpdata[9]==0 , bmpdata[9]>0 , bmpdata[6]==0 , bmpdata[6]>0 , bmpdata[3]==0 , bmpdata[3]>0 , bmpdata[0]==0 , bmpdata[0]>0 );
kohacraft 0:97881c3945b1 216 else
kohacraft 0:97881c3945b1 217 drowPixels( bmpdata[9]==0 , 1 , bmpdata[6]==0 , 1 , bmpdata[3]==0 , 1 , bmpdata[0]==0 , 1 );
kohacraft 0:97881c3945b1 218 }
kohacraft 0:97881c3945b1 219
kohacraft 0:97881c3945b1 220 }
kohacraft 0:97881c3945b1 221
kohacraft 0:97881c3945b1 222 lineEnd();
kohacraft 0:97881c3945b1 223 }
kohacraft 0:97881c3945b1 224 pageEnd();
kohacraft 0:97881c3945b1 225 }
kohacraft 0:97881c3945b1 226
kohacraft 0:97881c3945b1 227 void dispbmp2(FILE *fp)
kohacraft 0:97881c3945b1 228 {
kohacraft 0:97881c3945b1 229 dispbmp( fp , 0 ); //黒の部分描く
kohacraft 0:97881c3945b1 230 fseek(fp, 0 , SEEK_SET);//bitmap headder throw
kohacraft 0:97881c3945b1 231 dispbmp( fp , 1 ); //白の部分を描く
kohacraft 0:97881c3945b1 232 }
kohacraft 0:97881c3945b1 233
kohacraft 0:97881c3945b1 234 void powerOff()
kohacraft 0:97881c3945b1 235 {
kohacraft 0:97881c3945b1 236 setContBas( EN , 1);
kohacraft 1:8c9178c52155 237
kohacraft 1:8c9178c52155 238 setCL( 0 );
kohacraft 1:8c9178c52155 239 setContBas( LE , 0);
kohacraft 1:8c9178c52155 240 setContBas( OE , 0);
kohacraft 1:8c9178c52155 241 setContBas( NC10 , 0);
kohacraft 1:8c9178c52155 242 setContBas( SPH , 0);
kohacraft 1:8c9178c52155 243
kohacraft 1:8c9178c52155 244 setContBas( GMODE , 0);
kohacraft 1:8c9178c52155 245 setContBas( SPV , 0);
kohacraft 1:8c9178c52155 246 setContBas( CKV , 0);
kohacraft 1:8c9178c52155 247
kohacraft 1:8c9178c52155 248 setDataBas( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
kohacraft 1:8c9178c52155 249
kohacraft 0:97881c3945b1 250 }
kohacraft 0:97881c3945b1 251
kohacraft 0:97881c3945b1 252 void powerOn()
kohacraft 0:97881c3945b1 253 {
kohacraft 0:97881c3945b1 254 setContBas( EN , 0);
kohacraft 0:97881c3945b1 255 }