From 94b50753a50dfc171a65533c2a7dd65303bbdc2c Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 22 Mar 2024 20:48:11 +0100 Subject: [PATCH 1/8] i am above law i can push to master --- projects/RocketComputer/src/main.cpp | 62 ++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/projects/RocketComputer/src/main.cpp b/projects/RocketComputer/src/main.cpp index 94ec2ed..5b8aab2 100644 --- a/projects/RocketComputer/src/main.cpp +++ b/projects/RocketComputer/src/main.cpp @@ -1,14 +1,62 @@ #include -int x; +const unsigned long delayTime = 5000; // Delay time in milliseconds (5 seconds) +const int sensorPin = 2; // Example pin for sensor input + +volatile bool timerFlag = false; +volatile bool sensorFlag = false; + +// Function prototypes +void setupTimerInterrupt(); +void setupSensorInterrupt(); +void handleTimerInterrupt(); +void handleSensorInterrupt(); +void delayedFunction(); void setup() { - Serial.begin(9600); - x = 0; + Serial.begin(115200); + setupTimerInterrupt(); + setupSensorInterrupt(); } void loop() { - Serial.printf("X = %d \n", x); - x = x + 1; - delay(100); -} \ No newline at end of file + // Your main loop code here + if (timerFlag) { + timerFlag = false; + delayedFunction(); + } + if (sensorFlag) { + sensorFlag = false; + // Handle sensor input + Serial.println("Sensor triggered!"); + } + // Other loop logic +} + +void setupTimerInterrupt() { + // Set up timer interrupt to trigger every delayTime milliseconds + // Adjust the timer configuration based on your specific microcontroller + timerAlarmWrite(timerBegin(TIMER0), delayTime * 1000, true); + timerAttachInterrupt(timerBegin(TIMER0), &handleTimerInterrupt, true); + timerAlarmEnable(timerBegin(TIMER0)); +} + +void setupSensorInterrupt() { + pinMode(sensorPin, INPUT); + attachInterrupt(digitalPinToInterrupt(sensorPin), handleSensorInterrupt, CHANGE); +} + +void handleTimerInterrupt() { + // This function will be called when the timer interrupt triggers + timerFlag = true; +} + +void handleSensorInterrupt() { + // This function will be called when the sensor interrupt triggers + sensorFlag = true; +} + +void delayedFunction() { + // This function will be executed after delayTime milliseconds + Serial.println("Delayed function executed!"); +} From 522b254cd9a177759ca111cd1a5ad7b543e4f420 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 21 Jun 2024 18:47:14 +0200 Subject: [PATCH 2/8] init --- Main/include/gps.h | 7 ++ Main/include/utilities.h | 33 +++++++ Main/src/gps.cpp | 9 ++ projects/Main/.vscode/extensions.json | 2 + projects/Main/include/bmp.hpp | 16 +++ projects/Main/platformio.ini | 11 +++ projects/Main/src/bmp.cpp | 53 ++++++++++ projects/Main/src/button.cpp | 13 +-- projects/Main/src/main.cpp | 29 +++--- projects/RocketComputer/src/main.cpp | 123 +++++------------------- projects/T-beam/.gitignore | 5 + projects/T-beam/.vscode/extensions.json | 10 ++ projects/T-beam/include/gps.h | 11 +++ projects/T-beam/include/led.h | 6 ++ projects/T-beam/platformio.ini | 15 +++ projects/T-beam/src/gps.cpp | 26 +++++ projects/T-beam/src/led.cpp | 15 +++ projects/T-beam/src/main.cpp | 14 +++ projects/T-beam/test/README | 11 +++ projects/firmware | 1 + 20 files changed, 292 insertions(+), 118 deletions(-) create mode 100644 Main/include/gps.h create mode 100644 Main/include/utilities.h create mode 100644 Main/src/gps.cpp create mode 100644 projects/Main/include/bmp.hpp create mode 100644 projects/Main/src/bmp.cpp create mode 100644 projects/T-beam/.gitignore create mode 100644 projects/T-beam/.vscode/extensions.json create mode 100644 projects/T-beam/include/gps.h create mode 100644 projects/T-beam/include/led.h create mode 100644 projects/T-beam/platformio.ini create mode 100644 projects/T-beam/src/gps.cpp create mode 100644 projects/T-beam/src/led.cpp create mode 100644 projects/T-beam/src/main.cpp create mode 100644 projects/T-beam/test/README create mode 160000 projects/firmware diff --git a/Main/include/gps.h b/Main/include/gps.h new file mode 100644 index 0000000..eb7032d --- /dev/null +++ b/Main/include/gps.h @@ -0,0 +1,7 @@ +#include + +namespace gps { + +void get_gps(void *pvParameters); + +} // namespace gps \ No newline at end of file diff --git a/Main/include/utilities.h b/Main/include/utilities.h new file mode 100644 index 0000000..7f6bf26 --- /dev/null +++ b/Main/include/utilities.h @@ -0,0 +1,33 @@ + +#pragma once +#define LILYGO_TBeam_V1_X + +#ifndef LoRa_frequency +#define LoRa_frequency 433.0 +#endif + +#define UNUSE_PIN (0) + +#define GPS_RX_PIN 34 +#define GPS_TX_PIN 12 +#define BUTTON_PIN 38 +#define BUTTON_PIN_MASK GPIO_SEL_38 +#define I2C_SDA 21 +#define I2C_SCL 22 +#define PMU_IRQ 35 + +#define RADIO_SCLK_PIN 5 +#define RADIO_MISO_PIN 19 +#define RADIO_MOSI_PIN 27 +#define RADIO_CS_PIN 18 +#define RADIO_DIO0_PIN 26 +#define RADIO_RST_PIN 23 +#define RADIO_DIO1_PIN 33 +#define RADIO_BUSY_PIN 32 + +#define BOARD_LED 4 +#define LED_ON LOW +#define LED_OFF HIGH + +#define GPS_BAUD_RATE 9600 +#define HAS_GPS diff --git a/Main/src/gps.cpp b/Main/src/gps.cpp new file mode 100644 index 0000000..89c3bd1 --- /dev/null +++ b/Main/src/gps.cpp @@ -0,0 +1,9 @@ +#include "gps.h" + +namespace gps { + +// TinyGPSPlus gps; + +void get_gps(void* pvParameters) {} +int i = 0; +} // namespace gps \ No newline at end of file diff --git a/projects/Main/.vscode/extensions.json b/projects/Main/.vscode/extensions.json index bca82dc..080e70d 100644 --- a/projects/Main/.vscode/extensions.json +++ b/projects/Main/.vscode/extensions.json @@ -1,4 +1,6 @@ { + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format "recommendations": [ "platformio.platformio-ide" ], diff --git a/projects/Main/include/bmp.hpp b/projects/Main/include/bmp.hpp new file mode 100644 index 0000000..e46d9ae --- /dev/null +++ b/projects/Main/include/bmp.hpp @@ -0,0 +1,16 @@ +#pragma once +namespace bmp { +// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej +void begin(); + +struct Data { + float temperature; + float pressure; + float altitude; + + float get_as_hpa(); +}; + +Data measurements(); +void pretty_print(); +} // namespace bmp \ No newline at end of file diff --git a/projects/Main/platformio.ini b/projects/Main/platformio.ini index 0f688c6..435be1c 100644 --- a/projects/Main/platformio.ini +++ b/projects/Main/platformio.ini @@ -1,5 +1,16 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + [env:lolin32_lite] platform = espressif32 board = lolin32_lite framework = arduino monitor_speed = 115200 +lib_deps = adafruit/Adafruit BMP280 Library@^2.6.8 diff --git a/projects/Main/src/bmp.cpp b/projects/Main/src/bmp.cpp new file mode 100644 index 0000000..491f2aa --- /dev/null +++ b/projects/Main/src/bmp.cpp @@ -0,0 +1,53 @@ +#include "bmp.hpp" + +// korzystanie z Adafruit BMP280 Library by Adafruit +#include +#include + +// 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 +#define SEALEVELPRESSURE_HPA (1019.91) + +Adafruit_BMP280 bmp_obj; + +namespace bmp { + +// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej +void begin() { + if (!bmp_obj.begin(0x76)) { + 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(); + Serial.print("Temperature = "); + Serial.print(exp.temperature); + Serial.println(" *C"); + + Serial.print("Pressure = "); + Serial.print(exp.get_as_hpa()); + Serial.println(" hPa"); + + Serial.print("Approx. Altitude = "); + Serial.print(exp.altitude); + Serial.println(" m"); + + Serial.println(); +} + +float Data::get_as_hpa() { return bmp_obj.readPressure() / 100.0F; } +} // namespace bmp \ No newline at end of file diff --git a/projects/Main/src/button.cpp b/projects/Main/src/button.cpp index 569acd1..cd6c011 100644 --- a/projects/Main/src/button.cpp +++ b/projects/Main/src/button.cpp @@ -2,13 +2,8 @@ namespace button { -void button_task(void* pvParameters) -{ - uint32_t rx_msg; - for (;;) { - if (xQueueReceive(xQueue, &rx_msg, portMAX_DELAY)) { - Serial.println("Button pressed!"); - } - } +void button_task(void* pvParameters) { + Serial.println("Button pressed!"); + vTaskDelete(NULL); } -} // namespace button \ No newline at end of file +} // namespace button \ No newline at end of file diff --git a/projects/Main/src/main.cpp b/projects/Main/src/main.cpp index a1ce9ba..a6a8eec 100644 --- a/projects/Main/src/main.cpp +++ b/projects/Main/src/main.cpp @@ -1,5 +1,6 @@ #include +#include "bmp.hpp" #include "button.h" #include "interrupts.h" #include "led.h" @@ -8,23 +9,29 @@ QueueHandle_t xQueue; void setup() { Serial.begin(115200); - Serial.println("--- Starting... ---"); + Serial.println("--- Starting the rocket... ---"); xQueue = xQueueCreate(10, sizeof(uint32_t)); // create xQueue interrupts::setup(); + xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - //------ tutorial of how to setup a task - xTaskCreate( /* Command to create a task*/ - led::blink_task, /* Task function name */ - "LOLOLOLOLBLINK", /* String with name of task. */ - 10000, /* Stack size in bytes. - leave it 10000 for now*/ - NULL, /* Parameter passed as input - leave NULL for now*/ - 1, /* Priority of the task.- leave 1 for now*/ - NULL); /* Task handle. - leave NULL if not neccesary */ + bmp::Data globalData[10]; - //---------- below is the normal declaration + void bmp_task() { + for (;;) { + bmp::Data tempData[10]; + for (int i = 0; i < 10; i++) { + tempData[i] = bmp::measure(); + vTaskDelay(pdMS_TO_TICKS(100)); + } + // Copy tempData to globalData + memcpy(globalData, tempData, sizeof(globalData)); + } + } + + xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); if (xQueue != NULL) - xTaskCreate(button::button_task, "TaskButton", 10000, NULL, 1, NULL); + xTaskCreate(button::button_task, "button", 10000, NULL, 1, NULL); } void loop() { diff --git a/projects/RocketComputer/src/main.cpp b/projects/RocketComputer/src/main.cpp index bd19bd5..0e83292 100644 --- a/projects/RocketComputer/src/main.cpp +++ b/projects/RocketComputer/src/main.cpp @@ -1,119 +1,46 @@ -<<<<<<< HEAD -const unsigned long delayTime = 5000; // Delay time in milliseconds (5 seconds) -const int sensorPin = 2; // Example pin for sensor input - -volatile bool timerFlag = false; -volatile bool sensorFlag = false; - -// Function prototypes -void setupTimerInterrupt(); -void setupSensorInterrupt(); -void handleTimerInterrupt(); -void handleSensorInterrupt(); -void delayedFunction(); - -void setup() { - Serial.begin(115200); - setupTimerInterrupt(); - setupSensorInterrupt(); -} - -void loop() { - // Your main loop code here - if (timerFlag) { - timerFlag = false; - delayedFunction(); - } - if (sensorFlag) { - sensorFlag = false; - // Handle sensor input - Serial.println("Sensor triggered!"); - } - // Other loop logic -} - -void setupTimerInterrupt() { - // Set up timer interrupt to trigger every delayTime milliseconds - // Adjust the timer configuration based on your specific microcontroller - timerAlarmWrite(timerBegin(TIMER0), delayTime * 1000, true); - timerAttachInterrupt(timerBegin(TIMER0), &handleTimerInterrupt, true); - timerAlarmEnable(timerBegin(TIMER0)); -} - -void setupSensorInterrupt() { - pinMode(sensorPin, INPUT); - attachInterrupt(digitalPinToInterrupt(sensorPin), handleSensorInterrupt, CHANGE); -} - -void handleTimerInterrupt() { - // This function will be called when the timer interrupt triggers - timerFlag = true; -} - -void handleSensorInterrupt() { - // This function will be called when the sensor interrupt triggers - sensorFlag = true; -} - -void delayedFunction() { - // This function will be executed after delayTime milliseconds - Serial.println("Delayed function executed!"); -} -======= - - - - - #include #include -#define BUTTON_PIN 0 // Change this to your button pin +#define BUTTON_PIN 0 // Change this to your button pin QueueHandle_t xQueue; void IRAM_ATTR button_isr() { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - uint32_t isr_msg = 1; - xQueueSendFromISR(xQueue, &isr_msg, &xHigherPriorityTaskWoken); - if (xHigherPriorityTaskWoken) { - portYIELD_FROM_ISR(); - } + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + uint32_t isr_msg = 1; + xQueueSendFromISR(xQueue, &isr_msg, &xHigherPriorityTaskWoken); + if (xHigherPriorityTaskWoken) { + portYIELD_FROM_ISR(); + } } void TaskButton(void *pvParameters) { - uint32_t rx_msg; - for (;;) { - if (xQueueReceive(xQueue, &rx_msg, portMAX_DELAY)) { - // Button press detected, do something here - } + uint32_t rx_msg; + for (;;) { + if (xQueueReceive(xQueue, &rx_msg, portMAX_DELAY)) { + // Button press detected, do something here } + } } void setup() { - pinMode(BUTTON_PIN, INPUT_PULLUP); - attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), button_isr, FALLING); + pinMode(BUTTON_PIN, INPUT_PULLUP); + attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), button_isr, FALLING); - xQueue = xQueueCreate(10, sizeof(uint32_t)); - if (xQueue != NULL) { - xTaskCreate(TaskButton, "TaskButton", 10000, NULL, 1, NULL); - } - xTaskCreate( - TaskBlinkLED, /* Task function. */ - "TaskBlinkLED", /* String with name of task. */ - 10000, /* Stack size in bytes. */ - NULL, /* Parameter passed as input of the task */ - 1, /* Priority of the task. */ - NULL); /* Task handle. */ + xQueue = xQueueCreate(10, sizeof(uint32_t)); + if (xQueue != NULL) { + xTaskCreate(TaskButton, "TaskButton", 10000, NULL, 1, NULL); + } + xTaskCreate(TaskBlinkLED, /* Task function. */ + "TaskBlinkLED", /* String with name of task. */ + 10000, /* Stack size in bytes. */ + NULL, /* Parameter passed as input of the task */ + 1, /* Priority of the task. */ + NULL); /* Task handle. */ } void loop() { - // put your main code here, to run repeatedly: + // put your main code here, to run repeatedly: } - - - - ->>>>>>> a6e1e0c21321a2b29161f177a0311dfdbd8c53a4 diff --git a/projects/T-beam/.gitignore b/projects/T-beam/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/projects/T-beam/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/projects/T-beam/.vscode/extensions.json b/projects/T-beam/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/projects/T-beam/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/projects/T-beam/include/gps.h b/projects/T-beam/include/gps.h new file mode 100644 index 0000000..ad4f52c --- /dev/null +++ b/projects/T-beam/include/gps.h @@ -0,0 +1,11 @@ +#include +#define GPS_SERIAL_NUM 1 +#define GPS_RX_PIN 34 +#define GPS_TX_PIN 12 + +namespace gps { + +void init(); +void gps_loop(void* pvParameters); + +} // namespace gps diff --git a/projects/T-beam/include/led.h b/projects/T-beam/include/led.h new file mode 100644 index 0000000..419bdcf --- /dev/null +++ b/projects/T-beam/include/led.h @@ -0,0 +1,6 @@ +#include + +namespace led { + +void blink_task(void *pvParameters); +} // namespace led \ No newline at end of file diff --git a/projects/T-beam/platformio.ini b/projects/T-beam/platformio.ini new file mode 100644 index 0000000..2b364f5 --- /dev/null +++ b/projects/T-beam/platformio.ini @@ -0,0 +1,15 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:ttgo-t-beam] +platform = espressif32 +board = ttgo-t-beam +framework = arduino +monitor_speed = 115200 diff --git a/projects/T-beam/src/gps.cpp b/projects/T-beam/src/gps.cpp new file mode 100644 index 0000000..1f1f740 --- /dev/null +++ b/projects/T-beam/src/gps.cpp @@ -0,0 +1,26 @@ +#include "gps.h" + +namespace gps { + +HardwareSerial GPSSerial(GPS_SERIAL_NUM); + +void init() { GPSSerial.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); } + +void gps_loop(void* pvParameters) { + String nmea = ""; + for (;;) { + if (GPSSerial.available()) { + char c = GPSSerial.read(); + nmea += c; + } else { + if (nmea != "") { + Serial.println(nmea); + nmea = ""; + } else + Serial.println("------------"); + vTaskDelay(pdMS_TO_TICKS(100)); + } + } +} + +} // namespace gps diff --git a/projects/T-beam/src/led.cpp b/projects/T-beam/src/led.cpp new file mode 100644 index 0000000..f5027ca --- /dev/null +++ b/projects/T-beam/src/led.cpp @@ -0,0 +1,15 @@ +#include "led.h" + +namespace led { +void setup() {} + +void blink_task(void* pvParameters) { + pinMode(LED_BUILTIN, OUTPUT); + for (;;) { + digitalWrite(LED_BUILTIN, HIGH); + vTaskDelay(pdMS_TO_TICKS(500)); // delay for 500ms without blocking the CPU + digitalWrite(LED_BUILTIN, LOW); + vTaskDelay(pdMS_TO_TICKS(500)); // delay for 500ms + } +} +} // namespace led \ No newline at end of file diff --git a/projects/T-beam/src/main.cpp b/projects/T-beam/src/main.cpp new file mode 100644 index 0000000..025bd2f --- /dev/null +++ b/projects/T-beam/src/main.cpp @@ -0,0 +1,14 @@ +#include + +#include "gps.h" +#include "led.h" + +void setup() { + Serial.begin(115200); + Serial.println("--- Starting the rocket... ---"); + gps::init(); + xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); + xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); +} + +void loop() {} diff --git a/projects/T-beam/test/README b/projects/T-beam/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/projects/T-beam/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/projects/firmware b/projects/firmware new file mode 160000 index 0000000..147de75 --- /dev/null +++ b/projects/firmware @@ -0,0 +1 @@ +Subproject commit 147de75a0295e7c8e71605d7fd007dfa222a5c12 From 8296a6931638347af24cccf2fadb80b788ad11f2 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 21 Jun 2024 20:57:08 +0200 Subject: [PATCH 3/8] testing bme --- projects/T-beam/include/bmp.h | 18 ++++++++++ projects/T-beam/platformio.ini | 1 + projects/T-beam/src/bmp.cpp | 60 ++++++++++++++++++++++++++++++++++ projects/T-beam/src/gps.cpp | 16 ++++----- projects/T-beam/src/main.cpp | 15 ++++++++- 5 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 projects/T-beam/include/bmp.h create mode 100644 projects/T-beam/src/bmp.cpp diff --git a/projects/T-beam/include/bmp.h b/projects/T-beam/include/bmp.h new file mode 100644 index 0000000..72e6921 --- /dev/null +++ b/projects/T-beam/include/bmp.h @@ -0,0 +1,18 @@ +namespace bmp { +// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej +void init(); + +struct Data { + float temperature; + float pressure; + float altitude; + + float get_as_hpa(); +}; + +inline Data global_bmp; + +void get_bme(void* pvParameters); +Data measurements(); +void pretty_print(); +} // namespace bmp \ No newline at end of file diff --git a/projects/T-beam/platformio.ini b/projects/T-beam/platformio.ini index 2b364f5..703e447 100644 --- a/projects/T-beam/platformio.ini +++ b/projects/T-beam/platformio.ini @@ -13,3 +13,4 @@ platform = espressif32 board = ttgo-t-beam framework = arduino monitor_speed = 115200 +lib_deps = adafruit/Adafruit BMP280 Library@^2.6.8 diff --git a/projects/T-beam/src/bmp.cpp b/projects/T-beam/src/bmp.cpp new file mode 100644 index 0000000..5309a5f --- /dev/null +++ b/projects/T-beam/src/bmp.cpp @@ -0,0 +1,60 @@ +#include "bmp.h" + +// korzystanie z Adafruit BMP280 Library by Adafruit +#include +#include + +// 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 +#define SEALEVELPRESSURE_HPA (1019.91) + +namespace bmp { + +Adafruit_BMP280 bmp_obj; + +// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej +void init() { + if (!bmp_obj.begin(0x76)) { + Serial.println("Viable sensor BMP280 not found, check wiring!"); + while (1); + } +} + +void get_bme(void* pvParameters) { + for (;;) { + global_bmp = measurements(); + vTaskDelay(pdMS_TO_TICKS(500)); + } +} + +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(); + Serial.print("Temperature = "); + Serial.print(exp.temperature); + Serial.println(" *C"); + + Serial.print("Pressure = "); + Serial.print(exp.get_as_hpa()); + Serial.println(" hPa"); + + Serial.print("Approx. Altitude = "); + Serial.print(exp.altitude); + Serial.println(" m"); + + Serial.println(); +} + +float Data::get_as_hpa() { return bmp_obj.readPressure() / 100.0F; } +} // namespace bmp \ No newline at end of file diff --git a/projects/T-beam/src/gps.cpp b/projects/T-beam/src/gps.cpp index 1f1f740..320d5c6 100644 --- a/projects/T-beam/src/gps.cpp +++ b/projects/T-beam/src/gps.cpp @@ -9,17 +9,17 @@ 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)); } } diff --git a/projects/T-beam/src/main.cpp b/projects/T-beam/src/main.cpp index 025bd2f..58779f4 100644 --- a/projects/T-beam/src/main.cpp +++ b/projects/T-beam/src/main.cpp @@ -1,14 +1,27 @@ #include +#include +#include "bmp.h" #include "gps.h" #include "led.h" +void parser(void* pvParameters) { + for (;;) { + Serial.println(bmp::global_bmp.altitude); + vTaskDelay(pdMS_TO_TICKS(500)); + } +} + void setup() { Serial.begin(115200); Serial.println("--- Starting the rocket... ---"); gps::init(); xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); + // xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); + + // bmp::init(); + // xTaskCreate(bmp::get_bme, "bmp", 10000, NULL, 1, NULL); + xTaskCreate(parser, "parser", 10000, NULL, 1, NULL); } void loop() {} From 71c713421bb3c13ce811c8758fe7f631d8b9b09f Mon Sep 17 00:00:00 2001 From: Bartosz Date: Wed, 26 Jun 2024 22:04:30 +0200 Subject: [PATCH 4/8] added async BMP --- projects/T-beam/include/bmp.h | 2 +- projects/T-beam/src/bmp.cpp | 18 +++++++----------- projects/T-beam/src/main.cpp | 8 +++++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/projects/T-beam/include/bmp.h b/projects/T-beam/include/bmp.h index 72e6921..b83ad1b 100644 --- a/projects/T-beam/include/bmp.h +++ b/projects/T-beam/include/bmp.h @@ -14,5 +14,5 @@ inline Data global_bmp; void get_bme(void* pvParameters); Data measurements(); -void pretty_print(); +void pretty_print(Data); } // namespace bmp \ No newline at end of file diff --git a/projects/T-beam/src/bmp.cpp b/projects/T-beam/src/bmp.cpp index 5309a5f..53a186b 100644 --- a/projects/T-beam/src/bmp.cpp +++ b/projects/T-beam/src/bmp.cpp @@ -1,21 +1,21 @@ #include "bmp.h" -// korzystanie z Adafruit BMP280 Library by Adafruit #include #include -// 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) +#define CHIP_BME 0x60 +#define CHIP_BMP 0x58 +#define CHIP_ADDR 0x76 namespace bmp { Adafruit_BMP280 bmp_obj; -// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej +// Requires Wire.begin(SDA_PIN, SCL_PIN) void init() { - if (!bmp_obj.begin(0x76)) { + if (!bmp_obj.begin(CHIP_ADDR, CHIP_BME)) { Serial.println("Viable sensor BMP280 not found, check wiring!"); while (1); } @@ -30,17 +30,13 @@ void get_bme(void* pvParameters) { 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 pretty_print(Data exp) { Serial.print("Temperature = "); Serial.print(exp.temperature); Serial.println(" *C"); diff --git a/projects/T-beam/src/main.cpp b/projects/T-beam/src/main.cpp index 58779f4..6598370 100644 --- a/projects/T-beam/src/main.cpp +++ b/projects/T-beam/src/main.cpp @@ -7,7 +7,7 @@ void parser(void* pvParameters) { for (;;) { - Serial.println(bmp::global_bmp.altitude); + bmp::pretty_print(bmp::global_bmp); vTaskDelay(pdMS_TO_TICKS(500)); } } @@ -15,12 +15,14 @@ void parser(void* pvParameters) { void setup() { Serial.begin(115200); Serial.println("--- Starting the rocket... ---"); + Wire.begin(21, 22); + gps::init(); xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); // xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); - // bmp::init(); - // xTaskCreate(bmp::get_bme, "bmp", 10000, NULL, 1, NULL); + bmp::init(); + xTaskCreate(bmp::get_bme, "bmp", 10000, NULL, 1, NULL); xTaskCreate(parser, "parser", 10000, NULL, 1, NULL); } From 64eeacbd189865c869ae797184b359098e3aa1d8 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 27 Jun 2024 00:29:36 +0200 Subject: [PATCH 5/8] eeprom memory config init --- projects/T-beam/include/bmp.h | 3 ++- projects/T-beam/include/memory.h | 20 ++++++++++++++++++++ projects/T-beam/src/bmp.cpp | 28 +++++++++++++++++----------- projects/T-beam/src/main.cpp | 21 ++++++++++----------- projects/T-beam/src/memory.cpp | 26 ++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 23 deletions(-) create mode 100644 projects/T-beam/include/memory.h create mode 100644 projects/T-beam/src/memory.cpp diff --git a/projects/T-beam/include/bmp.h b/projects/T-beam/include/bmp.h index b83ad1b..0301495 100644 --- a/projects/T-beam/include/bmp.h +++ b/projects/T-beam/include/bmp.h @@ -10,9 +10,10 @@ struct Data { float get_as_hpa(); }; -inline Data global_bmp; +inline Data data; void get_bme(void* pvParameters); +void print_data(void* pvParameters); Data measurements(); void pretty_print(Data); } // namespace bmp \ No newline at end of file diff --git a/projects/T-beam/include/memory.h b/projects/T-beam/include/memory.h new file mode 100644 index 0000000..b0d7c7c --- /dev/null +++ b/projects/T-beam/include/memory.h @@ -0,0 +1,20 @@ +#include + +#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 diff --git a/projects/T-beam/src/bmp.cpp b/projects/T-beam/src/bmp.cpp index 53a186b..6bacb35 100644 --- a/projects/T-beam/src/bmp.cpp +++ b/projects/T-beam/src/bmp.cpp @@ -21,13 +21,6 @@ void init() { } } -void get_bme(void* pvParameters) { - for (;;) { - global_bmp = measurements(); - vTaskDelay(pdMS_TO_TICKS(500)); - } -} - Data measurements() { Data check; check.temperature = bmp_obj.readTemperature(); @@ -36,17 +29,30 @@ Data measurements() { return check; }; -void pretty_print(Data exp) { +void get_bme(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(); diff --git a/projects/T-beam/src/main.cpp b/projects/T-beam/src/main.cpp index 6044b2d..8275c8f 100644 --- a/projects/T-beam/src/main.cpp +++ b/projects/T-beam/src/main.cpp @@ -4,26 +4,25 @@ #include "bmp.h" #include "gps.h" #include "led.h" +#include "memory.h" -void parser(void* pvParameters) { - for (;;) { - bmp::pretty_print(bmp::global_bmp); - vTaskDelay(pdMS_TO_TICKS(500)); - } -} void setup() { Serial.begin(115200); Serial.println("--- Starting the rocket... ---"); Wire.begin(21, 22); + memory::init(); // loads config gps::init(); - xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - // xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); - bmp::init(); + + // xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); + xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); xTaskCreate(bmp::get_bme, "bmp", 10000, NULL, 1, NULL); - xTaskCreate(parser, "parser", 10000, NULL, 1, NULL); - xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); + xTaskCreate(bmp::print_data, "bmp printing", 10000, NULL, 1, NULL); + + memory::print_data(); + memory::config = memory::Config{222, 456.78, "Hello, EEPROM2!"}; + memory::save_config(memory::config); } void loop() {} diff --git a/projects/T-beam/src/memory.cpp b/projects/T-beam/src/memory.cpp new file mode 100644 index 0000000..1f798d1 --- /dev/null +++ b/projects/T-beam/src/memory.cpp @@ -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 \ No newline at end of file From a92df0f1f0fa262ca705e5dd70a48aa9bbe328a8 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 27 Jun 2024 00:33:14 +0200 Subject: [PATCH 6/8] cleanup --- {Main => Lolin}/.gitignore | 0 {Main => Lolin}/.vscode/extensions.json | 0 {Main => Lolin}/.vscode/settings.json | 0 {Main => Lolin}/include/README | 0 {Main => Lolin}/include/button.h | 0 {Main => Lolin}/include/gps.h | 0 {Main => Lolin}/include/interrupts.h | 0 {Main => Lolin}/include/led.h | 0 {Main => Lolin}/include/utilities.h | 0 {Main => Lolin}/lib/README | 0 {Main => Lolin}/platformio.ini | 0 {Main => Lolin}/src/button.cpp | 0 {Main => Lolin}/src/gps.cpp | 0 {Main => Lolin}/src/interrupts.cpp | 0 {Main => Lolin}/src/led.cpp | 0 {Main => Lolin}/src/main.cpp | 0 {Main => Lolin}/test/README | 0 .../LoRa_Transmitter => T-beam}/.gitignore | 0 .../.vscode/extensions.json | 0 {projects/T-beam => T-beam}/include/bmp.h | 0 {projects/T-beam => T-beam}/include/gps.h | 0 {projects/Main => T-beam}/include/led.h | 0 {projects/T-beam => T-beam}/include/memory.h | 0 {projects/T-beam => T-beam}/platformio.ini | 0 {projects/T-beam => T-beam}/src/bmp.cpp | 0 {projects/T-beam => T-beam}/src/gps.cpp | 0 {projects/T-beam => T-beam}/src/led.cpp | 0 {projects/T-beam => T-beam}/src/main.cpp | 0 {projects/T-beam => T-beam}/src/memory.cpp | 0 .../LoRa_Transmitter => T-beam}/test/README | 0 .../LoRa_Transmitter/.vscode/settings.json | 15 --- projects/LoRa_Transmitter/include/LoRa.hpp | 15 --- projects/LoRa_Transmitter/include/README | 39 -------- projects/LoRa_Transmitter/lib/README | 46 --------- projects/LoRa_Transmitter/platformio.ini | 14 --- projects/LoRa_Transmitter/src/LoRa.cpp | 29 ------ projects/LoRa_Transmitter/src/LoRa_debug.cpp | 99 ------------------- projects/LoRa_Transmitter/src/main.cpp | 20 ---- projects/LoRa_Transmitter/test.txt | 1 - projects/MPU/test.txt | 1 - projects/Main/.gitignore | 5 - projects/Main/.vscode/extensions.json | 10 -- projects/Main/.vscode/settings.json | 14 --- projects/Main/include/README | 39 -------- projects/Main/include/bmp.hpp | 16 --- projects/Main/include/button.h | 7 -- projects/Main/include/interrupts.h | 10 -- projects/Main/lib/README | 46 --------- projects/Main/platformio.ini | 16 --- projects/Main/src/bmp.cpp | 53 ---------- projects/Main/src/button.cpp | 9 -- projects/Main/src/interrupts.cpp | 18 ---- projects/Main/src/led.cpp | 14 --- projects/Main/src/main.cpp | 39 -------- projects/Main/test/README | 11 --- projects/RocketComputer/.gitignore | 5 - .../RocketComputer/.vscode/extensions.json | 10 -- projects/RocketComputer/lib/README | 46 --------- projects/RocketComputer/lib/led.hpp | 3 - projects/RocketComputer/platformio.ini | 14 --- projects/RocketComputer/src/led.cpp | 9 -- projects/RocketComputer/src/main.cpp | 46 --------- projects/RocketComputer/test/README | 11 --- projects/T-beam/.gitignore | 5 - projects/T-beam/.vscode/extensions.json | 10 -- projects/T-beam/include/led.h | 6 -- projects/T-beam/test/README | 11 --- projects/bmp/.gitignore | 2 - projects/bmp/.vscode/extensions.json | 10 -- projects/bmp/include/README | 39 -------- projects/bmp/include/bmp.hpp | 16 --- projects/bmp/lib/README | 46 --------- projects/bmp/platformio.ini | 15 --- projects/bmp/src/bmp.cpp | 55 ----------- projects/bmp/src/main.cpp | 15 --- projects/bmp/test/README | 11 --- projects/firmware | 1 - projects/spadochron/krzysiek.txt | 0 projects/spadochron/redme.txt | 1 - 79 files changed, 973 deletions(-) rename {Main => Lolin}/.gitignore (100%) rename {Main => Lolin}/.vscode/extensions.json (100%) rename {Main => Lolin}/.vscode/settings.json (100%) rename {Main => Lolin}/include/README (100%) rename {Main => Lolin}/include/button.h (100%) rename {Main => Lolin}/include/gps.h (100%) rename {Main => Lolin}/include/interrupts.h (100%) rename {Main => Lolin}/include/led.h (100%) rename {Main => Lolin}/include/utilities.h (100%) rename {Main => Lolin}/lib/README (100%) rename {Main => Lolin}/platformio.ini (100%) rename {Main => Lolin}/src/button.cpp (100%) rename {Main => Lolin}/src/gps.cpp (100%) rename {Main => Lolin}/src/interrupts.cpp (100%) rename {Main => Lolin}/src/led.cpp (100%) rename {Main => Lolin}/src/main.cpp (100%) rename {Main => Lolin}/test/README (100%) rename {projects/LoRa_Transmitter => T-beam}/.gitignore (100%) rename {projects/LoRa_Transmitter => T-beam}/.vscode/extensions.json (100%) rename {projects/T-beam => T-beam}/include/bmp.h (100%) rename {projects/T-beam => T-beam}/include/gps.h (100%) rename {projects/Main => T-beam}/include/led.h (100%) rename {projects/T-beam => T-beam}/include/memory.h (100%) rename {projects/T-beam => T-beam}/platformio.ini (100%) rename {projects/T-beam => T-beam}/src/bmp.cpp (100%) rename {projects/T-beam => T-beam}/src/gps.cpp (100%) rename {projects/T-beam => T-beam}/src/led.cpp (100%) rename {projects/T-beam => T-beam}/src/main.cpp (100%) rename {projects/T-beam => T-beam}/src/memory.cpp (100%) rename {projects/LoRa_Transmitter => T-beam}/test/README (100%) delete mode 100644 projects/LoRa_Transmitter/.vscode/settings.json delete mode 100644 projects/LoRa_Transmitter/include/LoRa.hpp delete mode 100644 projects/LoRa_Transmitter/include/README delete mode 100644 projects/LoRa_Transmitter/lib/README delete mode 100644 projects/LoRa_Transmitter/platformio.ini delete mode 100644 projects/LoRa_Transmitter/src/LoRa.cpp delete mode 100644 projects/LoRa_Transmitter/src/LoRa_debug.cpp delete mode 100644 projects/LoRa_Transmitter/src/main.cpp delete mode 100644 projects/LoRa_Transmitter/test.txt delete mode 100644 projects/MPU/test.txt delete mode 100644 projects/Main/.gitignore delete mode 100644 projects/Main/.vscode/extensions.json delete mode 100644 projects/Main/.vscode/settings.json delete mode 100644 projects/Main/include/README delete mode 100644 projects/Main/include/bmp.hpp delete mode 100644 projects/Main/include/button.h delete mode 100644 projects/Main/include/interrupts.h delete mode 100644 projects/Main/lib/README delete mode 100644 projects/Main/platformio.ini delete mode 100644 projects/Main/src/bmp.cpp delete mode 100644 projects/Main/src/button.cpp delete mode 100644 projects/Main/src/interrupts.cpp delete mode 100644 projects/Main/src/led.cpp delete mode 100644 projects/Main/src/main.cpp delete mode 100644 projects/Main/test/README delete mode 100644 projects/RocketComputer/.gitignore delete mode 100644 projects/RocketComputer/.vscode/extensions.json delete mode 100644 projects/RocketComputer/lib/README delete mode 100644 projects/RocketComputer/lib/led.hpp delete mode 100644 projects/RocketComputer/platformio.ini delete mode 100644 projects/RocketComputer/src/led.cpp delete mode 100644 projects/RocketComputer/src/main.cpp delete mode 100644 projects/RocketComputer/test/README delete mode 100644 projects/T-beam/.gitignore delete mode 100644 projects/T-beam/.vscode/extensions.json delete mode 100644 projects/T-beam/include/led.h delete mode 100644 projects/T-beam/test/README delete mode 100644 projects/bmp/.gitignore delete mode 100644 projects/bmp/.vscode/extensions.json delete mode 100644 projects/bmp/include/README delete mode 100644 projects/bmp/include/bmp.hpp delete mode 100644 projects/bmp/lib/README delete mode 100644 projects/bmp/platformio.ini delete mode 100644 projects/bmp/src/bmp.cpp delete mode 100644 projects/bmp/src/main.cpp delete mode 100644 projects/bmp/test/README delete mode 160000 projects/firmware delete mode 100644 projects/spadochron/krzysiek.txt delete mode 100644 projects/spadochron/redme.txt diff --git a/Main/.gitignore b/Lolin/.gitignore similarity index 100% rename from Main/.gitignore rename to Lolin/.gitignore diff --git a/Main/.vscode/extensions.json b/Lolin/.vscode/extensions.json similarity index 100% rename from Main/.vscode/extensions.json rename to Lolin/.vscode/extensions.json diff --git a/Main/.vscode/settings.json b/Lolin/.vscode/settings.json similarity index 100% rename from Main/.vscode/settings.json rename to Lolin/.vscode/settings.json diff --git a/Main/include/README b/Lolin/include/README similarity index 100% rename from Main/include/README rename to Lolin/include/README diff --git a/Main/include/button.h b/Lolin/include/button.h similarity index 100% rename from Main/include/button.h rename to Lolin/include/button.h diff --git a/Main/include/gps.h b/Lolin/include/gps.h similarity index 100% rename from Main/include/gps.h rename to Lolin/include/gps.h diff --git a/Main/include/interrupts.h b/Lolin/include/interrupts.h similarity index 100% rename from Main/include/interrupts.h rename to Lolin/include/interrupts.h diff --git a/Main/include/led.h b/Lolin/include/led.h similarity index 100% rename from Main/include/led.h rename to Lolin/include/led.h diff --git a/Main/include/utilities.h b/Lolin/include/utilities.h similarity index 100% rename from Main/include/utilities.h rename to Lolin/include/utilities.h diff --git a/Main/lib/README b/Lolin/lib/README similarity index 100% rename from Main/lib/README rename to Lolin/lib/README diff --git a/Main/platformio.ini b/Lolin/platformio.ini similarity index 100% rename from Main/platformio.ini rename to Lolin/platformio.ini diff --git a/Main/src/button.cpp b/Lolin/src/button.cpp similarity index 100% rename from Main/src/button.cpp rename to Lolin/src/button.cpp diff --git a/Main/src/gps.cpp b/Lolin/src/gps.cpp similarity index 100% rename from Main/src/gps.cpp rename to Lolin/src/gps.cpp diff --git a/Main/src/interrupts.cpp b/Lolin/src/interrupts.cpp similarity index 100% rename from Main/src/interrupts.cpp rename to Lolin/src/interrupts.cpp diff --git a/Main/src/led.cpp b/Lolin/src/led.cpp similarity index 100% rename from Main/src/led.cpp rename to Lolin/src/led.cpp diff --git a/Main/src/main.cpp b/Lolin/src/main.cpp similarity index 100% rename from Main/src/main.cpp rename to Lolin/src/main.cpp diff --git a/Main/test/README b/Lolin/test/README similarity index 100% rename from Main/test/README rename to Lolin/test/README diff --git a/projects/LoRa_Transmitter/.gitignore b/T-beam/.gitignore similarity index 100% rename from projects/LoRa_Transmitter/.gitignore rename to T-beam/.gitignore diff --git a/projects/LoRa_Transmitter/.vscode/extensions.json b/T-beam/.vscode/extensions.json similarity index 100% rename from projects/LoRa_Transmitter/.vscode/extensions.json rename to T-beam/.vscode/extensions.json diff --git a/projects/T-beam/include/bmp.h b/T-beam/include/bmp.h similarity index 100% rename from projects/T-beam/include/bmp.h rename to T-beam/include/bmp.h diff --git a/projects/T-beam/include/gps.h b/T-beam/include/gps.h similarity index 100% rename from projects/T-beam/include/gps.h rename to T-beam/include/gps.h diff --git a/projects/Main/include/led.h b/T-beam/include/led.h similarity index 100% rename from projects/Main/include/led.h rename to T-beam/include/led.h diff --git a/projects/T-beam/include/memory.h b/T-beam/include/memory.h similarity index 100% rename from projects/T-beam/include/memory.h rename to T-beam/include/memory.h diff --git a/projects/T-beam/platformio.ini b/T-beam/platformio.ini similarity index 100% rename from projects/T-beam/platformio.ini rename to T-beam/platformio.ini diff --git a/projects/T-beam/src/bmp.cpp b/T-beam/src/bmp.cpp similarity index 100% rename from projects/T-beam/src/bmp.cpp rename to T-beam/src/bmp.cpp diff --git a/projects/T-beam/src/gps.cpp b/T-beam/src/gps.cpp similarity index 100% rename from projects/T-beam/src/gps.cpp rename to T-beam/src/gps.cpp diff --git a/projects/T-beam/src/led.cpp b/T-beam/src/led.cpp similarity index 100% rename from projects/T-beam/src/led.cpp rename to T-beam/src/led.cpp diff --git a/projects/T-beam/src/main.cpp b/T-beam/src/main.cpp similarity index 100% rename from projects/T-beam/src/main.cpp rename to T-beam/src/main.cpp diff --git a/projects/T-beam/src/memory.cpp b/T-beam/src/memory.cpp similarity index 100% rename from projects/T-beam/src/memory.cpp rename to T-beam/src/memory.cpp diff --git a/projects/LoRa_Transmitter/test/README b/T-beam/test/README similarity index 100% rename from projects/LoRa_Transmitter/test/README rename to T-beam/test/README diff --git a/projects/LoRa_Transmitter/.vscode/settings.json b/projects/LoRa_Transmitter/.vscode/settings.json deleted file mode 100644 index aafc77c..0000000 --- a/projects/LoRa_Transmitter/.vscode/settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "editor.tabSize": 2, - "files.exclude": { - "**/.git": true, - }, - "editor.wordWrap": "on", - // C++ formatter settings - "[cpp]": { - "editor.defaultFormatter": "ms-vscode.cpptools", // Use the C/C++ extension as the default formatter - "editor.formatOnSave": true // Automatically format C++ files when saving - }, - "C_Cpp.clang_format_style": "file", // Use the .clang-format file in your project (if present) or default style - "C_Cpp.clang_format_fallbackStyle": "Google", // Fallback style if .clang-format file is not found - "editor.formatOnSave": true // Automatically format code when saving - } \ No newline at end of file diff --git a/projects/LoRa_Transmitter/include/LoRa.hpp b/projects/LoRa_Transmitter/include/LoRa.hpp deleted file mode 100644 index ffc5fce..0000000 --- a/projects/LoRa_Transmitter/include/LoRa.hpp +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef LORA_HPP -#define LORA_HPP - -#include - -namespace Lora { -extern HardwareSerial LoRaWioE5; - -void init(); -void send(String wiadomosc); - -} // namespace Lora - -#endif diff --git a/projects/LoRa_Transmitter/include/README b/projects/LoRa_Transmitter/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/projects/LoRa_Transmitter/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/projects/LoRa_Transmitter/lib/README b/projects/LoRa_Transmitter/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/projects/LoRa_Transmitter/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/projects/LoRa_Transmitter/platformio.ini b/projects/LoRa_Transmitter/platformio.ini deleted file mode 100644 index 3c944c8..0000000 --- a/projects/LoRa_Transmitter/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -;; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:lolin32_lite] -platform = espressif32 -board = lolin32_lite -framework = arduino -monitor_speed=115200 \ No newline at end of file diff --git a/projects/LoRa_Transmitter/src/LoRa.cpp b/projects/LoRa_Transmitter/src/LoRa.cpp deleted file mode 100644 index abf3bfa..0000000 --- a/projects/LoRa_Transmitter/src/LoRa.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "LoRa.hpp" - -namespace Lora { - -HardwareSerial LoRaWioE5(1); - -void init() { - // communication with LoRa Wio E5, RX and TX pins, baudrate 9600 - LoRaWioE5.begin(9600, SERIAL_8N1, 15, 19); - LoRaWioE5.print("AT+MODE=TEST\r\n"); // set transmitter in test mode - - // check if lora is available - if (LoRaWioE5.readString() != "+MODE: TEST") { - Serial.println("\nLora is not available"); - } - delay(1000); - - // setup LoRa for transmitting - LoRaWioE5.print( - "AT+TEST=RFCFG, 868, SF12, 125, 12, 15, 14, ON, OFF, OFF\r\n"); - delay(1000); -} - -void send(String wiadomosc) { - LoRaWioE5.print("AT+TEST=TXLRSTR,\"" + wiadomosc + "\"\r\n"); - // carriage return is essential -} - -} // namespace Lora \ No newline at end of file diff --git a/projects/LoRa_Transmitter/src/LoRa_debug.cpp b/projects/LoRa_Transmitter/src/LoRa_debug.cpp deleted file mode 100644 index 22a0838..0000000 --- a/projects/LoRa_Transmitter/src/LoRa_debug.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "LoRa.hpp" - -namespace Lora2 { - -HardwareSerial LoRaWioE5(1); - -void init() { - // ZROBIĆ DO SETUPU ODPOWIEDNIĄ OBSŁUGĘ W RAZIE ŹLE PODŁĄCZONEJ LoRy - // .isavailable() (taka metoda z chata) - - delay(1000); - LoRaWioE5.begin(9600, SERIAL_8N1, 15, 19); - // Komunikacja z modułem LoRa Wio E5, piny RX i TX - - Serial.println( - "\n[debug]Wstepna konfiguracja modulu"); // drukowanie do debugu, mozna - // usunac - // Ustawiamy moduł w tryb testowy - LoRaWioE5.print("AT+MODE=TEST\r\n"); // Ustawia tryb nadajnika na TEST - - String response = LoRaWioE5.readString(); - - if (response != "+MODE: TEST") { - Serial.println("\n[debug] Lora is not available"); - Serial.println("\n[debug] Failed message: " + response); - } - - Serial.println("\n[debug]Odpowiedz: " + response); - // Drukuje na serial monitorze odpowiedz na wyslana komende - - Serial.println("\n[debug]Przesylanie danych"); - delay(1000); // Chwilowe opoznienie, prawdopodobnie niezbedne do prawidlowego - // dzialania - - // Konfigurujemy moduł - LoRaWioE5.print( - "AT+TEST=RFCFG, 868, SF12, 125, 12, 15, 14, ON, OFF, OFF\r\n"); - // nastepne - // ustawienie - // nadajnika - response = LoRaWioE5.readString(); - Serial.println("\n[debug]Odpowiedz: " + response); - // Drukuje odpowiedz na komende na serial monitorze - delay(1000); -} - -void send(String wiadomosc) { - // Na transmiterze - - LoRaWioE5.print("AT+TEST=TXLRSTR,\"" + wiadomosc + "\"\r\n"); - // przenieisienie karteki zeby prawidlowo dzialalo - // Przesyla do LoRy komende, ktora wysyla wiadomosc, sformatowana w - // odpowiedniej funkcji, ktora jest przesylana jako argument - - String response = LoRaWioE5.readString(); - Serial.println("[debug]Odpowiedz: " + response); - // Drukuje odpowiedz na komende -} - -String give_mess(int i) { - String message; - - message = String(i) + ". Wiadomosc"; - Serial.print("\n[debug]Wprowadzono: "); - Serial.println(message); - - return message; -} - -String give_bme() { - String message; - - message = " 53, "; // temperatura - message += " 567, "; // wilgotnosc - message += " 242, "; // cisnienie - message += " 534"; // wysokosc - - Serial.print("\n[debug]Wprowadzono: "); - Serial.println(message); - - return message; -} - -String give_gps() { - String message = " Bledne dane "; - - message = " 523, "; // dl geogr - message += " 523,"; // szer geogr - message += " 234, "; // czas - message += " 654, "; // wysoksoc - message += " 4234"; // dokladnosc - - Serial.print("\n[debug]Wprowadzono: "); - Serial.println(message); - - return message; -} - -} // namespace Lora2 \ No newline at end of file diff --git a/projects/LoRa_Transmitter/src/main.cpp b/projects/LoRa_Transmitter/src/main.cpp deleted file mode 100644 index a1d5aac..0000000 --- a/projects/LoRa_Transmitter/src/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "LoRa.hpp" - -// Second serial port on ESP32 - -int i = 1; - -void setup() { - Serial.begin(115200); - Serial.println("start"); - Lora::init(); - // use lora2 ns for debug -} - -void loop() { - Lora::send(give_mess(i)); - delay(5000); // delay for readable sake - i++; -} - -String give_mess(int i) { return String(i) + ". Wiadomosc"; } diff --git a/projects/LoRa_Transmitter/test.txt b/projects/LoRa_Transmitter/test.txt deleted file mode 100644 index c47b963..0000000 --- a/projects/LoRa_Transmitter/test.txt +++ /dev/null @@ -1 +0,0 @@ -No siema \ No newline at end of file diff --git a/projects/MPU/test.txt b/projects/MPU/test.txt deleted file mode 100644 index 1bd28dc..0000000 --- a/projects/MPU/test.txt +++ /dev/null @@ -1 +0,0 @@ -coś diff --git a/projects/Main/.gitignore b/projects/Main/.gitignore deleted file mode 100644 index 89cc49c..0000000 --- a/projects/Main/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.pio -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/ipch diff --git a/projects/Main/.vscode/extensions.json b/projects/Main/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/projects/Main/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/projects/Main/.vscode/settings.json b/projects/Main/.vscode/settings.json deleted file mode 100644 index 4f51d5d..0000000 --- a/projects/Main/.vscode/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "editor.tabSize": 2, - "files.exclude": { - "**/.git": true, - }, - "editor.wordWrap": "on", - // C++ formatter settings - "[cpp]": { - "editor.defaultFormatter": "ms-vscode.cpptools", // Use the C/C++ extension as the default formatter - "editor.formatOnSave": true // Automatically format C++ files when saving - }, - "C_Cpp.clang_format_style": "file", // Use the .clang-format file in your project (if present) or default style - "C_Cpp.clang_format_fallbackStyle": "Google" // Fallback style if .clang-format file is not found -} diff --git a/projects/Main/include/README b/projects/Main/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/projects/Main/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/projects/Main/include/bmp.hpp b/projects/Main/include/bmp.hpp deleted file mode 100644 index e46d9ae..0000000 --- a/projects/Main/include/bmp.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -namespace bmp { -// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej -void begin(); - -struct Data { - float temperature; - float pressure; - float altitude; - - float get_as_hpa(); -}; - -Data measurements(); -void pretty_print(); -} // namespace bmp \ No newline at end of file diff --git a/projects/Main/include/button.h b/projects/Main/include/button.h deleted file mode 100644 index ed49245..0000000 --- a/projects/Main/include/button.h +++ /dev/null @@ -1,7 +0,0 @@ -#include -extern QueueHandle_t xQueue; - -namespace button { - -void button_task(void *pvParameters); -} // namespace button \ No newline at end of file diff --git a/projects/Main/include/interrupts.h b/projects/Main/include/interrupts.h deleted file mode 100644 index 2ccb479..0000000 --- a/projects/Main/include/interrupts.h +++ /dev/null @@ -1,10 +0,0 @@ -#include -#define BUTTON_PIN 0 // Change this to your button pin - -extern QueueHandle_t xQueue; - -namespace interrupts { - -void setup(); -void IRAM_ATTR button_isr(); -} // namespace interrupts diff --git a/projects/Main/lib/README b/projects/Main/lib/README deleted file mode 100644 index 2593a33..0000000 --- a/projects/Main/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/projects/Main/platformio.ini b/projects/Main/platformio.ini deleted file mode 100644 index 435be1c..0000000 --- a/projects/Main/platformio.ini +++ /dev/null @@ -1,16 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:lolin32_lite] -platform = espressif32 -board = lolin32_lite -framework = arduino -monitor_speed = 115200 -lib_deps = adafruit/Adafruit BMP280 Library@^2.6.8 diff --git a/projects/Main/src/bmp.cpp b/projects/Main/src/bmp.cpp deleted file mode 100644 index 491f2aa..0000000 --- a/projects/Main/src/bmp.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "bmp.hpp" - -// korzystanie z Adafruit BMP280 Library by Adafruit -#include -#include - -// 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 -#define SEALEVELPRESSURE_HPA (1019.91) - -Adafruit_BMP280 bmp_obj; - -namespace bmp { - -// wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej -void begin() { - if (!bmp_obj.begin(0x76)) { - 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(); - Serial.print("Temperature = "); - Serial.print(exp.temperature); - Serial.println(" *C"); - - Serial.print("Pressure = "); - Serial.print(exp.get_as_hpa()); - Serial.println(" hPa"); - - Serial.print("Approx. Altitude = "); - Serial.print(exp.altitude); - Serial.println(" m"); - - Serial.println(); -} - -float Data::get_as_hpa() { return bmp_obj.readPressure() / 100.0F; } -} // namespace bmp \ No newline at end of file diff --git a/projects/Main/src/button.cpp b/projects/Main/src/button.cpp deleted file mode 100644 index cd6c011..0000000 --- a/projects/Main/src/button.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "button.h" - -namespace button { - -void button_task(void* pvParameters) { - Serial.println("Button pressed!"); - vTaskDelete(NULL); -} -} // namespace button \ No newline at end of file diff --git a/projects/Main/src/interrupts.cpp b/projects/Main/src/interrupts.cpp deleted file mode 100644 index 4b0335f..0000000 --- a/projects/Main/src/interrupts.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "interrupts.h" - -namespace interrupts { - -void setup() { - pinMode(BUTTON_PIN, INPUT_PULLUP); - attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), button_isr, FALLING); -} - -void IRAM_ATTR button_isr() { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - uint32_t isr_msg = 1; - xQueueSendFromISR(xQueue, &isr_msg, &xHigherPriorityTaskWoken); - if (xHigherPriorityTaskWoken) { - portYIELD_FROM_ISR(); - } -} -} // namespace interrupts diff --git a/projects/Main/src/led.cpp b/projects/Main/src/led.cpp deleted file mode 100644 index a74ccc4..0000000 --- a/projects/Main/src/led.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "led.h" - -namespace led { - -void blink_task(void* pvParameters) { - pinMode(LED_BUILTIN, OUTPUT); - for (;;) { - digitalWrite(LED_BUILTIN, HIGH); - vTaskDelay(pdMS_TO_TICKS(500)); // delay for 500ms without blocking the CPU - digitalWrite(LED_BUILTIN, LOW); - vTaskDelay(pdMS_TO_TICKS(500)); // delay for 500ms - } -} -} // namespace led \ No newline at end of file diff --git a/projects/Main/src/main.cpp b/projects/Main/src/main.cpp deleted file mode 100644 index a6a8eec..0000000 --- a/projects/Main/src/main.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include - -#include "bmp.hpp" -#include "button.h" -#include "interrupts.h" -#include "led.h" - -QueueHandle_t xQueue; - -void setup() { - Serial.begin(115200); - Serial.println("--- Starting the rocket... ---"); - - xQueue = xQueueCreate(10, sizeof(uint32_t)); // create xQueue - interrupts::setup(); - xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - - bmp::Data globalData[10]; - - void bmp_task() { - for (;;) { - bmp::Data tempData[10]; - for (int i = 0; i < 10; i++) { - tempData[i] = bmp::measure(); - vTaskDelay(pdMS_TO_TICKS(100)); - } - // Copy tempData to globalData - memcpy(globalData, tempData, sizeof(globalData)); - } - } - - xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - if (xQueue != NULL) - xTaskCreate(button::button_task, "button", 10000, NULL, 1, NULL); -} - -void loop() { - // put your main code here, to run repeatedly: -} diff --git a/projects/Main/test/README b/projects/Main/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/projects/Main/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/projects/RocketComputer/.gitignore b/projects/RocketComputer/.gitignore deleted file mode 100644 index 89cc49c..0000000 --- a/projects/RocketComputer/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.pio -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/ipch diff --git a/projects/RocketComputer/.vscode/extensions.json b/projects/RocketComputer/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/projects/RocketComputer/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/projects/RocketComputer/lib/README b/projects/RocketComputer/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/projects/RocketComputer/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/projects/RocketComputer/lib/led.hpp b/projects/RocketComputer/lib/led.hpp deleted file mode 100644 index 23614fb..0000000 --- a/projects/RocketComputer/lib/led.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#define LED_BUILTIN 2 - -void TaskBlinkLED(void *pvParameters) \ No newline at end of file diff --git a/projects/RocketComputer/platformio.ini b/projects/RocketComputer/platformio.ini deleted file mode 100644 index 9680fa8..0000000 --- a/projects/RocketComputer/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:lolin32_lite] -platform = espressif32 -board = lolin32_lite -framework = arduino diff --git a/projects/RocketComputer/src/led.cpp b/projects/RocketComputer/src/led.cpp deleted file mode 100644 index 8c703ce..0000000 --- a/projects/RocketComputer/src/led.cpp +++ /dev/null @@ -1,9 +0,0 @@ -void TaskBlinkLED(void *pvParameters) { - pinMode(LED_BUILTIN, OUTPUT); - for(;;) { - digitalWrite(LED_BUILTIN, HIGH); - vTaskDelay(pdMS_TO_TICKS(500)); // delay for 500ms - digitalWrite(LED_BUILTIN, LOW); - vTaskDelay(pdMS_TO_TICKS(500)); // delay for 500ms - } -} \ No newline at end of file diff --git a/projects/RocketComputer/src/main.cpp b/projects/RocketComputer/src/main.cpp deleted file mode 100644 index 0e83292..0000000 --- a/projects/RocketComputer/src/main.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -#include -#include - -#define BUTTON_PIN 0 // Change this to your button pin - -QueueHandle_t xQueue; - -void IRAM_ATTR button_isr() { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - uint32_t isr_msg = 1; - xQueueSendFromISR(xQueue, &isr_msg, &xHigherPriorityTaskWoken); - if (xHigherPriorityTaskWoken) { - portYIELD_FROM_ISR(); - } -} - -void TaskButton(void *pvParameters) { - uint32_t rx_msg; - for (;;) { - if (xQueueReceive(xQueue, &rx_msg, portMAX_DELAY)) { - // Button press detected, do something here - } - } -} - -void setup() { - pinMode(BUTTON_PIN, INPUT_PULLUP); - attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), button_isr, FALLING); - - xQueue = xQueueCreate(10, sizeof(uint32_t)); - if (xQueue != NULL) { - xTaskCreate(TaskButton, "TaskButton", 10000, NULL, 1, NULL); - } - xTaskCreate(TaskBlinkLED, /* Task function. */ - "TaskBlinkLED", /* String with name of task. */ - 10000, /* Stack size in bytes. */ - NULL, /* Parameter passed as input of the task */ - 1, /* Priority of the task. */ - NULL); /* Task handle. */ -} - -void loop() { - // put your main code here, to run repeatedly: -} diff --git a/projects/RocketComputer/test/README b/projects/RocketComputer/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/projects/RocketComputer/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/projects/T-beam/.gitignore b/projects/T-beam/.gitignore deleted file mode 100644 index 89cc49c..0000000 --- a/projects/T-beam/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.pio -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/ipch diff --git a/projects/T-beam/.vscode/extensions.json b/projects/T-beam/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/projects/T-beam/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/projects/T-beam/include/led.h b/projects/T-beam/include/led.h deleted file mode 100644 index 419bdcf..0000000 --- a/projects/T-beam/include/led.h +++ /dev/null @@ -1,6 +0,0 @@ -#include - -namespace led { - -void blink_task(void *pvParameters); -} // namespace led \ No newline at end of file diff --git a/projects/T-beam/test/README b/projects/T-beam/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/projects/T-beam/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/projects/bmp/.gitignore b/projects/bmp/.gitignore deleted file mode 100644 index b9f3806..0000000 --- a/projects/bmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.pio -.vscode diff --git a/projects/bmp/.vscode/extensions.json b/projects/bmp/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/projects/bmp/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/projects/bmp/include/README b/projects/bmp/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/projects/bmp/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/projects/bmp/include/bmp.hpp b/projects/bmp/include/bmp.hpp deleted file mode 100644 index 9ca9def..0000000 --- a/projects/bmp/include/bmp.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -namespace bmp { -//wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej -void begin(); - -struct Data { - float temperature; - float pressure; - float altitude; - - float get_as_hpa(); -}; - -Data measurements(); -void pretty_print(); -} \ No newline at end of file diff --git a/projects/bmp/lib/README b/projects/bmp/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/projects/bmp/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/projects/bmp/platformio.ini b/projects/bmp/platformio.ini deleted file mode 100644 index 23528d1..0000000 --- a/projects/bmp/platformio.ini +++ /dev/null @@ -1,15 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:lolin32_lite] -platform = espressif32 -board = lolin32_lite -framework = arduino -lib_deps = adafruit/Adafruit BMP280 Library@^2.6.8 diff --git a/projects/bmp/src/bmp.cpp b/projects/bmp/src/bmp.cpp deleted file mode 100644 index 814eec4..0000000 --- a/projects/bmp/src/bmp.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "bmp.hpp" - -//korzystanie z Adafruit BMP280 Library by Adafruit -#include -#include - -// 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 -#define SEALEVELPRESSURE_HPA (1019.91) - -Adafruit_BMP280 bmp_obj; - -namespace bmp { - -//wymaga ustawienia Wire.begin(SDA_PIN, SCL_PIN) wcześniej -void begin() { - if (!bmp_obj.begin(0x76)) { - 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(); - Serial.print("Temperature = "); - Serial.print(exp.temperature); - Serial.println(" *C"); - - Serial.print("Pressure = "); - Serial.print(exp.get_as_hpa()); - Serial.println(" hPa"); - - Serial.print("Approx. Altitude = "); - Serial.print(exp.altitude); - Serial.println(" m"); - - Serial.println(); -} - -float Data::get_as_hpa() { - return bmp_obj.readPressure()/100.0F; -} -} \ No newline at end of file diff --git a/projects/bmp/src/main.cpp b/projects/bmp/src/main.cpp deleted file mode 100644 index 0e3dbb2..0000000 --- a/projects/bmp/src/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include "bmp.hpp" - - -void setup() { - Wire.begin(23,19); - Serial.begin(9600); - bmp::begin(); -} - -void loop() { - bmp::pretty_print(); - delay(2000); -} \ No newline at end of file diff --git a/projects/bmp/test/README b/projects/bmp/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/projects/bmp/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/projects/firmware b/projects/firmware deleted file mode 160000 index 147de75..0000000 --- a/projects/firmware +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 147de75a0295e7c8e71605d7fd007dfa222a5c12 diff --git a/projects/spadochron/krzysiek.txt b/projects/spadochron/krzysiek.txt deleted file mode 100644 index e69de29..0000000 diff --git a/projects/spadochron/redme.txt b/projects/spadochron/redme.txt deleted file mode 100644 index 74a4e7a..0000000 --- a/projects/spadochron/redme.txt +++ /dev/null @@ -1 +0,0 @@ -dupa123 \ No newline at end of file From b4f1cf6e77a2e88e3a60733cae025a410f9b7c4b Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 27 Jun 2024 00:43:51 +0200 Subject: [PATCH 7/8] cleanup --- T-beam/include/bmp.h | 2 +- T-beam/include/constants.h | 3 +++ T-beam/src/bmp.cpp | 2 +- T-beam/src/main.cpp | 11 ++++++----- 4 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 T-beam/include/constants.h diff --git a/T-beam/include/bmp.h b/T-beam/include/bmp.h index 0301495..162ff0a 100644 --- a/T-beam/include/bmp.h +++ b/T-beam/include/bmp.h @@ -12,7 +12,7 @@ struct Data { inline Data data; -void get_bme(void* pvParameters); +void get_bmp(void* pvParameters); void print_data(void* pvParameters); Data measurements(); void pretty_print(Data); diff --git a/T-beam/include/constants.h b/T-beam/include/constants.h new file mode 100644 index 0000000..2d9f24e --- /dev/null +++ b/T-beam/include/constants.h @@ -0,0 +1,3 @@ +#define SDA 21 +#define SCL 22 +#define BAUD_RATE 115200 \ No newline at end of file diff --git a/T-beam/src/bmp.cpp b/T-beam/src/bmp.cpp index 6bacb35..a023fb7 100644 --- a/T-beam/src/bmp.cpp +++ b/T-beam/src/bmp.cpp @@ -29,7 +29,7 @@ Data measurements() { return check; }; -void get_bme(void* pvParameters) { +void get_bmp(void* pvParameters) { for (;;) { data = measurements(); vTaskDelay(pdMS_TO_TICKS(500)); diff --git a/T-beam/src/main.cpp b/T-beam/src/main.cpp index 8275c8f..1502732 100644 --- a/T-beam/src/main.cpp +++ b/T-beam/src/main.cpp @@ -2,22 +2,23 @@ #include #include "bmp.h" +#include "constants.h" #include "gps.h" #include "led.h" #include "memory.h" void setup() { - Serial.begin(115200); - Serial.println("--- Starting the rocket... ---"); - Wire.begin(21, 22); + Wire.begin(SDA, SCL); + Serial.begin(BAUD_RATE); + Serial.println("--- ROCKET COMPUTER START ---"); - memory::init(); // loads config + memory::init(); // loads config as well gps::init(); bmp::init(); // xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - xTaskCreate(bmp::get_bme, "bmp", 10000, NULL, 1, NULL); + xTaskCreate(bmp::get_bmp, "bmp", 10000, NULL, 1, NULL); xTaskCreate(bmp::print_data, "bmp printing", 10000, NULL, 1, NULL); memory::print_data(); From c8d3a231222d870b85e78440d5056be5137de440 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 27 Jun 2024 00:47:05 +0200 Subject: [PATCH 8/8] more cleanup --- T-beam/include/constants.h | 3 ++- T-beam/src/main.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/T-beam/include/constants.h b/T-beam/include/constants.h index 2d9f24e..6d00461 100644 --- a/T-beam/include/constants.h +++ b/T-beam/include/constants.h @@ -1,3 +1,4 @@ #define SDA 21 #define SCL 22 -#define BAUD_RATE 115200 \ No newline at end of file +#define BAUD_RATE 115200 +#define DEFAULT_TASK_SIZE 10000 \ No newline at end of file diff --git a/T-beam/src/main.cpp b/T-beam/src/main.cpp index 1502732..d02c534 100644 --- a/T-beam/src/main.cpp +++ b/T-beam/src/main.cpp @@ -16,10 +16,10 @@ void setup() { gps::init(); bmp::init(); - // xTaskCreate(gps::gps_loop, "gps", 10000, NULL, 1, NULL); - xTaskCreate(led::blink_task, "blink", 10000, NULL, 1, NULL); - xTaskCreate(bmp::get_bmp, "bmp", 10000, NULL, 1, NULL); - xTaskCreate(bmp::print_data, "bmp printing", 10000, NULL, 1, NULL); + // 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!"};