Skip to content

Commit

Permalink
v40 (#69)
Browse files Browse the repository at this point in the history
* start v40 development

* CHANGE: CO2 alert lower values to 300

* [Feature] Enter setup mode API
Fixes #46

* update readme

* [Enhance] Add moving something to Setup mode display
Fixes #44

* update readme

* [Enhance] mDNS code ESP32 and ESP8266 are duplicated
Fixes #60

* [Enhance] Alerts should not occur if no sensor connected
Fixes #49

* update readme

* fIX: compile error

* fix #64

* CHANGE: Dont timer read if sensor not connected

* CHANGE: No sensor No alert

* FIX: Wait for reconfigure bar length invalid

* update readme

* refs #54

* [Feature] Air pressure delta
Fixes #54

* [Feature] Air pressure delta
Fixes #54 bigmode

* v40
  • Loading branch information
yakumo-saki authored Feb 12, 2021
1 parent 293b343 commit 377386d
Show file tree
Hide file tree
Showing 62 changed files with 1,105 additions and 617 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[*.cpp, *.h]
indent_size = 4
indent_style = tab
81 changes: 52 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,18 @@ Maybe I can support ST7789 on ESP8266. but not in TODO.

### http server

All endpoints are using GET Method
EnvBoyX has http API.

| ENDPOINT | description |
| ------------- | -------------------------- |
| / | returns sensor value as JSON.|
| /ping | returns pong. |
| /brightness?value=<brightness> | set display brightness (0-255) 0 means OFF |
| /display?value=<1 or 0> | set display power (1 = ON / 0 = OFF) |
| METHOD | ENDPOINT | RETURN | description |
| ------ | ------------- | -------------------------- |
| GET | / | JSON | sensor value as JSON.|
| GET | /ping | TEXT | returns pong. |
| GET | /stastics | JSON | stastics JSON |
| GET | /brightness?value=<brightness> | TEXT | set display brightness (0-255) 0 means OFF |
| GET | /display?value=<1 or 0> | TEXT | set display power (1 = ON / 0 = OFF) |
| POST | /goto_setup | TEXT | Go to setup mode at next boot |

NOTE: There is no reboot API, because of security reason.

#### note

Expand Down Expand Up @@ -162,6 +166,27 @@ esptool.py write_flash 0x1000 filename.bin

## Version History

* BUGFIX: Bug fix
* FIX: Fix not bug, but not friendly behavior
* CHANGE: Change some behavior
* ADD: Add new function
* DROP: Delete some functions
* NOTE: other things

### v40

* FIX: CO2 ppm alert value is not good.
* ADD: Add POST /goto_setup API.
* FIX: Delete unused source code.
* ADD: Add display invert (3sec) on setup mode (ST7789 / SSD1306)
* NOTE: platformio/espressif8266 @ 2.6.3
* FIX: MHZ19B RX, TX Pin settings are fixed to GPIO 14,0
* CHANGE: Stop prefixing "*" when co2ppm below 400 (use alerts for this purpose)
* FIX: Wait for reconfigure bar length invalid
* FIX: BME280: improve pressure precision (fix decimal values are truncated)
* ADD: Pressure delta
* CHANGE: ST7789: Normal: Dont show co2 when no co2 sensor.

### v39

* CHANGE: CONFIG: Add SSD1306 / SH1106 switch
Expand Down Expand Up @@ -196,12 +221,12 @@ esptool.py write_flash 0x1000 filename.bin

### v3.5

* Config: version 9 (was 8) and using JSON format
* Config: Migration between versions
* CHANGE: Config: version 9 (was 8) and using JSON format
* ADD: Config: Migration between versions

### v3.4

* Config: version 8 (was 6)
* CHANGE: Config: version 8 (was 6)
* BUGFIX: SSD1306 not shown in Setup Mode
* ADD: Default Brightness setting
* ADD: Screen Flip setting
Expand All @@ -216,58 +241,56 @@ esptool.py write_flash 0x1000 filename.bin

### v3.2

* Avoid using delay
* FIX: Avoid using delay
* ADD: I2C scan on startup.
* BUGFIX: ESP8266: I2C not working
* DROP: ESP8266: ST7789 is not supported (because of Pin config)

### v3.1

* Add vertical display mode(bigger font. ST7789 only)
* Refactoring
* ADD: vertical display mode(bigger font. ST7789 only)
* FIX: Refactoring

### v3.0

* Add ST7789 Support (T-Display)
* ST7789 is initial support, some screens are simplifyed.

### v2.7
* ADD: ST7789 Support (T-Display)
* NOTE: ST7789 is initial support, some screens are simplifyed.

Display item change.
### v2.7: Display item change update

* Delete alive indicator "*" after EnvBoyX string.
* Add alive indicator. EnvBoyX's "X" character now blinks.
* Delete prefix "IP:" before IP address
* Add mDNS name display. IP/mDNS display switches 3 sec interval.
* Abort TFT display implementation.
* CHANGE: Delete alive indicator "*" after EnvBoyX string.
* ADD: alive indicator. EnvBoyX's "X" character now blinks.
* CHANGE: prefix "IP:" before IP address
* ADD: mDNS name display. IP/mDNS display switches 3 sec interval.
* NOTE: Abort TFT display implementation.

### v2.6

* Fix mDNS not working
* BUGFIX: Fix mDNS not working

### v2.5

* Add /display endpoint.
* ADD: /display endpoint.

### v2.4

* Add /brightness endpoint.
* ADD: /brightness endpoint.

### v2.3

* Unifing EnvBoyX (ESP8266) and EnvBoyX32 (ESP32) again.
* FIX: Unifing EnvBoyX (ESP8266) and EnvBoyX32 (ESP32) again.

### v2.2

* missing version due to bug.

### v2.1

* Split EnvBoyX (8266) and EnvBoyX32 (ESP32)
* FIX: Split EnvBoyX (8266) and EnvBoyX32 (ESP32)

### v2.0

* Move to Platform.IO from Arduino IDE
* FIX: Move Arduino IDE to Platform.IO

### before v2.0

Expand Down
6 changes: 5 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ void save_config();

void list_dir();

/** config ok フラグファイルを作成する */
void create_configure_flag_file();

/** config ok フラグファイルを削除する */
void remove_configure_flag_file();
bool has_valid_config_file();
bool has_valid_config();
Expand All @@ -35,4 +38,5 @@ void trim_config();
void write_config_file(File f);

/** ファイルを読んでconfig値にセット。closeはしない */
bool read_config_file(File f, bool dump_config = false);
bool read_config_file(File f, bool dump_config);
bool read_config_file(File f);
1 change: 1 addition & 0 deletions include/display.h → include/display/display.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Arduino.h>

// セットアップモード表示
void disp_setup_startup_screen(String ipAddr);

void disp_wifi_info(String ip, String mDNS);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <Arduino.h>

void disp_ssd1306_wifi_info(String ip, String mDNS);
void disp_ssd1306_setup_startup_screen(String ipAddr, int disp_switch);

void disp_ssd1306_normal_startup_screen(String product_long);
void disp_ssd1306_setup_startup_screen(String ipAddr);

void disp_ssd1306_wait_for_reconfig_init();
void disp_ssd1306_wait_for_reconfig_bar(int now, const int max);

void disp_ssd1306_wifi_info(String ip, String mDNS);
void disp_ssd1306_wifi_starting();
void disp_ssd1306_wifi_error();
void disp_ssd1306_all_initialize_complete();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include <Arduino.h>

// 使える使えないの判断フラグ ST7789_SUPPORTED -> define.cpp
// このフラグで呼び出される実態が空っぽなのと実装されているものに分かれる。

/** ST7789V セットアップモード */
void disp_st7789_setup_startup_screen(String ipAddr);
void disp_st7789_setup_startup_screen(String ipAddr, int disp_switch);

void disp_st7789_wifi_info(String ip, String mDNS);
void disp_st7789_normal_startup_screen(String product_long);
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions include/display/display_util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "structs.h"
typedef struct {
float value;
bool positive = false; // 値が0.1以上のプラス。プラスでもマイナスでもない場合に注意
bool negative = false; // 絶対値が0.1以上のマイナス。プラスでもマイナスでもない場合に注意
bool drawIcon = true; // 絶対値0.2以上
String formattedValue; // プラス・マイナスを除去した数字だけフォーマット
} pressure_delta_t;

bool has_caution(value_alerts_t alerts);
bool has_warning(value_alerts_t alerts);

String format_air_pressure_delta(float value);
pressure_delta_t get_pressure_delta_struct(float pressureDelta);
File renamed without changes.
18 changes: 18 additions & 0 deletions include/display/st7789_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <Arduino.h>
#include <TFT_eSPI.h>

extern TFT_eSPI tft;

enum class ARROW_ICON {
NONE = 0, UP = 1, DOWN = 2, PLUS = 3, MINUS = 4
};

/**
* 矢印を書く
*/
void draw_arrow(int x, int y, ARROW_ICON type, uint16_t color, int height, int width);

/**
* 矢印を書く(12 x 22)
*/
void draw_arrow(int x, int y, ARROW_ICON type, uint16_t color);
18 changes: 18 additions & 0 deletions include/display/u8g2_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <Arduino.h>

enum class TextAlign { LEFT = 1 , RIGHT = 2 };

enum class TextDecoration { NONE = 0 , BOX = 2, INVERT = 4 };

void draw_string(int x, int y, String valueString, TextAlign align, const uint8_t *font);
void draw_string(int x, int y, String valueString, TextAlign align);

uint16_t draw_value(int x, int y, TextDecoration deco, TextAlign align, String valueString, const uint8_t *valueFont, String unitString, const uint8_t *unitFont);

/**
* 画面反転切り替え。画面の内容は変更せずに反転する。
* @param inverse true 反転する false しない
*/
void set_invert(bool inverse);
4 changes: 0 additions & 4 deletions include/display_util.h

This file was deleted.

1 change: 1 addition & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern config_t config;
// センサー値
// --------------------------------------------------------------------
extern sensor_values_t sensorValues;
extern sensor_characters_t sensorCharacters;

// --------------------------------------------------------------------
// 統計情報
Expand Down
1 change: 1 addition & 0 deletions include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void i2clog(String msg);
void stlog(String msg);
void ssdlog(String msg);
void statlog(String msg);
void pdeltalog(String msg);
void haltlog(String msg);
void debuglog(String msg);
void sectionlog(String msg);
Expand Down
2 changes: 1 addition & 1 deletion include/main_normal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ void init_sensors();
void setup_normal();
void loop_normal();
void read_data();
void init_timer();
void add_timer_tasks();
8 changes: 7 additions & 1 deletion include/sensors/adt7410.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
void adt_setup(void);
#include "structs.h"

sensor_characters_t adt_characters();

// 初期化
bool adt_setup(void);

void adt_read_data(void);
9 changes: 8 additions & 1 deletion include/sensors/am2320.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
void am_setup();
#include "structs.h"

//
sensor_characters_t am_characters();

// 初期化
bool am_setup();

void am_read_data();
8 changes: 7 additions & 1 deletion include/sensors/bh1750.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
void bh_setup();
#include "structs.h"

sensor_characters_t bh_characters();

// 初期化
bool bh_setup();

void bh_read_data();
7 changes: 6 additions & 1 deletion include/sensors/bme280.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
void bme_setup();
#include "structs.h"

sensor_characters_t bme_characters();

bool bme_setup();

void bme_read_data();
6 changes: 5 additions & 1 deletion include/sensors/lps22hb.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
void lps_setup(void);
#include "structs.h"

sensor_characters_t lps_characters();

bool lps_setup(void);
void lps_read_data();
6 changes: 5 additions & 1 deletion include/sensors/mhz19.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
void mhz_setup();
#include "structs.h"

sensor_characters_t mhz_characters();

bool mhz_setup();
void mhz_read_data();
10 changes: 10 additions & 0 deletions include/sensors/pressure_delta.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Air Pressure delta
//

/**
* 差分比較用に今の気圧を蓄積します。
*/
void store_air_pressure_history();

void store_air_pressure_delta();
6 changes: 5 additions & 1 deletion include/sensors/tsl2561.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
void tsl_setup();
#include "structs.h"

sensor_characters_t tsl_characters();

bool tsl_setup();
void read_data_tsl2561();
Loading

0 comments on commit 377386d

Please sign in to comment.