Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions projects/Main/include/bmp.hpp → T-beam/include/bmp.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
namespace bmp {
// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej
void begin();
void init();

struct Data {
float temperature;
Expand All @@ -11,6 +10,10 @@ struct Data {
float get_as_hpa();
};

inline Data data;

void get_bmp(void* pvParameters);
void print_data(void* pvParameters);
Data measurements();
void pretty_print();
void pretty_print(Data);
} // namespace bmp
4 changes: 4 additions & 0 deletions T-beam/include/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define SDA 21
#define SCL 22
#define BAUD_RATE 115200
#define DEFAULT_TASK_SIZE 10000
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions T-beam/include/memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <EEPROM.h>

#define MEMORY_SIZE 512

namespace memory {

struct Config {
int intValue;
float floatValue;
char stringValue[50];
};

inline Config config;

void init();
void save_config(Config&);
void load_config(Config&);
void print_data();

} // namespace memory
5 changes: 3 additions & 2 deletions projects/Main/platformio.ini → T-beam/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:lolin32_lite]
[env:ttgo-t-beam]
platform = espressif32
board = lolin32_lite
board = ttgo-t-beam
framework = arduino
monitor_speed = 115200
lib_deps = adafruit/Adafruit BMP280 Library@^2.6.8

45 changes: 27 additions & 18 deletions projects/Main/src/bmp.cpp → T-beam/src/bmp.cpp
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
#include "bmp.hpp"
#include "bmp.h"

// korzystanie z Adafruit BMP280 Library by Adafruit
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>

// ciśnienie powietrza na poziomie morza w hPa, altitude
// 1013.25 jest ogólną średnią
// 1019.91 jest wartością lokalną dla Krakowa w momencie pisania tego
// 1019.91 is avg Pressure in Cracow
#define SEALEVELPRESSURE_HPA (1019.91)

Adafruit_BMP280 bmp_obj;
#define CHIP_BME 0x60
#define CHIP_BMP 0x58
#define CHIP_ADDR 0x76

namespace bmp {

// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej
void begin() {
if (!bmp_obj.begin(0x76)) {
Adafruit_BMP280 bmp_obj;

// Requires Wire.begin(SDA_PIN, SCL_PIN)
void init() {
if (!bmp_obj.begin(CHIP_ADDR, CHIP_BME)) {
Serial.println("Viable sensor BMP280 not found, check wiring!");
while (1);
}
}

Data measurements() {
Data check;
// temperatura w Celsjuszach
check.temperature = bmp_obj.readTemperature();
// Ciśnienie w paskalach
check.pressure = bmp_obj.readPressure();
// przybliżona wysokość nad poziomem morza w metrach
check.altitude = bmp_obj.readAltitude(SEALEVELPRESSURE_HPA);
return check;
};

void pretty_print() {
Data exp = measurements();
void get_bmp(void* pvParameters) {
for (;;) {
data = measurements();
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void print_data(void* pvParameters) {
for (;;) {
pretty_print(data);
vTaskDelay(pdMS_TO_TICKS(500));
}
}

void pretty_print(Data data) {
Serial.print("Temperature = ");
Serial.print(exp.temperature);
Serial.print(data.temperature);
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(exp.get_as_hpa());
Serial.print(data.get_as_hpa());
Serial.println(" hPa");

Serial.print("Approx. Altitude = ");
Serial.print(exp.altitude);
Serial.print(data.altitude);
Serial.println(" m");

Serial.println();
Expand Down
17 changes: 9 additions & 8 deletions projects/T-beam/src/gps.cpp → T-beam/src/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ void init() { GPSSerial.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); }
void gps_loop(void* pvParameters) {
String nmea = "";
for (;;) {
if (GPSSerial.available()) {
while (GPSSerial.available()) {
char c = GPSSerial.read();
nmea += c;
} else {
if (nmea != "") {
Serial.println(nmea);
nmea = "";
} else
Serial.println("------------");
vTaskDelay(pdMS_TO_TICKS(100));
}

if (nmea != "") {
Serial.println(nmea);
nmea = "";
} else
Serial.println("------------");
vTaskDelay(pdMS_TO_TICKS(900));

}
}

Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions T-beam/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <Arduino.h>
#include <Wire.h>

#include "bmp.h"
#include "constants.h"
#include "gps.h"
#include "led.h"
#include "memory.h"

void setup() {
Wire.begin(SDA, SCL);
Serial.begin(BAUD_RATE);
Serial.println("--- ROCKET COMPUTER START ---");

memory::init(); // loads config as well
gps::init();
bmp::init();

// xTaskCreate(gps::gps_loop, "gps", DEFAULT_TASK_SIZE, NULL, 1, NULL);
xTaskCreate(led::blink_task, "blink", DEFAULT_TASK_SIZE, NULL, 1, NULL);
xTaskCreate(bmp::get_bmp, "bmp", DEFAULT_TASK_SIZE, NULL, 1, NULL);
xTaskCreate(bmp::print_data, "bmp print", DEFAULT_TASK_SIZE, NULL, 1, NULL);

memory::print_data();
memory::config = memory::Config{222, 456.78, "Hello, EEPROM2!"};
memory::save_config(memory::config);
}

void loop() {}
26 changes: 26 additions & 0 deletions T-beam/src/memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "memory.h"

#define CONFIG_ADDR 0

namespace memory {

void init() {
EEPROM.begin(MEMORY_SIZE);
load_config(config);
}

void save_config(Config& data) {
EEPROM.put(CONFIG_ADDR, data);
EEPROM.commit();
}
void load_config(Config& data) { EEPROM.get(CONFIG_ADDR, data); }

void print_data() {
Serial.print("Read int: ");
Serial.println(config.intValue);
Serial.print("Read float: ");
Serial.println(config.floatValue);
Serial.print("Read string: ");
Serial.println(config.stringValue);
}
} // namespace memory
File renamed without changes.
15 changes: 0 additions & 15 deletions projects/LoRa_Transmitter/.vscode/settings.json

This file was deleted.

15 changes: 0 additions & 15 deletions projects/LoRa_Transmitter/include/LoRa.hpp

This file was deleted.

39 changes: 0 additions & 39 deletions projects/LoRa_Transmitter/include/README

This file was deleted.

46 changes: 0 additions & 46 deletions projects/LoRa_Transmitter/lib/README

This file was deleted.

14 changes: 0 additions & 14 deletions projects/LoRa_Transmitter/platformio.ini

This file was deleted.

29 changes: 0 additions & 29 deletions projects/LoRa_Transmitter/src/LoRa.cpp

This file was deleted.

Loading