Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Update zeitraffer.c
Browse files Browse the repository at this point in the history
  • Loading branch information
theageoflove committed Nov 14, 2022
1 parent 9509f59 commit 1edff60
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions zeitraffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <input/input.h>
#include <notification/notification_messages.h>

//#include <notification/notification_messages_notes.h>
// Половина кода покрадена из https://github.com/zmactep/flipperzero-hello-world

int Time = 10;
int Count = 10;
Expand Down Expand Up @@ -37,12 +37,16 @@ static void draw_callback(Canvas* canvas, void* ctx) {
char temp_str[36];
canvas_clear(canvas);
canvas_set_font(canvas, FontPrimary);
if (Count == -1)
snprintf(temp_str,sizeof(temp_str),"Set: BULB %i sec",Time);
else if (Count == 0)
switch (Count) {
case -1:
snprintf(temp_str,sizeof(temp_str),"Set: BULB %i sec",Time);
break;
case 0:
snprintf(temp_str,sizeof(temp_str),"Set: infinite, %i sec",Time);
else
break;
default:
snprintf(temp_str,sizeof(temp_str),"Set: %i frames, %i sec",Count,Time);
}
canvas_draw_str(canvas, 3, 15, temp_str);
snprintf(temp_str,sizeof(temp_str),"Left: %i frames, %i sec",WorkCount,WorkTime);
canvas_draw_str(canvas, 3, 35, temp_str);
Expand Down Expand Up @@ -108,28 +112,26 @@ int32_t zeitraffer_app(void* p) {
// Наше событие — это нажатие кнопки
if(event.type == EventTypeInput) {
if(event.input.type == InputTypeShort) {
// Если нажата кнопка "назад", то выходим из цикла, а следовательно и из приложения

if(event.input.key == InputKeyBack) {
if(furi_timer_is_running(timer)) {
if(furi_timer_is_running(timer)) { // Если таймер запущен - нефиг мацать кнопки!
notification_message(notifications, &sequence_error);
}
else {
}
else {
WorkCount = Count;
WorkTime = 3;
if (Count == 0) {InfiniteShot = true; WorkCount = 1;} else InfiniteShot = false;
notification_message(notifications, &sequence_success);
}
// break;
}
}
if(event.input.key == InputKeyRight) {
if(furi_timer_is_running(timer)) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Count++;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
else {
Count++;
notification_message(notifications, &sequence_click);
}
}
if(event.input.key == InputKeyLeft) {
if(furi_timer_is_running(timer)) {
Expand All @@ -138,7 +140,6 @@ int32_t zeitraffer_app(void* p) {
else {
Count--;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyUp) {
Expand All @@ -148,7 +149,6 @@ int32_t zeitraffer_app(void* p) {
else {
Time++;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyDown) {
Expand All @@ -158,7 +158,6 @@ int32_t zeitraffer_app(void* p) {
else {
Time--;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyOk) {
Expand All @@ -174,7 +173,6 @@ int32_t zeitraffer_app(void* p) {
if (Count == 0) {InfiniteShot = true; WorkCount = 1;} else InfiniteShot = false;
if (Count == -1) {gpio_item_set_pin(4, true); gpio_item_set_pin(5, true); Bulb = true; WorkCount = 1; WorkTime = Time;} else Bulb = false;
notification_message(notifications, &sequence_success);
notification_message(notifications, &sequence_display_backlight_off_delay_1000);
}
}
}
Expand Down Expand Up @@ -203,7 +201,6 @@ int32_t zeitraffer_app(void* p) {
}
else {
Count = Count+10;
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyLeft) {
Expand All @@ -212,7 +209,6 @@ int32_t zeitraffer_app(void* p) {
}
else {
Count = Count-10;
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyUp) {
Expand All @@ -221,7 +217,6 @@ int32_t zeitraffer_app(void* p) {
}
else {
Time = Time+10;
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyDown) {
Expand All @@ -230,22 +225,24 @@ int32_t zeitraffer_app(void* p) {
}
else {
Time = Time-10;
//view_port_update(view_port);
}
}
}
// Наше событие — это сработавший таймер
} else if(event.type == EventTypeTick) {
// Отправляем нотификацию мигания синим светодиодом

WorkTime--;
// Отправляем нотификацию мигания синим светодиодом
notification_message(notifications, &sequence_blink_blue_100);
if (Backlight) {

if (Backlight) { // чо по подсветке?
notification_message(notifications, &sequence_display_backlight_on);
}
else {
notification_message(notifications, &sequence_display_backlight_off);
}
if( WorkTime < 1 ) {

if( WorkTime < 1 ) { // фоткаем

if (Bulb) {
gpio_item_set_all_pins(false); WorkCount = 0;
Expand All @@ -268,7 +265,7 @@ int32_t zeitraffer_app(void* p) {
view_port_update(view_port);
}
}
if( WorkCount < 1 ) {
if( WorkCount < 1 ) { // закончили
gpio_item_set_all_pins(false);
furi_timer_stop(timer);
notification_message(notifications, &sequence_audiovisual_alert);
Expand Down

0 comments on commit 1edff60

Please sign in to comment.