Added ESP8266, Screen fixes

This commit is contained in:
Carsten Schmiemann 2022-09-05 03:22:06 +02:00
parent b13dfc4fba
commit ec80f509ba
7 changed files with 17 additions and 7 deletions

View File

@ -22,6 +22,7 @@
"ostream": "cpp",
"thread": "cpp",
"regex": "cpp",
"utility": "cpp"
"utility": "cpp",
"ranges": "cpp"
}
}

View File

@ -26,8 +26,8 @@ board = esp12e
framework = arduino
lib_deps =
knolleary/PubSubClient@^2.8
extentsoftware/TBeamPower@^2.0.4
peterus/esp-logger @ 0.0.1
bblanchon/ArduinoJson@^6.19.4
olikraus/U8g2@^2.33.12
monitor_speed = 115200

View File

@ -30,7 +30,9 @@
#include <screens.h>
#include <pins.h>
U8G2_SSD1306_128X64_VCOMH0_F_HW_I2C display(U8G2_R0, OLED_RST, OLED_SCL, OLED_SDA);
//U8G2_SSD1306_128X64_VCOMH0_F_HW_I2C display(U8G2_R0, OLED_RST, OLED_SCL, OLED_SDA); OLED on TTGO
U8G2_ST7920_128X64_F_HW_SPI display(U8G2_R2, LCD_CS, U8X8_PIN_NONE);
//U8G2_ST7920_128X64_F_SW_SPI display(U8G2_R2, LCD_E_SCLK, LCD_RW_SI, LCD_CS, U8X8_PIN_NONE);
bool pv_charging = false;
@ -113,7 +115,7 @@ void display_screen_0(float pv_voltage, float pv_wattage, float battery_voltage,
display.setCursor(72,28); display.print(pv_wattage,0); display.print("W");
display.setCursor(72,38); display.print(pv_kwh); display.print("kWh");
display.setCursor(72,54); display.print(battery_voltage); display.print("V");
display.setCursor(72,64); display.print(pv_amps); display.print("A");
display.setCursor(72,63); display.print(pv_amps); display.print("A");
} while ( display.nextPage() );
}
@ -132,7 +134,7 @@ void display_screen_1(float battery_voltage, float battery_amps, float battery_w
display.setFont(u8g2_font_inr19_mf);
display.setCursor(70,63); display.print(battery_soc,0); display.print("%");
display.setFont(u8g2_font_6x10_tr);
int batt_fill_y = map(battery_soc, 0, 100, 63, 38);
int batt_fill_y = map(battery_soc, 0, 100, 62, 37);
int batt_fill_height = map(battery_soc, 0, 100, 0, 25);
display.setDrawColor(2);
display.drawBox(6,batt_fill_y,38,batt_fill_height);
@ -148,7 +150,7 @@ void display_screen_2(float grid_power, float inv_power, float inv_current, floa
display_category_2();
display.setCursor(10,45); display.print(grid_power,0); display.print("W");
display.setCursor(40,54); display.print(inv_power,0); display.print("W");
display.setCursor(40,64); display.print(inv_current,1); display.print("A");
display.setCursor(40,63); display.print(inv_current,1); display.print("A");
float ac_load = load_ph1 + load_ph2 + load_ph3;
display.setCursor(87,20); display.print(ac_load,0); display.print("W");
display.setCursor(101,38); display.print(pv_wattage,0); display.print("W");

View File

@ -24,7 +24,8 @@
*/
#include <Arduino.h>
#include <logger.h>
#include <WiFi.h>
//#include <WiFi.h> -ESP32
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <Wire.h>

View File

@ -22,8 +22,14 @@
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
; THE SOFTWARE.
*/
//TTGO OLED Screen
#define OLED_SDA 21
#define OLED_SCL 22
#define OLED_RST 16
//GLCD on ESP8266
#define LCD_E_SCLK 14
#define LCD_RW_SI 13
#define LCD_CS 15
#define BUTTON_PIN 38