epaper
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "epd1in54b.h" 00003 // Control 00004 PinName rst; 00005 PinName dc; 00006 PinName busy; 00007 // SPI communication 00008 PinName mosi; 00009 PinName miso; 00010 PinName sclk; 00011 PinName cs; 00012 00013 DigitalOut myled(LED1); 00014 00015 unsigned char frame_black[EPD_HEIGHT*EPD_WIDTH/8]; 00016 unsigned char frame_red[EPD_HEIGHT*EPD_WIDTH/8]; 00017 00018 00019 int main() { 00020 mosi = p5; 00021 miso = p6; 00022 sclk = p7; 00023 cs = p8; 00024 rst = p9; 00025 dc = p10; 00026 busy = p11; 00027 00028 memset(frame_black, 0xFF, sizeof(unsigned char)*EPD_HEIGHT*EPD_WIDTH/8); 00029 memset(frame_red, 0xFF, sizeof(unsigned char)*EPD_HEIGHT*EPD_WIDTH/8); 00030 00031 Epd epd = Epd(mosi, miso, sclk, cs, dc, rst, busy); 00032 if (epd.Init() != 0){ 00033 return -1; 00034 } 00035 00036 /* Draw something to the frame buffer */ 00037 // For simplicity, the arguments are explicit numerical coordinates 00038 epd.DrawRectangle(frame_black, 10, 60, 50, 110, COLORED); 00039 epd.DrawLine(frame_black, 10, 60, 50, 110, COLORED); 00040 epd.DrawLine(frame_black, 50, 60, 10, 110, COLORED); 00041 epd.DrawCircle(frame_black, 120, 80, 30, COLORED); 00042 epd.DrawFilledRectangle(frame_red, 10, 130, 50, 180, COLORED); 00043 epd.DrawFilledRectangle(frame_red, 0, 6, 200, 26, COLORED); 00044 epd.DrawFilledCircle(frame_red, 120, 150, 30, COLORED); 00045 00046 /*Write strings to the buffer */ 00047 epd.DrawStringAt(frame_black, 30, 30, "e-Paper Demo", &Font16, COLORED); 00048 epd.DrawStringAt(frame_red, 28, 10, "Hello world!", &Font16, UNCOLORED); 00049 00050 // display images 00051 epd.DisplayFrame(frame_black, frame_red); 00052 //epd.DisplayFrame(IMAGE_BLACK, IMAGE_RED); 00053 epd.Sleep(); 00054 00055 00056 while(1) { 00057 myled = 1; 00058 wait(0.5); 00059 myled = 0; 00060 wait(0.5); 00061 } 00062 }
Generated on Tue Aug 16 2022 09:27:57 by
1.7.2