Skip to content

Commit

Permalink
Merge pull request #255 from jgauchia/devel
Browse files Browse the repository at this point in the history
0.1.9 Release
  • Loading branch information
jgauchia authored Dec 11, 2024
2 parents a2af2a5 + 1bf0a32 commit 769fa25
Show file tree
Hide file tree
Showing 96 changed files with 1,384 additions and 734 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ESP32 Based GPS Navigator (LVGL - LovyanGFX).
|:-:|:-:|:-:|
| Add Waypoint | Add Waypoint (landscape) | Waypoint List |

|<img src="images/dev/settings.jpg">|<img src="images/dev/compasscal.jpg">|<img src="images/dev/touchcal.jpg">|<img src="images/dev/mapsettings.jpg">|<img src="images/dev/devicesettings.jpg">|
|<img src="images/dev/settings.jpg">|<img src="images/dev/compasscal.jpg">|<img src="images/dev/touchcal.jpg">|<img src="images/dev/mapsettings.jpg">|<img src="images/dev/devicesettings.png">|
|:-:|:-:|:-:|:-:|:-:|
| Settings | Compass Calibration | Touch Calibration | Map Settings | Device Settings |

Expand Down Expand Up @@ -84,8 +84,6 @@ If the board has a BOOT button (GPIO0) it is possible to use power saving functi
To do this, simply include the following Build Flag in the required env in platformio.ini

```-DPOWER_SAVE``` <br>
```-DARDUINO_RUNNING_CORE=1``` <br>
```-DARDUINO_EVENT_RUNNING_CORE=1``` <br>

> [!IMPORTANT]
> Currently, this project can run on any board with an ESP32S3 and at least a 320x480 TFT screen. The idea is to support all existing boards on the market that I can get to work, so if you don't want to use the specific IceNav board, please feel free to create an issue, and I will look into providing support.
Expand All @@ -107,10 +105,10 @@ To do this, simply include the following Build Flag in the required env in platf
|:------------|:--------------|:-----------------------------------|:-------------------------------------------------------|
| | 🔋 Batt. Monitor | ```-DADC1``` or ```-DADC2``` <br> ```-DBATT_PIN=ADCn_CHANNEL_x``` | |
| AT6558D | 🛰️ GPS | ```-DAT6558D_GPS``` | |
| HMC5883L | 🧭 Compass | ```-DHMC5883L``` | ```dfrobot/DFRobot_QMC5883@^1.0.0``` |
| QMC5883 | 🧭 Compass | ```-DQMC5883``` | ```dfrobot/DFRobot_QMC5883@^1.0.0``` |
| MPU9250 | 🧭 IMU (Compass) | ```-DIMU_MPU9250``` | ```bolderflight/Bolder Flight Systems MPU9250@^1.0.2```|
| BME280 | 🌡️ Temp <br> ☁️ Pres <br> 💧 Hum | ```-DBME280``` | ```adafruit/Adafruit Unified Sensor@^1.1.14``` <br> ```adafruit/Adafruit BusIO@^1.16.1``` <br> ```adafruit/Adafruit BME280 Library@^2.2.4```|
| HMC5883L | 🧭 Compass | ```-DHMC5883L``` | ```dfrobot/DFRobot_QMC5883@1.0.0``` |
| QMC5883 | 🧭 Compass | ```-DQMC5883``` | ```dfrobot/DFRobot_QMC5883@1.0.0``` |
| MPU9250 | 🧭 IMU (Compass) | ```-DIMU_MPU9250``` | ```bolderflight/Bolder Flight Systems MPU9250@1.0.2```|
| BME280 | 🌡️ Temp <br> ☁️ Pres <br> 💧 Hum | ```-DBME280``` | ```adafruit/Adafruit Unified Sensor@1.1.14``` <br> ```adafruit/Adafruit BusIO@1.16.2``` <br> ```adafruit/Adafruit BME280 Library@2.2.4```|

