|
@@ -2,7 +2,8 @@
|
|
|
#include "unitemp_icons.h"
|
|
#include "unitemp_icons.h"
|
|
|
static View* view;
|
|
static View* view;
|
|
|
|
|
|
|
|
-const uint8_t temp_positions[3][2] = {{37, 24}, {37, 16}, {9, 16}};
|
|
|
|
|
|
|
+static const uint8_t temp_positions[3][2] = {{37, 24}, {37, 16}, {9, 16}};
|
|
|
|
|
+static uint8_t sensor_index = 0;
|
|
|
|
|
|
|
|
static void _draw_noSensors(Canvas* canvas) {
|
|
static void _draw_noSensors(Canvas* canvas) {
|
|
|
canvas_draw_str(canvas, 0, 24, "Sensors not found");
|
|
canvas_draw_str(canvas, 0, 24, "Sensors not found");
|
|
@@ -19,8 +20,31 @@ static void _draw_temp(Canvas* canvas, float temp, uint8_t pos) {
|
|
|
canvas_draw_icon(
|
|
canvas_draw_icon(
|
|
|
canvas, temp_positions[pos][0] + 3, temp_positions[pos][1] + 3, &I_temp_C_11x14);
|
|
canvas, temp_positions[pos][0] + 3, temp_positions[pos][1] + 3, &I_temp_C_11x14);
|
|
|
|
|
|
|
|
- //Целая часть температуры
|
|
|
|
|
char buff[5];
|
|
char buff[5];
|
|
|
|
|
+ if((int8_t)temp == -128) {
|
|
|
|
|
+ snprintf(buff, 5, "--");
|
|
|
|
|
+ canvas_set_font(canvas, FontBigNumbers);
|
|
|
|
|
+ canvas_draw_str_aligned(
|
|
|
|
|
+ canvas,
|
|
|
|
|
+ temp_positions[pos][0] + 27,
|
|
|
|
|
+ temp_positions[pos][1] + 10,
|
|
|
|
|
+ AlignCenter,
|
|
|
|
|
+ AlignCenter,
|
|
|
|
|
+ buff);
|
|
|
|
|
+ uint8_t int_len = canvas_string_width(canvas, buff);
|
|
|
|
|
+ snprintf(buff, 4, ". -");
|
|
|
|
|
+ canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
+ canvas_draw_str_aligned(
|
|
|
|
|
+ canvas,
|
|
|
|
|
+ temp_positions[pos][0] + 27 + int_len,
|
|
|
|
|
+ temp_positions[pos][1] + 10 + 3,
|
|
|
|
|
+ AlignRight,
|
|
|
|
|
+ AlignCenter,
|
|
|
|
|
+ buff);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ //Целая часть температуры
|
|
|
|
|
+
|
|
|
snprintf(buff, 5, "%d", temp_int);
|
|
snprintf(buff, 5, "%d", temp_int);
|
|
|
canvas_set_font(canvas, FontBigNumbers);
|
|
canvas_set_font(canvas, FontBigNumbers);
|
|
|
canvas_draw_str_aligned(
|
|
canvas_draw_str_aligned(
|
|
@@ -46,7 +70,6 @@ static void _draw_temp(Canvas* canvas, float temp, uint8_t pos) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void _draw_sensorsCarousel(Canvas* canvas) {
|
|
static void _draw_sensorsCarousel(Canvas* canvas) {
|
|
|
- static uint8_t sensor_index = 0;
|
|
|
|
|
//Рисование рамки
|
|
//Рисование рамки
|
|
|
canvas_draw_rframe(canvas, 3, 0, 122, 63, 7);
|
|
canvas_draw_rframe(canvas, 3, 0, 122, 63, 7);
|
|
|
canvas_draw_rframe(canvas, 3, 0, 122, 64, 7);
|
|
canvas_draw_rframe(canvas, 3, 0, 122, 64, 7);
|
|
@@ -59,9 +82,17 @@ static void _draw_sensorsCarousel(Canvas* canvas) {
|
|
|
uint8_t line_len = canvas_string_width(canvas, app->sensors[sensor_index]->name) + 2;
|
|
uint8_t line_len = canvas_string_width(canvas, app->sensors[sensor_index]->name) + 2;
|
|
|
canvas_draw_line(canvas, 64 - line_len / 2, 12, 64 + line_len / 2, 12);
|
|
canvas_draw_line(canvas, 64 - line_len / 2, 12, 64 + line_len / 2, 12);
|
|
|
|
|
|
|
|
|
|
+ //Стрелка вправо
|
|
|
|
|
+ if(unitemp_sensors_getTypesCount() > 0 && sensor_index < unitemp_sensors_getCount() - 1) {
|
|
|
|
|
+ canvas_draw_icon(canvas, 64 + line_len / 2 + 4, 3, &I_arrow_right_5x9);
|
|
|
|
|
+ }
|
|
|
|
|
+ //Стрелка влево
|
|
|
|
|
+ if(sensor_index > 0) {
|
|
|
|
|
+ canvas_draw_icon(canvas, 64 - line_len / 2 - 8, 3, &I_arrow_left_5x9);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//Печать значения температуры
|
|
//Печать значения температуры
|
|
|
- // _draw_temp(canvas, app->sensors[sensor_index]->temp, 0);
|
|
|
|
|
- _draw_temp(canvas, (float)(furi_get_tick() % 30000) / 1000.0f - 15.0f, 0);
|
|
|
|
|
|
|
+ _draw_temp(canvas, app->sensors[sensor_index]->temp, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void _draw_callback(Canvas* canvas, void* _model) {
|
|
static void _draw_callback(Canvas* canvas, void* _model) {
|
|
@@ -77,43 +108,6 @@ static void _draw_callback(Canvas* canvas, void* _model) {
|
|
|
if(sensors_count > 0) {
|
|
if(sensors_count > 0) {
|
|
|
_draw_sensorsCarousel(canvas);
|
|
_draw_sensorsCarousel(canvas);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // //Рисование бара
|
|
|
|
|
- // canvas_draw_box(canvas, 0, 0, 128, 14);
|
|
|
|
|
- // canvas_set_color(canvas, ColorWhite);
|
|
|
|
|
- // canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- // canvas_draw_str_aligned(canvas, 64, 7, AlignCenter, AlignCenter, "Unitemp");
|
|
|
|
|
-
|
|
|
|
|
- // canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
- // if(unitemp_sensors_getCount() > 0) {
|
|
|
|
|
- // for(uint8_t i = 0; i < unitemp_sensors_getCount(); i++) {
|
|
|
|
|
- // canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- // canvas_draw_str(canvas, 0, 24 + 10 * i, app->sensors[i]->name);
|
|
|
|
|
-
|
|
|
|
|
- // canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
- // if(app->sensors[i]->status != UT_OK && app->sensors[i]->status != UT_EARLYPOOL &&
|
|
|
|
|
- // app->sensors[i]->status != UT_POLLING) {
|
|
|
|
|
- // if(app->sensors[i]->status == UT_BADCRC) {
|
|
|
|
|
- // canvas_draw_str(canvas, 96, 24 + 10 * i, "bad CRC");
|
|
|
|
|
- // } else {
|
|
|
|
|
- // canvas_draw_str(canvas, 96, 24 + 10 * i, "timeout");
|
|
|
|
|
- // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // char buff[20];
|
|
|
|
|
- // snprintf(
|
|
|
|
|
- // buff,
|
|
|
|
|
- // sizeof(buff),
|
|
|
|
|
- // "%2.1f*%c/%d%%",
|
|
|
|
|
- // (double)app->sensors[i]->temp,
|
|
|
|
|
- // app->settings.unit == CELSIUS ? 'C' : 'F',
|
|
|
|
|
- // (int8_t)app->sensors[i]->hum);
|
|
|
|
|
- // canvas_draw_str(canvas, 64, 24 + 10 * i, buff);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
- // if(unitemp_sensors_getCount() == 0) canvas_draw_str(canvas, 0, 24, "Sensors not found");
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static bool _input_callback(InputEvent* event, void* context) {
|
|
static bool _input_callback(InputEvent* event, void* context) {
|
|
@@ -123,6 +117,15 @@ static bool _input_callback(InputEvent* event, void* context) {
|
|
|
if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
|
if(event->key == InputKeyBack && event->type == InputTypeShort) {
|
|
|
app->processing = false;
|
|
app->processing = false;
|
|
|
}
|
|
}
|
|
|
|
|
+ //Пролистывание карусели по короткому нажатию "право"
|
|
|
|
|
+ if(event->key == InputKeyRight && event->type == InputTypeShort) {
|
|
|
|
|
+ if(++sensor_index >= unitemp_sensors_getCount()) sensor_index = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ //Пролистывание карусели по короткому нажатию "лево"
|
|
|
|
|
+ if(event->key == InputKeyLeft && event->type == InputTypeShort) {
|
|
|
|
|
+ if(--sensor_index >= unitemp_sensors_getCount())
|
|
|
|
|
+ sensor_index = unitemp_sensors_getCount() - 1;
|
|
|
|
|
+ }
|
|
|
//Вход в главное меню по короткому нажатию "Ок"
|
|
//Вход в главное меню по короткому нажатию "Ок"
|
|
|
if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
|
if(event->key == InputKeyOk && event->type == InputTypeShort) {
|
|
|
app->sensors_ready = false;
|
|
app->sensors_ready = false;
|