Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation fixes #2841

Merged
merged 32 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a0e8259
Add definitions for `FLASH_INIT_DATA` and `FLASH_INIT_DATA_VCC`.
mikee47 Jun 25, 2024
9187ca2
Review Host and Rp2040 README
mikee47 Jun 25, 2024
1ac0f10
Tidy Host Emulator documentation
mikee47 Jun 27, 2024
0f6ef9e
Update note on clang-tidy
mikee47 Jul 3, 2024
a4f4231
USE_US_TIMER not applicable to Esp32
mikee47 Jul 4, 2024
caedcc0
I2S driver not implemented yet for Esp32
mikee47 Jul 4, 2024
88577ac
Update notes on `STRICT` setting
mikee47 Jul 4, 2024
6d62c75
Sanitizers moved to main build
mikee47 Jul 8, 2024
44c7fc4
Change use of `build variables` to `configuration variables`
mikee47 Jul 8, 2024
2df92fa
Avoid use of typographic quotes
mikee47 Jul 8, 2024
04c67f7
Tidy up envvar references
mikee47 Jul 9, 2024
5ae61e5
Replace non-breaking space with regular space
mikee47 Jul 9, 2024
9a022fa
Update notes on esp8266 toolchain
mikee47 Jul 9, 2024
5deea48
Offer some suggestions on random restarts
mikee47 Jul 9, 2024
d3727d3
Fix Esp32/Host component titles
mikee47 Jul 9, 2024
b650186
Update README/About pages: Focus should be on C++
mikee47 Jun 27, 2024
314d2a0
Fix spelling errors / UTF-8 encoding issues
mikee47 Jul 14, 2024
3688b7d
Remove deprecated SPIFFS variables from documentation
mikee47 Jul 10, 2024
4a71d5d
Add note on status of espconn_ functions with updated lwip2 stack
mikee47 Jul 14, 2024
0637484
Review debugging notes
mikee47 Jul 15, 2024
481824a
Write python script to scan for dodgy characters
mikee47 Jul 14, 2024
319ccc6
Fix dodgy characters
mikee47 Jul 14, 2024
5e58bbf
Updates
mikee47 Jul 15, 2024
e6a04f5
Fixes
mikee47 Jul 9, 2024
b61ca9a
Move contents of Tools/ci/README into main CI information page
mikee47 Jul 15, 2024
bf4ef8c
Make information applicable to all architectures.
mikee47 Jul 15, 2024
7aab28f
Add Delegate class reference
mikee47 Jul 15, 2024
092a359
Review Arch README pages
mikee47 Jul 16, 2024
9128050
Revise Windows install intro
mikee47 Jul 16, 2024
6d21873
Fix links
mikee47 Jul 16, 2024
af84f60
Typo: rephrase.
mikee47 Jul 16, 2024
264916f
Quick run through codespell
mikee47 Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 59 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sming

