Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
bf05230
build: Update version
jgauchia Jun 1, 2025
07a7f0e
build: Change ESP core debug level
jgauchia Jun 1, 2025
cb12498
fix(gps): Fix issue #294
jgauchia Jun 1, 2025
82170db
feat(map): Enable button map in map screen
jgauchia Jun 1, 2025
6b4d96f
feat(maps): Chang map from LovyanGfx to LVGL Canvas
jgauchia Jun 1, 2025
6d8fead
fix(map): Fix map toolbar icons
jgauchia Jun 1, 2025
459a279
feat(map): Change zoom buttons to LVGL images
jgauchia Jun 1, 2025
5d268d6
fix(gfx): Fix option toolbar
jgauchia Jun 1, 2025
4cdc69d
fix(lvgl): Fix button bar after loading a GPX file
jgauchia Jun 7, 2025
be6cdfe
Merge pull request #297 from jgauchia/devel_canvas
jgauchia Jun 7, 2025
4422756
docs: Update screenshots
jgauchia Jun 7, 2025
33bc712
docs: Update screenshots
jgauchia Jun 7, 2025
7a7fede
build(lvgl): Update to 9.3.0
jgauchia Jun 7, 2025
1de8443
build: Enable LVGL monitor and fork library
jgauchia Jun 8, 2025
ef23f39
build: Update Libraries
jgauchia Jun 8, 2025
e076b6f
feat(map): Change navigation arrow to LVGL widget.
jgauchia Jun 8, 2025
c15480a
Merge branch 'devel' into devel_lvgl_9.3
jgauchia Jun 8, 2025
4afe5a8
feat(map): Change zoom label to LVGL widget
jgauchia Jun 8, 2025
93a433a
fix(zoom): Fix zoom event
jgauchia Jun 8, 2025
dfc9c9c
refactor(zoom): Unify zoom in & out event
jgauchia Jun 9, 2025
e7dd6aa
refactor(map): Refactor map arrow & zoom widgets
jgauchia Jun 9, 2025
636c3b2
fix(widgets): Fix compass screen widgets
jgauchia Jun 9, 2025
2519032
fix(lvgl): Fix lv_conf path buildflag
jgauchia Jun 10, 2025
503cc53
Merge branch 'devel' into devel_lvgl_9.3
jgauchia Jun 10, 2025
ff7d24e
refactor(map): Refactor map speed widget
jgauchia Jun 10, 2025
ec133d0
fix(widget): Set sunset & sunrise default time
jgauchia Jun 10, 2025
4066d19
refactor(map): Refactor compass map widget
jgauchia Jun 10, 2025
290d606
fix(map): Fix compass map rotation
jgauchia Jun 10, 2025
0f64d7a
fix(map): Fix map compass image,
jgauchia Jun 11, 2025
0798d92
refactor(map): Refactor map scale widget
jgauchia Jun 12, 2025
57a3b25
docs: Update screenshots
jgauchia Jun 12, 2025
94beb50
Merge branch 'devel' into devel_lvgl_9.3
jgauchia Jun 12, 2025
77f14e2
build: Disable LVGL perf monitor
jgauchia Jun 12, 2025
7204ac0
Merge pull request #298 from jgauchia/devel_lvgl_9.3
jgauchia Jun 22, 2025
e51d033
feat(nav): Add turn-by-turn navigation widget
jgauchia Jun 22, 2025
855ca5f
feat(nav): Get turn points from GPX track file
jgauchia Jun 22, 2025
f567144
fix(nav): Update turn points filtering by minimum angle and distance
jgauchia Jun 22, 2025
22c0f7a
chore: clean code
jgauchia Jun 22, 2025
dc49658
fix(nav): Update navigation icons
jgauchia Jun 24, 2025
8bca9da
test(nav): Add navigation functions
jgauchia Jun 24, 2025
5278c44
style: Fix indent and add functions definitions (brief)
jgauchia Jun 25, 2025
8819003
Merge from devel
jgauchia Jun 25, 2025
eefb4ea
fix(nav): Fix logs output for testing
jgauchia Jun 25, 2025
2cd9868
test(nav): First test of navigation
jgauchia Jun 25, 2025
c71c48d
test(nav): Testing navigation widgets
jgauchia Jun 29, 2025
8912b05
test(nav): Increase simulation speed
jgauchia Jun 29, 2025
e728ab0
docs: Fix Doxygen info
jgauchia Jun 29, 2025
e512499
Merge branch 'devel' into turn_by_turn
jgauchia Jun 29, 2025
56ef81c
docs: Fix Doxygen info
jgauchia Jun 29, 2025
684b055
test(nav): Add fake GPS signal from loaded track for simulate navigation
jgauchia Jul 4, 2025
1d90259
docs: Update screenshot
jgauchia Jul 4, 2025
581ac5e
feat(cli); Add CLI custom setting to enable/disable navigation simula…
jgauchia Jul 4, 2025
4fa645e
feat(ui): Add message box dialog
jgauchia Jul 7, 2025
a795546
fix(nav): Add out track image
jgauchia Jul 7, 2025
a6614de
docs: Fix doxygen info
jgauchia Jul 7, 2025
94729e2
perf(math): Add lookup tables for sine and cosine if PSRAM is available
jgauchia Jul 9, 2025
df26932
refactor(lvgl): Refactor LVGL display flush callback
jgauchia Jul 9, 2025
ec35f79
build: Add inline functions
jgauchia Jul 9, 2025
a656759
perf: Math functions optimization
jgauchia Jul 10, 2025
77d8d46
perf: Refactor and Optimize Map functtions
jgauchia Jul 10, 2025
91c0ff7
perf: Migrate GPS coordinate operations from double to float,
jgauchia Jul 11, 2025
906d924
Merge pull request #301 from jgauchia/perf_float
jgauchia Jul 11, 2025
0d3e889
feat(maps): Change vector map generation and render
jgauchia Jul 15, 2025
59f3865
feat: Mass copy script for Map TIles
jgauchia Jul 15, 2025
8b7f343
docs: Update README.md
jgauchia Jul 15, 2025
54be862
fix(script): Fix mass copy script
jgauchia Jul 15, 2025
c00a0ff
Merge pull request #299 from jgauchia/turn_by_turn
jgauchia Jul 15, 2025
6ed5d6a
test(map): Testing new render map functions
jgauchia Jul 21, 2025
e451d5a
chore: clean code and unused functions
jgauchia Jul 21, 2025
46ce18c
test(map): Testing render vector tiles
jgauchia Aug 1, 2025
d09bdb6
fix: Update tools/mass_copy/rsync_copy.sh
jgauchia Aug 1, 2025
6197406
fix: Update tools/mass_copy/rsync_copy.sh
jgauchia Aug 1, 2025
3611189
fix: Update lib/utils/src/gpsMath.cpp
jgauchia Aug 1, 2025
26e07af
fix: Update lib/lvgl/src/lvglFuncs.cpp
jgauchia Aug 1, 2025
3810c8d
refactor: Clean code and obsolete functions
jgauchia Aug 10, 2025
0df27a4
fix(map): Fix polygon borders in vector tiles
jgauchia Aug 10, 2025
8921e50
test: Test map drawing
jgauchia Aug 14, 2025
23da36c
fix: add exhaustive validation for binary tile readers
jgauchia Aug 20, 2025
416242a
fix: use PSRAM for tile buffer when available, fallback to RAM
jgauchia Aug 20, 2025
1d6b15e
perf: improve performance by batching line draw operations
jgauchia Aug 20, 2025
7956dad
fix: allow all draw commands
jgauchia Aug 21, 2025
f6b45f5
feat: Improve polygon border rendering. visual edge adjustment on til…
jgauchia Aug 21, 2025
6cf1173
feat: optimize polygon fill with fillTriangle for triangles
jgauchia Aug 21, 2025
6e5ff5f
chore: Add Vector draw functions to class
jgauchia Sep 6, 2025
7f93eed
refactor(maps): Optimize maps functions (memory, commands...)
jgauchia Sep 6, 2025
09615b8
docs: Update README.md
jgauchia Sep 7, 2025
f62122b
feat(cli): Add fill polygon user setting in CLI
jgauchia Sep 7, 2025
da1c149
Update lib/maps/src/maps.cpp
jgauchia Sep 7, 2025
6e9e609
Update lib/utils/src/gpsMath.hpp
jgauchia Sep 7, 2025
41c7a11
Merge pull request #303 from jgauchia/new_vector
jgauchia Sep 7, 2025
a46f4e6
fix(build): Fix MAKERFABS build
jgauchia Sep 19, 2025
5d54efe
fix(build): Fix ELECROW build
jgauchia Sep 19, 2025
4775585
fix(env); Fix ESP32_N16R4 env
jgauchia Sep 19, 2025
d044ecf
fix(maps): Review and fix the color system and layer priority to disp…
jgauchia Oct 10, 2025
7ab306e
perf(maps): Advanced memory pool for vector maps
jgauchia Oct 10, 2025
415f01f
feat(maps): Unified memory pool for vector maps
jgauchia Oct 11, 2025
f3cb377
chore(maps): Clean code
jgauchia Oct 11, 2025
efa6edd
perf(maps): RAII implementation for automatic memory management in ve…
jgauchia Oct 11, 2025
c34c22d
chore: fix .gitignore
jgauchia Oct 11, 2025
c0904f1
chore(maps): Clean obsolete code
jgauchia Oct 12, 2025
be51b96
perf(maps): Precompute coordinate transformation matrices
jgauchia Oct 12, 2025
901785b
perf(maps): More efficient batch rendering of vector maps
jgauchia Oct 12, 2025
c8ae2d1
fix(maps): Fix Preload tiles
jgauchia Oct 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
assets
tools/*.raw
tools/*.png
features.json
tile_generator.py
tile_viewer.py
59 changes: 22 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ESP32 Based GPS Navigator (LVGL - LovyanGFX).

## Screenshots

|<img src="images/dev/splash.png">|<img src="images/dev/compass.jpg">|<img src="images/dev/rendermap.jpg">|<img src="images/dev/satelliteinfo.jpg">|
|<img src="images/dev/splash.png">|<img src="images/dev/compass.jpg">|<img src="images/dev/mapnav.jpg">|<img src="images/dev/satelliteinfo.jpg">|
|:-:|:-:|:-:|:-:|

<details><summary>See more...</summary>
Expand Down Expand Up @@ -148,43 +148,29 @@ On SD Card map tiles (256x256 PNG Format) should be stored, in these folders str
|__________________ [ 📁 tile X folder (number) ]
|_______________________ 🗺️ tile Y file.png

## SD Vectorized Map File structure
## SD Vectorized Map File structure

Using [OSM_Extract](https://github.com/aresta/OSM_Extract) you can generate binary map files to later create vector maps. Once generated, these files should be saved in the `mymap` folder on the SD card.
Vectorized maps for IceNav can be generated using the Tile-Generator utility, which is available on GitHub at [jgauchia/Tile-Generator](https://github.com/jgauchia/Tile-Generator). This script allows you to convert map data into the required vector tile format compatible with IceNav. Please refer to the Tile-Generator repository for detailed instructions and usage examples on generating and preparing your own vector map files.

The PBF files can be downloaded from the [geofabrik](https://download.geofabrik.de/) website.
[ 📁 VECTMAP ]
|________ [ 📁 zoom folder (number) ]
|__________________ [ 📁 tile X folder (number) ]
|_______________________ 🗺️ tile Y file.bin

The PBF files should be saved in the `pbf` directory. Once saved, you should select the region or boundaries for which the GeoJSON files will be generated.
## Mass Copy Script for Map Tiles

To obtain the boundaries use `osmconvert file.pbf --out-statistics`:
```
lon min: -5.5203154
lon max: 11.7825360
lat min: 35.2703341
lat max: 44.4078541
```

or use [Bboxfinder](http://bboxfinder.com/) website drawing a box on desired area.


For generate GeoJSON files run inside `scripts` directory:
For efficient transfer of millions of map tiles to SD cards or external storage devices, IceNav includes a high-performance mass copy script. This script is optimized for copying large numbers of small files (such as map tiles) and can reduce transfer time from hours to minutes.

```bash
min_lon=123
min_lat=123
max_lon=123
max_lat=123

./pbf_to_geojson.sh $min_lon $min_lat $max_lon $max_lat /pbf/clipped.pbf /maps/test
```
**Key features:**
- ✅ **Optimized for millions of small files** - Much faster than traditional copy methods
- ✅ **Real-time progress monitoring** - See exactly what's being copied
- ✅ **Resumable transfers** - Continue interrupted copies
- ✅ **Built-in integrity verification** - Sample file verification
- ✅ **Performance metrics** - Speed and time statistics

For generate binary map files run inside `scripts` directory.
```bash
./extract_features.py $min_lon $min_lat $max_lon $max_lat /maps/test
```
Once the process is completed, the maps will be inside the `maps/mymap` directory. Copy all folders to the SD card except the `test_imgs` directory into `VECTMAP` folder of the SD Card.
For detailed instructions on how to use the mass copy script, please refer to the [Mass Copy Tools Documentation](tools/mass_copy/README.md).

Please follow the instructions provided by [OSM_Extract](https://github.com/aresta/OSM_Extract) for any further questions.
Download link: [tools/mass_copy/rsync_copy.sh](tools/mass_copy/rsync_copy.sh)

## Firmware install

Expand Down Expand Up @@ -244,7 +230,7 @@ Please follow the instructions provided by [OSM_Extract](https://github.com/ares

## CLI

IceNav has a basic CLI accessible via Serial and optionally via Telnet if enabled. When you access the CLI and type `help`, you should see the following commands:
IceNav has a basic CLI accessible via Serial and optionally via Telnet if enabled (port 11000). When you access the CLI and type `help`, you should see the following commands:

```bash
clear: clear shell
Expand All @@ -268,12 +254,13 @@ Some extra details:
KEYNAME DEFINED VALUE
======= ======= =====
defZoom custom 17 Default zoom
fullScrMap custom true Fullscreen map
vectMap custom false Vectorized map
mapSpeed custom true Show speed meter in map
mapScale custom true Show scale meter in map
mapComp custom true Show compass in map
mapCompRot custom true Rotate map with the compass
simNav custom false Indicates whether navigation simulation mode is enabled or disabled
fillPoly custom true Fill polygons in vectorized map
gpsTX custom 43 GPS Tx gpio
gpsRX custom 44 GPS Rx gpio
defLAT custom 52.5200 Default latitude
Expand Down Expand Up @@ -338,8 +325,8 @@ To access the Web File Server, simply use any browser and go to the following ad
- [ ] Multiple IMU's and Compass module implementation
- [X] Power saving
- [X] Vector maps
- [ ] Google Maps navigation style (turn by turn)
- [x] Optimize code
- [X] Google Maps navigation style (turn by turn)
- [X] Optimize code
- [X] Fix bugs!
- [X] Web file server

Expand All @@ -360,8 +347,6 @@ To access the Web File Server, simply use any browser and go to the following ad
* Improved auto mainScreen selection from env variable preset thanks to [@hpsaturn](https://github.com/hpsaturn)
* Improved getLat getLon from environment variables thanks to [@hpsaturn](https://github.com/hpsaturn)
* 3DPrint case for an ESP32S3 Makerfabs Parallel board thanks to [@hpsaturn](https://github.com/hpsaturn)
* Vectorial Maps routines [ESP32_GPS](https://github.com/aresta/ESP32_GPS) thanks to [@aresta](https://github.com/aresta)
* 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)
Expand Down
Binary file removed data/TODO.png
Binary file not shown.
Binary file added data/mapspeed.bin
Binary file not shown.
Binary file added data/navarrow.bin
Binary file not shown.
Binary file added data/zoom.bin
Binary file not shown.
Binary file added data/zoomin.bin
Binary file not shown.
Binary file added data/zoomout.bin
Binary file not shown.
Binary file added images/dev/mapnav.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 modified images/dev/mapsettings.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 modified images/dev/rendermap.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 modified images/dev/vectormap.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 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 ([email protected])
* @brief Boards Pin definitions
* @version 0.2.2
* @date 2025-05
* @version 0.2.3
* @date 2025-06
*/

