A simple example for analog input and EPD usage.
Dependencies: GDEP015OC1 acn_nrf52_saadc aconno_bsp
Fork of acd52832_3_Analog_In by
Diff: main.cpp
- Revision:
- 0:dc96b5c8e3f6
- Child:
- 2:4e505e17a701
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Jun 29 09:33:50 2017 +0000
@@ -0,0 +1,48 @@
+/* Copyright (c) 2017 Aconno. All Rights Reserved.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ */
+
+#include "mbed.h"
+#include "acd52832_bsp.h"
+#include "GDEP015OC1.h"
+
+#define delay_time 1000
+#define ADC_MAX_VALUE 1023
+
+SPI spi(PIN_EPD_MOSI, NC, PIN_EPD_SCK, NC);
+GDEP015OC1 epd = GDEP015OC1(spi, PIN_EPD_CS, PIN_EPD_DC, PIN_EPD_RST, PIN_EPD_BUSY);
+
+AnalogIn battery (p28);
+AnalogIn usb1 (p29);
+AnalogIn usb2 (p30);
+
+int main(){
+ char buffer[25] = {0};
+ wait_ms(100);
+
+ while(true){
+ epd.empty();
+ epd.write();
+
+ sprintf(buffer, "Battery: %4.0f", battery.read()*ADC_MAX_VALUE); // Create a string
+ epd.writeString(buffer,25,70,0); // Write new data to the buffer
+ epd.write(); // Write string to the EPD
+
+
+ sprintf(buffer, "USB1: %4.0f", usb1.read()*ADC_MAX_VALUE); // Create a string
+ epd.writeString(buffer,25,90,0); // Write new data to the buffer
+ epd.write(); // Write string to the EPD
+
+ sprintf(buffer, "USB2: %4.0f", usb2.read()*ADC_MAX_VALUE); // Create a string
+ epd.writeString(buffer,25,110,0); // Write new data to the buffer
+ epd.write(); // Write string to the EPD
+
+ wait_ms(delay_time);
+ }
+
+
+
+}
\ No newline at end of file