Sming is an asynchronous embedded C/C++ framework with superb performance and multiple network features.
Sming is an asynchronous embedded C++ framework with superb performance and multiple network features.
Sming is [open source](LICENSE), modular and supports [multiple architectures](https://sming.readthedocs.io/en/latest/features.html) including ESP8266, ESP32 and RP2040.

[![Examples](https://github.com/SmingHub/Sming/wiki/images/small/combine.png)](https://github.com/SmingHub/Sming/wiki/examples)
Expand Down Expand Up @@ -42,20 +42,21 @@ The purpose of Sming is to simplify the creation of embedded applications. The d

To follow the latest development you will need to clone our `develop` branch:

```
```bash
git clone https://github.com/SmingHub/Sming.git
```


## Examples
The examples are a great way to learn the API and brush up your C/C++ knowledge.
Once you have completed the installation of the development tools, you can get the latest source code.

```
The examples are a great way to learn the API and brush up your C++ knowledge.
Once you have completed the installation of the development tools, you can get the latest source code:

```bash
git clone https://github.com/SmingHub/Sming.git
```

And check some of the examples.
And check some of the examples:

- [Basic Blink](#basic-blink)
- [Simple GPIO input/output](#simple-gpio-inputoutput)
Expand All @@ -68,9 +69,10 @@ And check some of the examples.
- [Email Client](#email-client)

### Basic Blink

Blinking is something like the "Hello World" example for the embedded world. You can check it using the commands below:

```
```bash
cd Sming/samples
cd Basic_Blink
make # -- compiles the application
Expand All @@ -80,6 +82,7 @@ make flash # -- tries to upload the application to your ESP8266 device.
More information at **[Sample Projects](https://sming.readthedocs.io/en/latest/samples.html)** page.

### Simple GPIO Input/Output

```c++
#define LED_PIN 2 // GPIO2
...
Expand All @@ -90,18 +93,21 @@ digitalWrite(LED_PIN, HIGH);
For a complete example take a look at the [Basic_Blink](samples/Basic_Blink/app/application.cpp) sample.

### Start Serial Communication

```c++
Serial.begin(9600);
Serial.println("Hello Sming! Let's do smart things.");
```

### Connect to WiFi

```c++
WifiStation.enable(true);
WifiStation.config("LOCAL-NETWORK", "123456789087"); // Put your SSID and password here
```

### Read DHT22 sensor

```c++
#include <Libraries/DHTesp/DHTesp.h> // This is just a popular Arduino library!

Expand All @@ -110,35 +116,37 @@ DHTesp dht;

void init()
{
  dht.setup(DHT_PIN, DHTesp::DHT22);
dht.setup(DHT_PIN, DHTesp::DHT22);

  float h = dht.getHumidity();
  float t = dht.getTemperature();
float h = dht.getHumidity();
float t = dht.getTemperature();
}
```

Take a look at the code of the [Humidity_DHT22](samples/Humidity_DHT22/app/application.cpp) sample.

### HTTP Client

```c++
HttpClient thingSpeak;
...
thingSpeak.downloadString("http://api.thingspeak.com/update?key=XXXXXXX&field1=" + String(sensorValue), onDataSent);

void onDataSent(HttpClient& client, bool successful)
{
  if (successful) {
    Serial.println("Successful!");
  }
  else {
    Serial.println("Failed");
  }
if (successful) {
Serial.println("Successful!");
}
else {
Serial.println("Failed");
}
}
```

For more examples take a look at the [HttpClient](samples/HttpClient/app/application.cpp), [HttpClient_Instapush](samples/HttpClient_Instapush/app/application.cpp) and [HttpClient_ThingSpeak](samples/HttpClient_ThingSpeak/app/application.cpp) samples.

### OTA Application Update

```c++
void doUpgrade()
{
Expand All @@ -151,20 +159,21 @@ void doUpgrade()
// select rom partition to flash
auto part = ota.getNextBootPartition();

  // The content located on ROM_0_URL will be stored to the new partition
  otaUpdater->addItem(ROM_0_URL, part);
// The content located on ROM_0_URL will be stored to the new partition
otaUpdater->addItem(ROM_0_URL, part);

  // and/or set a callback (called on failure or success without switching requested)
  otaUpdater->setCallback(upgradeCallback);
// and/or set a callback (called on failure or success without switching requested)
otaUpdater->setCallback(upgradeCallback);

  // start update
  otaUpdater->start();
// start update
otaUpdater->start();
}
```

For a complete example take a look at the [Basic_Ota](samples/Basic_Ota/app/application.cpp) sample.

### HTTP Server

```c++
server.listen(80);
server.paths.set("/", onIndex);
Expand All @@ -178,28 +187,29 @@ Serial.println(WifiStation.getIP());

void onIndex(HttpRequest &request, HttpResponse &response)
{
  TemplateFileStream *tmpl = new TemplateFileStream("index.html");
  auto &vars = tmpl->variables();
  vars["counter"] = String(counter);
  vars["IP"] = WifiStation.getIP().toString();
  vars["MAC"] = WifiStation.getMAC();
  response.sendTemplate(tmpl);
TemplateFileStream *tmpl = new TemplateFileStream("index.html");
auto &vars = tmpl->variables();
vars["counter"] = String(counter);
vars["IP"] = WifiStation.getIP().toString();
vars["MAC"] = WifiStation.getMAC();
response.sendTemplate(tmpl);
}

void onFile(HttpRequest &request, HttpResponse &response)
{
  String file = request.getPath();
  if (file[0] == '/')
    file = file.substring(1);
String file = request.getPath();
if (file[0] == '/')
file = file.substring(1);

  response.setCache(86400, true);
  response.sendFile(file);
response.setCache(86400, true);
response.sendFile(file);
}
```

For more examples take a look at the [HttpServer_ConfigNetwork](samples/HttpServer_ConfigNetwork/app/application.cpp), [HttpServer_Bootstrap](samples/HttpServer_Bootstrap/app/application.cpp), [HttpServer_WebSockets](samples/HttpServer_WebSockets/app/application.cpp) and [HttpServer_AJAX](samples/HttpServer_AJAX/app/application.cpp) samples.

### Email Client

```c++
SmtpClient emailClient;

Expand All @@ -221,34 +231,36 @@ emailClient.send(mail);

int onMailSent(SmtpClient& client, int code, char* status)
{
    MailMessage* mail = client.getCurrentMessage();
MailMessage* mail = client.getCurrentMessage();

    ...
...

    if(!client.countPending()) {
        client.quit();
    }
if(!client.countPending()) {
client.quit();
}

    return 0;
return 0;
}

```

See the [SmtpClient sample](samples/SmtpClient/app/application.cpp) for details.

## Live Debugging

Applications based on Sming Framework that are flashed and running on an ESP8266 device can be debugged using interactive debuggers.
In order to debug an application it has to be re-compiled with the ENABLE_GDB=1 directive. And then flashed on the device. As shown below:

```
```bash
cd $SMING_HOME/../samples/LiveDebug
make clean
make ENABLE_GDB=1
make flashapp # <-- this will update only the application firmware.
```

Once the debuggable application is flashed on the device the developers have to run GDB. The easiest way to run the command-line GDB is to execute the following command:
```

```bash
make gdb
```

Expand All @@ -260,7 +272,8 @@ See [LiveDebug sample](samples/LiveDebug/) for details.

## Contribute

You can contribute to Sming by
You can contribute to Sming by:

- Providing Pull Requests with new features, bug fixes, new ideas, etc. See [Contributing](https://smingdev.readthedocs.io/en/latest/contribute/index.html) for details.
- Testing our latest source code and reporting issues.
- Supporting us financially to acquire hardware for testing and implementing or out of gratitude
Expand All @@ -276,8 +289,10 @@ In addition to that anyone who is helping this project can file an expense. If t
#### Backers and sponsors

Thank you to all the people who have backed Sming
<a href="https://opencollective.com/Sming#backers" target="_blank"><img src="https://opencollective.com/Sming/backers.svg?width=890"></a>
<a href="https://opencollective.com/Sming#backers" target="_blank">
<img src="https://opencollective.com/Sming/backers.svg?width=890" alt="backer"></a>

or sponsored it.

<a href="https://opencollective.com/Sming/sponsor/0/website" target="_blank"><img src="https://opencollective.com/Sming/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/Sming/sponsor/0/website" target="_blank">
<img src="https://opencollective.com/Sming/sponsor/0/avatar.svg" alt="sponsor"></a>
19 changes: 0 additions & 19 deletions Sming/Arch/Esp32/Components/driver/hw_timer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,6 @@ hw_timer: Hardware Timers

Driver for hardware timers.

Variables
---------

.. envvar:: USE_US_TIMER

0 (default): Use default /256 prescale for Timer2
1: Use /16 prescale

The following functions depend on Timer2:
- NOW() return value, the Timer2 tick count
- Software timers
- System time

Software timers are driven by Timer2, which by default uses a /256 prescale
providing a resolution of 3.2us and a range of 1' 54".

Enabling this setting increases the resolution to 200ns but reduces the maximum
software timer to 7" 9.5s.

API Documentation
-----------------

Expand Down
62 changes: 1 addition & 61 deletions Sming/Arch/Esp32/Components/driver/i2s.rst
Original file line number Diff line number Diff line change
@@ -1,64 +1,4 @@
I2S: Inter-IC Serial communications
===================================

Introduction
------------

`I2S <https://en.wikipedia.org/wiki/I%C2%B2S>`__ was designed for transfer of digital audio data.

The ESP8266 has two I2S modules (one transmitter and one receiver), both with hardware
`DMA <https://en.wikipedia.org/wiki/Direct_memory_access>`__ support, which means transfers from
RAM to the hardware SPI FIFO can be handled directly in hardware without any CPU involvement.


Sming I2S support
-----------------

The Sming driver deals with the complicated of setting up the hardware, using an API
similar to that in the Espressif RTOS SDK. In addition, DMA buffers may be accessed directly
to avoid double-buffering and the associated RAM and copy overhead.


Applications
------------

Audio
~~~~~

Playing MIDI files, MP3 files, speech synthesis, etc. is all possible using the ESP8266,
though many audio applications require considerable processing power.
That means you may need to disable WiFi and set the processor to run at full 160MHz speed.

High-quality multi-channel audio requires an external I2S DAC, which is what the protocol
was designed for in the first place. You may find problems with insufficient RAM,
but you can always add external SPI RAM.

More realistic uses include generating simple tones, beeps, playing pre-recorded WAV audio,
etc. to supplement existing projects. This can all be done in the background without
disrupting the system's main purpose, whatever that may be.

For such applications you can generate single-channel audio via the I2S OUT pin,
using `Pulse-density modulation <https://en.wikipedia.org/wiki/Pulse-density_modulation>`__.

See the :library:`ToneGenerator` library for a demonstration of this.


GPIO Expansion
~~~~~~~~~~~~~~

Expand GPIO using low-cost shift registers. https://github.com/lhartmann/esp8266_reprap.


Pixel-strip control
~~~~~~~~~~~~~~~~~~~

Devices such as WS2812-based NeoPixels use a simple, single-wire protocol.
I2S is ideal for this as it can be used to generate a precisely-timed bitstream
with very low CPU loading.


API Documentation
-----------------

.. doxygengroup:: i2s_driver
:content-only:
Not currently implemented for Esp32.
4 changes: 1 addition & 3 deletions Sming/Arch/Esp32/Components/gdbstub/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ GDB Stub for Esp32

This defines the command line to use when ``make gdb`` is run.

Esp32 debugging is handled via JTAG interface.

No additional code is required as serial debugging is not (currently) implemented.
See :doc:`/debugging/esp32/index`.
14 changes: 3 additions & 11 deletions Sming/Arch/Esp32/Components/heap/README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
Heap
====
Esp32 Heap
==========

This Component implements heap-related housekeeping functions. Heap usage is tracked using :component:`malloc_count`.
This also provides some validation (using *sentinels* to detect if memory blocks are overwritten).

.. envvar:: ENABLE_MALLOC_COUNT

We require :component:`malloc_count` to keep track of heap usage for system_get_free_heap_size().
It does this by hooking the memory allocation routines (malloc, free, etc.).
If you wish to disable this behaviour, set `ENABLE_MALLOC_COUNT=0`.
If using tools such as `Valgrind <https://www.valgrind.org>`__, this will provide a cleaner trace.
This Component supplements the actual heap implementation provided by the ESP IDF SDK.
13 changes: 0 additions & 13 deletions Sming/Arch/Esp32/Components/sming-arch/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,3 @@ Sming (Esp32)

This Component builds a library containing architecture-specific code, and defines dependencies for Sming to build for the Esp32.

Interactive debugging on the device
-----------------------------------

.. envvar:: ENABLE_GDB

In order to be able to debug live directly on the ESP8266 microcontroller you
should re-compile your application with ``ENABLE_GDB=1`` directive.

undefined (default)
Compile normally
1
Compile with debugging support provided by :component-esp8266:`gdbstub`.
See also the :sample:`LiveDebug` sample.
2 changes: 1 addition & 1 deletion Sming/Arch/Esp32/Components/spi_flash/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Esp8266 SPI Flash Support
Esp32 SPI Flash Support
=========================

Provides functions for access to flash memory.
Expand Down
Loading
Loading