Skip to content

Commit

Permalink
flip transition
Browse files Browse the repository at this point in the history
  • Loading branch information
lunokjod committed Jul 29, 2023
1 parent 9a37a54 commit 9dc5238
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/UI/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ TFT_eSprite * ShearSprite(TFT_eSprite *view, TransformationMatrix transform) {
// reduce the size of image using float value (0.5=50%)
TFT_eSprite * ScaleSprite(TFT_eSprite *view, float divisor) {
if ( nullptr == view ) { return nullptr; }
//return ShearSprite(view,{divisor,0,0,divisor});

//if ( 1.0 == divisor ) { return DuplicateSprite(view); } // is the same!!! @TODO Duplicate invert colors :( invert colors
if ( divisor < 0.0 ) { divisor=0.05; } // dont allow 0 scale
int16_t nh = view->height()*divisor; // calculate new size
Expand Down
1 change: 0 additions & 1 deletion src/UI/UI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ void BlurSprite(TFT_eSprite *view, int radius);
void ScreenSleep();
void ScreenWake();

//TFT_eSprite *TakeScreenShoot();
TFT_eSprite * GetSpriteRect(TFT_eSprite *view, int16_t x, int16_t y, int16_t h, int16_t w);
TFT_eSprite * DuplicateSprite(TFT_eSprite *view);
TFT_eSprite * ShearSprite(TFT_eSprite *view, TransformationMatrix transform);
Expand Down
51 changes: 51 additions & 0 deletions src/UI/transition/Flip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// LunokWatch, a open source smartwatch software
// Copyright (C) 2022,2023 Jordi Rubió <jordi@binarycell.org>
// This file is part of LunokWatch.
//
// LunokWatch is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// LunokWatch is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// LunokWatch. If not, see <https://www.gnu.org/licenses/>.
//

#include "Flip.hpp"
#include <freertos/semphr.h>
#include <freertos/task.h>
#include "../../lunokiot_config.hpp"
#include "../UI.hpp"
#include "../../app/LogView.hpp"

void FlipTransition(TFT_eSprite * curentView, TFT_eSprite * nextView) {
// scale screen buffer
const int images=4;
TFT_eSprite *scaledImgs[images];
scaledImgs[0] = ShearSprite(nextView,{1,-1,0,1});
scaledImgs[1] = ShearSprite(nextView,{1,-0.75,0,1});
scaledImgs[2] = ShearSprite(nextView,{1,-0.5,0,1});
scaledImgs[3] = ShearSprite(nextView,{1,-0.25,0,1});
for(int scale=0;scale<images;scale++) {
TickType_t nextStep = xTaskGetTickCount(); // get the current ticks
TFT_eSprite *scaledImg = scaledImgs[scale];
if ( nullptr != scaledImg ) {
scaledImg->pushSprite((TFT_WIDTH-scaledImg->width())/2,(TFT_HEIGHT-scaledImg->height())/2,TFT_PINK);
}
BaseType_t delayed = xTaskDelayUntil( &nextStep, (60 / portTICK_PERIOD_MS) ); // wait a ittle bit (freeRTOS must breath)
}
// push full image
nextView->pushSprite(0,0);
// cleanup
for(int i=0;i<images;i++) {
if ( nullptr == scaledImgs[i] ) { continue; }
scaledImgs[i]->deleteSprite();
delete scaledImgs[i];
}
}
26 changes: 26 additions & 0 deletions src/UI/transition/Flip.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// LunokWatch, a open source smartwatch software
// Copyright (C) 2022,2023 Jordi Rubió <jordi@binarycell.org>
// This file is part of LunokWatch.
//
// LunokWatch is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// LunokWatch is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// LunokWatch. If not, see <https://www.gnu.org/licenses/>.
//

#ifndef __LUNOKIOT__ANIMATION__FLIP__
#define __LUNOKIOT__ANIMATION__FLIP__
#include <LilyGoWatch.h>

void FlipTransition(TFT_eSprite * curentView, TFT_eSprite * nextView);

#endif
6 changes: 4 additions & 2 deletions src/system/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern TTGOClass *ttgo; // access to ttgo specific libs
#include "../UI/transition/Stripes.hpp" // animation
#include "../UI/transition/UpDown.hpp" // animation
#include "../UI/transition/Chess.hpp" // animation
#include "../UI/transition/Flip.hpp" // animation

#include "../app/LogView.hpp"

Expand Down Expand Up @@ -193,16 +194,17 @@ void LaunchApplicationTaskSync(LaunchApplicationDescriptor * appDescriptor,bool
static long transitionSelected = 0;
lUILog("Application: %p '%s' Transition: %ld\n", instance,instance->AppName(),transitionSelected);
//lUILog("@TODO DEBUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUG TRANSITION\n");
//transitionSelected=5; //@TODO DEBUG
//transitionSelected=6; //@TODO DEBUG
// run this part fast as possible
if ( 0 == transitionSelected ) { ZoomOutTransition(ptrToCurrent->canvas,appView); }
else if ( 1 == transitionSelected ) { FadeTransition(ptrToCurrent->canvas,appView); }
else if ( 2 == transitionSelected ) { DisplaceTransition(ptrToCurrent->canvas,appView); }
else if ( 3 == transitionSelected ) { StripeTransition(ptrToCurrent->canvas,appView); }
else if ( 4 == transitionSelected ) { UpDownTransition(ptrToCurrent->canvas,appView); }
else if ( 5 == transitionSelected ) { ChessTransition(ptrToCurrent->canvas,appView); }
else if ( 6 == transitionSelected ) { FlipTransition(ptrToCurrent->canvas,appView); }
transitionSelected++;
if ( transitionSelected > 5 ) { transitionSelected = 0; }
if ( transitionSelected > 6 ) { transitionSelected = 0; }

// restore my priority
vTaskPrioritySet(NULL,myPriority);
Expand Down

0 comments on commit 9dc5238

Please sign in to comment.