More progress, implement testing application, polish color gradient calculation code as well
parent
169d6eaa7e
commit
03ff18d178
@ -0,0 +1,34 @@
|
|||||||
|
#include "displayapp/screens/WeatherColorTester.h"
|
||||||
|
#include "displayapp/WeatherHelper.h"
|
||||||
|
#include "displayapp/LittleVgl.h"
|
||||||
|
#include <nrfx_log.h>
|
||||||
|
#include <algorithm> // std::fill
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
WeatherColorTester::WeatherColorTester(Pinetime::Components::LittleVgl& lvgl) : lvgl {lvgl} {
|
||||||
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WeatherColorTester::Refresh() { //WeatherHelper::oldMax
|
||||||
|
for (size_t i = 0; i < WeatherHelper::oldMax; ++i) {
|
||||||
|
// get current color
|
||||||
|
currentColor = WeatherHelper::TemperatureColor(i * 100);
|
||||||
|
// create area we want to color
|
||||||
|
lv_area_t area;
|
||||||
|
area.y1 = x + i;
|
||||||
|
area.x1 = 0;
|
||||||
|
area.y2 = (x + i) + 1;
|
||||||
|
area.x2 = y;
|
||||||
|
NRF_LOG_INFO("area coords: %i, %i, %i, %i", area.x1, area.y1, area.x2, area.y2);
|
||||||
|
// write the buffer to the display
|
||||||
|
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
|
||||||
|
std::fill(buffer, buffer + bufferSize, currentColor);
|
||||||
|
lvgl.FlushDisplay(&area, buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WeatherColorTester::~WeatherColorTester() {
|
||||||
|
lv_task_del(taskRefresh);
|
||||||
|
lv_obj_clean(lv_scr_act());
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "displayapp/apps/Apps.h"
|
||||||
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include "displayapp/Controllers.h"
|
||||||
|
#include <lvgl/src/lv_hal/lv_hal_disp.h>
|
||||||
|
#include "Symbols.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class WeatherColorTester : public Screen {
|
||||||
|
public:
|
||||||
|
explicit WeatherColorTester(Pinetime::Components::LittleVgl& lvgl);
|
||||||
|
WeatherColorTester() = delete;
|
||||||
|
~WeatherColorTester() override;
|
||||||
|
void Refresh() override;
|
||||||
|
private:
|
||||||
|
Pinetime::Components::LittleVgl& lvgl;
|
||||||
|
lv_task_t* taskRefresh;
|
||||||
|
static constexpr int x = 0;
|
||||||
|
static constexpr int y = 240;
|
||||||
|
static constexpr int bufferSize = (480);
|
||||||
|
lv_color_t buffer[bufferSize];
|
||||||
|
|
||||||
|
lv_color_t currentColor;
|
||||||
|
//static lv_disp_draw_buf_t disp_buf;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct AppTraits<Apps::WeatherColorTester> {
|
||||||
|
static constexpr Apps app = Apps::WeatherColorTester;
|
||||||
|
static constexpr const char* icon = Screens::Symbols::bolt;
|
||||||
|
static Screens::Screen* Create(AppControllers& controllers) {
|
||||||
|
return new Screens::WeatherColorTester(controllers.lvgl);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue