A simple example for analog input and EPD usage.

Dependencies:   GDEP015OC1 acn_nrf52_saadc aconno_bsp

Fork of acd52832_Car_battery_ch by Jurica Resetar

Committer:
jurica238814
Date:
Thu Jun 29 09:33:50 2017 +0000
Revision:
0:dc96b5c8e3f6
Child:
2:4e505e17a701
Init commit. The program works as specified.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jurica238814 0:dc96b5c8e3f6 1 /* Copyright (c) 2017 Aconno. All Rights Reserved.
jurica238814 0:dc96b5c8e3f6 2 *
jurica238814 0:dc96b5c8e3f6 3 * Licensees are granted free, non-transferable use of the information. NO
jurica238814 0:dc96b5c8e3f6 4 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
jurica238814 0:dc96b5c8e3f6 5 * the file.
jurica238814 0:dc96b5c8e3f6 6 */
jurica238814 0:dc96b5c8e3f6 7
jurica238814 0:dc96b5c8e3f6 8 #include "mbed.h"
jurica238814 0:dc96b5c8e3f6 9 #include "acd52832_bsp.h"
jurica238814 0:dc96b5c8e3f6 10 #include "GDEP015OC1.h"
jurica238814 0:dc96b5c8e3f6 11
jurica238814 0:dc96b5c8e3f6 12 #define delay_time 1000
jurica238814 0:dc96b5c8e3f6 13 #define ADC_MAX_VALUE 1023
jurica238814 0:dc96b5c8e3f6 14
jurica238814 0:dc96b5c8e3f6 15 SPI spi(PIN_EPD_MOSI, NC, PIN_EPD_SCK, NC);
jurica238814 0:dc96b5c8e3f6 16 GDEP015OC1 epd = GDEP015OC1(spi, PIN_EPD_CS, PIN_EPD_DC, PIN_EPD_RST, PIN_EPD_BUSY);
jurica238814 0:dc96b5c8e3f6 17
jurica238814 0:dc96b5c8e3f6 18 AnalogIn battery (p28);
jurica238814 0:dc96b5c8e3f6 19 AnalogIn usb1 (p29);
jurica238814 0:dc96b5c8e3f6 20 AnalogIn usb2 (p30);
jurica238814 0:dc96b5c8e3f6 21
jurica238814 0:dc96b5c8e3f6 22 int main(){
jurica238814 0:dc96b5c8e3f6 23 char buffer[25] = {0};
jurica238814 0:dc96b5c8e3f6 24 wait_ms(100);
jurica238814 0:dc96b5c8e3f6 25
jurica238814 0:dc96b5c8e3f6 26 while(true){
jurica238814 0:dc96b5c8e3f6 27 epd.empty();
jurica238814 0:dc96b5c8e3f6 28 epd.write();
jurica238814 0:dc96b5c8e3f6 29
jurica238814 0:dc96b5c8e3f6 30 sprintf(buffer, "Battery: %4.0f", battery.read()*ADC_MAX_VALUE); // Create a string
jurica238814 0:dc96b5c8e3f6 31 epd.writeString(buffer,25,70,0); // Write new data to the buffer
jurica238814 0:dc96b5c8e3f6 32 epd.write(); // Write string to the EPD
jurica238814 0:dc96b5c8e3f6 33
jurica238814 0:dc96b5c8e3f6 34
jurica238814 0:dc96b5c8e3f6 35 sprintf(buffer, "USB1: %4.0f", usb1.read()*ADC_MAX_VALUE); // Create a string
jurica238814 0:dc96b5c8e3f6 36 epd.writeString(buffer,25,90,0); // Write new data to the buffer
jurica238814 0:dc96b5c8e3f6 37 epd.write(); // Write string to the EPD
jurica238814 0:dc96b5c8e3f6 38
jurica238814 0:dc96b5c8e3f6 39 sprintf(buffer, "USB2: %4.0f", usb2.read()*ADC_MAX_VALUE); // Create a string
jurica238814 0:dc96b5c8e3f6 40 epd.writeString(buffer,25,110,0); // Write new data to the buffer
jurica238814 0:dc96b5c8e3f6 41 epd.write(); // Write string to the EPD
jurica238814 0:dc96b5c8e3f6 42
jurica238814 0:dc96b5c8e3f6 43 wait_ms(delay_time);
jurica238814 0:dc96b5c8e3f6 44 }
jurica238814 0:dc96b5c8e3f6 45
jurica238814 0:dc96b5c8e3f6 46
jurica238814 0:dc96b5c8e3f6 47
jurica238814 0:dc96b5c8e3f6 48 }