-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
950 changed files
with
338,365 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* IotWebConf01Minimal.ino -- IotWebConf is an ESP8266/ESP32 | ||
* non blocking WiFi/AP web configuration library for Arduino. | ||
* https://github.com/prampec/IotWebConf | ||
* | ||
* Copyright (C) 2020 Balazs Kelemen <[email protected]> | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE file for details. | ||
*/ | ||
|
||
/** | ||
* Example: Minimal | ||
* Description: | ||
* This example will shows the bare minimum required for IotWebConf to start up. | ||
* After starting up the thing, please search for WiFi access points e.g. with | ||
* your phone. Use password provided in the code! | ||
* After connecting to the access point the root page will automatically appears. | ||
* We call this "captive portal". | ||
* | ||
* Please set a new password for the Thing (for the access point) as well as | ||
* the SSID and password of your local WiFi. You cannot move on without these steps. | ||
* | ||
* You have to leave the access point before to let the Thing continue operation | ||
* with connecting to configured WiFi. | ||
* | ||
* Note that you can find detailed debug information in the serial console depending | ||
* on the settings IOTWEBCONF_DEBUG_TO_SERIAL, IOTWEBCONF_DEBUG_PWD_TO_SERIAL set | ||
* in the IotWebConf.h . | ||
*/ | ||
|
||
#include <IotWebConf.h> | ||
#include <IotWebConfUsing.h> // This loads aliases for easier class names. | ||
#include <IotWebConfOptionalGroup.h> | ||
|
||
// UpdateServer includes | ||
// For ESP32 IotWebConf provides a drop-in replacement for UpdateServer. | ||
# include <IotWebConfESP32HTTPUpdateServer.h> | ||
|
||
// -- Initial name of the Thing. Used e.g. as SSID of the own Access Point. | ||
const char thingName[] = "WDP"; | ||
|
||
// -- Initial password to connect to the Thing, when it creates an own Access Point. | ||
const char wifiInitialApPassword[] = "12345678"; | ||
|
||
#define STRING_LEN 128 | ||
#define NUMBER_LEN 32 | ||
|
||
// -- Configuration specific key. The value should be modified if config structure was changed. | ||
#define CONFIG_VERSION "1.01" | ||
|
||
// -- When CONFIG_PIN is pulled to ground on startup, the Thing will use the initial | ||
// password to buld an AP. (E.g. in case of lost password) | ||
#define CONFIG_PIN 35 | ||
|
||
#define LED_BUILTIN (4) //led | ||
|
||
// -- Status indicator pin. | ||
// First it will light up (kept LOW), on Wifi connection it will blink, | ||
// when connected to the Wifi it will turn off (kept HIGH). | ||
#define STATUS_PIN LED_BUILTIN | ||
|
||
// -- Maximal length the input-range attributes can have. | ||
#define RANGE_ATTR_LENGTH 60 | ||
|
||
|
||
// -- Method declarations. | ||
void handleRoot(); | ||
// -- Callback methods. | ||
void wifiConnected(); | ||
void configSaved(); | ||
void parseBytes(const char* str, char sep, byte* bytes, int maxBytes, int base); | ||
|
||
DNSServer dnsServer; | ||
WebServer server(80); | ||
HTTPUpdateServer httpUpdater; | ||
|
||
byte ip[4]; | ||
|
||
|
||
char MeterIp[STRING_LEN]; | ||
char metertypeParamValue[NUMBER_LEN]; | ||
|
||
IotWebConf iotWebConf(thingName, &dnsServer, &server, wifiInitialApPassword, CONFIG_VERSION); | ||
|
||
iotwebconf::OptionalParameterGroup MeterGroup = iotwebconf::OptionalParameterGroup("IAMMETER DSP", "IAMMETER", false); | ||
iotwebconf::TextParameter MeterIpParam = iotwebconf::TextParameter("IP address", "MeterIp", MeterIp, STRING_LEN, "192.168.1.6"); | ||
iotwebconf::NumberParameter metertypeParam = iotwebconf::NumberParameter("MeterType 1:Single 3:Three", "MeterType", metertypeParamValue, NUMBER_LEN, "3", "1..3", "min='1' max='3' step='1'"); | ||
|
||
// -- An instance must be created from the class defined above. | ||
iotwebconf::OptionalGroupHtmlFormatProvider optionalGroupHtmlFormatProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <ModbusIP_ESP8266.h> | ||
|
||
typedef struct _MeterDatas | ||
{ | ||
float Voltage_a ; //Voltage 0x0000 /100 V | ||
float Current_a; //Current 0x0001 /100 A | ||
float Power_a; //Power 0x0002 W | ||
double ImportEnergy_a; //ImportEnergy 0x0004 /800 kWh | ||
double ExportGrid_a; //ExportGrid 0x0006 /800 kWh | ||
float power_factor_a; //power_factor 0x0008 /1000 | ||
//NC 0x0009 | ||
|
||
float Voltage_b ; //Voltage 0x000A /100 V | ||
float Current_b; //Current 0x000B /100 A | ||
float Power_b; //Power 0x000C W | ||
double ImportEnergy_b; //ImportEnergy 0x000E /800 kWh | ||
double ExportGrid_b; //ExportGrid 0x0010 /800 kWh | ||
float power_factor_b; //power_factor 0x0012 /1000 | ||
//NC 0x0013 | ||
|
||
float Voltage_c ; //Voltage 0x0014 /100 V | ||
float Current_c; //Current 0x0015 /100 A | ||
float Power_c; //Power 0x0016 W | ||
double ImportEnergy_c; //ImportEnergy 0x0018 /800 kWh | ||
double ExportGrid_c; //ExportGrid 0x001A /800 kWh | ||
float power_factor_c; //power_factor 0x001C /1000 | ||
//NC 0x001D | ||
|
||
float Frequency; //Frequency 0x001E /100 Hz | ||
//NC 0x001F | ||
float Power_s; //Power sum 0x0020 W | ||
double ImportEnergy_s; //ImportEnergy sum 0x0022 /800 kWh | ||
double ExportGrid_s; //ExportGrid sum 0x0024 /800 kWh | ||
|
||
float apparent_power_a; //apparent_power | ||
float reactive_power_a; //reactive_power | ||
|
||
uint16_t address = 0x0048; //starting at register | ||
uint16_t quantitysingle = 10; //single phase meter | ||
uint16_t quantity = 38; //IAMMETER Three phase meter | ||
bool data_ok = false; | ||
|
||
String jsondata; | ||
} MeterDatas; | ||
|
||
MeterDatas wem3080t; | ||
uint16_t read_datas[38]; | ||
|
||
const int REG = 0; // Modbus Hreg Offset | ||
IPAddress remote(192, 168, 1, 6); // Address of Modbus Slave device | ||
const int LOOP_COUNT = 10; | ||
long refreshTime = 1000; | ||
|
||
ModbusIP mb; //ModbusIP object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
#include <lvgl.h> | ||
#include <LovyanGFX.hpp> | ||
|
||
class LGFX : public lgfx::LGFX_Device | ||
{ | ||
lgfx::Panel_ILI9341 _panel_instance; | ||
lgfx::Bus_SPI _bus_instance; // SPI bus instance // SPIバスのインスタンス | ||
lgfx::Light_PWM _light_instance; | ||
lgfx::Touch_XPT2046 _touch_instance; | ||
|
||
public: | ||
LGFX(void) | ||
{ | ||
{ // バス制御の設定を行います。 | ||
auto cfg = _bus_instance.config(); // Gets the structure for bus configuration. // バス設定用の構造体を取得します。 | ||
cfg.spi_host = HSPI_HOST; // Select the SPI to use // 使用するSPIを選択 (VSPI_HOST or HSPI_HOST) | ||
cfg.spi_mode = 0; // Set SPI communication mode (0 ~ 3) // SPI通信モードを設定 (0 ~ 3) | ||
cfg.freq_write = 55000000; // SPI clock at the time of transmission (up to 80MHz, rounded to the value obtained by dividing 80MHz by an integer) // 送信時のSPIクロック (最大80MHz, 80MHzを整数で割った値に丸められます) | ||
cfg.freq_read = 20000000; // SPI clock when receiving // 受信時のSPIクロック | ||
cfg.spi_3wire = false; // Set true when receiving with MOSI pin // 受信をMOSIピンで行う場合はtrueを設定 | ||
cfg.use_lock = true; // Set to true when using transaction lock // トランザクションロックを使用する場合はtrueを設定 | ||
cfg.dma_channel = 1; // Set the DMA channel (1 or 2. 0=disable) // 使用するDMAチャンネルを設定 (0=DMA不使用) | ||
cfg.pin_sclk = 14; // Set SPI SCLK pin number // SPIのSCLKピン番号を設定 | ||
cfg.pin_mosi = 13; // Set SPI MOSI pin number // SPIのMOSIピン番号を設定 | ||
cfg.pin_miso = 12; // Set SPI MISO pin number (-1 = disable) // SPIのMISOピン番号を設定 (-1 = disable) | ||
cfg.pin_dc = 2; // Set SPI D / C pin number (-1 = disable) // SPIのD/Cピン番号を設定 (-1 = disable) | ||
|
||
_bus_instance.config(cfg); // The set value is reflected on the bus. // 設定値をバスに反映します。 | ||
_panel_instance.setBus(&_bus_instance); // Set the bus on the panel. // バスをパネルにセットします。 | ||
} | ||
|
||
{ // Set the display panel control.//表示パネル制御の設定を行います。 | ||
auto cfg = _panel_instance.config(); // Gets the structure for display panel settings.// 表示パネル設定用の構造体を取得します。 | ||
cfg.pin_cs = 15; // Pin number to which CS is connected (-1 = disable) // CSが接続されているピン番号 (-1 = disable) | ||
cfg.pin_rst = -1; // Pin number to which RST is connected (-1 = disable) // RSTが接続されているピン番号 (-1 = disable) | ||
cfg.pin_busy = -1; // Pin number to which BUSY is connected (-1 = disable) // BUSYが接続されているピン番号 (-1 = disable) | ||
cfg.memory_width = 240; // Maximum width supported by driver IC // ドライバICがサポートしている最大の幅 | ||
cfg.memory_height = 320; // Maximum height supported by driver IC // ドライバICがサポートしている最大の高さ | ||
cfg.panel_width = 240; // Actually displayable width // 実際に表示可能な幅 | ||
cfg.panel_height = 320; // Actually displayable height // 実際に表示可能な高さ | ||
cfg.offset_x = 0; // Amount of X-direction offset of the panel // パネルのX方向オフセット量 | ||
cfg.offset_y = 0; // Amount of Y-direction offset of the panel // パネルのY方向オフセット量 | ||
cfg.offset_rotation = 0; // Offset of values in the direction of rotation 0 ~ 7 (4 ~ 7 are upside down) // 回転方向の値のオフセット 0~7 (4~7は上下反転) | ||
cfg.dummy_read_pixel = 8; // Number of dummy read bits before pixel reading // ピクセル読出し前のダミーリードのビット数 | ||
cfg.dummy_read_bits = 1; // Number of bits of dummy read before reading data other than pixels // ピクセル以外のデータ読出し前のダミーリードのビット数 | ||
cfg.readable = true; // Set to true if data can be read // データ読出しが可能な場合 trueに設定 | ||
cfg.invert = false; // Set to true if the light and darkness of the panel is reversed // パネルの明暗が反転してしまう場合 trueに設定 | ||
cfg.rgb_order = false; // Set to true if the red and blue of the panel are swapped // パネルの赤と青が入れ替わってしまう場合 trueに設定 | ||
cfg.dlen_16bit = false; // Set to true for panels that send data length in 16-bit units // データ長を16bit単位で送信するパネルの場合 trueに設定 | ||
cfg.bus_shared = true; // If the bus is shared with the SD card, set to true (bus control is performed with drawJpgFile etc.) // SDカードとバスを共有している場合 trueに設定(drawJpgFile等でバス制御を行います) | ||
|
||
_panel_instance.config(cfg); | ||
} | ||
|
||
{ // Set the backlight control. (Delete if not needed // バックライト制御の設定を行います。(必要なければ削除) | ||
auto cfg = _light_instance.config(); // Gets the structure for the backlight setting. // バックライト設定用の構造体を取得します。 | ||
|
||
cfg.pin_bl = 21; // Pin number to which the backlight is connected // バックライトが接続されているピン番号 | ||
cfg.invert = false; // True if you want to invert the brightness of the backlight // バックライトの輝度を反転させる場合 true | ||
cfg.freq = 44100; // Backlight PWM frequency // バックライトのPWM周波数 | ||
cfg.pwm_channel = 7; // PWM channel number to use // 使用するPWMのチャンネル番号 | ||
|
||
_light_instance.config(cfg); | ||
_panel_instance.setLight(&_light_instance); // Set the backlight on the panel. // バックライトをパネルにセットします。 | ||
} | ||
|
||
{ // Set the touch screen control. (Delete if not needed) // タッチスクリーン制御の設定を行います。(必要なければ削除) | ||
auto cfg = _touch_instance.config(); | ||
cfg.x_min = 0; // Minimum X value (raw value) obtained from touch screen // タッチスクリーンから得られる最小のX値(生の値) | ||
cfg.x_max = 239; // Maximum X value (raw value) obtained from the touch screen // タッチスクリーンから得られる最大のX値(生の値) | ||
cfg.y_min = 0; // Minimum Y value (raw value) obtained from touch screen // タッチスクリーンから得られる最小のY値(生の値) | ||
cfg.y_max = 319; // Maximum Y value (raw value) obtained from the touch screen // タッチスクリーンから得られる最大のY値(生の値) | ||
cfg.pin_int = 36; // Pin number to which INT is connected // INTが接続されているピン番号 | ||
cfg.bus_shared = true; // Set to true if you are using the same bus as the screen // 画面と共通のバスを使用している場合 trueを設定 | ||
cfg.offset_rotation = 0;// Adjustment when the display and touch orientation do not match Set with a value from 0 to 7 // 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定 | ||
cfg.spi_host = VSPI_HOST;// Select the SPI to use (HSPI_HOST or VSPI_HOST) // 使用するSPIを選択 (HSPI_HOST or VSPI_HOST) | ||
cfg.freq = 2500000; // Set SPI clock // SPIクロックを設定 | ||
cfg.pin_sclk = 25; // Pin number to which SCLK is connected // SCLKが接続されているピン番号 | ||
cfg.pin_mosi = 32; // Pin number to which MOSI is connected // MOSIが接続されているピン番号 | ||
cfg.pin_miso = 39; // Pin number to which MISO is connected // MISOが接続されているピン番号 | ||
cfg.pin_cs = 33; // Pin number to which CS is connected // CSが接続されているピン番号 | ||
|
||
_touch_instance.config(cfg); | ||
_panel_instance.setTouch(&_touch_instance); // Set the touch screen on the panel. // タッチスクリーンをパネルにセットします。 | ||
} | ||
setPanel(&_panel_instance); // Set the panel to be used. // 使用するパネルをセットします。 | ||
} | ||
}; | ||
|
||
|
||
/*Change to your screen resolution*/ | ||
static const uint32_t screenWidth = 320; | ||
static const uint32_t screenHeight = 240; | ||
static lv_disp_draw_buf_t draw_buf; | ||
static lv_color_t buf[ screenWidth * 10 ]; | ||
|
Oops, something went wrong.