-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from kike-canaries/devel
solar station mode feature
- Loading branch information
Showing
33 changed files
with
399 additions
and
114 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# These are supported funding model platforms | ||
github: hpsaturn | ||
liberapay: CanAirIO | ||
github: hpsaturn | ||
|
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 |
---|---|---|
@@ -1,36 +1,27 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
about: Create a report to help us improve. Thanks to contribute. | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
Thanks for help up and contribute to CanAirIO project. Please edit and fill this template. We recommend at less fill the description. | ||
|
||
## Description | ||
|
||
|
||
## To reproduce | ||
## Overview | ||
|
||
|
||
## Debug output | ||
|
||
|
||
## Device config | ||
|
||
If apply, please write the next information, you can have it on the settings section `Device info` on the CanAirIO app. | ||
**If apply**, please write the next information, you can have it on the settings section `Device info` on the CanAirIO app. | ||
|
||
``` | ||
board: please choose any TTGO T7, TTGO T-Display, ESP32DevKit, WemosOLED, etc | ||
firmware version: revxxx | ||
mobile app version: revxxx | ||
sensors: (sensors references and type connection) | ||
OLED: yes/no | ||
TFT: yes/no | ||
Power: Battery/USB | ||
``` | ||
|
||
## Additional context | ||
|
||
|
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 |
---|---|---|
|
@@ -7,5 +7,5 @@ assignees: '' | |
|
||
--- | ||
|
||
**Summary.** | ||
## Summary | ||
|
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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
## Description | ||
|
||
*Replace this paragraph with a description of what this PR is doing. If you're modifying existing behavior, describe the existing behavior, how this PR is changing it, and what motivated the change. If you're changing visual properties, consider including before/after screenshots (and runnable code snippets to reproduce them).* | ||
*Replace this paragraph with a description of what this PR is doing.* | ||
|
||
## Related Issues | ||
|
||
*Replace this paragraph with a list of issues related to this PR from our [issue database]. Indicate, which of these issues are resolved or fixed by this PR. There should be at least one issue listed here.* | ||
*Replace this paragraph with a list of issues related to this PR from our [issue database].* | ||
|
||
## Tests | ||
|
||
I added the following tests: | ||
|
||
*Replace this with a list of the tests that you added as part of this PR. |
Binary file not shown.
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
Binary file not shown.
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
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,14 @@ | ||
#include <driver/rtc_io.h> | ||
#include <esp_bt.h> | ||
#include <esp_bt_main.h> | ||
#include <esp_wifi.h> | ||
|
||
#include <Batterylib.hpp> | ||
|
||
void powerDeepSleepButton(); | ||
void powerDeepSleepTimer(int); | ||
void powerLightSleepTimer(int); | ||
void powerEnableSensors(); | ||
void powerDisableSensors(); | ||
void powerLoop(); | ||
void powerInit(); |
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
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 |
---|---|---|
|
@@ -8,8 +8,6 @@ class BatteryUpdateCallbacks { | |
|
||
class Battery { | ||
public: | ||
|
||
int vref = 1100; | ||
float curv = 0.0; | ||
bool debug; | ||
|
||
|
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 |
---|---|---|
@@ -1,35 +1,69 @@ | ||
#include <battery_oled.hpp> | ||
|
||
#ifndef M5STICKCPLUS | ||
#ifndef TTGO_TDISPLAY | ||
void Battery_OLED::setupBattADC() { | ||
esp_adc_cal_characteristics_t adc_chars; | ||
esp_adc_cal_value_t val_type = esp_adc_cal_characterize((adc_unit_t)ADC_UNIT_1, (adc_atten_t)ADC1_CHANNEL_6, (adc_bits_width_t)ADC_WIDTH_BIT_12, 1100, &adc_chars); | ||
// Check type of calibration value used to characterize ADC | ||
if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) { | ||
Serial.printf("-->[BATT] ADC eFuse Vref:%u mV\n", adc_chars.vref); | ||
vref = adc_chars.vref; | ||
} else if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) { | ||
Serial.printf("-->[BATT] ADC Two Point --> coeff_a:%umV coeff_b:%umV\n", adc_chars.coeff_a, adc_chars.coeff_b); | ||
} else { | ||
Serial.printf("-->[BATT] ADC Default Vref: %u mV\n", vref); | ||
} | ||
} | ||
|
||
void Battery_OLED::init(bool debug) { | ||
this->debug = debug; | ||
/* | ||
ADC_EN is the ADC detection enable port | ||
If the USB port is used for power supply, it is turned on by default. | ||
If it is powered by battery, it needs to be set to high level | ||
*/ | ||
pinMode(ADC_EN, OUTPUT); | ||
digitalWrite(ADC_EN, HIGH); | ||
delay(10); // suggested by @ygator user in issue #2 | ||
setupBattADC(); | ||
delay(10); // suggested by @ygator user in issue #2 | ||
} | ||
|
||
float Battery_OLED::getVoltage() { | ||
return 0; | ||
return curv; | ||
} | ||
|
||
bool Battery_OLED::isCharging() { | ||
return false; | ||
return curv > BATTERY_MAX_V + (BATTCHARG_MIN_V - BATTERY_MAX_V) / 2; | ||
} | ||
|
||
void Battery_OLED::printValues() { | ||
void Battery_OLED::printValues() { | ||
if (!debug) return; | ||
Serial.printf("-->[BATT] Battery voltage \t: %.3fv vref: %i Charge:%i\n", curv, vref, getCharge()); // Output voltage and current of Bat | ||
} | ||
|
||
void Battery_OLED::update() { | ||
void Battery_OLED::update() { | ||
digitalWrite(ADC_EN, HIGH); | ||
delay(10); // suggested by @ygator user in issue #2 | ||
uint16_t v = analogRead(ADC_PIN); | ||
curv = ((float)v / 4095.0) * 15.83; | ||
digitalWrite(ADC_EN, LOW); // for possible issue: https://github.com/Xinyuan-LilyGO/TTGO-T-Display/issues/6 | ||
|
||
} | ||
|
||
int Battery_OLED::getCharge() { | ||
return 0; | ||
if (isCharging()) { | ||
return calcPercentage(curv, BATTCHARG_MAX_V, BATTCHARG_MIN_V); | ||
} else { | ||
return calcPercentage(curv, BATTERY_MAX_V, BATTERY_MIN_V); | ||
} | ||
// return 0; | ||
} | ||
|
||
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_OLEDBATTERY) | ||
Battery_OLED battery; | ||
#endif | ||
|
||
#ifndef M5STICKCPLUS | ||
#ifndef TTGO_TDISPLAY | ||
Battery_OLED battery; | ||
#endif | ||
#endif | ||
|
||
|
||
|
||
#endif |
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
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
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
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
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
Oops, something went wrong.