void perform_delayed_operation(uint16_t opId, bool_t pleaseWaitInfo) { if(!isSensorBusy) { // Do immediately handle_delayed_operation_event(opId); } else { if(pleaseWaitInfo) { gfx_set_color(COLOR_BLACK); gfx_fill_rectangle(120, 100, 240, 72); gfx_set_color(COLOR_YELLOW); gfx_draw_rectangle(120, 100, 240, 72); gfx_set_text_pos(200, 130); gfx_set_font(&FONT_DIALOG_12); gfx_outtext("Please wait...", 20); } delayedOperation = opId; // ... and wait } }
void dashboard_draw_func(handle_t obj) { gui_widget_t *w = (gui_widget_t *) obj; gfx_set_color(COLOR_BLACK); gfx_fill_rectangle(w->left, w->top, w->width, w->height); if(gui_widget_get_state(w, STATE_FOCUSED)) gfx_set_color(COLOR_YELLOW); else gfx_set_color(COLOR_DARK_YELLOW); gfx_draw_rectangle(w->left, w->top, w->width, w->height); gfx_set_color(COLOR_WHITE); gfx_set_font(&FONT_DIALOG_12); gfx_set_text_pos(w->left + 10, w->top + 10); gfx_outtext("Pressure:", 100); gfx_set_text_pos(w->left + 10, w->top + 90); gfx_outtext("Humidity:", 100); gfx_set_text_pos(w->left + 10, w->top + 170); gfx_outtext("Temperature:", 100); if(w->extra != NULL) { dashboard_data_t *data = (dashboard_data_t*) w->extra; char buf[16]; int16_t trend; // Min & max gfx_set_text_pos(w->left + 10, w->top + 60); gfx_set_color(COLOR_CYAN); gfx_outtext("min: ", 10); if(data->pressure.min != 0x8000) tiny_sprintf(stringCache, "%d1 hPa", data->pressure.min); else tiny_sprintf(stringCache, "---"); gfx_set_color(data->alarmMask & ALARM_MIN_P ? COLOR_RED : COLOR_WHITE); gfx_outtext_ram(stringCache, 25); gfx_set_color(COLOR_CYAN); gfx_outtext(", max: ", 10); if(data->pressure.max != 0x8000) tiny_sprintf(stringCache, "%d1 hPa", data->pressure.max); else tiny_sprintf(stringCache, "---"); gfx_set_color(data->alarmMask & ALARM_MAX_P ? COLOR_RED : COLOR_WHITE); gfx_outtext_ram(stringCache, 25); gfx_set_text_pos(w->left + 10, w->top + 140); gfx_set_color(COLOR_MAGENTA); gfx_outtext("min: ", 10); if(data->humidity.min != 0x8000) tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.min); else tiny_sprintf(stringCache, "---"); gfx_set_color(data->alarmMask & ALARM_MIN_H ? COLOR_RED : COLOR_WHITE); gfx_outtext_ram(stringCache, 25); gfx_set_color(COLOR_MAGENTA); gfx_outtext(", max: ", 10); if(data->humidity.max != 0x8000) tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.max); else tiny_sprintf(stringCache, "---"); gfx_set_color(data->alarmMask & ALARM_MAX_H ? COLOR_RED : COLOR_WHITE); gfx_outtext_ram(stringCache, 25); gfx_set_text_pos(w->left + 10, w->top + 220); gfx_set_color(COLOR_YELLOW); gfx_outtext("min: ", 10); if(data->temperature.min != 0x8000) tiny_sprintf(stringCache, "%d2 *C", data->temperature.min); else tiny_sprintf(stringCache, "---"); gfx_set_color(data->alarmMask & ALARM_MIN_T ? COLOR_RED : COLOR_WHITE); gfx_outtext_ram(stringCache, 25); gfx_set_color(COLOR_YELLOW); gfx_outtext(", max: ", 10); if(data->temperature.max != 0x8000) tiny_sprintf(stringCache, "%d2 *C", data->temperature.max); else tiny_sprintf(stringCache, "---"); gfx_set_color(data->alarmMask & ALARM_MAX_T ? COLOR_RED : COLOR_WHITE); gfx_outtext_ram(stringCache, 25); // TREND trend = (data->pressure.trend - data->pressure.trendLast); if(trend < 2 && trend > -2) draw_minus(w->left + 170, w->top + 38); else { draw_arrow(w->left + 170, w->top + 23, (bool_t) (trend > 0)); tiny_sprintf(buf, "%c%d1", trend > 0? '+' : ' ', trend); gfx_set_text_pos(w->left + 150, w->top + 43); gfx_outtext_ram(buf, 16); } trend = (data->humidity.trend - data->humidity .trendLast); if (trend < 5 && trend > -5) draw_minus(w->left + 170, w->top + 118); else { draw_arrow(w->left + 170, w->top + 103, (bool_t) (trend > 0)); tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend); gfx_set_text_pos(w->left + 150, w->top + 123); gfx_outtext_ram(buf, 16); } trend = (data->temperature.trend - data->temperature.trendLast); if (trend < 2 && trend > -2) draw_minus(w->left + 170, w->top + 198); else { draw_arrow(w->left + 170, w->top + 183, (bool_t) (trend > 0)); tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend); gfx_set_text_pos(w->left + 150, w->top + 203); gfx_outtext_ram(buf, 16); } // Big digits gfx_set_font(&FONT_ARIALBLACK_36); gfx_set_color(COLOR_WHITE); gfx_set_text_pos(w->left + 10, w->top + 18); tiny_sprintf(stringCache, "%d1", data->pressure.val); gfx_outtext_ram(stringCache, 10); gfx_set_text_pos(w->left + 10, w->top + 98); tiny_sprintf(stringCache, "%d2", data->humidity.val); gfx_outtext_ram(stringCache, 10); gfx_set_text_pos(w->left + 10, w->top + 178); tiny_sprintf(stringCache, "%d2", data->temperature.val); gfx_outtext_ram(stringCache, 10); } }
void train3_model_enter() { gfx_set_font(&Helvetica_16); gfx_draw_string(10, 10, "Train3", GFX_SET_BLACK); OLED_Refresh_all(); }