Skip to content

Commit 5687e79

Browse files
committed
Added counter mode, where the count get increment whenever a falling edge on input is present. Reset with double click.
1 parent a622779 commit 5687e79

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

FTController.ino

+24-6
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ void update_display()
130130
case DISPLAY_OUT:
131131
display_out();
132132
break;
133+
case DISPLAY_RPM:
134+
display_rpm();
135+
break;
133136
case DISPLAY_COUNT:
134-
display_count();
137+
display_counter();
135138
break;
136139
case DISPLAY_TEMP:
137140
display_temp();
@@ -196,7 +199,7 @@ void display_temp()
196199
lcd.print(GetTemp());
197200
}
198201

199-
void display_count()
202+
void display_rpm()
200203
{
201204
static long lasttime = millis();
202205
static float val = 0;
@@ -239,6 +242,12 @@ void display_count()
239242
lcd.print(val, 0); //Cut digits after the point, we dont have that precision
240243
}
241244

245+
void display_counter()
246+
{
247+
lcd.print(F("Counter:"));
248+
lcd.setCursor(0, 1);
249+
lcd.print(counter_val());
250+
}
242251

243252

244253
/********************************************
@@ -501,11 +510,20 @@ void button_pressedCallback()
501510

502511
if (millis() - lasttime < DOUBLECLICK_TIME) //If button was double clicked, activate FREEZE mode
503512
{
504-
if (freeze == 0)
505-
freeze = 1;
513+
if (display_mode == DISPLAY_COUNT)
514+
{
515+
counter_reset();
516+
menu = MENU_HIDDEN;
517+
}
506518
else
507-
freeze = 0;
508-
menu = MENU_HIDDEN; //Hide menu
519+
{
520+
if (freeze == 0)
521+
freeze = 1;
522+
else
523+
freeze = 0;
524+
menu = MENU_HIDDEN; //Hide menu
525+
}
526+
509527
}
510528
}
511529
else

helpers.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ const PROGMEM uint8_t TABLE_SQRT[26] = { 0, 51, 72, 88, 102, 114, 125, 135, 144,
119119
#define DISPLAY_INPUT 0 //Shows the input values of the joysticks
120120
#define DISPLAY_VOLT 1 //Shows the input and MCU voltage
121121
#define DISPLAY_OUT 2 //Shows the output values
122-
#define DISPLAY_COUNT 3
123-
#define DISPLAY_TEMP 4 //Shows temperature
122+
#define DISPLAY_RPM 3 //Shows RPM rate
123+
#define DISPLAY_COUNT 4
124+
#define DISPLAY_TEMP 5 //Shows temperature
124125

125-
#define DISPLAY_MAX_VAL 4
126+
#define DISPLAY_MAX_VAL 5
126127
#define DISPLAY_DEFAULT DISPLAY_VOLT
127128

128129
//Config Menu states

menu.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void menu_config()
9090
TOGGLE_SETTING(config.counter_unit);
9191
break;
9292
case CONFIG_CDEBOUNCE:
93-
lcd.print(F("C.DEBNC:"));
93+
lcd.print(F("I.DEBNC:"));
9494
lcd.setCursor(0, 1);
9595
if (config.counter_debounce == 0)
9696
lcd.print("OFF");
@@ -101,14 +101,14 @@ void menu_config()
101101
TOGGLE_SETTING(config.counter_debounce);
102102
break;
103103
case CONFIG_CMULTI:
104-
lcd.print(F("C.MULTI:"));
104+
lcd.print(F("I.MULTI:"));
105105
lcd.setCursor(0, 1);
106106
lcd.print(config.counter_multi + 1);
107107
config.counter_multi += menu_action_rx();
108108
config.counter_multi += 10 * menu_action_ry();
109109
break;
110110
case CONFIG_CDIVIDE:
111-
lcd.print(F("C.DIVIDE:"));
111+
lcd.print(F("I.DIVIDE:"));
112112
lcd.setCursor(0, 1);
113113
lcd.print(config.counter_divide + 1);
114114
config.counter_divide += menu_action_rx();
@@ -202,6 +202,9 @@ void menu_display()
202202
case DISPLAY_OUT:
203203
lcd.print(F("Out Vals"));
204204
break;
205+
case DISPLAY_RPM:
206+
lcd.print(F("RPM"));
207+
break;
205208
case DISPLAY_COUNT:
206209
lcd.print(F("Counter"));
207210
break;

0 commit comments

Comments
 (0)