Audyt: poprawki integracji ESP32-S2/CC1101/LM317T i testy regresji
check / check-without-hardware (push) Canceled after 0s

- EXT1 wake: pociagniecia RTC przycisku/LF przed deep sleep (pull-up
  cyfrowy nie dziala przy wylaczonej domenie RTC_PERIPH)
- konsola: odrzucanie NaN/nieskonczonosci; przenosny modul parse z testami
- zasilanie: dzielnik ADC R2 180 kOhm (zakres do ~16 V zamiast nasycania
  ADC powyzej ~11,8 V)
- package_release: merge_bin --flash-freq 80m zgodne z lolin_s2_mini
- tpms_frame.py: saturacja temperatury zgodna z firmware
- testy: sciezka checksum w negatywach, test_parse, poprawny diagram bitow
This commit is contained in:
czcionka committed 2026-10-28 19:10:25 +00:00
1 parent d53299ba11
commit 882962b156
16 files changed
+231 -62

No files matched your search

+5 -1
View File
@@ -32,8 +32,12 @@
#ifndef PIN_VBAT_ADC
#define PIN_VBAT_ADC 1
#endif
/* Dzielnik mierzy zasilanie 12 V (prog LOWBATT 11,5 V). R2 = 180 kOhm
* daje pelny zakres ADC ok. 16,4 V przy pelnej skali 2,5 V (11 dB):
* 14,8 V ladowania daje 2,25 V na pinie, wiec odczyt nie nasyci sie.
* Wczesniejsze 270 kOhm nasycale ADC juz przy ok. 11,8 V. */
#define VBAT_DIVIDER_R1 1000000.0f
#define VBAT_DIVIDER_R2 270000.0f
#define VBAT_DIVIDER_R2 180000.0f
#define VBAT_CAL 1.000f
#define VBAT_SAMPLES 16
#define LOWBATT_THRESHOLD_MV 11500
+1 -49
View File
@@ -1,12 +1,11 @@
/* Konsola szeregowa: konfiguracja zapisywana w NVS, bez rekompilacji. */
#include <Arduino.h>
#include <esp_system.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "app.h"
#include "console.h"
#include "parse.h"
#include "power.h"
#include "settings_store.h"
@@ -14,53 +13,6 @@ static char line[96];
static uint8_t line_len;
static bool line_overflow;
static bool parse_u32(const char *text, uint32_t lo, uint32_t hi,
uint32_t *out, int base = 10)
{
if (text == NULL || *text == '\0' || *text == '-') {
return false;
}
errno = 0;
char *end = NULL;
unsigned long value = strtoul(text, &end, base);
if (errno != 0 || end == text || *end != '\0'
|| value < lo || value > hi) {
return false;
}
*out = (uint32_t)value;
return true;
}
static bool parse_i32(const char *text, int32_t lo, int32_t hi, int32_t *out)
{
if (text == NULL || *text == '\0') {
return false;
}
errno = 0;
char *end = NULL;
long value = strtol(text, &end, 10);
if (errno != 0 || end == text || *end != '\0' || value < lo || value > hi) {
return false;
}
*out = value;
return true;
}
static bool parse_float(const char *text, float lo, float hi, float *out)
{
if (text == NULL || *text == '\0') {
return false;
}
errno = 0;
char *end = NULL;
float value = strtof(text, &end);
if (errno != 0 || end == text || *end != '\0' || value < lo || value > hi) {
return false;
}
*out = value;
return true;
}
static bool parse_wheel(const char *text, uint8_t *wheel, bool allow_all = false)
{
if (allow_all && text != NULL && strcmp(text, "all") == 0) {
+53
View File
@@ -0,0 +1,53 @@
#include <errno.h>
#include <stdlib.h>
#include "parse.h"
bool parse_u32(const char *text, uint32_t lo, uint32_t hi, uint32_t *out,
int base)
{
if (text == NULL || *text == '\0' || *text == '-') {
return false;
}
errno = 0;
char *end = NULL;
unsigned long value = strtoul(text, &end, base);
if (errno != 0 || end == text || *end != '\0'
|| value < lo || value > hi) {
return false;
}
*out = (uint32_t)value;
return true;
}
bool parse_i32(const char *text, int32_t lo, int32_t hi, int32_t *out)
{
if (text == NULL || *text == '\0') {
return false;
}
errno = 0;
char *end = NULL;
long value = strtol(text, &end, 10);
if (errno != 0 || end == text || *end != '\0' || value < lo || value > hi) {
return false;
}
*out = value;
return true;
}
bool parse_float(const char *text, float lo, float hi, float *out)
{
if (text == NULL || *text == '\0') {
return false;
}
errno = 0;
char *end = NULL;
float value = strtof(text, &end);
/* Odwrocone porownanie odrzuca tez NaN (obie strony falszywe). */
if (errno != 0 || end == text || *end != '\0'
|| !(value >= lo && value <= hi)) {
return false;
}
*out = value;
return true;
}
+22
View File
@@ -0,0 +1,22 @@
/* Parsowanie argumentow konsoli; modul przenosny (testy native). */
#ifndef TPMS_PARSE_H
#define TPMS_PARSE_H
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
bool parse_u32(const char *text, uint32_t lo, uint32_t hi, uint32_t *out,
int base = 10);
bool parse_i32(const char *text, int32_t lo, int32_t hi, int32_t *out);
/* Odrzuca NaN i nieskonczonosc; zakres domkniety [lo, hi]. */
bool parse_float(const char *text, float lo, float hi, float *out);
#ifdef __cplusplus
}
#endif
#endif
+27
View File
@@ -2,6 +2,7 @@
#include <Arduino.h>
#include <esp_sleep.h>
#include <driver/gpio.h>
#include <driver/rtc_io.h>
#include <soc/soc_caps.h>
#if SOC_BT_SUPPORTED
#include <esp32-hal-bt.h>
@@ -74,6 +75,32 @@ void power_deep_sleep(uint32_t seconds)
#if PIN_LF_TRIGGER >= 0
wake_mask |= 1ULL << PIN_LF_TRIGGER;
#endif
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
/* Cyfrowe pull-up/pull-down (pinMode) nie dzialaja w deep sleep, gdy
* domena RTC_PERIPH jest wylaczona. Bez pociagniec RTC piny budzenia
* plywaja i EXT1 moze budzic losowo; konfigurujemy je tu i utrzymujemy
* mechanizmem HOLD (wg ESP-IDF sleep_modes dla EXT1). */
#if PIN_BUTTON >= 0
rtc_gpio_init((gpio_num_t)PIN_BUTTON);
#if BTN_ACTIVE_LEVEL == 0
rtc_gpio_pulldown_dis((gpio_num_t)PIN_BUTTON);
rtc_gpio_pullup_en((gpio_num_t)PIN_BUTTON);
#else
rtc_gpio_pullup_dis((gpio_num_t)PIN_BUTTON);
rtc_gpio_pulldown_en((gpio_num_t)PIN_BUTTON);
#endif
#endif
#if PIN_LF_TRIGGER >= 0
rtc_gpio_init((gpio_num_t)PIN_LF_TRIGGER);
#if LF_ACTIVE_LEVEL == 0
rtc_gpio_pulldown_dis((gpio_num_t)PIN_LF_TRIGGER);
rtc_gpio_pullup_en((gpio_num_t)PIN_LF_TRIGGER);
#else
rtc_gpio_pullup_dis((gpio_num_t)PIN_LF_TRIGGER);
rtc_gpio_pulldown_en((gpio_num_t)PIN_LF_TRIGGER);
#endif
#endif
#endif /* SOC_RTCIO_INPUT_OUTPUT_SUPPORTED */
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
esp_deep_sleep_enable_gpio_wakeup(wake_mask, ESP_GPIO_WAKEUP_GPIO_LOW);
#else