Skip to content

Commit

Permalink
Version 1.2.0 (Release
Browse files Browse the repository at this point in the history
Reworks:
 - the way to change the current stopwatch, timer, counter
  • Loading branch information
iron-mesh committed Nov 27, 2024
1 parent e0b65ce commit aef3634
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 42 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

**NotOnlyClock** - это устройство для самостоятельной сборки, которое построено из недорогих и доступных компонентов, в 2024 году их можно приобрести практически на любом маркетплейсе, и конечно на всем известном AliExpress. Центральным компонентом устройства является плата Arduino Nano, что позволяет нам легко прошивать микроконтроллер, так как достаточно подключить плату к порту USB компьютера, а затем скомпилировать и загрузить прошивку, всего за несколько секунд. Корпус устройства выполнен из листов фанеры и поэтому он обладает высокой прочность и эстетическим внешним видом, в отличие от заводских пластиковых корпусов или корпусов, которые многие энтузиасты печатают на своих домашних 3D принтерах. Его можно полностью произвести в домашних условиях, для этого не нужно быть мастером схемотехники или столярного дела, нужно только иметь небольшое число простых инструментов. Кстати, я не рассказал о функциях устройства, вот они:

-часы;
-будильник;
-таймер;
-секундомер;
-термометр, барометр и гигрометр;
-Часы;
-Будильник;
-8 Таймеров;
-8 Секундомеров;
-Термометр, Барометр и Гигрометр;
- 9 Счетчиков нажатий;
-пользовательские настройки для задания поведения устройства;
-(открытый исходный код, что позволяет добавлять свои функции).

Expand Down
108 changes: 92 additions & 16 deletions firmware/desktop_stopwatch/buttons_handler.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@

bool ask_questions(char *msg){
bool answer = false;
reset_buttons();
display_text(msg);
while(1){
if (!(button1.tick() || button3.tick())) continue;

if (button1.click())
break;

if (button3.click()){
answer = true;
break;
}
}
reset_buttons();
call_display_update();
return answer;
}

void init_buttons(){
button1.setStepTimeout(BTN_STEP_TIMEOUT);
button2.setStepTimeout(BTN_STEP_TIMEOUT);
Expand Down Expand Up @@ -119,8 +140,8 @@ void handle_buttons(){
case STOPWATCH:

if (button1.pressFor(1000) && button1.release()){
current_stopwatch = input_uint8(current_stopwatch + 1, 1, 8, false) - 1;
call_display_update();
set_mode(STOPWATCH_SELECT);
button1.reset();
}

if (button3.release()){
Expand All @@ -136,16 +157,32 @@ void handle_buttons(){
}
break;

case STOPWATCH_SELECT:
if (button1.release()){
set_mode(STOPWATCH);
button1.reset();
}

if (button2.release()){
current_stopwatch = (current_stopwatch > 0) ? current_stopwatch - 1 : UNIT_ARR_SIZE - 1;
call_display_update();
}

if (button3.release()){
current_stopwatch = (current_stopwatch < (UNIT_ARR_SIZE - 1)) ? current_stopwatch + 1 : 0;
call_display_update();
}
break;

case TIMER:
if (button1.pressFor(1000) && button1.release()){
current_timer = input_uint8(current_timer + 1, 1, 8, false) - 1;
call_display_update();
set_mode(TIMER_SELECT);
button1.reset();
}

if (button2.holding() && button3.click()){
set_mode(TIMER_TUNE);
reset_buttons();
return ;
}
if (button3.release()){
Time t = timers[current_timer].time;
Expand All @@ -165,10 +202,27 @@ void handle_buttons(){
}
break;

case TIMER_SELECT:
if (button1.release()){
set_mode(TIMER);
button1.reset();
}

if (button2.release()){
current_timer = (current_timer > 0) ? current_timer - 1 : UNIT_ARR_SIZE - 1;
call_display_update();
}

if (button3.release()){
current_timer = (current_timer < (UNIT_ARR_SIZE - 1)) ? current_timer + 1 : 0;
call_display_update();
}
break;

case TIMER_TUNE:
if (button1.release()){
set_mode(TIMER);
button1.reset();
button1.reset();
}
if (button2.holding() && button3.click()){
timers[current_timer].start_time.h = 0;
Expand Down Expand Up @@ -235,7 +289,7 @@ void handle_buttons(){
}
}

if (button2.holding() && button3.holding()){
if (button2.holding() && button3.holding()){
reset_buttons();
set_mode(CLOCK);
display_text("9OOd dA4");
Expand All @@ -244,27 +298,49 @@ void handle_buttons(){
break;

case COUNTER:
if (button1.pressFor(1000) && button1.release()){
set_mode(COUNTER_SELECT);
button1.reset();
}

if (counter_mode_values[current_counter] != 0 && button2.pressing() && button3.release()){
if (ask_questions("reset"))
counter_mode_values[current_counter] = 0;
}

if(button2.release()){
if (counter_mode_value > -9999999)
counter_mode_value --;
if (counter_mode_values[current_counter] > -99999)
counter_mode_values[current_counter] --;
else
counter_mode_value = 0;
counter_mode_values[current_counter] = 0;
call_display_update();
}

if(button3.release()){
if (counter_mode_value < 99999999)
counter_mode_value ++;
if (counter_mode_values[current_counter] < 999999)
counter_mode_values[current_counter] ++;
else
counter_mode_value = 0;
counter_mode_values[current_counter] = 0;
call_display_update();
}
break;

case COUNTER_SELECT:
if (button1.release()){
set_mode(COUNTER);
button1.reset();
}

if (counter_mode_value != 0 && button2.pressFor(2000) && button3.pressFor(2000)){
counter_mode_value = 0;
if (button2.release()){
current_counter = (current_counter > 0) ? current_counter - 1 : 8;
call_display_update();
}
break;

if (button3.release()){
current_counter = (current_counter < (8)) ? current_counter + 1 : 0;
call_display_update();
}
break;

}

Expand Down
11 changes: 8 additions & 3 deletions firmware/desktop_stopwatch/desktop_stopwatch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// firmware configuration
#define DEBUG 0 // 1 - debug is activated, 0 - deactivated
#define VERSION "1.2.0d"
#define VERSION "1.2.0"
#define DISPLAY_INVERTED 1 // 1 - inverted connection of segments to MAX7219, 0 - not
#define USE_RTC_MODULE 0 // 1 - use RTC, 0 - don't use

Expand All @@ -33,6 +33,7 @@
#define ALIGNMENT_DISP 0
#endif


//types definitions
enum Modes{
STOPWATCH,
Expand All @@ -44,7 +45,10 @@ enum Modes{
CLOCK_TUNE,
TIMER_TUNE,
ALARM_TUNE,
TIMER_EXPIRED};
TIMER_EXPIRED,
STOPWATCH_SELECT,
TIMER_SELECT,
COUNTER_SELECT};

enum WeatherUnit{TEMPERATURE,
HUMIDITY,
Expand Down Expand Up @@ -122,13 +126,14 @@ volatile uint16_t alarm_off_counter = 0;
volatile uint16_t alarm_snooze_counter = 0;
uint8_t current_stopwatch = 0;
uint8_t current_timer = 0;
long counter_mode_value = 0;
uint8_t current_counter = 0;

Time clock_time;
Time alarm_time;
const uint8_t UNIT_ARR_SIZE = 8;
StopwatchUnit stopwatches[UNIT_ARR_SIZE];
TimerUnit timers[UNIT_ARR_SIZE];
long counter_mode_values[9];

char disp_buf[17];

Expand Down
31 changes: 18 additions & 13 deletions firmware/desktop_stopwatch/display_functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ void send_time_to_dispbuff(){
clear_display_buffer();
switch (current_mode){
case STOPWATCH:
case STOPWATCH_SELECT:
t = stopwatches[current_stopwatch].time;
sep = '-';
break;
case TIMER:
case TIMER_SELECT:
t = timers[current_timer].time;
sep = '_';
break;
Expand Down Expand Up @@ -89,22 +91,18 @@ void send_time_to_dispbuff(){

switch (current_mode){
case STOPWATCH:
if ((a == current_stopwatch) || (stopwatches[a].is_launched && show_active_units_dots)){
disp_buf[i] = '.';
i++;
}
case STOPWATCH_SELECT:
if ((a == current_stopwatch) || (stopwatches[a].is_launched && show_active_units_dots))
disp_buf[i++] = '.';
break;
case TIMER:
if ((a == current_timer) || (timers[a].is_launched && show_active_units_dots)){
disp_buf[i] = '.';
i++;
}
case TIMER_SELECT:
if ((a == current_timer) || (timers[a].is_launched && show_active_units_dots))
disp_buf[i++] = '.';
break;
case TIMER_EXPIRED:
if (timers[a].is_expired){
disp_buf[i] = '.';
i++;
}
if (timers[a].is_expired)
disp_buf[i++] = '.';
break;
}
}
Expand Down Expand Up @@ -157,10 +155,12 @@ void update_display(){
break;

case STOPWATCH:
case STOPWATCH_SELECT:
send_time_to_dispbuff();
break;

case TIMER:
case TIMER_SELECT:
case TIMER_EXPIRED:
send_time_to_dispbuff();
break;
Expand All @@ -174,8 +174,13 @@ void update_display(){
break;

case COUNTER:
case COUNTER_SELECT:
clear_display_buffer();
ltoa(counter_mode_value, disp_buf, DEC);
ltoa(counter_mode_values[current_counter], disp_buf, DEC);
for (int i = strlen(disp_buf); i < 7; i++){
disp_buf[i] = ' ';
}
disp_buf[7] = (current_counter + 1) + 48;
break;
}

Expand Down
17 changes: 14 additions & 3 deletions firmware/desktop_stopwatch/other_functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ void set_mode(Modes mode){
timers[current_timer].time.h = timers[current_timer].start_time.h;
timers[current_timer].time.m = timers[current_timer].start_time.m;
timers[current_timer].time.s = timers[current_timer].start_time.s;
blinking_zone = -1;
set_display_blinking(false);
break;
case TIMER_EXPIRED:
blinking_zone = -1;
set_display_blinking(false);
buzzer_timer.stop();
for(int i = 0; i < UNIT_ARR_SIZE; i++){
Expand All @@ -59,6 +57,11 @@ void set_mode(Modes mode){
set_display_blinking(false);
buzzer_timer.stop();
break;
case STOPWATCH_SELECT:
case TIMER_SELECT:
case COUNTER_SELECT:
set_display_blinking(false);
break;
}

switch (mode){
Expand All @@ -77,27 +80,35 @@ void set_mode(Modes mode){
clock_time.s = 0;
break;
case ALARM_TUNE:
blinking_zone = -1;
set_display_blinking(true);
// is_alarm_snooze = false;
break;
case TIMER_TUNE:
timers[current_timer].is_launched = false;
set_display_blinking(true);
blinking_zone = 6;
break;
case TIMER_EXPIRED:
blinking_zone = -1;
set_display_blinking(true);
switch_display(true);
if (settings.p11_use_speaker)
buzzer_timer.start();
break;
case ALARM:
blinking_zone = -1;
set_display_blinking(true);
switch_display(true);
buzzer_timer.start();
if (settings.p12_alarm_duration > 0)
alarm_off_counter = 60 * settings.p12_alarm_duration;
break;
case STOPWATCH_SELECT:
case TIMER_SELECT:
case COUNTER_SELECT:
blinking_zone = -1;
set_display_blinking(true);
break;
}

current_mode = mode;
Expand Down
4 changes: 2 additions & 2 deletions firmware/desktop_stopwatch/time_functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ ISR(TIMER1_A){
}
}
}
if ((current_mode == STOPWATCH && stopwatches[current_stopwatch].is_launched) ||
(current_mode == TIMER && timers[current_timer].is_launched) )
if (((current_mode == STOPWATCH || current_mode == STOPWATCH_SELECT) && stopwatches[current_stopwatch].is_launched) ||
((current_mode == TIMER || current_mode == TIMER_SELECT) && timers[current_timer].is_launched) )
call_display_update();

if (is_alarm_snooze && is_alarm_active){
Expand Down

0 comments on commit aef3634

Please sign in to comment.