You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

120 lines
3.3 KiB

#include <Arduino.h>
enum parts
{
HTML_BEGIN,
HTML_END,
STYLE,
SCRIPT_BEGIN,
SCRIPT_END
};
const char html_begin[] PROGMEM = {
"<!DOCTYPE html>\
<html>"};
const char style[] PROGMEM = {
"<head>\
<style>\
button {\
width: 190px;\
height: 40px;\
}\
#navs {\
height: 40px;\
width: 400px;\
position: relative;\
}\
footer {\
height: 5%;\
text-align: center;\
width: 100%;\
margin-top: 100px;\
}\
.clear {\
clear: left;\
}\
#hbs_text {\
text-align: left;\
width: 400px;\
text-indent: 20px;\
}\
</style>\
<meta charset=\"UTF-8\">\
<meta http-equiv=\"refresh\" content=\"1\">\
</head>\
<body>\
\
<div id=\"main_block\" align=\"center\">\
<h2>Лабораторная работа</h2>\
<h3>Высокочувствительный оптодатчик ADPD2214</h3>\
<p id=\"hbs_text\">Применяется для измерения пульса, расчета фотоплетизмограммы. Низкое энергопотребление, а также управляемое выключение\
этого электроприбора позволяет использовать его в портативных устройствах.\
</p>\
<p id=\"hbs_text\">Также применяется в химическом анализе. Частота обновления графика - 1 раз в двадцать секунд. Данные с сенсора снимаются\
с частотой в 20Hz. </p>\
\
<canvas id=\"myCanvas\" width=\"400\" height=\"200\" style=\"border:1px solid #3c70ff;\">\
Браузер устарел!\
</canvas>\
\
"};
const char script_begin[] PROGMEM = {
"<script>\
var c = document.getElementById(\"myCanvas\");\
var context = c.getContext(\"2d\");\
var randomNumbers, randNumsLength;\
context.moveTo(0, 200);"};
const char script_end[] PROGMEM = {
"context.stroke();\
context.font = \"50px Arial\";\
context.fillText(\"122\",300,170);\
</script>"};
const char html_end[] PROGMEM = {
"<div id=\"navs\">\
<button onclick=\"window.location.href='/acc.html?f=0'\" class=\"button\">Акселерометр</button>\
</div>\
<div class=\"clear\"></div>\
\
</div>\
<footer>\
Тамбовский Государственный Технический Университет 2017 г.\
</footer>\
</body>\
</html>"};
static int getHtml(parts p, char &adr, uint16_t buf_size, uint16_t bias)
{
char *buffer = &adr;
const char *html_part;
int length = 0;
switch (p)
{
case HTML_BEGIN:
html_part = html_begin;
break;
case HTML_END:
html_part = html_end;
break;
case STYLE:
html_part = style;
break;
case SCRIPT_BEGIN:
html_part = script_begin;
break;
case SCRIPT_END:
html_part = script_end;
break;
}
length = strlen_P(html_part);
for (int i = 0; i != length; i++)
{
if (i > buf_size)
return i;
buffer[i + bias] = pgm_read_byte_near(html_part + i);
}
return length;
}