#pragma once
Expand Down Expand Up @@ -122,7 +122,7 @@
extern const uint8_t TCH_I2C_PORT = 0;
extern const uint8_t TCH_I2C_SDA = GPIO_NUM_38;
extern const uint8_t TCH_I2C_SCL = GPIO_NUM_39;
extern const uint8_t TCH_I2C_INT = GPIO_NUM_40;
extern const uint8_t TCH_I2C_INT = -1;

extern const uint8_t SD_CS = GPIO_NUM_4;
extern const uint8_t SD_MISO = GPIO_NUM_19;
Expand Down
88 changes: 47 additions & 41 deletions lib/battery/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,88 @@
* @file battery.cpp
* @author Jordi Gauchía ([email protected])
* @brief Battery monitor definition and functions
* @version 0.2.2
* @date 2025-05
* @version 0.2.3
* @date 2025-06
*/


#include "battery.hpp"

/**
* @brief Battery Class constructor
*
* @brief Constructs a Battery monitoring object for voltage measurement and percentage calculation.
*/
Battery::Battery() {}

/**
* @brief Configure ADC Channel for battery reading
* @brief Initializes the ADC channel(s) required for battery voltage measurement.
*
* @details Configures the hardware ADC based on the ESP32 chip (ADC1 or ADC2).
*/
void Battery::initADC()
{
#ifdef ADC1
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(BATT_PIN, ADC_ATTEN_DB_12);
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(BATT_PIN, ADC_ATTEN_DB_12);
#endif

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

/**
* @brief Set battery voltage levels
* @brief Sets the maximum and minimum voltage levels for battery charge calculation.
*
* @param maxVoltage -> Full Charge voltage
* @param minVoltage -> Min Charge voltage
* @param maxVoltage Voltage considered as fully charged.
* @param minVoltage Voltage considered as minimum safe level.
*/
void Battery::setBatteryLevels(float maxVoltage, float minVoltage)
{
batteryMax = maxVoltage;
batteryMin = minVoltage;
batteryMax = maxVoltage;
batteryMin = minVoltage;
}

/**
* @brief Read battery charge and return %.
* @brief Reads and computes the current battery charge as a percentage.
*
* @details Takes 100 ADC samples, averages them, compensates for the voltage divider, and calculates the charge percentage.
* Returns a value between 0 and 100 (values above 160 are treated as 0).
*
* @return float -> % Charge
* @return float Percentage of battery charge (0–100% typically).
*/
float Battery::readBattery()
{
long sum = 0; // Sum of samples taken
float voltage = 0.0; // Calculated voltage
float output = 0.0; // Output value
int32_t sum = 0; /**< Accumulator for ADC samples. */
constexpr int samples = 100; /**< Number of ADC samples. */
constexpr float invSamples = 1.0f / samples; /**< Precomputed inverse for averaging. */

/**< Collect ADC samples */
for (int i = 0; i < samples; ++i)
{
#ifdef ADC1
sum += static_cast<int32_t>(adc1_get_raw(BATT_PIN));
#endif

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

ets_delay_us(100); /**< Slightly reduced delay for better responsiveness. */
}

for (int i = 0; i < 100; i++)
{
#ifdef ADC1
sum += static_cast<long>(adc1_get_raw(BATT_PIN));
#endif
/**< Convert ADC value to voltage */
float voltage = (sum * invSamples) * (V_REF / 4096.0f); /**< Averaged and scaled ADC voltage. */

#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
/**< Compensate for voltage divider (R1 = R2 = 100kΩ) */
voltage *= 2.0f;

delayMicroseconds(150);
}
/**< Round to 2 decimal places */
voltage = roundf(voltage * 100.0f) * 0.01f;

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;
/**< Calculate battery percentage */
float output = ((voltage - batteryMin) / (batteryMax - batteryMin)) * 100.0f;

output = ((voltage - batteryMin) / (batteryMax - batteryMin)) * 100;
return (output <= 160) ? output : 0.0f;
/**< Clamp out-of-range values */
return (output <= 160.0f) ? output : 0.0f;
}
25 changes: 16 additions & 9 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 ([email protected])
* @brief Battery monitor definition and functions
* @version 0.2.2
* @date 2025-05
* @version 0.2.3
* @date 2025-06
*/

#pragma once
Expand All @@ -12,17 +12,24 @@
#include <driver/adc.h>
#include <esp_adc_cal.h>


/**
* @class Battery
* @brief Provides battery voltage monitoring and charge estimation.
*
* @details Handles ADC initialization, voltage range configuration, and computes battery charge percentage.
*/
class Battery
{
private:
float batteryMax;
float batteryMin;
static constexpr float V_REF = 3.9; // ADC reference voltage
float batteryMax; /**< Maximum (full charge) voltage. */
float batteryMin; /**< Minimum (empty) voltage. */
static constexpr float V_REF = 3.9; /**< ADC reference voltage. */

public:
Battery();
Battery();

void initADC();
void setBatteryLevels(float maxVoltage, float minVoltage);
float readBattery();
void initADC();
void setBatteryLevels(float maxVoltage, float minVoltage);
float readBattery();
};
15 changes: 6 additions & 9 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 ([email protected])
* @brief BME280 Sensor functions
* @version 0.2.2
* @date 2025-05
* @version 0.2.3
* @date 2025-06
*/

#include "bme.hpp"
Expand All @@ -12,16 +12,13 @@

Adafruit_BME280 bme = Adafruit_BME280();

/**
* @brief Temperature reading values
*
*/
uint8_t tempValue = 0;
uint8_t tempOld = 0;
uint8_t tempValue = 0; /**< Stores the current temperature value from the BME280 sensor. */
uint8_t tempOld = 0; /**< Stores the previous temperature value for comparison. */

/**
* @brief Init BME sensor
* @brief Initializes the BME280 sensor and sets up I2C communication.
*
* @details Optionally allows advanced configuration for oversampling and filtering.
*/
void initBME()
{
Expand Down
17 changes: 6 additions & 11 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 ([email protected])
* @brief BME280 Sensor functions
* @version 0.2.2
* @date 2025-05
* @version 0.2.3
* @date 2025-06
*/

#pragma once
Expand All @@ -15,15 +15,10 @@
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

/**
* @brief BME280 Address
*
*/
#define BME_ADDRESS 0x76

extern Adafruit_BME280 bme;
extern uint8_t tempValue;
extern uint8_t tempOld;
#define BME_ADDRESS 0x76 /**< I2C address for the BME280 sensor (default: 0x76). */
extern Adafruit_BME280 bme; /**< Global instance of the BME280 sensor driver. */
extern uint8_t tempValue; /**< Stores the latest temperature reading from the BME280 sensor. */
extern uint8_t tempOld; /**< Stores the previous temperature value to detect changes. */

void initBME();

Expand Down
Loading