ban4jp -
/
AkiSpiLcd_demo
Simple animation demo.
Fork of AkiSpiLcd_example by
main.cpp@0:3569e2cfb60b, 2014-05-01 (annotated)
- Committer:
- k4zuki
- Date:
- Thu May 01 00:01:02 2014 +0000
- Revision:
- 0:3569e2cfb60b
- Child:
- 1:be675380f70b
first version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
k4zuki | 0:3569e2cfb60b | 1 | #define MBEDSHIELD_050 |
k4zuki | 0:3569e2cfb60b | 2 | |
k4zuki | 0:3569e2cfb60b | 3 | #include "mbed.h" |
k4zuki | 0:3569e2cfb60b | 4 | #include "hogepic.h" |
k4zuki | 0:3569e2cfb60b | 5 | #include "AkiSpiLcd.h" |
k4zuki | 0:3569e2cfb60b | 6 | /* |
k4zuki | 0:3569e2cfb60b | 7 | 1 SCLK d3=p13 |
k4zuki | 0:3569e2cfb60b | 8 | 2 MOSI d5=p11 |
k4zuki | 0:3569e2cfb60b | 9 | 3 CS d2=p14 |
k4zuki | 0:3569e2cfb60b | 10 | 4 DISP enable d7=p24 |
k4zuki | 0:3569e2cfb60b | 11 | */ |
k4zuki | 0:3569e2cfb60b | 12 | /* |
k4zuki | 0:3569e2cfb60b | 13 | SPI LCD(MOSI_,NC,SCK_); |
k4zuki | 0:3569e2cfb60b | 14 | DigitalOut CS(D2); |
k4zuki | 0:3569e2cfb60b | 15 | DigitalOut DISP(D5); |
k4zuki | 0:3569e2cfb60b | 16 | DigitalOut COMCLK(D4); |
k4zuki | 0:3569e2cfb60b | 17 | */ |
k4zuki | 0:3569e2cfb60b | 18 | AkiSpiLcd LCD(MOSI_, SCK_, D2, D5); |
k4zuki | 0:3569e2cfb60b | 19 | DigitalOut myled(LED1); |
k4zuki | 0:3569e2cfb60b | 20 | //Ticker disp; |
k4zuki | 0:3569e2cfb60b | 21 | extern volatile const uint8_t hogepic[]; |
k4zuki | 0:3569e2cfb60b | 22 | /* |
k4zuki | 0:3569e2cfb60b | 23 | void dispinvert(void) |
k4zuki | 0:3569e2cfb60b | 24 | { |
k4zuki | 0:3569e2cfb60b | 25 | } |
k4zuki | 0:3569e2cfb60b | 26 | */ |
k4zuki | 0:3569e2cfb60b | 27 | int main() |
k4zuki | 0:3569e2cfb60b | 28 | { |
k4zuki | 0:3569e2cfb60b | 29 | |
k4zuki | 0:3569e2cfb60b | 30 | wait_ms(1); |
k4zuki | 0:3569e2cfb60b | 31 | LCD.cls(); |
k4zuki | 0:3569e2cfb60b | 32 | LCD.updateSingle(10,(uint8_t*)(hogepic+2000)); |
k4zuki | 0:3569e2cfb60b | 33 | LCD.updateMulti(100,(240-100),(uint8_t*)(hogepic)); |
k4zuki | 0:3569e2cfb60b | 34 | /* |
k4zuki | 0:3569e2cfb60b | 35 | // disp.attach(&dispinvert,0.1); |
k4zuki | 0:3569e2cfb60b | 36 | CS=0; |
k4zuki | 0:3569e2cfb60b | 37 | |
k4zuki | 0:3569e2cfb60b | 38 | LCD.format(8,0); |
k4zuki | 0:3569e2cfb60b | 39 | LCD.frequency(1000000); |
k4zuki | 0:3569e2cfb60b | 40 | |
k4zuki | 0:3569e2cfb60b | 41 | CS=1; |
k4zuki | 0:3569e2cfb60b | 42 | LCD.write(0x20); |
k4zuki | 0:3569e2cfb60b | 43 | LCD.write(0x00); |
k4zuki | 0:3569e2cfb60b | 44 | wait_us(5); |
k4zuki | 0:3569e2cfb60b | 45 | CS=0; |
k4zuki | 0:3569e2cfb60b | 46 | |
k4zuki | 0:3569e2cfb60b | 47 | DISP=1; |
k4zuki | 0:3569e2cfb60b | 48 | |
k4zuki | 0:3569e2cfb60b | 49 | CS=1; |
k4zuki | 0:3569e2cfb60b | 50 | LCD.write(0x80); |
k4zuki | 0:3569e2cfb60b | 51 | for(int j=0; j<240; j++) { |
k4zuki | 0:3569e2cfb60b | 52 | LCD.write( |
k4zuki | 0:3569e2cfb60b | 53 | ( ( (j+1) & 0x01 ) << 7 )| |
k4zuki | 0:3569e2cfb60b | 54 | ( ( (j+1) & 0x02 ) << 5 )| |
k4zuki | 0:3569e2cfb60b | 55 | ( ( (j+1) & 0x04 ) << 3 )| |
k4zuki | 0:3569e2cfb60b | 56 | ( ( (j+1) & 0x08 ) << 1 )| |
k4zuki | 0:3569e2cfb60b | 57 | ( ( (j+1) & 0x10 ) >> 1 )| |
k4zuki | 0:3569e2cfb60b | 58 | ( ( (j+1) & 0x20 ) >> 3 )| |
k4zuki | 0:3569e2cfb60b | 59 | ( ( (j+1) & 0x40 ) >> 5 )| |
k4zuki | 0:3569e2cfb60b | 60 | ( ( (j+1) & 0x80 ) >> 7 ) |
k4zuki | 0:3569e2cfb60b | 61 | ); |
k4zuki | 0:3569e2cfb60b | 62 | |
k4zuki | 0:3569e2cfb60b | 63 | for(int i=0; i<50; i++) { |
k4zuki | 0:3569e2cfb60b | 64 | // LCD.write(0xf0); |
k4zuki | 0:3569e2cfb60b | 65 | LCD.write(hogepic[50*j+i]); |
k4zuki | 0:3569e2cfb60b | 66 | } |
k4zuki | 0:3569e2cfb60b | 67 | LCD.write(0x00); |
k4zuki | 0:3569e2cfb60b | 68 | LCD.write(0x00); |
k4zuki | 0:3569e2cfb60b | 69 | } |
k4zuki | 0:3569e2cfb60b | 70 | wait_us(2); |
k4zuki | 0:3569e2cfb60b | 71 | CS=0; |
k4zuki | 0:3569e2cfb60b | 72 | */ |
k4zuki | 0:3569e2cfb60b | 73 | while(1) { |
k4zuki | 0:3569e2cfb60b | 74 | myled = 1; |
k4zuki | 0:3569e2cfb60b | 75 | wait(0.2); |
k4zuki | 0:3569e2cfb60b | 76 | myled = 0; |
k4zuki | 0:3569e2cfb60b | 77 | wait(0.2); |
k4zuki | 0:3569e2cfb60b | 78 | } |
k4zuki | 0:3569e2cfb60b | 79 | } |
k4zuki | 0:3569e2cfb60b | 80 |