color rotation using modulo, ran clang-format for InfiniPaint

This commit is contained in:
Clemens von Molo 2021-11-01 11:46:27 +01:00
parent 5e1f4839da
commit 2d98530976
3 changed files with 12 additions and 7 deletions

View File

@ -410,7 +410,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::Twos>(this);
break;
case Apps::Paint:
currentScreen = std::make_unique<Screens::InfiniPaint>(this, lvgl,motorController);
currentScreen = std::make_unique<Screens::InfiniPaint>(this, lvgl, motorController);
break;
case Apps::Paddle:
currentScreen = std::make_unique<Screens::Paddle>(this, lvgl);

View File

@ -4,7 +4,10 @@
using namespace Pinetime::Applications::Screens;
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl, Pinetime::Controllers::MotorController& motor) : Screen(app), lvgl {lvgl}, motor{motor} {
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app,
Pinetime::Components::LittleVgl& lvgl,
Pinetime::Controllers::MotorController& motor)
: Screen(app), lvgl {lvgl}, motor {motor} {
std::fill(b, b + bufferSize, selectColor);
}
@ -15,7 +18,11 @@ InfiniPaint::~InfiniPaint() {
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case Pinetime::Applications::TouchEvents::LongTap:
color = (color + 1) % 8;
switch (color) {
case 0:
selectColor = LV_COLOR_MAGENTA;
break;
case 1:
selectColor = LV_COLOR_GREEN;
break;
@ -40,12 +47,10 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
default:
color = 0;
selectColor = LV_COLOR_MAGENTA;
break;
}
std::fill(b, b + bufferSize, selectColor);
color++;
motor.RunForDuration(50);
return true;
default:

View File

@ -1,9 +1,9 @@
#pragma once
#include <lvgl/lvgl.h>
#include <cstdint>
#include "Screen.h"
#include "components/motor/MotorController.h"
#include <cstdint>
#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Components {
@ -30,7 +30,7 @@ namespace Pinetime {
static constexpr uint16_t bufferSize = width * height;
lv_color_t b[bufferSize];
lv_color_t selectColor = LV_COLOR_WHITE;
uint8_t color = 3;
uint8_t color = 2;
};
}
}