You've already forked TEF6686_ESP32
Compare commits
2 Commits
a3f1c194ba
...
f8c7e2a36d
| Author | SHA1 | Date | |
|---|---|---|---|
|
f8c7e2a36d
|
|||
|
86181c1439
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
sdkconfig**
|
||||
!sdkconfig.defaults
|
||||
3
CMakeLists.txt
Normal file
3
CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(TEF6686_ESP32)
|
||||
@@ -12,5 +12,4 @@ extern ESP32Time rtc;
|
||||
extern bool rx_rtc_avail;
|
||||
|
||||
bool init_rtc();
|
||||
void sync_from_rx_rtc(int32_t offset = 0);
|
||||
void set_time(time_t time);
|
||||
@@ -6,7 +6,8 @@ platform = espressif32
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
framework = arduino, espidf
|
||||
board_build.f_flash = 80000000L
|
||||
board_build.partitions = maxapp.csv
|
||||
build_flags =
|
||||
-Wall
|
||||
@@ -18,8 +19,8 @@ build_flags =
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-Wl,--gc-sections
|
||||
-DARDUINO_LOOP_STACK_SIZE=4096
|
||||
-Werror
|
||||
-Wno-error=missing-field-initializers
|
||||
monitor_filters =
|
||||
esp32_exception_decoder
|
||||
default
|
||||
|
||||
50
sdkconfig.defaults
Normal file
50
sdkconfig.defaults
Normal file
@@ -0,0 +1,50 @@
|
||||
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y
|
||||
CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
|
||||
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_BEFORE_NORESET=y
|
||||
CONFIG_ESPTOOLPY_AFTER_NORESET=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="maxapp.csv"
|
||||
CONFIG_ARDUINO_RUN_CORE0=y
|
||||
CONFIG_ARDUINO_SELECTIVE_COMPILATION=y
|
||||
# CONFIG_ARDUINO_SELECTIVE_AsyncUDP is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_AzureIoT is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_BLE is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_BluetoothSerial is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_EEPROM is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_FFat is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_HTTPClient is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_LITTLEFS is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_NetBIOS is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_Preferences is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_SD is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_SD_MMC is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_SimpleBLE is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_Ticker is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_Update is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_WiFiClientSecure is not set
|
||||
# CONFIG_ARDUINO_SELECTIVE_WiFiProv is not set
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y
|
||||
CONFIG_ESP32_REV_MIN_1=y
|
||||
# CONFIG_ETH_USE_ESP32_EMAC is not set
|
||||
# CONFIG_ETH_USE_SPI_ETHERNET is not set
|
||||
# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set
|
||||
# CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_HAL_ASSERTION_DISABLE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
|
||||
# CONFIG_LOG_COLORS is not set
|
||||
CONFIG_MBEDTLS_PSK_MODES=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||
# CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK is not set
|
||||
# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK is not set
|
||||
# CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK is not set
|
||||
# CONFIG_MQTT_PROTOCOL_311 is not set
|
||||
# CONFIG_MQTT_TRANSPORT_SSL is not set
|
||||
CONFIG_SPIFFS_MAX_PARTITIONS=1
|
||||
# CONFIG_SPIFFS_USE_MTIME is not set
|
||||
# CONFIG_WS_TRANSPORT is not set
|
||||
# CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER is not set
|
||||
6
src/CMakeLists.txt
Normal file
6
src/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file was automatically generated for projects
|
||||
# without default 'CMakeLists.txt' file.
|
||||
|
||||
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
|
||||
|
||||
idf_component_register(SRCS ${app_sources})
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -21,6 +21,9 @@ using fs::FS;
|
||||
#include "nonvolatile.h"
|
||||
#include "utils.h"
|
||||
#include "system_console.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#pragma endregion
|
||||
|
||||
Console console(&tft);
|
||||
@@ -846,7 +849,7 @@ int GetNum() {
|
||||
// According to the docs, register 0 contains pins IO0_x where x is equal to the bit from the right (x = 7, is MSB)
|
||||
|
||||
int cnt = 0;
|
||||
int16_t temp;
|
||||
uint16_t temp;
|
||||
unsigned int num;
|
||||
if(Wire.available() == 2) {
|
||||
keypadtimer = millis();
|
||||
@@ -1398,7 +1401,6 @@ void setup() {
|
||||
else {
|
||||
rtcset = true;
|
||||
console.print("RX8010SJ is used as a time source");
|
||||
sync_from_rx_rtc();
|
||||
}
|
||||
} else console.print("RX8010SJ is not available at address " + String(RX8010SJ_ADDRESS, HEX));
|
||||
|
||||
@@ -3959,4 +3961,13 @@ uint8_t doAutoMemory(uint16_t startfreq, uint16_t stopfreq, uint8_t startmem, ui
|
||||
SQ = false;
|
||||
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void app_main() {
|
||||
initArduino();
|
||||
setup();
|
||||
while(true) {
|
||||
loop();
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
69
src/rtc.cpp
69
src/rtc.cpp
@@ -8,7 +8,7 @@ bool NTPupdated;
|
||||
ESP32Time rtc(0);
|
||||
bool rx_rtc_avail = false;
|
||||
|
||||
byte readFromModule(byte address) {
|
||||
inline byte readFromModule(byte address) {
|
||||
Wire.beginTransmission(RX8010SJ_ADDRESS);
|
||||
Wire.write(address);
|
||||
Wire.endTransmission();
|
||||
@@ -43,35 +43,7 @@ inline byte sumValueFromBinary(byte binary, byte length) {
|
||||
return sum;
|
||||
}
|
||||
|
||||
bool init_rtc() {
|
||||
rtc.setTime(0);
|
||||
byte flagregister = readFromModule(0x1E);
|
||||
if((flagregister >> 1) & 1) {
|
||||
while((flagregister >> 1) & 1) {
|
||||
writeToModule(0x1E, 0); // clear VLF
|
||||
flagregister = readFromModule(0x1E);
|
||||
}
|
||||
writeToModule(0x17, 216); // Reserved register
|
||||
writeToModule(0x1F, 0); // Control register
|
||||
writeToModule(0x31, 8); // Reserved register
|
||||
writeToModule(0x32, 0); // IRQ control register
|
||||
|
||||
Wire.beginTransmission(RX8010SJ_ADDRESS);
|
||||
Wire.write(0x10);
|
||||
Wire.write(0);
|
||||
Wire.write(0);
|
||||
Wire.write(toBCD(12));
|
||||
Wire.write(1 << 2);
|
||||
Wire.write(toBCD(14));
|
||||
Wire.write(1);
|
||||
Wire.write(toBCD(26));
|
||||
Wire.endTransmission();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void sync_from_rx_rtc(int32_t offset) {
|
||||
void sync_from_rx_rtc(int32_t offset = 0) {
|
||||
if(!rx_rtc_avail) return;
|
||||
struct tm timeinfo;
|
||||
|
||||
@@ -97,10 +69,46 @@ void sync_from_rx_rtc(int32_t offset) {
|
||||
}
|
||||
}
|
||||
|
||||
bool init_rtc() {
|
||||
rtc.setTime(0);
|
||||
byte flagregister = readFromModule(0x1E);
|
||||
if((flagregister >> 1) & 1) {
|
||||
while((flagregister >> 1) & 1) {
|
||||
writeToModule(0x1E, 0); // clear VLF
|
||||
flagregister = readFromModule(0x1E);
|
||||
}
|
||||
writeToModule(0x17, 216); // Reserved register
|
||||
writeToModule(0x1F, 64); // Control register, stop bit set
|
||||
|
||||
Wire.beginTransmission(RX8010SJ_ADDRESS);
|
||||
Wire.write(0x31);
|
||||
Wire.write(8); // Reserved register
|
||||
Wire.write(0); // IRQ control register
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.beginTransmission(RX8010SJ_ADDRESS);
|
||||
Wire.write(0x10);
|
||||
Wire.write(0);
|
||||
Wire.write(0);
|
||||
Wire.write(toBCD(12));
|
||||
Wire.write(1 << 2);
|
||||
Wire.write(toBCD(14));
|
||||
Wire.write(1);
|
||||
Wire.write(toBCD(26));
|
||||
Wire.endTransmission();
|
||||
writeToModule(0x1F, 0); // Unset stop bit
|
||||
sync_from_rx_rtc();
|
||||
return true;
|
||||
}
|
||||
sync_from_rx_rtc();
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_time(time_t time) {
|
||||
rtc.setTime(time);
|
||||
if(!rx_rtc_avail) return;
|
||||
struct tm* timeinfo = gmtime(&time);
|
||||
writeToModule(0x1F, 64);
|
||||
Wire.beginTransmission(RX8010SJ_ADDRESS);
|
||||
Wire.write(0x10);
|
||||
Wire.write(toBCD(timeinfo->tm_sec));
|
||||
@@ -111,4 +119,5 @@ void set_time(time_t time) {
|
||||
Wire.write(toBCD(timeinfo->tm_mon + 1));
|
||||
Wire.write(toBCD((1900 + timeinfo->tm_year) % 100));
|
||||
Wire.endTransmission();
|
||||
writeToModule(0x1F, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user