Change folder structure
This commit is contained in:
parent
7db1eb46e2
commit
3dcd0560c2
@ -21,3 +21,4 @@ lib_deps =
|
||||
khoih-prog/ESP_WifiManager@^1.12.1
|
||||
adafruit/Adafruit GFX Library@^1.11.7
|
||||
knolleary/PubSubClient@^2.8
|
||||
lennarthennigs/Button2@^2.3.2
|
||||
|
@ -1,34 +1,4 @@
|
||||
#include <Arduino.h>
|
||||
#include <GxEPD2_BW.h>
|
||||
|
||||
#include <Adafruit_GFX.h>
|
||||
#include "../include/fonts/Pixeltype8pt7b.h"
|
||||
#include "../include/fonts/Pixeltype16pt7b.h"
|
||||
#include "../include/fonts/Fipps_Regular8pt7b.h"
|
||||
#include "../include/fonts/SilomBol7pt7b.h"
|
||||
|
||||
const unsigned char gfx_wireless[] PROGMEM = {
|
||||
0x00, 0xe0, 0x10, 0xc8, 0x28, 0xa8, 0x00};
|
||||
|
||||
const unsigned char gfx_build[] PROGMEM = {
|
||||
0x00, 0x50, 0xf8, 0x88, 0x88, 0xf8, 0x00};
|
||||
|
||||
class EinkAnalogDisplay
|
||||
{
|
||||
private:
|
||||
int16_t min;
|
||||
int16_t max;
|
||||
uint8_t dac;
|
||||
GxEPD2_BW<GxEPD2_213_B72, (uint16_t)250U> *display;
|
||||
void centerText(const char *text, int16_t x, int16_t y);
|
||||
|
||||
public:
|
||||
EinkAnalogDisplay(GxEPD2_BW<GxEPD2_213_B72, (uint16_t)250U> *display, uint8_t dacPin);
|
||||
~EinkAnalogDisplay();
|
||||
void drawFace(int16_t min, int16_t max, char *name, char* unit, uint8_t lines = 5);
|
||||
int setArm(float value);
|
||||
void drawMeta(const char *wireless_str);
|
||||
};
|
||||
#include "./einkanalog.h"
|
||||
|
||||
EinkAnalogDisplay::EinkAnalogDisplay(GxEPD2_BW<GxEPD2_213_B72, (uint16_t)250U> *display, uint8_t dacPin)
|
||||
{
|
28
src/einkanalog/einkanalog.h
Normal file
28
src/einkanalog/einkanalog.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef EIAD_H
|
||||
#define EIAD_H
|
||||
#include <global.h>
|
||||
|
||||
const unsigned char gfx_wireless[] PROGMEM = {
|
||||
0x00, 0xe0, 0x10, 0xc8, 0x28, 0xa8, 0x00};
|
||||
|
||||
const unsigned char gfx_build[] PROGMEM = {
|
||||
0x00, 0x50, 0xf8, 0x88, 0x88, 0xf8, 0x00};
|
||||
|
||||
class EinkAnalogDisplay
|
||||
{
|
||||
private:
|
||||
int16_t min;
|
||||
int16_t max;
|
||||
uint8_t dac;
|
||||
GxEPD2_BW<GxEPD2_213_B72, (uint16_t)250U> *display;
|
||||
void centerText(const char *text, int16_t x, int16_t y);
|
||||
|
||||
public:
|
||||
EinkAnalogDisplay(GxEPD2_BW<GxEPD2_213_B72, (uint16_t)250U> *display, uint8_t dacPin);
|
||||
~EinkAnalogDisplay();
|
||||
void drawFace(int16_t min, int16_t max, char *name, char* unit, uint8_t lines = 5);
|
||||
int setArm(float value);
|
||||
void drawMeta(const char *wireless_str);
|
||||
};
|
||||
|
||||
#endif
|
35
src/global.h
Normal file
35
src/global.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// Wifi
|
||||
#include <WiFi.h>
|
||||
#include <WiFiMulti.h>
|
||||
|
||||
// MQTT
|
||||
#include <PubSubClient.h>
|
||||
|
||||
// DAC
|
||||
#define DAC1 25
|
||||
|
||||
// Buttons
|
||||
#include "Button2.h"
|
||||
#define BTN_L 22
|
||||
#define BTN_R 21
|
||||
|
||||
// Display
|
||||
#include <GxEPD2_BW.h>
|
||||
|
||||
// Fonts
|
||||
#include <Adafruit_GFX.h>
|
||||
#include "../include/fonts/Pixeltype8pt7b.h"
|
||||
#include "../include/fonts/Pixeltype16pt7b.h"
|
||||
#include "../include/fonts/Fipps_Regular8pt7b.h"
|
||||
#include "../include/fonts/SilomBol7pt7b.h"
|
||||
|
||||
// Local helper files
|
||||
#include "./einkanalog/einkanalog.h"
|
||||
#include "./helpers/mqtt.h"
|
||||
|
||||
#endif
|
14
src/helpers/mqtt.cpp
Normal file
14
src/helpers/mqtt.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "mqtt.h"
|
||||
|
||||
void callback(char *topic, byte *payload, unsigned int length)
|
||||
{
|
||||
Serial.print("Message arrived [");
|
||||
Serial.print(topic);
|
||||
Serial.println("] ");
|
||||
|
||||
// char array[length + 1] = {};
|
||||
// memcpy(array, payload, length);
|
||||
// array[length] = '\0';
|
||||
// Serial.println(String(array).toFloat() / 1000.0);
|
||||
// ead.setArm(String(array).toFloat() / 1000.0);
|
||||
}
|
7
src/helpers/mqtt.h
Normal file
7
src/helpers/mqtt.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef MQTT_H
|
||||
#define MQTT_H
|
||||
#include <global.h>
|
||||
|
||||
void callback(char *topic, byte *payload, unsigned int length);
|
||||
|
||||
#endif
|
56
src/main.cpp
56
src/main.cpp
@ -1,47 +1,37 @@
|
||||
#include <Arduino.h>
|
||||
#include "global.h"
|
||||
|
||||
// Wifi
|
||||
#include <WiFi.h>
|
||||
#include <WiFiMulti.h>
|
||||
|
||||
WiFiMulti WiFiMulti;
|
||||
WiFiClient espClient;
|
||||
IPAddress server(192, 168, 2, 196);
|
||||
|
||||
// MQTT
|
||||
#include <PubSubClient.h>
|
||||
PubSubClient client(espClient);
|
||||
|
||||
// DAC
|
||||
#define DAC1 25
|
||||
|
||||
// BTN
|
||||
#define BTN_L
|
||||
#define BTN_R
|
||||
// Buttons
|
||||
Button2 btn_L, btn_R;
|
||||
|
||||
// Display
|
||||
#include <GxEPD2_BW.h>
|
||||
GxEPD2_BW<GxEPD2_213_B72, GxEPD2_213_B72::HEIGHT> display(GxEPD2_213_B72(/*CS=5*/ SS, /*DC=*/17, /*RST=*/16, /*BUSY=*/4));
|
||||
|
||||
#include "./einkanalog.h"
|
||||
// Helpers
|
||||
EinkAnalogDisplay ead(&display, DAC1);
|
||||
|
||||
// Fonts
|
||||
#include <Adafruit_GFX.h>
|
||||
#include "../include/fonts/Pixeltype8pt7b.h"
|
||||
#include "../include/fonts/Pixeltype16pt7b.h"
|
||||
|
||||
void callback(char *topic, byte *payload, unsigned int length)
|
||||
void btnHandler(Button2 &btn)
|
||||
{
|
||||
Serial.print("Message arrived [");
|
||||
Serial.print(topic);
|
||||
Serial.print("] ");
|
||||
|
||||
// char array[length + 1] = {};
|
||||
// memcpy(array, payload, length);
|
||||
// array[length] = '\0';
|
||||
// Serial.println(String(array).toFloat() / 1000.0);
|
||||
// ead.setArm(String(array).toFloat() / 1000.0);
|
||||
switch (btn.getType())
|
||||
{
|
||||
case single_click:
|
||||
break;
|
||||
case double_click:
|
||||
Serial.print("double ");
|
||||
break;
|
||||
}
|
||||
Serial.print("click ");
|
||||
Serial.print("on button #");
|
||||
Serial.print((btn == btn_L) ? "L" : "R");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void setup()
|
||||
@ -52,6 +42,15 @@ void setup()
|
||||
|
||||
Serial.println("T5 Dashboard " __DATE__ " " __TIME__);
|
||||
|
||||
// Buttons
|
||||
btn_L.begin(BTN_L, INPUT_PULLUP, true);
|
||||
btn_L.setClickHandler(btnHandler);
|
||||
btn_L.setDoubleClickHandler(btnHandler);
|
||||
|
||||
btn_R.begin(BTN_R, INPUT_PULLUP, true);
|
||||
btn_R.setClickHandler(btnHandler);
|
||||
btn_R.setDoubleClickHandler(btnHandler);
|
||||
|
||||
display.fillScreen(GxEPD_WHITE);
|
||||
display.setTextColor(GxEPD_BLACK);
|
||||
display.setFont(&Pixeltype8pt7b);
|
||||
@ -131,5 +130,8 @@ void loop()
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
|
||||
btn_L.loop();
|
||||
btn_R.loop();
|
||||
client.loop();
|
||||
}
|
Loading…
Reference in New Issue
Block a user