Hello,
Can't find how at ArduinoIDE2 with ESP32S3 create and use simple SW or HW Time Counter (aka "stopwatch") without needing any additional libraries etc. No tasks, no interrupt, just count time in seconds from 00:00:00:00 (hr:mn:sc:milsc) at 24hr format maybe with days in front like 01:23:59:59:1000? Seems very simple, but can't find how to make it without any additional libraries and complex [struct] etc which I don't need!
Simple Time Counter (stopwatch)
Re: Simple Time Counter (stopwatch)
Asked chat GPT and here is it's response.
Code: Select all
#include "esp_system.h"
#include "esp_timer.h"
#include "esp_log.h"
void app_main() {
// Initialize the system
esp_err_t ret = esp_system_initialize();
if (ret != ESP_OK) {
ESP_LOGE("main", "Initialization failed, error = %d", ret);
return;
}
// Get the current uptime in milliseconds
uint64_t uptime_ms = esp_timer_get_time() / 1000;
// Display the uptime in seconds
ESP_LOGI("main", "Uptime: %llu seconds", uptime_ms / 1000);
// You can also convert uptime to hours, minutes, and seconds if needed
uint64_t seconds = uptime_ms / 1000;
uint64_t minutes = seconds / 60;
uint64_t hours = minutes / 60;
seconds %= 60;
minutes %= 60;
ESP_LOGI("main", "Uptime: %llu hours, %llu minutes, %llu seconds", hours, minutes, seconds);
}
Re: Simple Time Counter (stopwatch)
For Arduino!
More simple, withOUT 3 #include!username wrote: ↑Fri Nov 03, 2023 5:12 amAsked chat GPT and here is it's response.Code: Select all
#include "esp_system.h" #include "esp_timer.h" #include "esp_log.h"
Re: Simple Time Counter (stopwatch)
Just curious, what the issue with #include?More simple, withOUT 3 #include!
You already #include arduino.h, and that one line pulls in a ton of stuff.
Who is online
Users browsing this forum: axellin, Bing [Bot] and 123 guests