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

Commit

Permalink
BULB
Browse files Browse the repository at this point in the history
  • Loading branch information
theageoflove committed Nov 11, 2022
1 parent 6e9c4ed commit 7144030
Showing 1 changed file with 57 additions and 5 deletions.
62 changes: 57 additions & 5 deletions zeitraffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ int Count = 10;
int WorkTime = 0;
int WorkCount = 0;
bool InfiniteShot = false;
bool Bulb = false;

const NotificationSequence sequence_click = {
&message_note_c7,
Expand All @@ -35,7 +36,12 @@ static void draw_callback(Canvas* canvas, void* ctx) {
char temp_str[36];
canvas_clear(canvas);
canvas_set_font(canvas, FontPrimary);
snprintf(temp_str,sizeof(temp_str),"Set: %i frames, %i sec",Count,Time);
if (Count == -1)
snprintf(temp_str,sizeof(temp_str),"Set: BULB %i sec",Time);
else if (Count == 0)
snprintf(temp_str,sizeof(temp_str),"Set: infinite, %i sec",Time);
else
snprintf(temp_str,sizeof(temp_str),"Set: %i frames, %i sec",Count,Time);
canvas_draw_str(canvas, 3, 20, temp_str);
snprintf(temp_str,sizeof(temp_str),"Left: %i frames, %i sec",WorkCount,WorkTime);
canvas_draw_str(canvas, 3, 45, temp_str);
Expand Down Expand Up @@ -113,36 +119,57 @@ int32_t zeitraffer_app(void* p) {
// break;
}
if(event.input.key == InputKeyRight) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Count++;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyLeft) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Count--;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyUp) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Time++;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyDown) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Time--;
notification_message(notifications, &sequence_click);
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyOk) {

if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
notification_message(notifications, &sequence_click);
furi_timer_stop(timer);
}
else {
furi_timer_start(timer, 1000);
if (WorkCount == 0) WorkCount = Count;
if (WorkTime == 0) WorkTime = 3;
if (Count == 0) {InfiniteShot = true; WorkCount = 1;} else InfiniteShot = false;
if (Count == -1) {gpio_item_set_all_pins(true); Bulb = true; WorkCount = 1; WorkTime = Time;} else Bulb = false;
notification_message(notifications, &sequence_success);
}
}
Expand All @@ -163,28 +190,53 @@ int32_t zeitraffer_app(void* p) {
}
if(event.input.type == InputTypeRepeat) {
if(event.input.key == InputKeyRight) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Count = Count+10;
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyLeft) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Count = Count-10;
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyUp) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Time = Time+10;
//view_port_update(view_port);
}
}
if(event.input.key == InputKeyDown) {
if(furi_timer_is_running(timer)) {
notification_message(notifications, &sequence_error);
}
else {
Time = Time-10;
//view_port_update(view_port);
}
}
}
// Наше событие — это сработавший таймер
} else if(event.type == EventTypeTick) {
// Отправляем нотификацию мигания синим светодиодом
WorkTime--;
notification_message(notifications, &sequence_blink_blue_100);
if( WorkTime < 1 ) {

if (Bulb) {
gpio_item_set_all_pins(false); WorkCount = 0;
}
else {
WorkCount--;
view_port_update(view_port);
notification_message(notifications, &sequence_click);
Expand All @@ -198,8 +250,8 @@ int32_t zeitraffer_app(void* p) {

WorkTime = Time;
view_port_update(view_port);

}
}
}
if( WorkCount < 1 ) {
gpio_item_set_all_pins(false);
furi_timer_stop(timer);
Expand All @@ -209,7 +261,7 @@ int32_t zeitraffer_app(void* p) {
}
}
if (Time < 1) Time = 1;
if (Count < 0) Count = 0;
if (Count < -1) Count = 0;
}

// Очищаем таймер
Expand Down

0 comments on commit 7144030

Please sign in to comment.