EmbAJAX
Simplistic framework for creating and handling displays and controls on a web page served by an embeddable device (Arduino or other microcontroller with Arduino support).
Macros
macro_definitions.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define JS_QUOTED_STRING_ARG
 
#define HTML_QUOTED_STRING_ARG
 
#define HTML_ESCAPED_STRING_ARG
 
#define PLAIN_STRING_ARG
 
#define INTEGER_VALUE_ARG
 
#define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, NAME, ...)
 
#define printF_(...)
 
#define JS_QUOTED_STRING(X)
 
#define HTML_QUOTED_STRING(X)
 
#define HTML_ESCAPED_STRING(X)
 
#define PLAIN_STRING(X)
 
#define INTEGER_VALUE(X)
 
#define printFormatted(...)
 Print a static string with parameters replaced, roughly similar to printf. More...
 
#define printF_3(F1, A1a, A1b)
 
#define printF_4(F1, A1a, A1b, F2)
 
#define printF_6(F1, A1a, A1b, F2, A2a, A2b)
 
#define printF_7(F1, A1a, A1b, F2, A2a, A2b, F3)
 
#define printF_9(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b)
 
#define printF_10(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4)
 
#define printF_12(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b)
 
#define printF_13(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5)
 
#define printF_15(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b)
 
#define printF_16(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6)
 
#define printF_18(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b)
 
#define printF_19(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7)
 
#define printF_21(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b)
 
#define printF_22(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b, F8)
 
#define printF_24(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b, F8, A8a, A8b)
 
#define printF_25(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b, F8, A8a, A8b, F9)
 
#define printF_proxy(X, ...)
 

Detailed Description

EmbAJAX - Simplistic framework for creating and handling displays and controls on a WebPage served by an Arduino (or other small device).

Copyright (C) 2018-2023 Thomas Friedrichsmeier

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Macro definitions. Please note that many of these are internal. Please stick to the documented ones.

Macro Definition Documentation

◆ HTML_ESCAPED_STRING

#define HTML_ESCAPED_STRING (   X)

For use in printFormatted(): Insert a string replacing HTML entities that could break parsing: "<& .

◆ HTML_QUOTED_STRING

#define HTML_QUOTED_STRING (   X)

For use in printFormatted(): Insert an argument such that is suitable as a string attribute value in HTML. Surrounding quotes are added, automatically.

◆ INTEGER_VALUE

#define INTEGER_VALUE (   X)

For use in printFormatted(): Insert an integer value as a string (base 10).

◆ JS_QUOTED_STRING

#define JS_QUOTED_STRING (   X)

For use in printFormatted(): Insert an argument such that is suitable as a string literal in JavaScript. Surrounding quotes are added, automatically.

◆ PLAIN_STRING

#define PLAIN_STRING (   X)

For use in printFormatted(): Insert an plain string argument, as is.

◆ printFormatted

#define printFormatted (   ...)

Print a static string with parameters replaced, roughly similar to printf.

This is the primary function for elements to "print" to the client, i.e. to send the HTML/JS code needed to make the element work. The usage may best be explained by example (actual code of EmbAJAXSlider:

_driver->printFormatted("<input type=\"range\" id=", HTML_QUOTED_STRING(_id),
" min=", INTEGER_VALUE(_min), " max=", INTEGER_VALUE(_max),
" value=", INTEGER_VALUE(_value),
" oninput=\"doRequest(this.id, this.value);\" onchange=\"oninput();\"/>");
#define INTEGER_VALUE(X)
Definition: macro_definitions.h:56
#define HTML_QUOTED_STRING(X)
Definition: macro_definitions.h:49

First thing to note is that - although this function is technically implemented as a macro - it behaves like a public member function of EmbAJAXOutputDriverBase. Actually the macro relays to appropriate helper functions in that class.

Arguments can be either string literals, or values. These two kinds of argument have to be used alternatingly (which is usually needed, anyway), i.e. "string", value, "string", value... Values have to be wrapped by one of HTML_QUOTED_STRING(), INTEGER_VALUE(), HTML_ESCAPED_STRING, JS_QUOTED_STRING, PLAIN_STRING, which will control just how the value is inserted (with of without quotes, with HTML entities escaped, etc.).

Internally, all static portions of the output will be concatenated to a single string, which - on architectures where it matters - will automatically be wrapped inside an F() macro, for storage in FLASH memory, thus helping a lot to reduce RAM usage (not yet implemented, to come soon).

For efficiency reasons, you should try to merge as many bits of output in a single printFormatted(), as possible. I.e. instead of

_driver->printFormatted("id=", HTML_QUOTED_STRING(_id));
_driver->printFormatted(" value=", INTEGER_VALUE(_value));

always use:

_driver->printFormatted("id=", HTML_QUOTED_STRING(_id), _driver->printFormatted(" value=", INTEGER_VALUE(_value));