Added Dallas + moved reciver
This commit is contained in:
parent
7cd53b63f8
commit
bab9d3e5d2
|
|
@ -0,0 +1,5 @@
|
||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 717 B |
|
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>ESP WEB SERVER</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
<link rel="icon" type="image/png" href="favicon.png">
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="topnav">
|
||||||
|
<h1>ESP WEB SERVER</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="card-grid">
|
||||||
|
<div class="card">
|
||||||
|
<p class="card-title"><i class="fas fa-lightbulb"></i> GPIO 2</p>
|
||||||
|
<p>
|
||||||
|
<a href="on"><button class="button-on">ON</button></a>
|
||||||
|
<a href="off"><button class="button-off">OFF</button></a>
|
||||||
|
</p>
|
||||||
|
<p class="state">State: %STATE%</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
html {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topnav {
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #0A1128;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-grid {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
grid-gap: 2rem;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-title {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #034078
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=submit] {
|
||||||
|
border: none;
|
||||||
|
color: #FEFCFB;
|
||||||
|
background-color: #034078;
|
||||||
|
padding: 15px 15px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
width: 100px;
|
||||||
|
margin-right: 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=submit]:hover {
|
||||||
|
background-color: #1282A2;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text], input[type=number], select {
|
||||||
|
width: 50%;
|
||||||
|
padding: 12px 20px;
|
||||||
|
margin: 18px;
|
||||||
|
display: inline-block;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
.value{
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #1282A2;
|
||||||
|
}
|
||||||
|
.state {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: #1282A2;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
border: none;
|
||||||
|
color: #FEFCFB;
|
||||||
|
padding: 15px 32px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
width: 100px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
}
|
||||||
|
.button-on {
|
||||||
|
background-color: #034078;
|
||||||
|
}
|
||||||
|
.button-on:hover {
|
||||||
|
background-color: #1282A2;
|
||||||
|
}
|
||||||
|
.button-off {
|
||||||
|
background-color: #858585;
|
||||||
|
}
|
||||||
|
.button-off:hover {
|
||||||
|
background-color: #252524;
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 56 KiB |
|
|
@ -21,3 +21,4 @@ lib_deps =
|
||||||
peterus/esp-logger@^1.0.0
|
peterus/esp-logger@^1.0.0
|
||||||
sandeepmistry/LoRa@^0.8.0
|
sandeepmistry/LoRa@^0.8.0
|
||||||
olikraus/U8g2_for_Adafruit_GFX@^1.8.0
|
olikraus/U8g2_for_Adafruit_GFX@^1.8.0
|
||||||
|
milesburton/DallasTemperature@^3.11.0
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ Eink::Eink(int csPin, int dcPin, int rstPin, int busyPin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eink::setup_eink() {
|
void Eink::setup_eink()
|
||||||
|
{
|
||||||
|
|
||||||
SPI.begin(EPD_SCLK, EPD_MISO, EPD_MOSI);
|
SPI.begin(EPD_SCLK, EPD_MISO, EPD_MOSI);
|
||||||
eink.init(115200, true, 2, false);
|
eink.init(115200, true, 2, false);
|
||||||
|
|
@ -23,14 +24,14 @@ void Eink::setup_eink() {
|
||||||
u8g2Fonts.setForegroundColor(GxEPD_BLACK); // apply Adafruit GFX color
|
u8g2Fonts.setForegroundColor(GxEPD_BLACK); // apply Adafruit GFX color
|
||||||
u8g2Fonts.setBackgroundColor(GxEPD_WHITE);
|
u8g2Fonts.setBackgroundColor(GxEPD_WHITE);
|
||||||
|
|
||||||
|
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "Display init done!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "Display init done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eink::show_display(String header, int wait){
|
void Eink::show_display(String header, int wait)
|
||||||
|
{
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "One line: %s", header.c_str());
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "One line: %s", header.c_str());
|
||||||
eink.setFont(&FreeMonoBold9pt7b);
|
eink.setFont(&FreeMonoBold9pt7b);
|
||||||
eink.setCursor(0,10);
|
eink.setCursor(0, 10);
|
||||||
eink.println(header);
|
eink.println(header);
|
||||||
eink.println("Line 2");
|
eink.println("Line 2");
|
||||||
eink.println("Line 3");
|
eink.println("Line 3");
|
||||||
|
|
@ -43,17 +44,19 @@ void Eink::show_display(String header, int wait){
|
||||||
eink.getTextBounds(header, 0, 0, &x1, &y1, &w, &h);
|
eink.getTextBounds(header, 0, 0, &x1, &y1, &w, &h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Eink::show_temp(float temperature)
|
||||||
void Eink::show_temp(float temperature){
|
{
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "Show temp: %f", temperature);
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "Show temp: %f", temperature);
|
||||||
|
|
||||||
int textX = 40;
|
int textX = 40;
|
||||||
u8g2Fonts.setFont(u8g2_font_fur42_tf );
|
//u8g2Fonts.setFont(u8g2_font_fur42_tf);
|
||||||
|
u8g2Fonts.setFont(u8g2_font_inr46_mf);
|
||||||
|
|
||||||
drawString(textX, 70, String(temperature, 1) + "°", LEFT);
|
drawString(textX, 70, String(temperature, 1) + "°", LEFT);
|
||||||
drawMercury(temperature);
|
drawMercury(temperature);
|
||||||
}
|
}
|
||||||
void Eink::drawSignalBars(int x, int y, int percentage) {
|
void Eink::drawSignalBars(int x, int y, int percentage)
|
||||||
|
{
|
||||||
// Define stapler properties
|
// Define stapler properties
|
||||||
const int staplerWidth = 4;
|
const int staplerWidth = 4;
|
||||||
const int staplerHeight = 14;
|
const int staplerHeight = 14;
|
||||||
|
|
@ -66,7 +69,8 @@ void Eink::drawSignalBars(int x, int y, int percentage) {
|
||||||
int currentHeight;
|
int currentHeight;
|
||||||
int staplerY;
|
int staplerY;
|
||||||
// Loop to draw staplers with variable heights and bottom alignment
|
// Loop to draw staplers with variable heights and bottom alignment
|
||||||
for (int i = 0; i < numBars; i++) {
|
for (int i = 0; i < numBars; i++)
|
||||||
|
{
|
||||||
// Calculate x-position for each stapler
|
// Calculate x-position for each stapler
|
||||||
staplerX = x + i * (staplerWidth + staplerSpacing);
|
staplerX = x + i * (staplerWidth + staplerSpacing);
|
||||||
|
|
||||||
|
|
@ -79,7 +83,7 @@ void Eink::drawSignalBars(int x, int y, int percentage) {
|
||||||
eink.fillRect(staplerX, staplerY, staplerWidth, currentHeight, GxEPD_BLACK);
|
eink.fillRect(staplerX, staplerY, staplerWidth, currentHeight, GxEPD_BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString(staplerX +staplerWidth +2, staplerY , String(percentage) + "%", LEFT);
|
drawString(staplerX + staplerWidth + 2, staplerY, String(percentage) + "%", LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eink::display(bool partialupgrade)
|
void Eink::display(bool partialupgrade)
|
||||||
|
|
@ -89,56 +93,49 @@ void Eink::display(bool partialupgrade)
|
||||||
eink.display(partialupgrade);
|
eink.display(partialupgrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eink::drawMercury(float temperature){
|
void Eink::drawMercury(float temperature)
|
||||||
|
{
|
||||||
int x = 20;
|
int x = 20;
|
||||||
int y = 30;
|
int y = 30;
|
||||||
int height = 60;
|
int height = 60;
|
||||||
int width = 10;
|
int width = 10;
|
||||||
int mercuryLevel = map(temperature, 0.0, 100.0, 20, height);
|
int mercuryLevel = map(temperature, 0.0, 100.0, 20, height);
|
||||||
int radius = 14;
|
int radius = 14;
|
||||||
eink.drawRect(x, y - radius + 2, width, height,GxEPD_BLACK );
|
eink.drawRect(x, y - radius + 2, width, height, GxEPD_BLACK);
|
||||||
|
|
||||||
eink.drawCircle(x + (width/2) , y + height, radius, GxEPD_BLACK);
|
eink.drawCircle(x + (width / 2), y + height, radius, GxEPD_BLACK);
|
||||||
eink.fillCircle(x + (width/2), y + height, radius - 2, GxEPD_BLACK);
|
eink.fillCircle(x + (width / 2), y + height, radius - 2, GxEPD_BLACK);
|
||||||
|
|
||||||
eink.fillRect(
|
eink.fillRect(
|
||||||
x + 2,
|
x + 2,
|
||||||
y + height - mercuryLevel - radius + 2,
|
y + height - mercuryLevel - radius + 2,
|
||||||
width - 4,
|
width - 4,
|
||||||
mercuryLevel,
|
mercuryLevel,
|
||||||
GxEPD_BLACK
|
GxEPD_BLACK);
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eink::drawBattery(int x, int y) {
|
void Eink::drawBattery(int x, int y, int percentage)
|
||||||
|
{
|
||||||
uint8_t percentage = 100;
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "drawBattery: %d %", percentage);
|
||||||
float voltage = analogRead(35) / 4096.0 * 7.46;
|
|
||||||
if (voltage > 1 ) { // Only display if there is a valid reading
|
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK", "Voltage: %d", voltage);
|
|
||||||
percentage = 2836.9625 * pow(voltage, 4) - 43987.4889 * pow(voltage, 3) + 255233.8134 * pow(voltage, 2) - 656689.7123 * voltage + 632041.7303;
|
|
||||||
if (voltage >= 4.20) percentage = 100;
|
|
||||||
if (voltage <= 3.50) percentage = 0;
|
|
||||||
eink.drawRect(x + 15, y - 12, 19, 10, GxEPD_BLACK);
|
eink.drawRect(x + 15, y - 12, 19, 10, GxEPD_BLACK);
|
||||||
eink.fillRect(x + 34, y - 10, 2, 5, GxEPD_BLACK);
|
eink.fillRect(x + 34, y - 10, 2, 5, GxEPD_BLACK);
|
||||||
eink.fillRect(x + 17, y - 10, 15 * percentage / 100.0, 6, GxEPD_BLACK);
|
eink.fillRect(x + 17, y - 10, 15 * percentage / 100.0, 6, GxEPD_BLACK);
|
||||||
drawString(x + 60, y - 11, String(percentage) + "%", RIGHT);
|
drawString(x + 60, y - 11, String(percentage) + "%", RIGHT);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eink::drawString(int x, int y, String text, alignmentType alignment) {
|
void Eink::drawString(int x, int y, String text, alignmentType alignment)
|
||||||
|
{
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK drawstring", "x: %d", y);
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK drawstring", "x: %d", y);
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK drawstring", "y: %d", x);
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "EINK drawstring", "y: %d", x);
|
||||||
|
|
||||||
|
int16_t x1, y1; // the bounds of x,y and w and h of the variable 'text' in pixels.
|
||||||
int16_t x1, y1; //the bounds of x,y and w and h of the variable 'text' in pixels.
|
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
eink.setTextWrap(false);
|
eink.setTextWrap(false);
|
||||||
eink.getTextBounds(text, x, y, &x1, &y1, &w, &h);
|
eink.getTextBounds(text, x, y, &x1, &y1, &w, &h);
|
||||||
if (alignment == RIGHT) x = x - w;
|
if (alignment == RIGHT)
|
||||||
if (alignment == CENTER) x = x - w / 2;
|
x = x - w;
|
||||||
u8g2Fonts.setCursor(x+2, y + h);
|
if (alignment == CENTER)
|
||||||
|
x = x - w / 2;
|
||||||
|
u8g2Fonts.setCursor(x + 2, y + h);
|
||||||
u8g2Fonts.print(text);
|
u8g2Fonts.print(text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,18 +4,7 @@
|
||||||
#include <GxEPD2_BW.h>
|
#include <GxEPD2_BW.h>
|
||||||
#include "epd/GxEPD2_213.h"
|
#include "epd/GxEPD2_213.h"
|
||||||
#include <U8g2_for_Adafruit_GFX.h>
|
#include <U8g2_for_Adafruit_GFX.h>
|
||||||
|
#include "pins.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define EPD_MOSI (23)
|
|
||||||
#define EPD_MISO (-1) //elink no use
|
|
||||||
#define EPD_SCLK (18)
|
|
||||||
|
|
||||||
#define EPD_BUSY (4)
|
|
||||||
#define EPD_RSET (16)
|
|
||||||
#define EPD_DC (17)
|
|
||||||
#define EPD_CS (5)
|
|
||||||
|
|
||||||
class Eink {
|
class Eink {
|
||||||
public:
|
public:
|
||||||
|
|
@ -24,7 +13,7 @@ public:
|
||||||
void setup_eink();
|
void setup_eink();
|
||||||
void show_temp(float temperature);
|
void show_temp(float temperature);
|
||||||
void show_display(String header, int wait=100);
|
void show_display(String header, int wait=100);
|
||||||
void drawBattery(int x, int y);
|
void drawBattery(int x, int y, int percentage=100);
|
||||||
void drawSignalBars(int x, int y, int numBars);
|
void drawSignalBars(int x, int y, int numBars);
|
||||||
void display(bool partialupgrade = false);
|
void display(bool partialupgrade = false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
#include "io.hpp"
|
||||||
|
#include "logger.h"
|
||||||
|
#include "pins.hpp"
|
||||||
|
#include "WiFi.h"
|
||||||
|
#include "driver/adc.h"
|
||||||
|
#include <esp_wifi.h>
|
||||||
|
#include <esp_bt.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern logging::Logger logger;
|
||||||
|
|
||||||
|
IO::IO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void IO::setup_io() {
|
||||||
|
oneWire.begin(DI_DALLAS);
|
||||||
|
sensors.begin();
|
||||||
|
sensors.setResolution(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IO::set_low_power() {
|
||||||
|
digitalWrite ( DI_LED, LOW );
|
||||||
|
setCpuFrequencyMhz(80);
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
btStop();
|
||||||
|
|
||||||
|
esp_wifi_stop();
|
||||||
|
esp_bt_controller_disable();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t IO::read_battery() {
|
||||||
|
uint8_t percentage = 100;
|
||||||
|
|
||||||
|
float voltage = analogRead(ADC_BATTERY) / 4096.0 * 7.46;
|
||||||
|
//float voltage = analogRead(35) / 4096.0 * 7.46;
|
||||||
|
if (voltage > 1 ) { // Only display if there is a valid reading
|
||||||
|
percentage = 2836.9625 * pow(voltage, 4) - 43987.4889 * pow(voltage, 3) + 255233.8134 * pow(voltage, 2) - 656689.7123 * voltage + 632041.7303;
|
||||||
|
if (voltage >= 4.20) percentage = 100;
|
||||||
|
if (voltage <= 3.50) percentage = 0;
|
||||||
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "io", "Voltage: %f", voltage);
|
||||||
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "io", "Percentage: %d", percentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return percentage;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float IO::read_temp() {
|
||||||
|
|
||||||
|
sensors.requestTemperatures(); // Request temperature readings
|
||||||
|
float tempC = sensors.getTempCByIndex(0);
|
||||||
|
if (tempC != DEVICE_DISCONNECTED_C)
|
||||||
|
{
|
||||||
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "io", "Temp: %f", tempC);
|
||||||
|
}else{
|
||||||
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "io", "Couldn't read temp");
|
||||||
|
}
|
||||||
|
float chipTemp = temperatureRead();
|
||||||
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "io", "chipTemp: %f", chipTemp);
|
||||||
|
return tempC;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef IO_H
|
||||||
|
#define IO_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <OneWire.h>
|
||||||
|
#include <DallasTemperature.h>
|
||||||
|
|
||||||
|
|
||||||
|
class IO {
|
||||||
|
public:
|
||||||
|
IO();
|
||||||
|
void setup_io();
|
||||||
|
void set_low_power();
|
||||||
|
float read_temp();
|
||||||
|
uint8_t read_battery();
|
||||||
|
private:
|
||||||
|
OneWire oneWire;
|
||||||
|
DallasTemperature sensors;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* IO_H */
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "lorahandler.hpp"
|
#include "lorahandler.hpp"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "pins.hpp"
|
||||||
|
|
||||||
extern logging::Logger logger;
|
extern logging::Logger logger;
|
||||||
extern Config config;
|
extern Config config;
|
||||||
|
|
@ -9,8 +10,8 @@ void LoraHandler::setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
||||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
SPI.begin(RADIO_SCK, RADIO_MISO, RADIO_MOSI, RADIO_CS);
|
||||||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
|
LoRa.setPins(RADIO_CS, RADIO_RST, RADIO_IRQ);
|
||||||
|
|
||||||
long freq = config.loraConfig.frequency;
|
long freq = config.loraConfig.frequency;
|
||||||
if (!LoRa.begin(freq))
|
if (!LoRa.begin(freq))
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,6 @@
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <LoRa.h>
|
#include <LoRa.h>
|
||||||
|
|
||||||
#define LORA_SCK 5
|
|
||||||
#define LORA_MISO 19
|
|
||||||
#define LORA_MOSI 27
|
|
||||||
#define LORA_CS 18 // CS --> NSS
|
|
||||||
#define LORA_RST 14
|
|
||||||
#define LORA_IRQ 26 // IRQ --> DIO0
|
|
||||||
|
|
||||||
struct ReceivedLoRaPacket {
|
struct ReceivedLoRaPacket {
|
||||||
String text;
|
String text;
|
||||||
int rssi;
|
int rssi;
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,41 @@
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "eink.hpp"
|
#include "eink.hpp"
|
||||||
|
#include "io.hpp"
|
||||||
|
|
||||||
logging::Logger logger;
|
logging::Logger logger;
|
||||||
Eink eink;
|
Eink eink;
|
||||||
|
IO io;
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
// TODO check if pin 22(ledbuiltin 2) is a led
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
logger.setDebugLevel(logging::LoggerLevel::LOGGER_LEVEL_INFO);
|
logger.setDebugLevel(logging::LoggerLevel::LOGGER_LEVEL_INFO);
|
||||||
#endif
|
#endif
|
||||||
delay(100);
|
//delay(100);
|
||||||
|
io.set_low_power();
|
||||||
|
io.setup_io();
|
||||||
|
uint8_t battery = io.read_battery();
|
||||||
|
float temp = io.read_temp();
|
||||||
eink.setup_eink();
|
eink.setup_eink();
|
||||||
delay(100);
|
// delay(100);
|
||||||
|
|
||||||
eink.drawBattery(186, 14); // eink width 250 - drawbattery width
|
eink.drawBattery(186, 14, battery); // eink width 250 - drawbattery width
|
||||||
eink.drawSignalBars(180 - 24 - 4, 12, 84); // drawbattery width - drawsignal
|
eink.drawSignalBars(180 - 24 - 4, 12, 84); // drawbattery width - drawsignal
|
||||||
eink.show_temp(30.0);
|
eink.show_temp(30.0);
|
||||||
eink.display();
|
eink.display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
eink.show_temp(30.0);
|
||||||
|
eink.display(true);
|
||||||
|
sleep(10);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef PINS_H
|
||||||
|
#define PINS_H
|
||||||
|
|
||||||
|
// Pin assignments for EPD display
|
||||||
|
const int EPD_MOSI = 23;
|
||||||
|
const int EPD_MISO = -1; // elink no use
|
||||||
|
const int EPD_SCLK = 18;
|
||||||
|
|
||||||
|
const int EPD_BUSY = 4;
|
||||||
|
const int EPD_RSET = 16;
|
||||||
|
const int EPD_DC = 17;
|
||||||
|
const int EPD_CS = 5;
|
||||||
|
|
||||||
|
// Pin assignments for LORA module
|
||||||
|
const int RADIO_SCK = 5;
|
||||||
|
const int RADIO_MISO = 19;
|
||||||
|
const int RADIO_MOSI = 27;
|
||||||
|
const int RADIO_CS = 18; // CS --> NSS
|
||||||
|
const int RADIO_RST = 14;
|
||||||
|
const int RADIO_IRQ = 26; // IRQ --> DIO0
|
||||||
|
|
||||||
|
// Battery pin
|
||||||
|
const int ADC_BATTERY = 12; //builtin = 35
|
||||||
|
|
||||||
|
const int DI_DALLAS = 32;
|
||||||
|
// Builtin LED
|
||||||
|
const int DI_LED = 22;
|
||||||
|
#endif /* PINS_H */
|
||||||
Loading…
Reference in New Issue