Skip to content

Commit

Permalink
Merge pull request #143 from kike-canaries/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
hpsaturn authored Nov 12, 2021
2 parents 7d6de69 + 04e726a commit 79c9ee2
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 135 deletions.
42 changes: 30 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,34 @@ We have different alternatives for load the current firmware. In order of comple

You will able to install the last version of CanAirIO firmware with internet updates via a simple Arduino sketch that it will doing all for you, you only need to use the official [Arduino IDE](https://www.arduino.cc/en/software) or [Arduino Droid app for Android](https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinodroid2&hl=en&gl=US) for load this [simple sketch](https://github.com/hpsaturn/esp32-canairio-loader/blob/master/canairio_loader/canairio_loader.ino). Please follow the instructions [here](https://github.com/hpsaturn/esp32-canairio-loader) or follow the next [YouTube video guide](https://youtu.be/FjfGdnTk-rc) for Android OTG installation alternative.

## Via binaries (Linux and MacOSx)
## Via binaries

You can download the last firmware version in [releases](https://github.com/kike-canaries/esp32-hpma115s0/releases) section. Download the last release from `assets` section in releases and please uncompress zip file.
You can download the last firmware version in [releases](https://github.com/kike-canaries/esp32-hpma115s0/releases) section. Download the last **production** release from `assets` section, for example:

### USB alternative
![releases assets](images/assets.jpg)

Connect your CanAirIO device to your USB and execute the next command for your model board*, like this:
please uncompress the zip file and connect your CanAirIO device to your USB and execute the next command for upload the firmware to your model board, for example to a TTGO_T7 board you should run the next commands:

### Linux and MacOSx

``` bash
unzip canairio_rev414_20190829.zip
cd canairio_installer
./install.sh canairio_TTGO_T7_rev605_20200925.bin
./install.sh canairio_TTGO_T7_rev839.bin
```

**Note**: you need python2 or python3 with pyserial in your system.

### OTA alternative
### Windows

Please read the [Espressif Uploader](https://canair.io/docs/firmware_upload.html#espressif-uploader) section in the main documentation for details to load the firmware via the oficial **Espressif Download Tool** in Windows.

### OTA WAN updates

CanAirIO has two channels for remote OTA updates of your device, production channel and development channel. With that you don't need again install the firmware for any update, all here is automatic and you only need have WiFi enable on your device for receive this firmware updates.

If you want the last testing updates, please choose in the previous step the development firmware (zip file with **dev** name), and upload it to your board.

### OTA LAN alternative

After USB binary installation, you will able to send OTA updates to any board supported, like this:

Expand All @@ -68,11 +79,6 @@ Also you can specify the IP address:
More details and options of `CanAirIO Installer` [here](https://github.com/kike-canaries/canairio_firmware/tree/master/releases/installer/canairio_installer#readme)


## Via binaries (Windows)

Please read the [Espressif Uploader](https://canair.io/docs/firmware_upload.html#espressif-uploader) section in the main documentation for details to load the firmware via the oficial **Espressif Download Tool** in Windows.


## Via PlatformIO (Compiling on Linux, Mac or Windows)

Please install first [PlatformIO](http://platformio.org/) open source ecosystem for IoT development compatible with **Arduino** IDE and its command line tools (Windows, MacOs and Linux). Also, you may need to install [git](http://git-scm.com/) in your system.
Expand Down Expand Up @@ -165,6 +171,14 @@ We have some build guides with different alternatives, please visit our [CanAirI

<a href="https://canair.io/docs" target="_blank"><img src="https://raw.githubusercontent.com/kike-canaries/canairio_firmware/master/images/collage.jpg" height="400" ></a>

## Building Guide

<a href="https://youtu.be/V2eO1UN5u7Y" target="_blank" style="padding-left: 20px" ><img src="images/canairio_bike_make_of_youtube.jpg" width="420" ></a>

## Soldering Guide (some improvements)

<a href="https://youtu.be/Oarq0K0Sz3c" target="_blank" style="padding-left: 20px" ><img src="images/canairio_bike_soldering_on_youtube.jpg" width="420" ></a>

# TODO

- [X] Enable/Disable APIs from App
Expand All @@ -176,5 +190,9 @@ We have some build guides with different alternatives, please visit our [CanAirI
- [x] Multiple variables in chart (C02,PM2.5,Hum,Temp,etc)
- [x] Map of each recorded track in details
- [x] InfluxDB schema (by geohashes)
- [x] New pax counter variable (People around the device)
- [x] WiFi SSIDs scanner for have a choose list of it in the app
- [x] Pax counter disable/enable
- [ ] Sensor community alternativa for fixed stations
- [ ] Anonymous authentication

Binary file added images/assets.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/canairio_bike_make_of_youtube.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/canairio_bike_soldering_on_youtube.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 0 additions & 58 deletions include/status.hpp

This file was deleted.

30 changes: 29 additions & 1 deletion lib/configlib/ConfigApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void ConfigApp::reload() {
toffset = preferences.getFloat("toffset", 0.0);
altoffset = preferences.getFloat("altoffset", 0.0);
devmode = preferences.getBool("debugEnable", false);
pax_enable = preferences.getBool("paxEnable", true);
i2conly = preferences.getBool("i2conly", false);

preferences.end();
Expand All @@ -54,6 +55,7 @@ String ConfigApp::getCurrentConfig() {
doc["ifxpt"] = preferences.getUInt("ifxpt", ifx.pt); // influxdb sensor tags
doc["geo"] = preferences.getString("geo", ""); // influxdb GeoHash tag
doc["denb"] = preferences.getBool("debugEnable", false); // debug mode enable
doc["penb"] = preferences.getBool("paxEnable", true); // PaxCounter enable
doc["i2conly"] = preferences.getBool("i2conly", false); // force only i2c sensors
doc["toffset"] = preferences.getFloat("toffset", 0.0); // temperature offset
doc["altoffset"] = preferences.getFloat("altoffset",0.0);// altitude offset
Expand Down Expand Up @@ -162,6 +164,19 @@ bool ConfigApp::saveAltitudeOffset(float offset) {
return true;
}

bool ConfigApp::saveSSID(String ssid){
if (ssid.length() > 0) {
preferences.begin(_app_name, false);
preferences.putString("ssid", ssid);
preferences.end();
setLastKeySaved("ssid");
Serial.println("-->[CONF] WiFi SSID saved!");
return true;
}
DEBUG("-->[W][CONF] empty Wifi SSID");
return false;
}

bool ConfigApp::saveWifi(String ssid, String pass){
if (ssid.length() > 0) {
preferences.begin(_app_name, false);
Expand Down Expand Up @@ -236,6 +251,13 @@ bool ConfigApp::debugEnable(bool enable) {
return true;
}

bool ConfigApp::paxEnable(bool enable) {
saveBool("paxEnable", enable);
pax_enable = enable;
Serial.println("-->[CONF] updating PaxCounter mode: " + String(enable));
return true;
}

bool ConfigApp::saveI2COnly(bool enable) {
saveBool("i2conly", enable);
i2conly = enable;
Expand Down Expand Up @@ -266,7 +288,8 @@ bool ConfigApp::save(const char *json) {
if (doc.containsKey("stime")) return saveSampleTime(doc["stime"] | 0);
if (doc.containsKey("stype")) return saveSensorType(doc["stype"] | 0);
if (doc.containsKey("ifxdb")) return saveInfluxDb(doc["ifxdb"] | "", doc["ifxip"] | "", doc["ifxpt"] | 0);
if (doc.containsKey("ssid")) return saveWifi(doc["ssid"] | "", doc["pass"] | "");
if (doc.containsKey("pass") && doc.containsKey("ssid")) return saveWifi(doc["ssid"] | "", doc["pass"] | "");
if (doc.containsKey("ssid")) return saveSSID(doc["ssid"] | "");
if (doc.containsKey("lat")) return saveGeo(doc["lat"].as<double>(), doc["lon"].as<double>(), doc["geo"] | "");
if (doc.containsKey("toffset")) return saveTempOffset(doc["toffset"].as<float>());
if (doc.containsKey("altoffset")) return saveAltitudeOffset(doc["altoffset"].as<float>());
Expand All @@ -278,6 +301,7 @@ bool ConfigApp::save(const char *json) {
if (act.equals("ist")) return ifxdbEnable(doc["ienb"].as<bool>());
if (act.equals("dst")) return debugEnable(doc["denb"].as<bool>());
if (act.equals("i2c")) return saveI2COnly(doc["i2conly"].as<bool>());
if (act.equals("pst")) return paxEnable(doc["penb"].as<bool>());
if (act.equals("rbt")) reboot();
if (act.equals("cls")) clear();
if (act.equals("clb")) performCO2Calibration();
Expand Down Expand Up @@ -326,6 +350,10 @@ bool ConfigApp::isWifiEnable() {
return wifi_enable;
}

bool ConfigApp::isPaxEnable() {
return pax_enable;
}

bool ConfigApp::isIfxEnable() {
return ifxdb_enable;
}
Expand Down
8 changes: 8 additions & 0 deletions lib/configlib/ConfigApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class ConfigApp {

bool saveSensorType(int type);

bool saveSSID(String ssid);

bool saveWifi(String ssid, String pass);

bool saveInfluxDb(String db, String ip, int pt);
Expand All @@ -66,10 +68,14 @@ class ConfigApp {
bool ifxdbEnable(bool enable);

bool debugEnable(bool enable);

bool paxEnable(bool enable);

String getCurrentConfig();

bool isWifiEnable();

bool isPaxEnable();

bool isIfxEnable();

Expand Down Expand Up @@ -112,6 +118,8 @@ class ConfigApp {
bool wifi_enable;
///InfluxDB cloud publication on/off
bool ifxdb_enable;
/// PaxCounter on/off
bool pax_enable = true;
///WiFi state
bool wifi_connected;

Expand Down
12 changes: 11 additions & 1 deletion lib/gui-utils-oled/src/GUIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void guiTask(void* pvParameters) {
gui.displayMainValues();
gui.displayGUIStatusFlags();
gui.pageEnd();
// batteryloop(); // battery charge status (deprecated)
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
Expand Down Expand Up @@ -53,6 +54,10 @@ void GUIUtils::displayInit() {
this->u8g2 = u8g2;
dw = u8g2.getDisplayWidth();
dh = u8g2.getDisplayHeight();

// init battery (only for some boards)
// batteryInit();

Serial.println("-->[OGUI] display config ready.");
}

Expand Down Expand Up @@ -390,7 +395,7 @@ void GUIUtils::displayMainValues() {
}

// TODO: separate this function, format/display
void GUIUtils::setSensorData(int mainValue, int chargeLevel, float humi, float temp, int rssi, int deviceType) {
void GUIUtils::setSensorData(int mainValue, float humi, float temp, int rssi, int deviceType) {
suspendTaskGUI();
_deviceType = deviceType;
_humi = humi;
Expand Down Expand Up @@ -485,6 +490,10 @@ void GUIUtils::setWifiMode(bool enable){

}

void GUIUtils::setPaxMode(bool enable){

}

void GUIUtils::setSampleTime(int time){

}
Expand All @@ -494,6 +503,7 @@ void GUIUtils::setTrackValues(float speed, float distance){
}

void GUIUtils::setTrackTime(int h, int m, int s){

}

void GUIUtils::suspendTaskGUI(){
Expand Down
8 changes: 6 additions & 2 deletions lib/gui-utils-oled/src/GUIUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <U8g2lib.h>
#include "hal.hpp"
#include "battery.hpp"

class GUIUserPreferencesCallbacks;
class GUIUtils {
Expand Down Expand Up @@ -41,7 +42,7 @@ class GUIUtils {

void clearScreen();

void setSensorData(int mainValue, int chargeLevel, float humi, float temp, int rssi, int deviceType);
void setSensorData(int mainValue, float humi, float temp, int rssi, int deviceType);

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

Expand All @@ -51,6 +52,8 @@ class GUIUtils {

void setWifiMode(bool enable);

void setPaxMode(bool enable);

void setSampleTime(int time);

void setTrackValues(float speed, float distance);
Expand Down Expand Up @@ -123,7 +126,8 @@ class GUIUserPreferencesCallbacks {
public:
virtual ~GUIUserPreferencesCallbacks () {};
virtual void onWifiMode(bool enable);
virtual void onBrightness(int value);
virtual void onPaxMode(bool enable);
virtual void onBrightness(int value);
virtual void onColorsInverted(bool enable);
virtual void onSampleTime(int time);
virtual void onCalibrationReady();
Expand Down
File renamed without changes.
File renamed without changes.
27 changes: 22 additions & 5 deletions lib/gui-utils-tft/src/TFTUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,31 @@ void TFTUtils::setWifiMode(bool enable){
updateWifiMode();
}

void TFTUtils::notifyWifiMode(){
_wifi_enable = !_wifi_enable;
void TFTUtils::setPaxMode(bool enable){
_pax_enable = enable;
updateWifiMode();
}

void TFTUtils::notifyWifiMode(){
if(_wifi_enable && !_pax_enable) {
_wifi_enable = !_wifi_enable;
_pax_enable = !_pax_enable;
}
else if (_pax_enable) _pax_enable = !_pax_enable;
else _wifi_enable = !_wifi_enable;
if(mGUICallBacks != nullptr) getInstance()->mGUICallBacks->onWifiMode(_wifi_enable);
if(mGUICallBacks != nullptr) getInstance()->mGUICallBacks->onPaxMode(_pax_enable);
updateWifiMode();
}

void TFTUtils::updateWifiMode(){
if (state < 1) return;
tft.fillRect(MARVALL, SSTART+PRESETH*2, 54, 13, TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setCursor(MARVALL, SSTART+PRESETH*2, 2);
if(_wifi_enable) tft.println("On");
else tft.println("PAX");
else if (_pax_enable) tft.println("PAX");
else tft.println("Off");
}

void TFTUtils::notifySampleTime(){
Expand Down Expand Up @@ -528,7 +541,7 @@ void TFTUtils::displayMainValues(){
}

// TODO: separate this function, format/display
void TFTUtils::setSensorData(int mainValue, int chargeLevel, float humi, float temp, int rssi, int deviceType) {
void TFTUtils::setSensorData(int mainValue, float humi, float temp, int rssi, int deviceType) {
suspendTaskGUI();
_deviceType = deviceType;
_humi = humi;
Expand Down Expand Up @@ -575,7 +588,7 @@ void TFTUtils::displayGUIStatusFlags() {

if (sensorLive) drawFanIcon();
if (dataOn) drawDataIcon();
// if (preferenceSave);
if (preferenceSave) drawPreferenceSaveIcon();

if (dataOn) dataOn = false; // reset trigger for publish data ok.
if (preferenceSave) preferenceSave = false; // reset trigger for save preference ok.
Expand Down Expand Up @@ -675,6 +688,10 @@ void TFTUtils::drawDataIcon () {
tft.drawBitmap(96, 1, iconArrows, 12, 16, TFT_BLACK, TFT_WHITE);
}

void TFTUtils::drawPreferenceSaveIcon () {
tft.drawBitmap(83, 1, iconSave, 12, 16, TFT_BLACK, TFT_GREEN);
}

void TFTUtils::pageStart() {
// fast interactions (80ms)
checkButtons();
Expand Down
Loading

0 comments on commit 79c9ee2

Please sign in to comment.