[^1]: For ELECROW board UART port is shared with USB connection, GPS pinout are mapped to IO19 and IO40 (Analog and Digital Port). If CLI isn't used is possible to attach GPS module to UART port but for upload the firmware (change pinout at **hal.hpp**), the module should be disconnected.
[^2]: See **hal.hpp** for pinouts configuration
Expand Down Expand Up @@ -210,6 +208,8 @@ Please follow the instructions provided by [OSM_Extract](https://github.com/ares
> pio run --target uploadfs
> ```
> [!TIP]
> Optional, firmware upgrade is possible from SD Card, please see [PR #259](https://github.com/jgauchia/IceNav-v3/pull/259) for detailed instructions
> [!TIP]
> Optional, for map debugging with specific coordinates, or when you are in indoors, you are able to set the defaults coordinates, on two ways:
Expand Down Expand Up @@ -248,7 +248,7 @@ outnmea: toggle GPS NMEA output (or Ctrl+C to stop)
poweroff: perform a ESP32 deep sleep
reboot: perform a ESP32 reboot
scshot: screenshot to SD or sending a PC
settings: device settings
setdstzone: set DST (Daylight Saving Time zone: NONE, EU or USA)
waypoint: waypoint utilities
webfile: enable/disable Web file server
wipe: wipe preferences to factory default
Expand All @@ -270,6 +270,7 @@ Some extra details:
VmaxBatt custom
VminBatt custom
tempOffs custom
defGMT custom
```
**kset KEYNAME**: Set user custom settings:
Expand Down Expand Up @@ -300,8 +301,6 @@ nc -l -p 8123 > screenshot.png
Additionally, you can download the screenshot with webfile server.
**settings**: Device settings type `settings` for detailed options.
**waypoint**: type `waypoint` for detailed options.
Additionally, this waypoint command can send the waypoint over WiFi using the following syntax (replace IP with your PC IP):
Expand Down Expand Up @@ -338,7 +337,7 @@ To access the Web File Server, simply use any browser and go to the following ad
- [X] Vector maps
- [ ] Google Maps navigation style
- [x] Optimize code
- [ ] Fix bugs!
- [X] Fix bugs!
- [X] Web file server
Expand All @@ -362,10 +361,11 @@ To access the Web File Server, simply use any browser and go to the following ad
* OSM to binary vectorial maps [OSM_Extract](https://github.com/aresta/OSM_Extract) thanks to [@aresta](https://github.com/aresta)
* Preferences Library [Easy Preferences](https://github.com/hpsaturn/easy-preferences) thanks to [@hpsaturn](https://github.com/hpsaturn)
* Wifi CLI manager [esp32-wifi-cli](https://github.com/hpsaturn/esp32-wifi-cli) thanks to [@hpsaturn](https://github.com/hpsaturn)
* Web file server based in [@smford](https://github.com/smford) [esp32-asyncwebserver-fileupload-example ](https://github.com/smford/esp32-asyncwebserver-fileupload-example)
* Web file server based in [@smford](https://github.com/smford) [esp32-asyncwebserver-fileupload-example](https://github.com/smford/esp32-asyncwebserver-fileupload-example)
* Solar sunset and sunrise [SolarCalculator](https://github.com/jpb10/SolarCalculator) thanks to [@jpb10](https://github.com/jpb10)
---
Map data is available thanks to the great OpenStreetMap project and contributors. The map data is available under the Open Database License.
© OpenStreetMap contributors
[© OpenStreetMap contributors](https://www.openstreetmap.org/copyright)
4 changes: 1 addition & 3 deletions boards/elecrow-esp32-s3-n16r8v-terminal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
"-DARDUINO_USB_MODE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
Expand Down
2 changes: 0 additions & 2 deletions boards/icenav-esp32-s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1",
"-DPOWER_SAVE",
"-DADC2",
"-DBATT_PIN=ADC2_CHANNEL_6",
Expand Down
Binary file added data/sunrise.bin
Binary file not shown.
Binary file added data/sunset.bin
Binary file not shown.
Binary file modified images/dev/compass.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 removed images/dev/devicesettings.jpg
Binary file not shown.
Binary file added images/dev/devicesettings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions include/hal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file hal.hpp
* @author Jordi Gauchía (jgauchia@gmx.es)
* @brief Boards Pin definitions
* @version 0.1.8
* @date 2024-11
* @version 0.1.9
* @date 2024-12
*/

#ifndef HAL_HPP
Expand Down
102 changes: 50 additions & 52 deletions lib/battery/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,78 @@
* @file battery.cpp
* @author Jordi Gauchía (jgauchia@gmx.es)
* @brief Battery monitor definition and functions
* @version 0.1.8
* @date 2024-11
* @version 0.1.9
* @date 2024-12
*/


#include "battery.hpp"

/**
* @brief Battery values
*
*/
uint8_t battLevel = 0;
uint8_t battLevelOld = 0;
float batteryMax = 4.2; // maximum voltage of battery
float batteryMin = 3.6; // minimum voltage of battery before shutdown
Battery::Battery() {}

/**
* @brief Configure ADC Channel for battery reading
*
*/
void initADC()
void Battery::initADC()
{
// When VDD_A is 3.3V:
// 0dB attenuation (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
// 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
// 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
// 12dB attenuation (ADC_ATTEN_DB_12) gives full-scale voltage 3.9V

#ifdef ADC1
#ifdef ADC1
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(BATT_PIN, ADC_ATTEN_DB_12);
#endif
adc1_config_channel_atten(BATT_PIN, ADC_ATTEN_DB_12);
#endif

#ifdef ADC2
#ifdef ADC2
adc2_config_channel_atten(BATT_PIN, ADC_ATTEN_DB_12);
#endif
#endif
}

/**
* @brief Set battery voltage levels
*
* @param maxVoltage -> Full Charge voltage
* @param minVoltage -> Min Charge voltage
*/
void Battery::setBatteryLevels(float maxVoltage, float minVoltage)
{
batteryMax = maxVoltage;
batteryMin = minVoltage;
}

/**
* @brief Read battery charge and return %
* @brief Read battery charge and return %.
*
* @return float -> % Charge
*/
float batteryRead()
float Battery::readBattery()
{
long sum = 0; // sum of samples taken
float voltage = 0.0; // calculated voltage
float output = 0.0; // output value
for (int i = 0; i < 100; i++)
{
long sum = 0; // Sum of samples taken
float voltage = 0.0; // Calculated voltage
float output = 0.0; // Output value

for (int i = 0; i < 100; i++)
{
#ifdef ADC1
sum += static_cast<long>(adc1_get_raw(BATT_PIN));
#endif

#ifdef ADC2
int readRaw;
esp_err_t r = adc2_get_raw(BATT_PIN, ADC_WIDTH_BIT_12, &readRaw);
if (r == ESP_OK)
sum += static_cast<long>(readRaw);
#endif

#ifdef ADC1
sum += (long)adc1_get_raw(BATT_PIN);
#endif
delayMicroseconds(150);
}

#ifdef ADC2
int readRaw;
esp_err_t r = adc2_get_raw(BATT_PIN, ADC_WIDTH_BIT_12, &readRaw);
if (r == ESP_OK)
sum += (long)readRaw;
#endif
voltage = sum / 100.0;
// Custom board has a divider circuit
constexpr float R1 = 100000.0; // Resistance of R1 (100K)
constexpr float R2 = 100000.0; // Resistance of R2 (100K)
voltage = (voltage * V_REF) / 4096.0;
voltage = voltage / (R2 / (R1 + R2));
voltage = roundf(voltage * 100) / 100;

delayMicroseconds(150);
}
voltage = sum / (float)100;
// custom board has a divider circuit
float R1 = 100000.0; // resistance of R1 (100K)
float R2 = 100000.0; // resistance of R2 (100K)
voltage = (voltage * V_REF) / 4096.0;
voltage = voltage / (R2 / (R1 + R2));
voltage = roundf(voltage * 100) / 100;
output = ((voltage - batteryMin) / (batteryMax - batteryMin)) * 100;
if (output <= 160)
return output;
else
return 0.0f;
output = ((voltage - batteryMin) / (batteryMax - batteryMin)) * 100;
return (output <= 160) ? output : 0.0f;
}
25 changes: 14 additions & 11 deletions lib/battery/battery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file battery.hpp
* @author Jordi Gauchía (jgauchia@gmx.es)
* @brief Battery monitor definition and functions
* @version 0.1.8
* @date 2024-11
* @version 0.1.9
* @date 2024-12
*/

#ifndef BATTERY_HPP
Expand All @@ -13,16 +13,19 @@
#include <driver/adc.h>
#include <esp_adc_cal.h>

static esp_adc_cal_characteristics_t characteristics;
#define V_REF 3.9 // ADC reference voltage
class Battery
{
private:
float batteryMax;
float batteryMin;
static constexpr float V_REF = 3.9; // ADC reference voltage

extern float batteryMax; // 4.2; // maximum voltage of battery
extern float batteryMin; // 3.6; // minimum voltage of battery before shutdown
public:
Battery();

extern uint8_t battLevel;
extern uint8_t battLevelOld;

void initADC();
float batteryRead();
void initADC();
void setBatteryLevels(float maxVoltage, float minVoltage);
float readBattery();
};

#endif
4 changes: 2 additions & 2 deletions lib/bme/bme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file bme.cpp
* @author Jordi Gauchía (jgauchia@gmx.es)
* @brief BME280 Sensor functions
* @version 0.1.8
* @date 2024-11
* @version 0.1.9
* @date 2024-12
*/

#include "bme.hpp"
Expand Down
4 changes: 2 additions & 2 deletions lib/bme/bme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file bme.hpp
* @author Jordi Gauchía (jgauchia@gmx.es)
* @brief BME280 Sensor functions
* @version 0.1.8
* @date 2024-11
* @version 0.1.9
* @date 2024-12
*/

#ifndef BME_HPP
Expand Down
Loading

0 comments on commit 769fa25

Please sign in to comment.