Обновление Arduino

This commit is contained in:
2024-05-04 23:17:18 +03:00
parent 3c5f55f5f6
commit 0a33eb02ea
10 changed files with 46 additions and 33 deletions

View File

@ -1,10 +1,11 @@
# Arduino
## std
![Arduino Logo](../../assets/languages/arduino.svg)
* [Пример, который возвращает дату и время компиляции скетча](compile_date_time.c)
* [Размер типов перенных в байтах](variables_sizes.ino)
* Пример работы с [EEPROM](eeprom.ino)
## Дата и время
- [`__DATE__` и `__TIME__`](date/compile_date_time.c) — Пример, который отображает дату и время компиляции скетча
- [](date/DATE_to_YYYY-MM-DD.c) — Функция для преобразования `__DATE__` в формат `ГГГГ-ММ-ДД`
## Функции
@ -12,6 +13,10 @@
## Память
### EEPROM
- [EEPROM](memory/eeprom.ino) — Пример работы с EEPROM
| Тип | Чтение из программы | Запись из программы | Очистка при перезагрузке |
|--------|---------------------|---------------------|--------------------------|
| Flash | Да, PROGMEM | Можно, но сложно | Нет |
@ -25,3 +30,12 @@ EEPROM представляет собой область памяти, сост
* ATmega2560 (Arduino Mega): `4 кБ`
* ATtiny85 (Digispark): `512 Б`
* ESP8266 / ESP32: `4096 Б`
### RAM
- [EEPROM](memory/variables_sizes.ino) — Размер типов перенных в байтах
- [`free_ram()`](memory/free_ram.c) — Функция, которая возвращает количество свободной RAM
## Serial
- [`serial.find()`](memory/find.ino) — Ищет строку полученную из Serial

View File

@ -1,21 +0,0 @@
// TODO: Добавить описание
// TODO: Добавить в README.md
// Adapted from http://stackoverflow.com/questions/1765014/convert-string-from-date-into-a-time-t
// Formats __DATE__ to YYYY-MM-DD format
String ArduinoDateToDisplayDate(char const *time) {
char s_month[5];
int month, day, year;
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
sscanf(time, "%s %d %d", s_month, &day, &year);
month = (strstr(month_names, s_month)-month_names)/3;
String monthText = month < 10 ? "0" + String(month) : String(month);
String dayText = day < 10 ? "0" + String(day) : String(day);
return String(year) + "-" + monthText + "-" + dayText;
}
// https://gist.github.com/djohnson001/6df673a8d7f8ac04246a

View File

@ -0,0 +1,19 @@
// Adapted from http://stackoverflow.com/questions/1765014/convert-string-from-date-into-a-time-t
// Formats __DATE__ to YYYY-MM-DD format
String ArduinoDateToDisplayDate(char const *time) {
char s_month[5];
int month, day, year;
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
sscanf(time, "%s %d %d", s_month, &day, &year);
month = (strstr(month_names, s_month)-month_names)/3;
String monthText = month < 10 ? "0" + String(month) : String(month);
String dayText = day < 10 ? "0" + String(day) : String(day);
return String(year) + "-" + monthText + "-" + dayText;
}
// https://gist.github.com/djohnson001/6df673a8d7f8ac04246a

View File

@ -3,9 +3,9 @@
*/
void loop() {
Serial.println("Built: " __DATE__ " | " __TIME__);
/**
* Output:
* Built: Aug 16 2023 | 21:42:32
*/
Serial.println("Built: " __DATE__ " | " __TIME__);
/**
* Output:
* Built: Aug 16 2023 | 21:42:32
*/
}

View File

@ -1,5 +1,6 @@
int freeRAM() {
int free_ram() {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

View File

@ -9,8 +9,7 @@ void setup() {
if (Serial.available() > 0) {
if (Serial.find(target))
Serial.println("found");
// вывести found, если было послано hello
Serial.println("found"); // выведет `found`, если получено `hello`
}
}