Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: page/page.c
- Revision:
- 58:e5ab14ef6ea6
- Parent:
- 57:8fa31ff4e773
- Child:
- 59:309e78f243dd
--- a/page/page.c Thu Mar 07 13:40:12 2019 +0000
+++ b/page/page.c Fri Mar 08 16:07:56 2019 +0000
@@ -138,49 +138,28 @@
snprintf(text, sizeof(text), "%8d", value); //Right align with enough spaces so that the length is always constant.
PageAddLabelledValue(label, labelwidth, text);
}
-void PageAddTextInput(char* action, float width, char* label, float labelwidth, char* name, float inputwidth, char* value)
+void PageAddInputText(float labelwidth, char* label, float inputwidth, char* value, char* action, char* name)
{
- HttpAddText("<form action='"); HttpAddText(action); HttpAddText("' method='get'>\r\n");
-
- char text[100];
- if (width < 0.01)
- {
- HttpAddText("<div>");
- }
- else
- {
- snprintf(text, sizeof(text), "<div style='width:%.1fem; display:inline-block;'>", width);
- HttpAddText(text);
- }
- snprintf(text, sizeof(text), "<div style='width:%.1fem; display:inline-block;'>%s</div>", labelwidth, label);
- HttpAddText(text);
- snprintf(text, sizeof(text), "<input type='text' name='%s' style='width:%.1fem;' value='%s'>", name, inputwidth, value);
- HttpAddText(text);
- HttpAddText("</div>\r\n");
- HttpAddText("<input type='submit' value='Set' style='display:none;'>\r\n</form>\r\n");
+ HttpAddF ("<form action='%s' method='get'>\r\n", action);
+ HttpAddF (" <div style='width:%.1fem; display:inline-block;'>%s</div>\r\n", labelwidth, label);
+ HttpAddF (" <input type='text' name='%s' style='width:%.1fem;' value='%s'>\r\n", name, inputwidth, value);
+ HttpAddText(" <input type='submit' value='Set' style='display:none;'>\r\n");
+ HttpAddF ("</form>\r\n");
}
-void PageAddIntInput(char* action, float width, char* label, float labelwidth, char* name, float inputwidth, int value)
+void PageAddInputInt(float labelwidth, char* label, float inputwidth, int value, char* action, char* name)
{
char text[30];
snprintf(text, sizeof(text), "%d", value);
- PageAddTextInput(action, width, label, labelwidth, name, inputwidth, text);
+ PageAddInputText(labelwidth, label, inputwidth, text, action, name);
}
-void PageAddCheckInput(char* action, char* label, float labelwidth, char* name, char* button)
+void PageAddInputButton(float labelwidth, char* label, char* value, char* action, char* name)
{
- char text[100];
- HttpAddText("<form action='"); HttpAddText(action); HttpAddText("' method='get'>\r\n");
- HttpAddText("<input type='hidden' name='"); HttpAddText(name); HttpAddText("'>\r\n");
- if (labelwidth < 0.1)
- {
- HttpAddText(label); HttpAddText("\r\n");
- }
- else
- {
- snprintf(text, sizeof(text), "<div style='width:%.1fem; display:inline-block;'>%s</div>\r\n", labelwidth, label);
- HttpAddText(text);
- }
- HttpAddText("<input type='submit' value='"); HttpAddText(button); HttpAddText("'>\r\n");
+ HttpAddF("<form action='%s' method='get'>\r\n", action);
+ HttpAddF("<input type='hidden' name='%s'>\r\n", name);
+ if (labelwidth < 0.1) HttpAddF("%s\r\n", label);
+ else HttpAddF("<div style='width:%.1fem; display:inline-block;'>%s</div>\r\n", labelwidth, label);
+ HttpAddF("<input type='submit' value='%s'>\r\n", value);
HttpAddText("</form>\r\n");
}
void PageAddTm(struct tm* ptm)
@@ -205,51 +184,34 @@
else if (ptm->tm_isdst == 0) HttpAddText(" GMT");
else HttpAddText(" UTC");
}
-void PageAddAjaxToggle(float labelwidth, char* label, char* id, char* request)
+void PageAddAjaxInputToggle(float labelwidth, char* label, char* id, char* name)
{
- char text[100];
-
- snprintf(text, sizeof(text), "<div><div style='display: inline-block; width:%.1fem;'>", labelwidth);
- HttpAddText(text);
- HttpAddText(label);
+ HttpAddText("<div>\r\n");
+ HttpAddF (" <div style='display: inline-block; width:%.1fem;'>%s</div>\r\n", labelwidth, label);
+ HttpAddF (" <div class='toggle' id='%s' dir='ltr' onclick='AjaxRequest(\"%s=1\")'>\r\n", id, name);
+ HttpAddText(" <div class='slot'></div><div class='knob'></div>\r\n");
+ HttpAddText(" </div>\r\n");
HttpAddText("</div>\r\n");
-
- HttpAddText("<div class='toggle' id='");
- HttpAddText(id);
- HttpAddText("' dir='ltr' onclick='AjaxRequest(\"");
- HttpAddText(request);
- HttpAddText("=1\")'>\r\n");
-
- HttpAddText("<div class='slot'></div><div class='knob'></div>\r\n");
-
- HttpAddText("</div></div>\r\n");
}
-void PageAddAjaxInput(float labelwidth, char* label, float inputwidth, char* id, char* request)
-{
- char text[100];
-
- snprintf(text, sizeof(text), "<div><div style='display: inline-block; width:%.1fem;'>", labelwidth);
- HttpAddText(text);
- HttpAddText(label);
+void PageAddAjaxLed(float labelwidth, char* label, char* id)
+{
+ HttpAddText("<div>\r\n");
+ HttpAddF (" <div style='display:inline-block; width:%.1fem;'>%s</div>\r\n", labelwidth, label);
+ HttpAddF (" <div class='led' id='%s' dir='ltr'></div>\r\n", id);
HttpAddText("</div>\r\n");
-
- HttpAddText("<input type='text' id='");
- HttpAddText(id);
- HttpAddText("' style='width:");
- sprintf(text, "%.1fem;", inputwidth);
- HttpAddText(text);
- HttpAddText("' onchange='AjaxRequest(\"");
- HttpAddText(request);
- HttpAddText("=\" + this.value)'>\r\n");
-
+}
+void PageAddAjaxInput(float labelwidth, char* label, float inputwidth, char* id, char* name)
+{
+ HttpAddText("<div>\r\n");
+ HttpAddF (" <div style='display: inline-block; width:%.1fem;'>%s</div>\r\n", labelwidth, label);
+ HttpAddF (" <input type='text' id='%s' style='width:%.1fem;' onchange='AjaxRequest(\"%s=\" + this.value)'>\r\n", id, inputwidth, name);
HttpAddText("</div>\r\n");
}
void PageAddAjaxLabelled(float labelwidth, char* label, char* id, char* suffix)
{
- HttpAddText("<div>");
- HttpAddF ("<div style='width:%.1fem; display:inline-block;'>%s</div>", labelwidth, label);
- HttpAddText("<span id='"); HttpAddText(id); HttpAddText("'></span>");
- HttpAddText(suffix);
+ HttpAddText("<div>\r\n");
+ HttpAddF (" <div style='width:%.1fem; display:inline-block;'>%s</div>\r\n", labelwidth, label);
+ HttpAddF (" <span id='%s'></span>%s\r\n", id, suffix);
HttpAddText("</div>\r\n");
}