A simple example for analog input and EPD usage.
Dependencies: GDEP015OC1 acn_nrf52_saadc aconno_bsp
Fork of acd52832_3_Analog_In by
main.cpp
- Committer:
- jurica238814
- Date:
- 2017-06-29
- Revision:
- 2:4e505e17a701
- Parent:
- 0:dc96b5c8e3f6
- Child:
- 3:4fb622e929d0
File content as of revision 2:4e505e17a701:
/* 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);
}
}
