Skip to content

Commit

Permalink
Merge pull request #133 from kike-canaries/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
hpsaturn authored Nov 1, 2021
2 parents 4f22691 + e039565 commit 66c086e
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 14 deletions.
6 changes: 4 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ updateFlavorBinaries() {
}

clean () {
rm -r $RELDIR/$BINDIR
rm -r $RELDIR/$MANIFEST
rm -rf $RELDIR/$BINDIR
rm -rf $RELDIR/$MANIFEST
rm -f $INSDIR/*.bin
rm -f $INSDIR/*.py # old installer
}

build () {
Expand Down
1 change: 1 addition & 0 deletions include/wifi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void wifiStop();
void wifiRestart();
void wifiLoop();
int getWifiRSSI();
String getDeviceInfo();

void influxDbInit();
void influxDbLoop();
Expand Down
4 changes: 4 additions & 0 deletions lib/gui-utils-oled/src/GUIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ void GUIUtils::setGUIStatusFlags(bool wifiOn, bool bleOn, bool blePair) {
}
}

void GUIUtils::setInfoData(String info) {
// TODO:
}

void GUIUtils::displayGUIStatusFlags() {
#ifdef TTGO_TQ
if (_bleOn)
Expand Down
2 changes: 2 additions & 0 deletions lib/gui-utils-oled/src/GUIUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class GUIUtils {

void setGUIStatusFlags(bool wifiOn, bool bleOn, bool blePair);

void setInfoData(String info);

void setBrightness(uint32_t value);

void setWifiMode(bool enable);
Expand Down
51 changes: 45 additions & 6 deletions lib/gui-utils-tft/src/TFTUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,31 @@ void TFTUtils::showWindowBike(){
Serial.println("-->[TGUI] displayed bike screen");
}

void TFTUtils::showInfoWindow() {
showStatus();
tft.setTextColor(TFT_GREENYELLOW, TFT_BLACK);
tft.setTextFont(1);
tft.setFreeFont(&Orbitron_Medium_20);
tft.setTextDatum(MC_DATUM);
tft.drawString("DEVINFO", tft.width() / 2, 30);
tft.drawLine(18,44,117,44,TFT_GREY);
state = 7;
refreshInfoWindow();
Serial.println("-->[TGUI] displayed info screen");
}

void TFTUtils::refreshInfoWindow() {
if (state != 7) return;
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setTextFont(2);
tft.setTextPadding(5);
tft.setTextDatum(CR_DATUM);
tft.setCursor(0, 50, 2);
tft.println(_info);
}

void TFTUtils::showSetup() {

showStatus();
tft.setTextColor(TFT_GREENYELLOW, TFT_BLACK);
tft.setFreeFont(&Orbitron_Medium_20);
Expand All @@ -173,6 +197,12 @@ void TFTUtils::showSetup() {
tft.setCursor(MARGINL, SSTART+PRESETH*4, 2);
tft.println("CALIBRT:");

tft.setCursor(MARGINL, SSTART+PRESETH*5, 2);
tft.println("INFO:");

tft.setCursor(MARVALL, SSTART+PRESETH*5, 2);
tft.println(String(VERSION));

updateInvertValue();
updateWifiMode();
updateSampleTime();
Expand Down Expand Up @@ -269,16 +299,17 @@ void TFTUtils::setSampleTime(int time){
updateSampleTime();
}

void TFTUtils::updateSampleTime(){
tft.fillRect(MARVALL, SSTART+PRESETH*3, 54, 13, TFT_BLACK);
void TFTUtils::updateSampleTime() {
if (state < 1) return;
tft.fillRect(MARVALL, SSTART + PRESETH * 3, 54, 13, TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setCursor(MARVALL, SSTART+PRESETH*3, 2);
tft.println(""+String(_sample_time)+"s");
tft.setCursor(MARVALL, SSTART + PRESETH * 3, 2);
tft.println("" + String(_sample_time) + "s");
}

void TFTUtils::updateCalibrationField(){
static uint_fast64_t calibretts = 0; // timestamp for GUI refresh
if (state >= 1 && millis() - calibretts > 1000) {
if (state >= 1 && state < 6 && millis() - calibretts > 1000) {
calibretts = millis();
tft.fillRect(MARVALL, SSTART + PRESETH * 4, 54, 13, TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
Expand Down Expand Up @@ -333,6 +364,7 @@ void TFTUtils::checkButtons() {
if(state==3)notifyWifiMode();
if(state==4)notifySampleTime();
if(state==5)startCalibration();
if(state==6)showInfoWindow();
}
if (holdR > 20) suspend();
} else {
Expand All @@ -346,7 +378,7 @@ void TFTUtils::checkButtons() {
pressL = 1;
if (state++ == 0) showSetup();
if (state >= 1) refreshSetup();
if (state == 6) restoreMain();
if (state >= 7) restoreMain();
}
if(holdL > 10 && state >= 1) restoreMain();
} else {
Expand Down Expand Up @@ -520,6 +552,12 @@ void TFTUtils::setGUIStatusFlags(bool wifiOn, bool bleOn, bool blePair) {
}
}

void TFTUtils::setInfoData(String info) {
suspendTaskGUI();
_info = info;
resumeTaskGUI();
}

void TFTUtils::displayGUIStatusFlags() {
static uint_fast64_t sensor_status_ts = 0; // timestamp for GUI refresh
if ((millis() - sensor_status_ts > 1000)) {
Expand Down Expand Up @@ -649,6 +687,7 @@ void TFTUtils::pageStart() {
}
updateCalibrationField();
displayGUIStatusFlags();
refreshInfoWindow();
}

void TFTUtils::pageEnd() {
Expand Down
8 changes: 8 additions & 0 deletions lib/gui-utils-tft/src/TFTUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class TFTUtils {

void setGUIStatusFlags(bool wifiOn, bool bleOn, bool blePair);

void setInfoData(String info);

void displayMainValues();

void displayDataOnIcon();
Expand Down Expand Up @@ -173,6 +175,8 @@ class TFTUtils {

bool _blePair;

String _info = "";

bool isNewData;

TaskHandle_t xHandle;
Expand All @@ -189,6 +193,10 @@ class TFTUtils {

void refreshSetup();

void showInfoWindow();

void refreshInfoWindow();

void displaySensorAverage(int average);

void displayMainUnit(String unit);
Expand Down
8 changes: 4 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ platform = espressif32
framework = arduino
upload_speed = 1500000
monitor_speed = 115200
version = 0.4.4
revision = 833
target = prod
version = 0.4.5
revision = 837
target = dev
monitor_filters = time
extra_scripts = pre:prebuild.py
build_flags =
Expand All @@ -28,7 +28,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6
tobiasschuerg/ESP8266 Influxdb @ ^3.8.0
https://github.com/hpsaturn/esp32FOTA.git
hpsaturn/CanAirIO Air Quality Sensors Library@^0.3.6
hpsaturn/CanAirIO Air Quality Sensors Library@^0.3.7

[esp32_common]
platform = espressif32
Expand Down
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ void refreshGUIData() {
temp,
getWifiRSSI(),
deviceType);

gui.setInfoData(getDeviceInfo());
}

class MyGUIUserPreferencesCallbacks : public GUIUserPreferencesCallbacks {
Expand Down Expand Up @@ -70,14 +72,14 @@ class MyGUIUserPreferencesCallbacks : public GUIUserPreferencesCallbacks {
};
void onCalibrationReady(){
Serial.println("-->[MAIN] onCalibrationReady");
sensors.setCO2RecalibrationFactor(418); // ==> Calibration factor on outdoors
sensors.setCO2RecalibrationFactor(400); // ==> Calibration factor on outdoors
};
};

class MyRemoteConfigCallBacks : public RemoteConfigCallbacks {
void onCO2Calibration () {
Serial.println("-->[MAIN] onRemoteConfig CO2 Calibration");
sensors.setCO2RecalibrationFactor(418); // ==> Calibration factor on outdoors
sensors.setCO2RecalibrationFactor(400); // ==> Calibration factor on outdoors
};

void onAltitudeOffset (float altitude) {
Expand Down
12 changes: 12 additions & 0 deletions src/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,15 @@ int getWifiRSSI() {
else return 0;
}

String getDeviceInfo () {
String info = String(FLAVOR) + "\n";
info = info + "Rev" + String(REVISION) +" v" + String(VERSION) + "\n";
info = info + sensors.getPmDeviceSelected() + "\n\n";

info = info + "Host: " + hostId + "\n";
info = info + "(" + WiFi.localIP().toString() + ")\n";
info = info + "OTA: " + String(TARGET) + " channel\n\n";
info = info + "Fixed station:\n";
info = info + influxdbGetStationName();
return info;
}

0 comments on commit 66c086e

Please sign in to comment.