![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Sample
Dependencies: mbed Utilities SDFileSystem WConstants DS1820_Test TinyGPSPlus epd1in54
main.cpp@7:c971d55efc99, 2019-01-07 (annotated)
- Committer:
- WaleedElmughrabi
- Date:
- Mon Jan 07 19:18:43 2019 +0000
- Revision:
- 7:c971d55efc99
- Parent:
- 2:b60cb847489c
Font72
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:005629fe3609 | 1 | #include "mbed.h" |
WaleedElmughrabi | 7:c971d55efc99 | 2 | #include "epd1in54.h" |
WaleedElmughrabi | 7:c971d55efc99 | 3 | |
WaleedElmughrabi | 7:c971d55efc99 | 4 | Serial serial(USBTX, USBRX,115200); //Local terminal Baud rate |
WaleedElmughrabi | 7:c971d55efc99 | 5 | |
WaleedElmughrabi | 7:c971d55efc99 | 6 | //E-ink Display |
WaleedElmughrabi | 7:c971d55efc99 | 7 | PinName rst; PinName dc; PinName busy; PinName mosi; PinName miso; PinName sclk; PinName cs; |
WaleedElmughrabi | 7:c971d55efc99 | 8 | unsigned char frame_black[EPD_HEIGHT*EPD_WIDTH/8]; |
WaleedElmughrabi | 7:c971d55efc99 | 9 | Epd epd = Epd(PB_5, PB_4, PB_3, PA_8, PC_4, PC_7, PB_10); |
WaleedElmughrabi | 7:c971d55efc99 | 10 | |
WaleedElmughrabi | 7:c971d55efc99 | 11 | double liquidTemp = 0; |
WaleedElmughrabi | 7:c971d55efc99 | 12 | double ambientTemp = 0; |
WaleedElmughrabi | 7:c971d55efc99 | 13 | char cValt[32]; |
screamer | 0:005629fe3609 | 14 | |
WaleedElmughrabi | 7:c971d55efc99 | 15 | int Display(double t) |
WaleedElmughrabi | 7:c971d55efc99 | 16 | { |
WaleedElmughrabi | 7:c971d55efc99 | 17 | Epd epd = Epd(PB_5, PB_4, PB_3, PA_8, PC_4, PC_7, PB_10); |
WaleedElmughrabi | 7:c971d55efc99 | 18 | |
WaleedElmughrabi | 7:c971d55efc99 | 19 | sprintf(cValt,"%.2f", t); |
WaleedElmughrabi | 7:c971d55efc99 | 20 | memset(frame_black, 0xFF, sizeof(unsigned char)*EPD_HEIGHT*EPD_WIDTH/8); |
WaleedElmughrabi | 7:c971d55efc99 | 21 | if (epd.Init(lut_full_update) != 0) { |
WaleedElmughrabi | 7:c971d55efc99 | 22 | return -1; |
WaleedElmughrabi | 7:c971d55efc99 | 23 | } |
WaleedElmughrabi | 7:c971d55efc99 | 24 | //Write strings to the buffer |
WaleedElmughrabi | 7:c971d55efc99 | 25 | epd.DrawStringAt(frame_black, 0, 50, cValt, &Font72, COLORED); |
WaleedElmughrabi | 7:c971d55efc99 | 26 | |
WaleedElmughrabi | 7:c971d55efc99 | 27 | // Display the frame_buffer |
WaleedElmughrabi | 7:c971d55efc99 | 28 | epd.SetFrameMemory(frame_black, 0, 0, epd.width, epd.height); |
WaleedElmughrabi | 7:c971d55efc99 | 29 | epd.DisplayFrame(); |
WaleedElmughrabi | 7:c971d55efc99 | 30 | epd.Sleep(); |
WaleedElmughrabi | 7:c971d55efc99 | 31 | return 1; |
WaleedElmughrabi | 7:c971d55efc99 | 32 | } |
WaleedElmughrabi | 7:c971d55efc99 | 33 | |
WaleedElmughrabi | 7:c971d55efc99 | 34 | |
WaleedElmughrabi | 7:c971d55efc99 | 35 | |
WaleedElmughrabi | 7:c971d55efc99 | 36 | |
WaleedElmughrabi | 7:c971d55efc99 | 37 | |
WaleedElmughrabi | 7:c971d55efc99 | 38 | |
screamer | 0:005629fe3609 | 39 | |
screamer | 0:005629fe3609 | 40 | int main() { |
WaleedElmughrabi | 7:c971d55efc99 | 41 | |
screamer | 0:005629fe3609 | 42 | while(1) { |
WaleedElmughrabi | 7:c971d55efc99 | 43 | serial.printf("SystemCoreClock is %d Hz...........\r\n", SystemCoreClock); |
WaleedElmughrabi | 7:c971d55efc99 | 44 | wait(2); |
WaleedElmughrabi | 7:c971d55efc99 | 45 | |
WaleedElmughrabi | 7:c971d55efc99 | 46 | ambientTemp = 20.0; |
WaleedElmughrabi | 7:c971d55efc99 | 47 | printf("Ambient Temperature %3.1foC\r\n", ambientTemp); |
WaleedElmughrabi | 7:c971d55efc99 | 48 | liquidTemp = 20.5; |
WaleedElmughrabi | 7:c971d55efc99 | 49 | printf("liquid Temperature %3.1foC\r\n", liquidTemp); |
WaleedElmughrabi | 7:c971d55efc99 | 50 | Display(ambientTemp); |
WaleedElmughrabi | 7:c971d55efc99 | 51 | wait(2); //little delay to prevent double writing |
screamer | 0:005629fe3609 | 52 | } |
screamer | 0:005629fe3609 | 53 | } |