2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/InfiniPaint.h"
|
|
|
|
#include "displayapp/DisplayApp.h"
|
|
|
|
#include "displayapp/LittleVgl.h"
|
2022-08-16 01:21:23 -04:00
|
|
|
#include "displayapp/InfiniTimeTheme.h"
|
2020-08-21 05:55:59 -04:00
|
|
|
|
2021-10-13 17:35:54 -04:00
|
|
|
#include <algorithm> // std::fill
|
|
|
|
|
2020-08-21 05:55:59 -04:00
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
2021-11-01 06:46:27 -04:00
|
|
|
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app,
|
|
|
|
Pinetime::Components::LittleVgl& lvgl,
|
|
|
|
Pinetime::Controllers::MotorController& motor)
|
|
|
|
: Screen(app), lvgl {lvgl}, motor {motor} {
|
2021-04-03 22:08:51 -04:00
|
|
|
std::fill(b, b + bufferSize, selectColor);
|
2020-08-21 05:55:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
InfiniPaint::~InfiniPaint() {
|
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
2021-04-18 13:28:14 -04:00
|
|
|
switch (event) {
|
|
|
|
case Pinetime::Applications::TouchEvents::LongTap:
|
2021-11-01 06:46:27 -04:00
|
|
|
color = (color + 1) % 8;
|
2021-04-03 22:08:51 -04:00
|
|
|
switch (color) {
|
|
|
|
case 0:
|
|
|
|
selectColor = LV_COLOR_MAGENTA;
|
|
|
|
break;
|
|
|
|
case 1:
|
2022-08-16 01:21:23 -04:00
|
|
|
selectColor = Colors::green;
|
2021-04-03 22:08:51 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
selectColor = LV_COLOR_WHITE;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
selectColor = LV_COLOR_RED;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
selectColor = LV_COLOR_CYAN;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
selectColor = LV_COLOR_YELLOW;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
selectColor = LV_COLOR_BLUE;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
selectColor = LV_COLOR_BLACK;
|
|
|
|
break;
|
2021-04-18 13:28:14 -04:00
|
|
|
|
2021-04-03 22:08:51 -04:00
|
|
|
default:
|
|
|
|
color = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
std::fill(b, b + bufferSize, selectColor);
|
2021-11-01 07:10:06 -04:00
|
|
|
motor.RunForDuration(35);
|
2021-04-03 22:08:51 -04:00
|
|
|
return true;
|
2021-04-04 08:51:22 -04:00
|
|
|
default:
|
|
|
|
return true;
|
2021-04-03 22:08:51 -04:00
|
|
|
}
|
2020-08-21 05:55:59 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) {
|
|
|
|
lv_area_t area;
|
2020-10-04 08:08:48 -04:00
|
|
|
area.x1 = x - (width / 2);
|
|
|
|
area.y1 = y - (height / 2);
|
|
|
|
area.x2 = x + (width / 2) - 1;
|
|
|
|
area.y2 = y + (height / 2) - 1;
|
2020-08-21 05:55:59 -04:00
|
|
|
lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None);
|
|
|
|
lvgl.FlushDisplay(&area, b);
|
|
|
|
return true;
|
|
|
|
}
|