@@ -46,7 +46,7 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
4646}
4747
4848StopWatch::StopWatch (DisplayApp* app)
49- : Screen(app), running {true }, currentState {States::INIT }, currentEvent {Events::STOP }, startTime {}, oldTimeElapsed {},
49+ : Screen(app), running {true }, currentState {States::Init }, currentEvent {Events::Stop }, startTime {}, oldTimeElapsed {},
5050 currentTimeSeparated {}, lapBuffer {}, lapNr {}, lapPressed {false } {
5151
5252 time = lv_label_create (lv_scr_act (), nullptr );
@@ -87,9 +87,9 @@ StopWatch::~StopWatch() {
8787
8888bool StopWatch::Refresh () {
8989 // @startuml CHIP8_state
90- // State "INIT " as init
91- // State "RUNNING " as run
92- // State "HALTED " as halt
90+ // State "Init " as init
91+ // State "Running " as run
92+ // State "Halted " as halt
9393
9494 // [*] --> init
9595 // init -> run : press play
@@ -102,7 +102,7 @@ bool StopWatch::Refresh() {
102102 switch (currentState) {
103103 // Init state when an user first opens the app
104104 // and when a stop/reset button is pressed
105- case States::INIT : {
105+ case States::Init : {
106106 if (btnStopLap) {
107107 lv_obj_del (btnStopLap);
108108 }
@@ -115,7 +115,7 @@ bool StopWatch::Refresh() {
115115 lapBuffer.clearBuffer ();
116116 lapNr = 0 ;
117117
118- if (currentEvent == Events::PLAY ) {
118+ if (currentEvent == Events::Play ) {
119119 btnStopLap = lv_btn_create (lv_scr_act (), nullptr );
120120 btnStopLap->user_data = this ;
121121 lv_obj_set_event_cb (btnStopLap, stop_lap_event_handler);
@@ -125,11 +125,11 @@ bool StopWatch::Refresh() {
125125 lv_label_set_text (txtStopLap, Symbols::lapsFlag);
126126
127127 startTime = xTaskGetTickCount ();
128- currentState = States::RUNNING ;
128+ currentState = States::Running ;
129129 }
130130 break ;
131131 }
132- case States::RUNNING : {
132+ case States::Running : {
133133 lv_label_set_text (txtPlayPause, Symbols::pause);
134134 lv_label_set_text (txtStopLap, Symbols::lapsFlag);
135135
@@ -150,25 +150,25 @@ bool StopWatch::Refresh() {
150150 lapPressed = false ;
151151 }
152152
153- if (currentEvent == Events::PAUSE ) {
153+ if (currentEvent == Events::Pause ) {
154154 // Reset the start time
155155 startTime = 0 ;
156156 // Store the current time elapsed in cache
157157 oldTimeElapsed += timeElapsed;
158- currentState = States::HALTED ;
158+ currentState = States::Halted ;
159159 }
160160 break ;
161161 }
162- case States::HALTED : {
162+ case States::Halted : {
163163 lv_label_set_text (txtPlayPause, Symbols::play);
164164 lv_label_set_text (txtStopLap, Symbols::stop);
165165
166- if (currentEvent == Events::PLAY ) {
166+ if (currentEvent == Events::Play ) {
167167 startTime = xTaskGetTickCount ();
168- currentState = States::RUNNING ;
168+ currentState = States::Running ;
169169 }
170- if (currentEvent == Events::STOP ) {
171- currentState = States::INIT ;
170+ if (currentEvent == Events::Stop ) {
171+ currentState = States::Init ;
172172 oldTimeElapsed = 0 ;
173173 }
174174 break ;
@@ -184,25 +184,25 @@ bool StopWatch::OnButtonPushed() {
184184
185185void StopWatch::playPauseBtnEventHandler (lv_event_t event) {
186186 if (event == LV_EVENT_CLICKED) {
187- if (currentState == States::INIT ) {
188- currentEvent = Events::PLAY ;
187+ if (currentState == States::Init ) {
188+ currentEvent = Events::Play ;
189189 } else {
190190 // Simple Toggle for play/pause
191- currentEvent = (currentEvent == Events::PLAY ? Events::PAUSE : Events::PLAY );
191+ currentEvent = (currentEvent == Events::Play ? Events::Pause : Events::Play );
192192 }
193193 }
194194}
195195
196196void StopWatch::stopLapBtnEventHandler (lv_event_t event) {
197197 if (event == LV_EVENT_CLICKED) {
198198 // If running, then this button is used to save laps
199- if (currentState == States::RUNNING ) {
199+ if (currentState == States::Running ) {
200200 lapBuffer.addLaps (currentTimeSeparated);
201201 lapNr++;
202202 lapPressed = true ;
203203
204- } else if (currentState == States::HALTED ) {
205- currentEvent = Events::STOP ;
204+ } else if (currentState == States::Halted ) {
205+ currentEvent = Events::Stop ;
206206 } else {
207207 // Not possible to reach here. Do nothing.
208208 }
0 commit comments